From 0ab0edc654f348b9d3072de64c2310d37788d67a Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Fri, 12 Aug 2022 18:50:13 +0300 Subject: [PATCH] Refactoring. --- src/app/puzzle/carousel/vpcarrousel.cpp | 14 +- src/app/puzzle/carousel/vpcarrousel.h | 15 +- src/app/puzzle/carousel/vpcarrouselpiece.cpp | 12 +- src/app/puzzle/carousel/vpcarrouselpiece.h | 6 +- .../puzzle/carousel/vpcarrouselpiecelist.cpp | 165 +- .../puzzle/carousel/vpcarrouselpiecelist.h | 6 +- src/app/puzzle/carousel/vpmimedatapiece.cpp | 6 +- src/app/puzzle/carousel/vpmimedatapiece.h | 12 +- .../puzzlepreferencesconfigurationpage.cpp | 4 +- .../puzzlepreferencesconfigurationpage.h | 13 +- .../puzzlepreferenceslayoutpage.cpp | 6 +- .../configpages/puzzlepreferenceslayoutpage.h | 23 +- .../configpages/puzzlepreferencespathpage.cpp | 10 +- .../configpages/puzzlepreferencespathpage.h | 11 +- .../puzzle/dialogs/dialogpuzzlepreferences.h | 15 +- .../puzzle/dialogs/dialogsavemanuallayout.cpp | 11 +- .../puzzle/dialogs/dialogsavemanuallayout.h | 15 +- src/app/puzzle/dialogs/vpdialogabout.cpp | 20 +- src/app/puzzle/dialogs/vpdialogabout.h | 17 +- src/app/puzzle/layout/layoutdef.cpp | 4 +- src/app/puzzle/layout/layoutdef.h | 8 +- src/app/puzzle/layout/vplayout.cpp | 16 +- src/app/puzzle/layout/vplayout.h | 14 +- src/app/puzzle/layout/vppiece.cpp | 11 +- src/app/puzzle/main.cpp | 22 +- src/app/puzzle/scene/vpgraphicspiece.cpp | 112 +- src/app/puzzle/scene/vpgraphicspiece.h | 11 +- .../puzzle/scene/vpgraphicspiececontrols.cpp | 17 +- .../puzzle/scene/vpgraphicspiececontrols.h | 5 +- src/app/puzzle/scene/vpgraphicssheet.h | 6 +- src/app/puzzle/scene/vpmaingraphicsview.cpp | 360 +- src/app/puzzle/scene/vpmaingraphicsview.h | 10 +- src/app/puzzle/undocommands/vpundoaddsheet.h | 12 +- src/app/puzzle/undocommands/vpundocommand.cpp | 8 +- .../undocommands/vpundomovepieceonsheet.h | 12 +- .../puzzle/undocommands/vpundooriginmove.cpp | 2 +- .../puzzle/undocommands/vpundooriginmove.h | 14 +- .../puzzle/undocommands/vpundopiecemove.cpp | 4 +- src/app/puzzle/undocommands/vpundopiecemove.h | 28 +- .../puzzle/undocommands/vpundopiecerotate.cpp | 4 +- .../puzzle/undocommands/vpundopiecerotate.h | 30 +- .../undocommands/vpundopiecezvaluemove.cpp | 6 +- .../undocommands/vpundopiecezvaluemove.h | 4 +- .../puzzle/undocommands/vpundoremovesheet.cpp | 7 +- .../puzzle/undocommands/vpundoremovesheet.h | 12 +- src/app/puzzle/vpapplication.cpp | 8 +- src/app/puzzle/vpcommandline.cpp | 30 +- src/app/puzzle/vpcommandline.h | 39 +- src/app/puzzle/vpcommands.cpp | 42 +- src/app/puzzle/vpcommands.h | 2 +- src/app/puzzle/vpmainwindow.cpp | 1102 ++++--- src/app/puzzle/vpmainwindow.h | 74 +- src/app/puzzle/vpsettings.cpp | 41 +- src/app/puzzle/vpsettings.h | 4 +- src/app/puzzle/xml/vplayoutfilereader.cpp | 18 +- src/app/puzzle/xml/vplayoutfilereader.h | 15 +- src/app/puzzle/xml/vplayoutfilewriter.cpp | 3 + src/app/puzzle/xml/vplayoutfilewriter.h | 9 +- src/app/puzzle/xml/vplayoutliterals.cpp | 162 +- src/app/puzzle/xml/vplayoutliterals.h | 2 +- .../tapepreferencesconfigurationpage.cpp | 11 +- .../tapepreferencesconfigurationpage.h | 13 +- .../configpages/tapepreferencespathpage.cpp | 10 +- .../configpages/tapepreferencespathpage.h | 11 +- src/app/tape/dialogs/dialogabouttape.cpp | 21 +- src/app/tape/dialogs/dialogabouttape.h | 17 +- .../dialogs/dialogdimensioncustomnames.cpp | 2 +- src/app/tape/dialogs/dialogdimensionlabels.h | 9 +- src/app/tape/dialogs/dialogmdatabase.cpp | 341 +- src/app/tape/dialogs/dialogmdatabase.h | 69 +- .../dialogs/dialogmeasurementscsvcolumns.cpp | 167 +- .../dialogs/dialogmeasurementscsvcolumns.h | 28 +- .../tape/dialogs/dialognewmeasurements.cpp | 14 +- src/app/tape/dialogs/dialognewmeasurements.h | 17 +- .../tape/dialogs/dialogrestrictdimension.cpp | 390 ++- .../tape/dialogs/dialogrestrictdimension.h | 14 +- src/app/tape/dialogs/dialogsetupmultisize.cpp | 2 + .../tape/dialogs/dialogtapepreferences.cpp | 1 - src/app/tape/dialogs/dialogtapepreferences.h | 17 +- src/app/tape/main.cpp | 21 +- src/app/tape/mapplication.cpp | 7 +- src/app/tape/tmainwindow.cpp | 1882 +++++------ src/app/tape/tmainwindow.h | 122 +- src/app/tape/version.h | 10 +- src/app/tape/vlitepattern.cpp | 8 +- src/app/tape/vlitepattern.h | 19 +- src/app/tape/vtapesettings.cpp | 14 +- src/app/tape/vtapesettings.h | 7 +- src/app/valentina/core/vapplication.cpp | 57 +- src/app/valentina/core/vapplication.h | 1 - src/app/valentina/core/vcmdexport.cpp | 362 +- src/app/valentina/core/vcmdexport.h | 97 +- src/app/valentina/core/vformulaproperty.cpp | 58 +- src/app/valentina/core/vformulaproperty.h | 29 +- .../valentina/core/vformulapropertyeditor.cpp | 66 +- .../valentina/core/vformulapropertyeditor.h | 18 +- .../core/vtooloptionspropertybrowser.cpp | 958 +++--- .../core/vtooloptionspropertybrowser.h | 20 +- .../preferencesconfigurationpage.cpp | 14 +- .../preferencesconfigurationpage.h | 21 +- .../configpages/preferencespathpage.cpp | 20 +- .../dialogs/configpages/preferencespathpage.h | 13 +- .../configpages/preferencespatternpage.cpp | 13 +- .../configpages/preferencespatternpage.h | 17 +- src/app/valentina/dialogs/dialogaboutapp.cpp | 24 +- src/app/valentina/dialogs/dialogaboutapp.h | 14 +- .../dialogs/dialogaddbackgroundimage.h | 4 +- .../dialogs/dialogdatetimeformats.cpp | 12 +- .../valentina/dialogs/dialogdatetimeformats.h | 19 +- .../dialogs/dialogfinalmeasurements.cpp | 132 +- .../dialogs/dialogfinalmeasurements.h | 24 +- src/app/valentina/dialogs/dialoghistory.cpp | 557 ++-- src/app/valentina/dialogs/dialoghistory.h | 49 +- .../valentina/dialogs/dialogincrements.cpp | 76 +- src/app/valentina/dialogs/dialogincrements.h | 4 +- .../dialogs/dialogknownmaterials.cpp | 9 +- .../valentina/dialogs/dialogknownmaterials.h | 13 +- .../dialogs/dialoglayoutprogress.cpp | 20 +- .../valentina/dialogs/dialoglayoutprogress.h | 15 +- .../dialogs/dialoglayoutsettings.cpp | 273 +- .../valentina/dialogs/dialoglayoutsettings.h | 93 +- .../valentina/dialogs/dialognewpattern.cpp | 15 +- src/app/valentina/dialogs/dialognewpattern.h | 17 +- .../dialogs/dialogpatternproperties.cpp | 92 +- .../dialogs/dialogpatternproperties.h | 44 +- .../valentina/dialogs/dialogpreferences.cpp | 6 +- src/app/valentina/dialogs/dialogpreferences.h | 17 +- .../valentina/dialogs/dialogsavelayout.cpp | 66 +- src/app/valentina/dialogs/dialogsavelayout.h | 63 +- .../dialogs/vwidgetbackgroundimages.h | 4 +- src/app/valentina/dialogs/vwidgetdetails.cpp | 35 +- src/app/valentina/dialogs/vwidgetdetails.h | 15 +- src/app/valentina/dialogs/vwidgetgroups.cpp | 161 +- src/app/valentina/dialogs/vwidgetgroups.h | 18 +- src/app/valentina/main.cpp | 22 +- src/app/valentina/mainwindow.cpp | 2900 +++++++++-------- src/app/valentina/mainwindow.h | 247 +- src/app/valentina/mainwindowsnogui.cpp | 25 +- src/app/valentina/mainwindowsnogui.h | 4 +- src/app/valentina/xml/vpattern.cpp | 60 +- src/app/valentina/xml/vpattern.h | 5 +- src/libs/fervor/fvavailableupdate.h | 7 +- src/libs/fervor/fvupdater.cpp | 4 +- src/libs/fervor/fvupdater.h | 6 +- src/libs/fervor/fvupdatewindow.h | 7 +- src/libs/ifc/exception/vexception.cpp | 8 +- src/libs/ifc/exception/vexception.h | 4 +- src/libs/ifc/xml/vabstractconverter.h | 2 +- src/libs/ifc/xml/vabstractmconverter.h | 2 +- src/libs/ifc/xml/vabstractpattern.cpp | 2 +- src/libs/ifc/xml/vabstractpattern.h | 4 +- src/libs/ifc/xml/vdomdocument.cpp | 8 +- src/libs/ifc/xml/vdomdocument.h | 5 +- src/libs/ifc/xml/vlabeltemplateconverter.h | 2 +- src/libs/ifc/xml/vlayoutconverter.h | 2 +- src/libs/ifc/xml/vpatternconverter.cpp | 198 +- src/libs/ifc/xml/vpatternconverter.h | 4 +- src/libs/ifc/xml/vpatternimage.h | 2 +- src/libs/ifc/xml/vvitconverter.cpp | 10 +- src/libs/ifc/xml/vvitconverter.h | 4 +- src/libs/ifc/xml/vvstconverter.cpp | 8 +- src/libs/ifc/xml/vvstconverter.h | 4 +- src/libs/ifc/xml/vwatermarkconverter.h | 2 +- src/libs/qmuparser/qmudef.h | 9 + src/libs/qmuparser/qmuformulabase.h | 2 +- src/libs/qmuparser/qmuparserbytecode.cpp | 340 +- src/libs/qmuparser/qmuparserbytecode.h | 58 +- src/libs/qmuparser/qmuparsercallback.cpp | 2 +- src/libs/qmuparser/qmuparsercallback.h | 2 +- src/libs/qmuparser/qmuparsererror.h | 5 +- src/libs/qmuparser/qmuparsertest.h | 4 +- src/libs/qmuparser/qmuparsertoken.h | 87 +- src/libs/qmuparser/qmuparsertokenreader.cpp | 85 +- src/libs/qmuparser/qmuparsertokenreader.h | 151 +- src/libs/qmuparser/qmutokenparser.h | 2 +- src/libs/vdxf/dxiface.h | 4 +- src/libs/vdxf/libdxfrw/drw_base.h | 9 + src/libs/vdxf/libdxfrw/drw_entities.h | 5 +- src/libs/vdxf/libdxfrw/intern/drw_dbg.h | 3 +- src/libs/vdxf/libdxfrw/intern/drw_textcodec.h | 4 +- src/libs/vdxf/libdxfrw/intern/dxfreader.h | 3 +- src/libs/vdxf/libdxfrw/intern/dxfwriter.h | 2 +- src/libs/vdxf/libdxfrw/libdxfrw.h | 2 +- src/libs/vdxf/vdxfengine.h | 2 +- src/libs/vdxf/vdxfpaintdevice.h | 3 +- src/libs/vformat/vlabeltemplate.h | 2 +- src/libs/vformat/vmeasurements.cpp | 2 +- src/libs/vformat/vmeasurements.h | 4 +- src/libs/vformat/vpatternrecipe.h | 4 +- src/libs/vformat/vwatermark.h | 4 +- src/libs/vgeometry/vabstractcurve.cpp | 2 +- src/libs/vgeometry/vabstractcurve.h | 2 +- src/libs/vgeometry/varc.cpp | 2 +- src/libs/vgeometry/vcubicbezier.cpp | 4 +- src/libs/vgeometry/vcubicbezier.h | 4 +- src/libs/vgeometry/vcubicbezierpath.cpp | 6 +- src/libs/vgeometry/vcubicbezierpath.h | 6 +- src/libs/vgeometry/vgobject.cpp | 4 +- src/libs/vgeometry/vgobject.h | 4 +- src/libs/vgeometry/vplacelabelitem.cpp | 4 +- src/libs/vgeometry/vplacelabelitem.h | 4 +- src/libs/vgeometry/vpointf.cpp | 4 +- src/libs/vgeometry/vpointf.h | 4 +- src/libs/vgeometry/vspline.cpp | 4 +- src/libs/vgeometry/vsplinepath.cpp | 6 +- src/libs/vgeometry/vsplinepath.h | 6 +- src/libs/vgeometry/vsplinepoint.cpp | 8 +- src/libs/vgeometry/vsplinepoint.h | 8 +- src/libs/vlayout/dialogs/dialoglayoutscale.h | 7 +- .../vlayout/dialogs/vabstractlayoutdialog.h | 4 +- src/libs/vlayout/dialogs/watermarkwindow.h | 5 +- src/libs/vlayout/vabstractpiece.cpp | 202 +- src/libs/vlayout/vabstractpiece.h | 120 +- src/libs/vlayout/vabstractpiece_p.h | 2 +- src/libs/vlayout/vbank.cpp | 4 +- src/libs/vlayout/vbank.h | 4 +- src/libs/vlayout/vbestsquare.cpp | 4 +- src/libs/vlayout/vbestsquare.h | 4 +- src/libs/vlayout/vcontour.cpp | 4 +- src/libs/vlayout/vcontour.h | 4 +- src/libs/vlayout/vlayoutexporter.cpp | 4 +- src/libs/vlayout/vlayoutexporter.h | 2 +- src/libs/vlayout/vlayoutgenerator.h | 4 +- src/libs/vlayout/vlayoutpaper.cpp | 4 +- src/libs/vlayout/vlayoutpaper.h | 4 +- src/libs/vlayout/vlayoutpiece.cpp | 4 +- src/libs/vlayout/vlayoutpiece.h | 6 +- src/libs/vlayout/vlayoutpiecepath.cpp | 4 +- src/libs/vlayout/vlayoutpiecepath.h | 4 +- src/libs/vlayout/vposter.h | 4 +- src/libs/vlayout/vprintlayout.h | 4 +- src/libs/vlayout/vrawlayout.h | 2 +- src/libs/vlayout/vrawsapoint.h | 2 +- src/libs/vlayout/vsapoint.h | 2 +- src/libs/vlayout/vtextmanager.h | 2 +- src/libs/vmisc/backport/qscopeguard.h | 2 +- src/libs/vmisc/def.cpp | 10 +- src/libs/vmisc/def.h | 6 +- src/libs/vmisc/defglobal.h | 2 - src/libs/vmisc/dialogs/dialogexporttocsv.h | 7 +- src/libs/vmisc/dialogs/dialogselectlanguage.h | 7 +- src/libs/vmisc/qt_dispatch/qt_dispatch.h | 4 +- src/libs/vmisc/qxtcsvmodel.cpp | 2 +- src/libs/vmisc/qxtcsvmodel.h | 4 +- src/libs/vmisc/testvapplication.h | 6 +- src/libs/vmisc/vabstractapplication.h | 4 +- src/libs/vmisc/vabstractvalapplication.h | 4 +- src/libs/vmisc/vcommonsettings.cpp | 368 +-- src/libs/vmisc/vcommonsettings.h | 234 +- src/libs/vmisc/vlockguard.h | 4 +- src/libs/vmisc/vtablesearch.h | 7 +- src/libs/vmisc/vvalentinasettings.cpp | 110 +- src/libs/vmisc/vvalentinasettings.h | 4 +- src/libs/vobj/vobjengine.h | 4 +- src/libs/vobj/vobjpaintdevice.h | 5 +- src/libs/vpatterndb/calculator.h | 2 +- .../floatItemData/vabstractfloatitemdata.cpp | 4 +- .../floatItemData/vabstractfloatitemdata.h | 2 +- .../floatItemData/vgrainlinedata.cpp | 6 +- .../vpatterndb/floatItemData/vgrainlinedata.h | 2 +- .../floatItemData/vpatternlabeldata.cpp | 6 +- .../floatItemData/vpatternlabeldata.h | 2 +- .../floatItemData/vpiecelabeldata.cpp | 6 +- .../floatItemData/vpiecelabeldata.h | 2 +- .../vpatterndb/variables/vcurvevariable.cpp | 4 +- .../vpatterndb/variables/vcurvevariable.h | 4 +- src/libs/vpatterndb/variables/vincrement.cpp | 4 +- src/libs/vpatterndb/variables/vincrement.h | 4 +- .../variables/vinternalvariable.cpp | 4 +- .../vpatterndb/variables/vinternalvariable.h | 4 +- src/libs/vpatterndb/variables/vlineangle.cpp | 4 +- src/libs/vpatterndb/variables/vlineangle.h | 4 +- src/libs/vpatterndb/variables/vlinelength.cpp | 4 +- src/libs/vpatterndb/variables/vlinelength.h | 4 +- .../vpatterndb/variables/vmeasurement.cpp | 4 +- src/libs/vpatterndb/variables/vmeasurement.h | 4 +- src/libs/vpatterndb/variables/vvariable.cpp | 4 +- src/libs/vpatterndb/variables/vvariable.h | 4 +- src/libs/vpatterndb/vcontainer.cpp | 9 +- src/libs/vpatterndb/vcontainer.h | 6 +- src/libs/vpatterndb/vformula.h | 4 +- src/libs/vpatterndb/vformula_p.h | 2 +- src/libs/vpatterndb/vnodedetail.cpp | 4 +- src/libs/vpatterndb/vnodedetail.h | 4 +- src/libs/vpatterndb/vpassmark.h | 2 +- src/libs/vpatterndb/vpiece.cpp | 4 +- src/libs/vpatterndb/vpiece.h | 6 +- src/libs/vpatterndb/vpiecenode.cpp | 4 +- src/libs/vpatterndb/vpiecenode.h | 4 +- src/libs/vpatterndb/vpiecepath.cpp | 4 +- src/libs/vpatterndb/vpiecepath.h | 4 +- src/libs/vpatterndb/vtranslatemeasurements.h | 4 +- .../vpropertyexplorer/checkablemessagebox.cpp | 2 +- .../vpropertyexplorer/checkablemessagebox.h | 5 +- .../plugins/Vector3d/vvector3dproperty.h | 4 +- .../vpropertyexplorer/plugins/vboolproperty.h | 4 +- .../plugins/vcolorproperty.h | 4 +- .../plugins/vcolorpropertyeditor.h | 5 +- .../plugins/vemptyproperty.h | 4 +- .../vpropertyexplorer/plugins/venumproperty.h | 4 +- .../vpropertyexplorer/plugins/vfileproperty.h | 4 +- .../plugins/vfilepropertyeditor.h | 4 +- .../plugins/vlabelproperty.h | 4 +- .../plugins/vlinecolorproperty.h | 4 +- .../plugins/vlinetypeproperty.h | 4 +- .../plugins/vnumberproperty.h | 5 +- .../plugins/vobjectproperty.h | 4 +- .../plugins/vpointfproperty.h | 4 +- .../plugins/vshortcutproperty.h | 4 +- .../plugins/vshortcutpropertyeditor.h | 4 +- .../plugins/vstringproperty.h | 4 +- .../vpropertyexplorer/plugins/vtextproperty.h | 2 +- src/libs/vpropertyexplorer/vproperty.h | 6 +- src/libs/vpropertyexplorer/vproperty_p.h | 2 +- .../vpropertyexplorer/vpropertydelegate.h | 2 +- .../vpropertyexplorer_global.h | 9 + .../vpropertyfactorymanager.h | 6 +- .../vpropertyexplorer/vpropertyformview.h | 4 +- .../vpropertyexplorer/vpropertyformview_p.h | 2 +- .../vpropertyexplorer/vpropertyformwidget.h | 4 +- src/libs/vpropertyexplorer/vpropertymodel.h | 4 +- src/libs/vpropertyexplorer/vpropertymodel_p.h | 3 +- src/libs/vpropertyexplorer/vpropertyset.cpp | 2 + src/libs/vpropertyexplorer/vpropertyset.h | 4 +- src/libs/vpropertyexplorer/vpropertyset_p.h | 4 +- .../vpropertyexplorer/vpropertytreeview.h | 6 +- src/libs/vtest/abstracttest.h | 2 +- .../vtools/dialogs/support/dialogeditlabel.h | 7 +- src/libs/vtools/dialogs/support/dialogundo.h | 7 +- .../vtools/dialogs/tools/dialogalongline.cpp | 3 +- .../vtools/dialogs/tools/dialogalongline.h | 4 +- .../vtools/dialogs/tools/dialogbisector.cpp | 3 +- .../vtools/dialogs/tools/dialogbisector.h | 4 +- .../vtools/dialogs/tools/dialogcubicbezier.h | 4 +- .../dialogs/tools/dialogcubicbezierpath.h | 4 +- .../tools/dialogcurveintersectaxis.cpp | 3 +- .../dialogs/tools/dialogcurveintersectaxis.h | 4 +- .../vtools/dialogs/tools/dialogcutarc.cpp | 3 +- src/libs/vtools/dialogs/tools/dialogcutarc.h | 4 +- .../vtools/dialogs/tools/dialogcutspline.cpp | 3 +- .../vtools/dialogs/tools/dialogcutspline.h | 4 +- .../dialogs/tools/dialogcutsplinepath.cpp | 3 +- .../dialogs/tools/dialogcutsplinepath.h | 4 +- .../dialogs/tools/dialogellipticalarc.cpp | 15 +- .../dialogs/tools/dialogellipticalarc.h | 4 +- .../vtools/dialogs/tools/dialogendline.cpp | 6 +- src/libs/vtools/dialogs/tools/dialogendline.h | 4 +- .../dialogs/tools/dialogflippingbyaxis.h | 4 +- .../dialogs/tools/dialogflippingbyline.h | 4 +- src/libs/vtools/dialogs/tools/dialoggroup.h | 4 +- src/libs/vtools/dialogs/tools/dialogheight.h | 4 +- src/libs/vtools/dialogs/tools/dialogline.h | 4 +- .../dialogs/tools/dialoglineintersect.h | 4 +- .../dialogs/tools/dialoglineintersectaxis.cpp | 3 +- .../dialogs/tools/dialoglineintersectaxis.h | 4 +- src/libs/vtools/dialogs/tools/dialogmove.cpp | 9 +- src/libs/vtools/dialogs/tools/dialogmove.h | 4 +- .../vtools/dialogs/tools/dialognormal.cpp | 3 +- src/libs/vtools/dialogs/tools/dialognormal.h | 4 +- .../tools/dialogpointfromarcandtangent.h | 4 +- .../tools/dialogpointfromcircleandtangent.cpp | 5 +- .../tools/dialogpointfromcircleandtangent.h | 4 +- .../dialogs/tools/dialogpointofcontact.cpp | 3 +- .../dialogs/tools/dialogpointofcontact.h | 4 +- .../dialogs/tools/dialogpointofintersection.h | 4 +- .../tools/dialogpointofintersectionarcs.h | 4 +- .../dialogpointofintersectioncircles.cpp | 10 +- .../tools/dialogpointofintersectioncircles.h | 4 +- .../tools/dialogpointofintersectioncurves.h | 4 +- .../vtools/dialogs/tools/dialogrotation.cpp | 3 +- .../vtools/dialogs/tools/dialogrotation.h | 4 +- .../dialogs/tools/dialogshoulderpoint.cpp | 3 +- .../dialogs/tools/dialogshoulderpoint.h | 4 +- .../vtools/dialogs/tools/dialogsinglepoint.h | 4 +- .../vtools/dialogs/tools/dialogspline.cpp | 28 +- src/libs/vtools/dialogs/tools/dialogspline.h | 4 +- .../vtools/dialogs/tools/dialogsplinepath.h | 4 +- src/libs/vtools/dialogs/tools/dialogtool.cpp | 12 +- src/libs/vtools/dialogs/tools/dialogtool.h | 4 +- .../vtools/dialogs/tools/dialogtriangle.h | 4 +- .../vtools/dialogs/tools/dialogtruedarts.h | 4 +- .../vtools/dialogs/tools/dialoguniondetails.h | 4 +- .../tools/piece/dialogduplicatedetail.h | 4 +- .../dialogs/tools/piece/dialoginsertnode.h | 4 +- .../tools/piece/dialogpatternmaterials.h | 7 +- .../dialogs/tools/piece/dialogpiecepath.cpp | 20 +- .../dialogs/tools/piece/dialogpiecepath.h | 4 +- .../vtools/dialogs/tools/piece/dialogpin.h | 4 +- .../dialogs/tools/piece/dialogplacelabel.cpp | 18 +- .../dialogs/tools/piece/dialogplacelabel.h | 4 +- .../tools/piece/dialogseamallowance.cpp | 22 +- .../dialogs/tools/piece/dialogseamallowance.h | 4 +- .../backgroundimage/vbackgroundimageitem.h | 4 +- .../backgroundimage/vbackgroundsvgitem.h | 4 +- .../operation/flipping/vabstractflipping.h | 4 +- .../operation/flipping/vtoolflippingbyaxis.h | 4 +- .../operation/flipping/vtoolflippingbyline.h | 4 +- .../drawTools/operation/vabstractoperation.h | 4 +- .../tools/drawTools/operation/vtoolmove.h | 4 +- .../tools/drawTools/operation/vtoolrotation.h | 4 +- .../drawTools/toolcurve/vabstractspline.h | 6 +- .../tools/drawTools/toolcurve/vtoolarc.h | 4 +- .../drawTools/toolcurve/vtoolarcwithlength.h | 4 +- .../drawTools/toolcurve/vtoolcubicbezier.h | 4 +- .../toolcurve/vtoolcubicbezierpath.h | 4 +- .../drawTools/toolcurve/vtoolellipticalarc.h | 4 +- .../tools/drawTools/toolcurve/vtoolspline.h | 4 +- .../drawTools/toolcurve/vtoolsplinepath.h | 4 +- .../tooldoublepoint/vtooldoublepoint.h | 4 +- .../tooldoublepoint/vtooltruedarts.h | 4 +- .../toolsinglepoint/toolcut/vtoolcut.h | 4 +- .../toolsinglepoint/toolcut/vtoolcutarc.h | 4 +- .../toolsinglepoint/toolcut/vtoolcutspline.h | 4 +- .../toolcut/vtoolcutsplinepath.h | 4 +- .../toollinepoint/vtoolalongline.h | 4 +- .../toollinepoint/vtoolbisector.h | 4 +- .../toollinepoint/vtoolcurveintersectaxis.h | 4 +- .../toollinepoint/vtoolendline.h | 4 +- .../toollinepoint/vtoolheight.h | 4 +- .../toollinepoint/vtoollineintersectaxis.h | 4 +- .../toollinepoint/vtoollinepoint.h | 4 +- .../toollinepoint/vtoolnormal.h | 4 +- .../toollinepoint/vtoolshoulderpoint.h | 4 +- .../toolsinglepoint/vtoolbasepoint.h | 4 +- .../toolsinglepoint/vtoollineintersect.h | 4 +- .../vtoolpointfromarcandtangent.h | 4 +- .../vtoolpointfromcircleandtangent.h | 4 +- .../toolsinglepoint/vtoolpointofcontact.h | 4 +- .../vtoolpointofintersection.h | 4 +- .../vtoolpointofintersectionarcs.h | 4 +- .../vtoolpointofintersectioncircles.h | 4 +- .../vtoolpointofintersectioncurves.h | 4 +- .../toolsinglepoint/vtoolsinglepoint.cpp | 4 +- .../toolsinglepoint/vtoolsinglepoint.h | 4 +- .../toolpoint/toolsinglepoint/vtooltriangle.h | 4 +- .../drawTools/toolpoint/vabstractpoint.h | 4 +- src/libs/vtools/tools/drawTools/vdrawtool.h | 4 +- src/libs/vtools/tools/drawTools/vtoolline.h | 4 +- .../vtools/tools/nodeDetails/vabstractnode.h | 4 +- src/libs/vtools/tools/nodeDetails/vnodearc.h | 5 +- .../tools/nodeDetails/vnodeellipticalarc.h | 5 +- .../vtools/tools/nodeDetails/vnodepoint.h | 5 +- .../vtools/tools/nodeDetails/vnodespline.h | 5 +- .../tools/nodeDetails/vnodesplinepath.h | 5 +- .../vtools/tools/nodeDetails/vtoolpiecepath.h | 5 +- src/libs/vtools/tools/nodeDetails/vtoolpin.h | 5 +- .../tools/nodeDetails/vtoolplacelabel.h | 5 +- src/libs/vtools/tools/toolsdef.h | 2 +- src/libs/vtools/tools/vabstracttool.h | 4 +- src/libs/vtools/tools/vdatatool.cpp | 8 +- src/libs/vtools/tools/vdatatool.h | 4 +- src/libs/vtools/tools/vinteractivetool.h | 4 +- src/libs/vtools/tools/vtoolseamallowance.h | 4 +- src/libs/vtools/tools/vtooluniondetails.cpp | 5 +- src/libs/vtools/tools/vtooluniondetails.h | 5 +- .../vtools/undocommands/addpatternpiece.h | 5 +- src/libs/vtools/undocommands/addpiece.h | 4 +- src/libs/vtools/undocommands/addtocalc.h | 5 +- .../vtools/undocommands/deletepatternpiece.h | 5 +- src/libs/vtools/undocommands/deletepiece.h | 4 +- src/libs/vtools/undocommands/deltool.h | 5 +- .../undocommands/image/addbackgroundimage.h | 4 +- .../image/deletebackgroundimage.h | 4 +- .../image/hideallbackgroundimages.h | 2 +- .../undocommands/image/hidebackgroundimage.h | 2 +- .../image/holdallbackgroundimages.h | 2 +- .../undocommands/image/holdbackgroundimage.h | 2 +- .../undocommands/image/movebackgroundimage.h | 4 +- .../image/opaquebackgroundimage.h | 2 +- .../image/renamebackgroundimage.h | 2 +- .../undocommands/image/resetbackgroundimage.h | 2 +- .../image/rotatebackgroundimage.h | 2 +- .../undocommands/image/scalebackgroundimage.h | 4 +- .../image/zvaluemovebackgroundimage.h | 2 +- .../undocommands/label/moveabstractlabel.h | 4 +- .../undocommands/label/movedoublelabel.h | 5 +- .../vtools/undocommands/label/movelabel.h | 5 +- .../undocommands/label/operationmovelabel.h | 5 +- .../undocommands/label/operationshowlabel.h | 5 +- .../undocommands/label/showdoublelabel.h | 5 +- .../vtools/undocommands/label/showlabel.h | 5 +- src/libs/vtools/undocommands/movepiece.h | 5 +- src/libs/vtools/undocommands/movespline.h | 5 +- src/libs/vtools/undocommands/movesplinepath.h | 5 +- src/libs/vtools/undocommands/movespoint.h | 5 +- src/libs/vtools/undocommands/renamepp.h | 5 +- .../vtools/undocommands/savepieceoptions.h | 5 +- .../undocommands/savepiecepathoptions.h | 5 +- .../undocommands/saveplacelabeloptions.h | 5 +- .../vtools/undocommands/savetooloptions.h | 5 +- .../vtools/undocommands/togglepiecestate.h | 9 +- src/libs/vtools/undocommands/undogroup.h | 33 +- src/libs/vtools/undocommands/vundocommand.cpp | 9 +- src/libs/vtools/undocommands/vundocommand.h | 4 +- .../line/operation/visoperation.h | 4 +- .../line/operation/vistoolflippingbyaxis.h | 5 +- .../line/operation/vistoolflippingbyline.h | 5 +- .../line/operation/vistoolmove.h | 5 +- .../line/operation/vistoolrotation.h | 5 +- src/libs/vtools/visualization/line/visline.h | 4 +- .../visualization/line/vistoolalongline.h | 5 +- .../visualization/line/vistoolbisector.h | 5 +- .../line/vistoolcurveintersectaxis.h | 5 +- .../visualization/line/vistoolendline.h | 5 +- .../vtools/visualization/line/vistoolheight.h | 5 +- .../vtools/visualization/line/vistoolline.h | 5 +- .../visualization/line/vistoollineintersect.h | 5 +- .../line/vistoollineintersectaxis.h | 5 +- .../vtools/visualization/line/vistoolnormal.h | 5 +- .../line/vistoolpointfromarcandtangent.h | 5 +- .../line/vistoolpointfromcircleandtangent.h | 5 +- .../line/vistoolpointofcontact.h | 5 +- .../line/vistoolpointofintersection.h | 5 +- .../line/vistoolpointofintersectionarcs.h | 5 +- .../line/vistoolpointofintersectioncircles.h | 5 +- .../visualization/line/vistoolshoulderpoint.h | 5 +- .../visualization/line/vistoolspecialpoint.h | 5 +- .../visualization/line/vistooltriangle.h | 5 +- .../visualization/line/vistooltruedarts.h | 5 +- src/libs/vtools/visualization/path/vispath.h | 4 +- .../path/vispiecespecialpoints.h | 4 +- .../visualization/path/vistoolcubicbezier.h | 4 +- .../path/vistoolcubicbezierpath.h | 4 +- .../vtools/visualization/path/vistoolcutarc.h | 4 +- .../visualization/path/vistoolcutspline.h | 4 +- .../visualization/path/vistoolcutsplinepath.h | 4 +- .../path/vistoolduplicatedetail.h | 4 +- .../visualization/path/vistoolellipticalarc.h | 4 +- .../vtools/visualization/path/vistoolpiece.h | 4 +- .../visualization/path/vistoolpiecepath.h | 4 +- .../path/vistoolpointofintersectioncurves.h | 4 +- .../vtools/visualization/visualization.cpp | 10 +- src/libs/vtools/visualization/visualization.h | 4 +- src/libs/vwidgets/fancytabbar/fancytab.h | 7 +- src/libs/vwidgets/fancytabbar/fancytabbar.h | 4 +- src/libs/vwidgets/qtcolorpicker.cpp | 8 +- src/libs/vwidgets/qtcolorpicker.h | 6 +- src/libs/vwidgets/scalesceneitems.h | 4 +- src/libs/vwidgets/vabstractmainwindow.cpp | 5 +- src/libs/vwidgets/vabstractmainwindow.h | 6 +- src/libs/vwidgets/vabstractsimple.h | 4 +- src/libs/vwidgets/vcomboboxdelegate.h | 7 +- src/libs/vwidgets/vcontrolpointspline.h | 4 +- src/libs/vwidgets/vcurvepathitem.h | 2 +- .../vwidgets/vdecorationaligningdelegate.h | 7 +- src/libs/vwidgets/velidedlabel.h | 7 +- src/libs/vwidgets/vgrainlineitem.h | 4 +- src/libs/vwidgets/vgraphicssimpletextitem.h | 2 +- src/libs/vwidgets/vlineedit.cpp | 2 +- src/libs/vwidgets/vlineedit.h | 11 +- src/libs/vwidgets/vmaingraphicsscene.h | 4 +- src/libs/vwidgets/vmaingraphicsview.h | 11 +- src/libs/vwidgets/vnobrushscalepathitem.h | 2 +- src/libs/vwidgets/vpieceitem.h | 4 +- src/libs/vwidgets/vplaintextedit.h | 2 +- src/libs/vwidgets/vscenepoint.h | 2 +- src/libs/vwidgets/vsimplecurve.h | 4 +- src/libs/vwidgets/vsimplepoint.h | 4 +- src/libs/vwidgets/vtextgraphicsitem.h | 4 +- src/libs/vwidgets/vwidgetpopup.h | 7 +- .../CollectionTest/tst_tapecommandline.cpp | 2 +- src/test/CollectionTest/tst_tapecommandline.h | 5 +- .../tst_valentinacommandline.cpp | 4 +- .../CollectionTest/tst_valentinacommandline.h | 5 +- .../TranslationsTest/tst_abstractregexp.h | 5 +- .../tst_abstracttranslation.h | 7 +- src/test/TranslationsTest/tst_buitinregexp.h | 4 +- .../TranslationsTest/tst_measurementregexp.h | 6 +- .../TranslationsTest/tst_qmuparsererrormsg.h | 5 +- .../tst_tslocaletranslation.h | 4 +- src/test/TranslationsTest/tst_tstranslation.h | 4 +- src/test/ValentinaTest/tst_dxf.h | 5 +- src/test/ValentinaTest/tst_findpoint.h | 2 +- src/test/ValentinaTest/tst_misc.h | 6 +- src/test/ValentinaTest/tst_nameregexp.h | 2 +- src/test/ValentinaTest/tst_qmutokenparser.h | 7 +- src/test/ValentinaTest/tst_readval.h | 7 +- src/test/ValentinaTest/tst_vabstractcurve.h | 2 +- src/test/ValentinaTest/tst_vabstractpiece.h | 2 +- src/test/ValentinaTest/tst_varc.h | 2 +- src/test/ValentinaTest/tst_vcommandline.h | 6 +- src/test/ValentinaTest/tst_vcubicbezierpath.h | 6 +- src/test/ValentinaTest/tst_vdomdocument.h | 6 +- src/test/ValentinaTest/tst_vellipticalarc.h | 6 +- src/test/ValentinaTest/tst_vgobject.h | 2 +- src/test/ValentinaTest/tst_vlayoutdetail.h | 2 +- src/test/ValentinaTest/tst_vlockguard.h | 2 +- src/test/ValentinaTest/tst_vmeasurements.h | 2 +- src/test/ValentinaTest/tst_vpiece.h | 5 +- src/test/ValentinaTest/tst_vpointf.h | 6 +- src/test/ValentinaTest/tst_vposter.h | 2 +- src/test/ValentinaTest/tst_vspline.h | 6 +- src/test/ValentinaTest/tst_vsplinepath.h | 6 +- .../ValentinaTest/tst_vtooluniondetails.h | 6 +- src/test/ValentinaTest/tst_vtranslatevars.h | 7 +- 595 files changed, 8727 insertions(+), 8081 deletions(-) diff --git a/src/app/puzzle/carousel/vpcarrousel.cpp b/src/app/puzzle/carousel/vpcarrousel.cpp index 5944bf134..281c1d851 100644 --- a/src/app/puzzle/carousel/vpcarrousel.cpp +++ b/src/app/puzzle/carousel/vpcarrousel.cpp @@ -32,7 +32,9 @@ #include #include +#if QT_VERSION < QT_VERSION_CHECK(5, 7, 0) #include "../vmisc/backport/qoverload.h" +#endif // QT_VERSION < QT_VERSION_CHECK(5, 7, 0) #include "../layout/vpsheet.h" #include "../layout/vplayout.h" @@ -40,7 +42,13 @@ #include #include -Q_LOGGING_CATEGORY(pCarrousel, "p.carrousel") +QT_WARNING_PUSH +QT_WARNING_DISABLE_CLANG("-Wmissing-prototypes") +QT_WARNING_DISABLE_INTEL(1418) + +Q_LOGGING_CATEGORY(pCarrousel, "p.carrousel") // NOLINT + +QT_WARNING_POP //--------------------------------------------------------------------------------------------------------------------- VPCarrousel::VPCarrousel(const VPLayoutPtr &layout, QWidget *parent) : @@ -108,7 +116,7 @@ void VPCarrousel::Refresh() ui->comboBoxPieceList->blockSignals(true); - for (const auto& sheet: m_pieceLists) + for (const auto& sheet: qAsConst(m_pieceLists)) { ui->comboBoxPieceList->addItem(GetSheetName(sheet), sheet.sheetUuid); } @@ -227,7 +235,7 @@ void VPCarrousel::on_ActivePieceListChanged(int index) } //--------------------------------------------------------------------------------------------------------------------- -VPLayoutWeakPtr VPCarrousel::Layout() const +auto VPCarrousel::Layout() const -> VPLayoutWeakPtr { return m_layout; } diff --git a/src/app/puzzle/carousel/vpcarrousel.h b/src/app/puzzle/carousel/vpcarrousel.h index a7f121eec..3f160cafc 100644 --- a/src/app/puzzle/carousel/vpcarrousel.h +++ b/src/app/puzzle/carousel/vpcarrousel.h @@ -32,8 +32,10 @@ #include #include #include -#include "../layout/vppiece.h" +#include + #include "../layout/layoutdef.h" +#include "../vmisc/defglobal.h" namespace Ui { @@ -51,10 +53,10 @@ struct VPCarrouselSheet class VPCarrousel : public QWidget { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit VPCarrousel(const VPLayoutPtr &layout, QWidget *parent = nullptr); - virtual ~VPCarrousel() = default; + ~VPCarrousel() override = default; /** * @brief SetOrientation Sets the orientation to the given value and refreshes @@ -76,7 +78,7 @@ public: */ void Clear(); - VPLayoutWeakPtr Layout() const; + auto Layout() const -> VPLayoutWeakPtr; public slots: /** @@ -86,7 +88,7 @@ public slots: void on_ActiveSheetChanged(const VPSheetPtr &sheet); protected: - virtual void changeEvent(QEvent* event) override; + void changeEvent(QEvent* event) override; private slots: @@ -97,7 +99,8 @@ private slots: void on_ActivePieceListChanged(int index); private: - Q_DISABLE_COPY(VPCarrousel) + // cppcheck-suppress unknownMacro + Q_DISABLE_COPY_MOVE(VPCarrousel) // NOLINT Ui::VPCarrousel *ui; VPLayoutWeakPtr m_layout{}; diff --git a/src/app/puzzle/carousel/vpcarrouselpiece.cpp b/src/app/puzzle/carousel/vpcarrouselpiece.cpp index bd0af36ad..a98903209 100644 --- a/src/app/puzzle/carousel/vpcarrouselpiece.cpp +++ b/src/app/puzzle/carousel/vpcarrouselpiece.cpp @@ -32,15 +32,17 @@ #include #include -#include "vpmimedatapiece.h" -#include "vpcarrouselpiecelist.h" -#include "vpcarrousel.h" -#include "../layout/vpsheet.h" #include "../layout/vppiece.h" #include -Q_LOGGING_CATEGORY(pCarrouselPiece, "p.carrouselPiece") +QT_WARNING_PUSH +QT_WARNING_DISABLE_CLANG("-Wmissing-prototypes") +QT_WARNING_DISABLE_INTEL(1418) + +Q_LOGGING_CATEGORY(pCarrouselPiece, "p.carrouselPiece") // NOLINT + +QT_WARNING_POP //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/puzzle/carousel/vpcarrouselpiece.h b/src/app/puzzle/carousel/vpcarrouselpiece.h index 1786a8396..8146210ac 100644 --- a/src/app/puzzle/carousel/vpcarrouselpiece.h +++ b/src/app/puzzle/carousel/vpcarrouselpiece.h @@ -32,6 +32,7 @@ #include #include "../layout/layoutdef.h" +#include "../vmisc/defglobal.h" class VPCarrouselPiece : public QListWidgetItem { @@ -39,7 +40,7 @@ public: enum { Type = UserType + 1}; explicit VPCarrouselPiece(const VPPiecePtr &piece, QListWidget* parent); - virtual ~VPCarrouselPiece() = default; + ~VPCarrouselPiece() override = default; /** * @brief GetPiece Returns the corresponding layout piece @@ -61,7 +62,8 @@ public: private: - Q_DISABLE_COPY(VPCarrouselPiece) + // cppcheck-suppress unknownMacro + Q_DISABLE_COPY_MOVE(VPCarrouselPiece) // NOLINT VPPieceWeakPtr m_piece; }; diff --git a/src/app/puzzle/carousel/vpcarrouselpiecelist.cpp b/src/app/puzzle/carousel/vpcarrouselpiecelist.cpp index 9e22971b8..037ed73c3 100644 --- a/src/app/puzzle/carousel/vpcarrouselpiecelist.cpp +++ b/src/app/puzzle/carousel/vpcarrouselpiecelist.cpp @@ -35,15 +35,24 @@ #include "vpcarrousel.h" #include "vpcarrouselpiece.h" +#if QT_VERSION < QT_VERSION_CHECK(5, 7, 0) #include "../vmisc/backport/qoverload.h" +#endif // QT_VERSION < QT_VERSION_CHECK(5, 7, 0) #include "vpmimedatapiece.h" #include "../layout/vpsheet.h" #include "../layout/vplayout.h" #include "../undocommands/vpundomovepieceonsheet.h" +#include "../layout/vppiece.h" #include -Q_LOGGING_CATEGORY(pCarrouselPieceList, "p.carrouselPieceList") +QT_WARNING_PUSH +QT_WARNING_DISABLE_CLANG("-Wmissing-prototypes") +QT_WARNING_DISABLE_INTEL(1418) + +Q_LOGGING_CATEGORY(pCarrouselPieceList, "p.carrouselPieceList") // NOLINT + +QT_WARNING_POP //--------------------------------------------------------------------------------------------------------------------- VPCarrouselPieceList::VPCarrouselPieceList(QWidget* parent) : @@ -70,7 +79,7 @@ void VPCarrouselPieceList::Refresh() if(not m_pieceList.isEmpty()) { // create the corresponding carrousel pieces - for (auto piece : m_pieceList) + for (const auto &piece : qAsConst(m_pieceList)) // NOLINT(clang-analyzer-cplusplus.NewDeleteLeaks) { if (not piece.isNull()) { @@ -102,7 +111,8 @@ void VPCarrouselPieceList::mousePressEvent(QMouseEvent *event) if (!(event->modifiers() & Qt::ControlModifier)) { // clearSelection doesn't work properly here so we go through the elements. - for(auto *item: selectedItems()) + const QList items = selectedItems(); + for(auto *item: items) { item->setSelected(false); } @@ -135,7 +145,8 @@ void VPCarrouselPieceList::startDrag(Qt::DropActions supportedActions) QListWidgetItem* _item = currentItem(); if(_item->type() == VPCarrouselPiece::Type) { - auto *pieceItem = static_cast (_item); + auto *pieceItem = dynamic_cast (_item); + SCASSERT(pieceItem != nullptr) if (m_carrousel == nullptr) { @@ -183,94 +194,97 @@ void VPCarrouselPieceList::dragMoveEvent(QDragMoveEvent* e) void VPCarrouselPieceList::contextMenuEvent(QContextMenuEvent *event) { QListWidgetItem* _item = currentItem(); - if(_item != nullptr && _item->type() == VPCarrouselPiece::Type) + if(_item == nullptr || _item->type() != VPCarrouselPiece::Type) { - auto *pieceItem = static_cast (_item); + return; + } - VPPiecePtr piece = pieceItem->GetPiece(); - VPLayoutPtr layout = piece->Layout(); + auto *pieceItem = dynamic_cast (_item); + SCASSERT(pieceItem != nullptr) - if (piece.isNull() || layout.isNull()) + VPPiecePtr piece = pieceItem->GetPiece(); + VPLayoutPtr layout = piece->Layout(); + + if (piece.isNull() || layout.isNull()) + { + return; + } + + QMenu menu; + + QVector moveToActions; + + if (not piece->Sheet().isNull()) + { + QList sheets = layout->GetSheets(); + sheets.removeAll(piece->Sheet()); + + if (not sheets.isEmpty()) { - return; - } + QMenu *moveMenu = menu.addMenu(tr("Move to")); - QMenu menu; - - QVector moveToActions; - - if (not piece->Sheet().isNull()) - { - QList sheets = layout->GetSheets(); - sheets.removeAll(piece->Sheet()); - - if (not sheets.isEmpty()) + for (const auto &sheet : sheets) { - QMenu *moveMenu = menu.addMenu(tr("Move to")); - - for (const auto &sheet : sheets) + if (not sheet.isNull()) { - if (not sheet.isNull()) - { - QAction* moveToSheet = moveMenu->addAction(sheet->GetName()); - moveToSheet->setData(QVariant::fromValue(sheet)); - moveToActions.append(moveToSheet); - } + QAction* moveToSheet = moveMenu->addAction(sheet->GetName()); + moveToSheet->setData(QVariant::fromValue(sheet)); + moveToActions.append(moveToSheet); } } } + } - QAction *moveAction = menu.addAction(tr("Move to Sheet")); - moveAction->setVisible(false); + QAction *moveAction = menu.addAction(tr("Move to Sheet")); + moveAction->setVisible(false); - QAction *deleteAction = menu.addAction(tr("Delete")); - deleteAction->setVisible(false); + QAction *deleteAction = menu.addAction(tr("Delete")); + deleteAction->setVisible(false); - QAction *removeAction = menu.addAction(tr("Remove from Sheet")); - removeAction->setVisible(false); + QAction *removeAction = menu.addAction(tr("Remove from Sheet")); + removeAction->setVisible(false); - if(not m_pieceList.isEmpty() && ConstFirst(m_pieceList)->Sheet() == nullptr) + if(not m_pieceList.isEmpty() && ConstFirst(m_pieceList)->Sheet() == nullptr) + { + moveAction->setVisible(true); + deleteAction->setVisible(true); + } + + if(not m_pieceList.isEmpty() && ConstFirst(m_pieceList)->Sheet() != nullptr) + { + removeAction->setVisible(true); + } + + QAction *selectedAction = menu.exec(event->globalPos()); + + if (selectedAction == moveAction) + { + VPSheetPtr sheet = layout->GetFocusedSheet(); + if (not sheet.isNull()) { - moveAction->setVisible(true); - deleteAction->setVisible(true); - } - - if(not m_pieceList.isEmpty() && ConstFirst(m_pieceList)->Sheet() != nullptr) - { - removeAction->setVisible(true); - } - - QAction *selectedAction = menu.exec(event->globalPos()); - - if (selectedAction == moveAction) - { - VPSheetPtr sheet = layout->GetFocusedSheet(); - if (not sheet.isNull()) - { - piece->ClearTransformations(); - QRectF rect = sheet->GetMarginsRect(); - piece->SetPosition(QPointF(rect.topLeft().x() + 1, rect.topLeft().y() + 1)); - piece->SetZValue(1.0); - auto *command = new VPUndoMovePieceOnSheet(layout->GetFocusedSheet(), piece); - layout->UndoStack()->push(command); - } - } - else if (selectedAction == deleteAction) - { - auto *command = new VPUndoMovePieceOnSheet(layout->GetTrashSheet(), piece); - layout->UndoStack()->push(command); - } - else if (selectedAction == removeAction) - { - auto *command = new VPUndoMovePieceOnSheet(VPSheetPtr(), piece); - layout->UndoStack()->push(command); - } - else if (moveToActions.contains(selectedAction)) - { - auto *command = new VPUndoMovePieceOnSheet(qvariant_cast(selectedAction->data()), piece); + piece->ClearTransformations(); + QRectF rect = sheet->GetMarginsRect(); + piece->SetPosition(QPointF(rect.topLeft().x() + 1, rect.topLeft().y() + 1)); + piece->SetZValue(1.0); + auto *command = new VPUndoMovePieceOnSheet(layout->GetFocusedSheet(), piece); layout->UndoStack()->push(command); } } + else if (selectedAction == deleteAction) + { + auto *command = new VPUndoMovePieceOnSheet(layout->GetTrashSheet(), piece); + layout->UndoStack()->push(command); + } + else if (selectedAction == removeAction) + { + auto *command = new VPUndoMovePieceOnSheet(VPSheetPtr(), piece); + layout->UndoStack()->push(command); + } + else if (moveToActions.contains(selectedAction)) + { + auto *command = new VPUndoMovePieceOnSheet(qvariant_cast(selectedAction->data()), piece); + layout->UndoStack()->push(command); + } } //--------------------------------------------------------------------------------------------------------------------- @@ -282,7 +296,8 @@ void VPCarrouselPieceList::on_SelectionChangedExternal() QListWidgetItem* _item = item(i); if(_item->type() == VPCarrouselPiece::Type) { - auto *itemPiece = static_cast (_item); + auto *itemPiece = dynamic_cast (_item); + SCASSERT(itemPiece != nullptr) itemPiece->RefreshSelection(); } } diff --git a/src/app/puzzle/carousel/vpcarrouselpiecelist.h b/src/app/puzzle/carousel/vpcarrouselpiecelist.h index 75714c7cf..9a0fae51b 100644 --- a/src/app/puzzle/carousel/vpcarrouselpiecelist.h +++ b/src/app/puzzle/carousel/vpcarrouselpiecelist.h @@ -36,10 +36,10 @@ class VPCarrouselPieceList : public QListWidget { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit VPCarrouselPieceList(QWidget* parent); - virtual ~VPCarrouselPieceList() = default; + ~VPCarrouselPieceList() override = default; /** * @brief Refresh refreshes the items of the carrousel piece list @@ -74,7 +74,7 @@ protected: void contextMenuEvent(QContextMenuEvent *event) override; private: - Q_DISABLE_COPY(VPCarrouselPieceList) + Q_DISABLE_COPY_MOVE(VPCarrouselPieceList) // NOLINT QList m_pieceList{}; QPoint m_dragStart{}; diff --git a/src/app/puzzle/carousel/vpmimedatapiece.cpp b/src/app/puzzle/carousel/vpmimedatapiece.cpp index ef71ebc9b..4789feef7 100644 --- a/src/app/puzzle/carousel/vpmimedatapiece.cpp +++ b/src/app/puzzle/carousel/vpmimedatapiece.cpp @@ -33,7 +33,7 @@ #include "../layout/vppiece.h" -const QString VPMimeDataPiece::mineFormatPiecePtr = QStringLiteral("application/vnd.puzzle.piece.ptr"); +const QString VPMimeDataPiece::mineFormatPiecePtr = QStringLiteral("application/vnd.puzzle.piece.ptr"); // NOLINT(cert-err58-cpp) //--------------------------------------------------------------------------------------------------------------------- VPMimeDataPiece::VPMimeDataPiece(const QUuid &layoutUuid) @@ -65,14 +65,14 @@ auto VPMimeDataPiece::DragCursor(const QPixmap &piecePixmap) -> QPixmap dragCursor.fill(Qt::transparent); QPainter painter(&dragCursor); painter.drawPixmap(dragCursor.width()/2, dragCursor.height()/2, piecePixmap); - QPixmap cursor = QPixmap("://cursor/collect.png"); + QPixmap cursor(QStringLiteral("://cursor/collect.png")); painter.drawPixmap(dragCursor.width()/2 - cursor.width()/2, dragCursor.height()/2 - cursor.height()/2, cursor); painter.end(); return dragCursor; } //--------------------------------------------------------------------------------------------------------------------- -const QUuid &VPMimeDataPiece::LayoutUuid() const +auto VPMimeDataPiece::LayoutUuid() const -> const QUuid & { return m_layoutUuid; } diff --git a/src/app/puzzle/carousel/vpmimedatapiece.h b/src/app/puzzle/carousel/vpmimedatapiece.h index 5dfb7c5ad..2cafc668b 100644 --- a/src/app/puzzle/carousel/vpmimedatapiece.h +++ b/src/app/puzzle/carousel/vpmimedatapiece.h @@ -34,16 +34,17 @@ #include #include "../layout/layoutdef.h" +#include "../vmisc/defglobal.h" class VPMimeDataPiece : public QMimeData { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit VPMimeDataPiece(const QUuid &layoutUuid); - virtual ~VPMimeDataPiece() = default; + ~VPMimeDataPiece() override = default; - virtual auto formats() const -> QStringList override; + auto formats() const -> QStringList override; /** * @brief GetPiecePtr Returns the piece pointer of the mime data @@ -61,10 +62,11 @@ public: static const QString mineFormatPiecePtr; - const QUuid &LayoutUuid() const; + auto LayoutUuid() const -> const QUuid &; private: - Q_DISABLE_COPY(VPMimeDataPiece) + // cppcheck-suppress unknownMacro + Q_DISABLE_COPY_MOVE(VPMimeDataPiece) // NOLINT VPPieceWeakPtr m_piece{}; diff --git a/src/app/puzzle/dialogs/configpages/puzzlepreferencesconfigurationpage.cpp b/src/app/puzzle/dialogs/configpages/puzzlepreferencesconfigurationpage.cpp index bb5371900..8fefa097c 100644 --- a/src/app/puzzle/dialogs/configpages/puzzlepreferencesconfigurationpage.cpp +++ b/src/app/puzzle/dialogs/configpages/puzzlepreferencesconfigurationpage.cpp @@ -113,12 +113,12 @@ auto PuzzlePreferencesConfigurationPage::Apply() -> QStringList if (m_langChanged) { - const QString locale = qvariant_cast(ui->langCombo->currentData()); + const auto locale = qvariant_cast(ui->langCombo->currentData()); settings->SetLocale(locale); m_langChanged = false; VAbstractApplication::VApp()->LoadTranslation(locale); - qApp->processEvents();// force to call changeEvent + QCoreApplication::processEvents();// force to call changeEvent } /* Maximum number of commands in undo stack may only be set when the undo stack is empty, since setting it on a diff --git a/src/app/puzzle/dialogs/configpages/puzzlepreferencesconfigurationpage.h b/src/app/puzzle/dialogs/configpages/puzzlepreferencesconfigurationpage.h index 1656a2922..f2ae802f9 100644 --- a/src/app/puzzle/dialogs/configpages/puzzlepreferencesconfigurationpage.h +++ b/src/app/puzzle/dialogs/configpages/puzzlepreferencesconfigurationpage.h @@ -30,6 +30,8 @@ #include +#include "../vmisc/defglobal.h" + namespace Ui { class PuzzlePreferencesConfigurationPage; @@ -37,19 +39,20 @@ namespace Ui class PuzzlePreferencesConfigurationPage : public QWidget { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit PuzzlePreferencesConfigurationPage(QWidget *parent = nullptr); - virtual ~PuzzlePreferencesConfigurationPage(); + ~PuzzlePreferencesConfigurationPage() override; - QStringList Apply(); + auto Apply() -> QStringList; protected: - virtual void changeEvent(QEvent* event) override; + void changeEvent(QEvent* event) override; private: - Q_DISABLE_COPY(PuzzlePreferencesConfigurationPage) + // cppcheck-suppress unknownMacro + Q_DISABLE_COPY_MOVE(PuzzlePreferencesConfigurationPage) // NOLINT Ui::PuzzlePreferencesConfigurationPage *ui; bool m_langChanged{false}; }; diff --git a/src/app/puzzle/dialogs/configpages/puzzlepreferenceslayoutpage.cpp b/src/app/puzzle/dialogs/configpages/puzzlepreferenceslayoutpage.cpp index 23b0bd39f..2152ed44d 100644 --- a/src/app/puzzle/dialogs/configpages/puzzlepreferenceslayoutpage.cpp +++ b/src/app/puzzle/dialogs/configpages/puzzlepreferenceslayoutpage.cpp @@ -399,7 +399,7 @@ void PuzzlePreferencesLayoutPage::InitLayoutUnits() } //--------------------------------------------------------------------------------------------------------------------- -QSizeF PuzzlePreferencesLayoutPage::Template(VAbstractLayoutDialog::PaperSizeTemplate t) const +auto PuzzlePreferencesLayoutPage::Template(VAbstractLayoutDialog::PaperSizeTemplate t) const -> QSizeF { const Unit layoutUnit = LayoutUnit(); @@ -413,7 +413,6 @@ QSizeF PuzzlePreferencesLayoutPage::Template(VAbstractLayoutDialog::PaperSizeTem case VAbstractLayoutDialog::PaperSizeTemplate::Letter: case VAbstractLayoutDialog::PaperSizeTemplate::Legal: case VAbstractLayoutDialog::PaperSizeTemplate::Tabloid: - return VAbstractLayoutDialog::GetTemplateSize(t, layoutUnit); case VAbstractLayoutDialog::PaperSizeTemplate::Roll24in: case VAbstractLayoutDialog::PaperSizeTemplate::Roll30in: case VAbstractLayoutDialog::PaperSizeTemplate::Roll36in: @@ -422,13 +421,12 @@ QSizeF PuzzlePreferencesLayoutPage::Template(VAbstractLayoutDialog::PaperSizeTem case VAbstractLayoutDialog::PaperSizeTemplate::Roll48in: case VAbstractLayoutDialog::PaperSizeTemplate::Roll62in: case VAbstractLayoutDialog::PaperSizeTemplate::Roll72in: - return VAbstractLayoutDialog::GetTemplateSize(t, layoutUnit); case VAbstractLayoutDialog::PaperSizeTemplate::Custom: return VAbstractLayoutDialog::GetTemplateSize(t, layoutUnit); default: break; } - return QSizeF(); + return {}; } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/puzzle/dialogs/configpages/puzzlepreferenceslayoutpage.h b/src/app/puzzle/dialogs/configpages/puzzlepreferenceslayoutpage.h index f10ba67b4..e20b885df 100644 --- a/src/app/puzzle/dialogs/configpages/puzzlepreferenceslayoutpage.h +++ b/src/app/puzzle/dialogs/configpages/puzzlepreferenceslayoutpage.h @@ -40,16 +40,16 @@ namespace Ui class PuzzlePreferencesLayoutPage : public QWidget { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit PuzzlePreferencesLayoutPage(QWidget *parent = nullptr); - ~PuzzlePreferencesLayoutPage(); + ~PuzzlePreferencesLayoutPage() override; - QStringList Apply(); + auto Apply() -> QStringList; protected: - virtual void changeEvent(QEvent* event) override; + void changeEvent(QEvent* event) override; private slots: void ConvertPaperSize(); @@ -62,21 +62,22 @@ private slots: void SwapTileOrientation(bool checked); private: - Q_DISABLE_COPY(PuzzlePreferencesLayoutPage) + // cppcheck-suppress unknownMacro + Q_DISABLE_COPY_MOVE(PuzzlePreferencesLayoutPage) // NOLINT Ui::PuzzlePreferencesLayoutPage *ui; Unit m_oldLayoutUnit{Unit::Mm}; bool m_settingsChanged{false}; void InitLayoutUnits(); - QSizeF Template(VAbstractLayoutDialog::PaperSizeTemplate t) const; - QSizeF SheetTemplate() const; - QSizeF TileTemplate() const; + auto Template(VAbstractLayoutDialog::PaperSizeTemplate t) const -> QSizeF; + auto SheetTemplate() const -> QSizeF; + auto TileTemplate() const -> QSizeF; void MinimumSheetPaperSize(); void MinimumTilePaperSize(); - Unit LayoutUnit() const; + auto LayoutUnit() const -> Unit; void SetLayoutUnit(Unit unit); void SheetSize(const QSizeF &size); @@ -87,10 +88,10 @@ private: void SheetPaperSizeChanged(); void TilePaperSizeChanged(); - QMarginsF GetSheetMargins() const; + auto GetSheetMargins() const -> QMarginsF; void SetSheetMargins(const QMarginsF &value); - QMarginsF GetTileMargins() const; + auto GetTileMargins() const -> QMarginsF; void SetTileMargins(const QMarginsF &value); void SetPieceGap(qreal gap); diff --git a/src/app/puzzle/dialogs/configpages/puzzlepreferencespathpage.cpp b/src/app/puzzle/dialogs/configpages/puzzlepreferencespathpage.cpp index cc8a79429..66d4a54f2 100644 --- a/src/app/puzzle/dialogs/configpages/puzzlepreferencespathpage.cpp +++ b/src/app/puzzle/dialogs/configpages/puzzlepreferencespathpage.cpp @@ -180,35 +180,35 @@ void PuzzlePreferencesPathPage::InitTable() { ui->pathTable->setItem(0, 0, new QTableWidgetItem(tr("My Individual Measurements"))); - QTableWidgetItem *item = new QTableWidgetItem(settings->GetPathIndividualMeasurements()); + auto *item = new QTableWidgetItem(settings->GetPathIndividualMeasurements()); item->setToolTip(settings->GetPathIndividualMeasurements()); ui->pathTable->setItem(0, 1, item); } { ui->pathTable->setItem(1, 0, new QTableWidgetItem(tr("My Multisize Measurements"))); - QTableWidgetItem *item = new QTableWidgetItem(settings->GetPathMultisizeMeasurements()); + auto *item = new QTableWidgetItem(settings->GetPathMultisizeMeasurements()); item->setToolTip(settings->GetPathMultisizeMeasurements()); ui->pathTable->setItem(1, 1, item); } { ui->pathTable->setItem(2, 0, new QTableWidgetItem(tr("My Patterns"))); - QTableWidgetItem *item = new QTableWidgetItem(settings->GetPathPattern()); + auto *item = new QTableWidgetItem(settings->GetPathPattern()); item->setToolTip(settings->GetPathPattern()); ui->pathTable->setItem(2, 1, item); } { ui->pathTable->setItem(3, 0, new QTableWidgetItem(tr("My Templates"))); - QTableWidgetItem *item = new QTableWidgetItem(settings->GetPathTemplate()); + auto *item = new QTableWidgetItem(settings->GetPathTemplate()); item->setToolTip(settings->GetPathTemplate()); ui->pathTable->setItem(3, 1, item); } { ui->pathTable->setItem(4, 0, new QTableWidgetItem(tr("My Layouts"))); - QTableWidgetItem *item = new QTableWidgetItem(settings->GetPathManualLayouts()); + auto *item = new QTableWidgetItem(settings->GetPathManualLayouts()); item->setToolTip(settings->GetPathManualLayouts()); ui->pathTable->setItem(4, 1, item); } diff --git a/src/app/puzzle/dialogs/configpages/puzzlepreferencespathpage.h b/src/app/puzzle/dialogs/configpages/puzzlepreferencespathpage.h index 139208758..09254588f 100644 --- a/src/app/puzzle/dialogs/configpages/puzzlepreferencespathpage.h +++ b/src/app/puzzle/dialogs/configpages/puzzlepreferencespathpage.h @@ -30,6 +30,8 @@ #include +#include "../vmisc/defglobal.h" + namespace Ui { class PuzzlePreferencesPathPage; @@ -37,23 +39,24 @@ namespace Ui class PuzzlePreferencesPathPage : public QWidget { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit PuzzlePreferencesPathPage(QWidget *parent = nullptr); - virtual ~PuzzlePreferencesPathPage(); + ~PuzzlePreferencesPathPage() override; void Apply(); protected: - virtual void changeEvent(QEvent* event) override; + void changeEvent(QEvent* event) override; private slots: void DefaultPath(); void EditPath(); private: - Q_DISABLE_COPY(PuzzlePreferencesPathPage) + // cppcheck-suppress unknownMacro + Q_DISABLE_COPY_MOVE(PuzzlePreferencesPathPage) // NOLINT Ui::PuzzlePreferencesPathPage *ui; void InitTable(); diff --git a/src/app/puzzle/dialogs/dialogpuzzlepreferences.h b/src/app/puzzle/dialogs/dialogpuzzlepreferences.h index c84390bf1..bb8ae8cf7 100644 --- a/src/app/puzzle/dialogs/dialogpuzzlepreferences.h +++ b/src/app/puzzle/dialogs/dialogpuzzlepreferences.h @@ -30,6 +30,8 @@ #include +#include "../vmisc/defglobal.h" + namespace Ui { class DialogPuzzlePreferences; @@ -42,19 +44,19 @@ class PuzzlePreferencesLayoutPage; class DialogPuzzlePreferences : public QDialog { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit DialogPuzzlePreferences(QWidget *parent = nullptr); - virtual ~DialogPuzzlePreferences(); + ~DialogPuzzlePreferences() override; signals: void UpdateProperties(); protected: - virtual void showEvent(QShowEvent *event) override; - virtual void resizeEvent(QResizeEvent *event) override; - virtual void changeEvent(QEvent* event) override; + void showEvent(QShowEvent *event) override; + void resizeEvent(QResizeEvent *event) override; + void changeEvent(QEvent* event) override; private slots: void Apply(); @@ -62,7 +64,8 @@ private slots: void PageChanged(QListWidgetItem *current, QListWidgetItem *previous); private: - Q_DISABLE_COPY(DialogPuzzlePreferences) + // cppcheck-suppress unknownMacro + Q_DISABLE_COPY_MOVE(DialogPuzzlePreferences) // NOLINT Ui::DialogPuzzlePreferences *ui; bool m_isInitialized{false}; PuzzlePreferencesConfigurationPage *m_configurationPage; diff --git a/src/app/puzzle/dialogs/dialogsavemanuallayout.cpp b/src/app/puzzle/dialogs/dialogsavemanuallayout.cpp index 4e85c3efc..52420034e 100644 --- a/src/app/puzzle/dialogs/dialogsavemanuallayout.cpp +++ b/src/app/puzzle/dialogs/dialogsavemanuallayout.cpp @@ -36,14 +36,11 @@ #include #ifndef Q_OS_WIN - Q_GLOBAL_STATIC_WITH_ARGS(const QString, baseFilenameRegExp, (QLatin1String("^[^\\/]+$"))) + Q_GLOBAL_STATIC_WITH_ARGS(const QString, baseFilenameRegExp, (QLatin1String("^[^\\/]+$"))) // NOLINT #else - Q_GLOBAL_STATIC_WITH_ARGS(const QString, baseFilenameRegExp, (QLatin1String("^[^\\:?\"*|\\/<>]+$"))) + Q_GLOBAL_STATIC_WITH_ARGS(const QString, baseFilenameRegExp, (QLatin1String("^[^\\:?\"*|\\/<>]+$"))) // NOLINT #endif -bool DialogSaveManualLayout::havePdf = false; -bool DialogSaveManualLayout::tested = false; - //--------------------------------------------------------------------------------------------------------------------- DialogSaveManualLayout::DialogSaveManualLayout(int count, bool consoleExport, const QString &fileName, QWidget *parent) : VAbstractLayoutDialog(parent), @@ -334,7 +331,7 @@ void DialogSaveManualLayout::SetTilesScheme(bool value) } //--------------------------------------------------------------------------------------------------------------------- -bool DialogSaveManualLayout::IsTilesScheme() const +auto DialogSaveManualLayout::IsTilesScheme() const -> bool { switch(Format()) { @@ -500,6 +497,8 @@ void DialogSaveManualLayout::ShowExample() //--------------------------------------------------------------------------------------------------------------------- auto DialogSaveManualLayout::SupportPSTest() -> bool { + static bool havePdf = false; + static bool tested = false; if (!tested) { havePdf = VLayoutExporter::SupportPDFConversion(); diff --git a/src/app/puzzle/dialogs/dialogsavemanuallayout.h b/src/app/puzzle/dialogs/dialogsavemanuallayout.h index 8d2bb065c..62dcbc99c 100644 --- a/src/app/puzzle/dialogs/dialogsavemanuallayout.h +++ b/src/app/puzzle/dialogs/dialogsavemanuallayout.h @@ -38,12 +38,12 @@ class DialogSaveManualLayout; class DialogSaveManualLayout : public VAbstractLayoutDialog { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit DialogSaveManualLayout(int count, bool consoleExport, const QString &fileName = QString(), QWidget *parent = nullptr); - virtual ~DialogSaveManualLayout(); + ~DialogSaveManualLayout() override; auto Path() const -> QString; auto FileName() const -> QString; @@ -66,7 +66,7 @@ public: auto IsTilesScheme() const -> bool; protected: - virtual void showEvent(QShowEvent *event) override; + void showEvent(QShowEvent *event) override; private slots: void Save(); @@ -74,17 +74,16 @@ private slots: void ShowExample(); private: - Q_DISABLE_COPY(DialogSaveManualLayout) + // cppcheck-suppress unknownMacro + Q_DISABLE_COPY_MOVE(DialogSaveManualLayout) // NOLINT Ui::DialogSaveManualLayout *ui; int m_count; bool m_isInitialized{false}; bool m_scaleConnected{true}; bool m_consoleExport; - static bool havePdf; - static bool tested; - static bool SupportPSTest(); - static QVector > InitFormats(); + static auto SupportPSTest() -> bool; + static auto InitFormats() -> QVector >; void RemoveFormatFromList(LayoutExportFormats format); diff --git a/src/app/puzzle/dialogs/vpdialogabout.cpp b/src/app/puzzle/dialogs/vpdialogabout.cpp index 857c0b12e..a1a000da0 100644 --- a/src/app/puzzle/dialogs/vpdialogabout.cpp +++ b/src/app/puzzle/dialogs/vpdialogabout.cpp @@ -28,7 +28,7 @@ #include "vpdialogabout.h" #include "ui_vpdialogabout.h" -#include "../version.h" +#include "../vmisc/projectversion.h" #include "../vmisc/def.h" #include "../fervor/fvupdater.h" @@ -43,7 +43,7 @@ VPDialogAbout::VPDialogAbout(QWidget *parent) :QDialog(parent), ui(new Ui::VPDialogAbout), - isInitialized(false) + m_isInitialized(false) { ui->setupUi(this); @@ -52,7 +52,7 @@ VPDialogAbout::VPDialogAbout(QWidget *parent) RetranslateUi(); connect(ui->pushButton_Web_Site, &QPushButton::clicked, this, []() { - if ( not QDesktopServices::openUrl(QUrl(VER_COMPANYDOMAIN_STR))) + if ( not QDesktopServices::openUrl(QUrl(QStringLiteral(VER_COMPANYDOMAIN_STR)))) { qWarning() << tr("Cannot open your default browser"); } @@ -100,7 +100,7 @@ void VPDialogAbout::showEvent(QShowEvent *event) return; } - if (isInitialized) + if (m_isInitialized) { return; } @@ -109,7 +109,7 @@ void VPDialogAbout::showEvent(QShowEvent *event) setMaximumSize(size()); setMinimumSize(size()); - isInitialized = true;//first show windows are held + m_isInitialized = true;//first show windows are held } //--------------------------------------------------------------------------------------------------------------------- @@ -125,17 +125,17 @@ void VPDialogAbout::FontPointSize(QWidget *w, int pointSize) //--------------------------------------------------------------------------------------------------------------------- void VPDialogAbout::RetranslateUi() { - ui->label_Puzzle_Version->setText(QString("Puzzle %1").arg(APP_VERSION_STR)); - ui->labelBuildRevision->setText(tr("Build revision: %1").arg(BUILD_REVISION)); + ui->label_Puzzle_Version->setText(QStringLiteral("Puzzle %1").arg(APP_VERSION_STR)); + ui->labelBuildRevision->setText(tr("Build revision: %1").arg(QStringLiteral(BUILD_REVISION))); ui->label_QT_Version->setText(buildCompatibilityString()); - const QDate date = QLocale::c().toDate(QString(__DATE__).simplified(), QLatin1String("MMM d yyyy")); - ui->label_Puzzle_Built->setText(tr("Built on %1 at %2").arg(date.toString(), __TIME__)); + const QDate date = QLocale::c().toDate(QStringLiteral(__DATE__).simplified(), QStringLiteral("MMM d yyyy")); + ui->label_Puzzle_Built->setText(tr("Built on %1 at %2").arg(date.toString(), QStringLiteral(__TIME__))); ui->label_Legal_Stuff->setText(QApplication::translate("InternalStrings", "The program is provided AS IS with NO WARRANTY OF ANY " "KIND, INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY " "AND FITNESS FOR A PARTICULAR PURPOSE.")); - ui->pushButton_Web_Site->setText(tr("Web site : %1").arg(VER_COMPANYDOMAIN_STR)); + ui->pushButton_Web_Site->setText(tr("Web site : %1").arg(QStringLiteral(VER_COMPANYDOMAIN_STR))); } diff --git a/src/app/puzzle/dialogs/vpdialogabout.h b/src/app/puzzle/dialogs/vpdialogabout.h index fce48ca0e..e1c993d49 100644 --- a/src/app/puzzle/dialogs/vpdialogabout.h +++ b/src/app/puzzle/dialogs/vpdialogabout.h @@ -31,6 +31,8 @@ #include +#include "../vmisc/defglobal.h" + namespace Ui { class VPDialogAbout; @@ -38,22 +40,23 @@ namespace Ui class VPDialogAbout : public QDialog { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit VPDialogAbout(QWidget *parent = nullptr); - virtual ~VPDialogAbout(); + ~VPDialogAbout() override; protected: - virtual void changeEvent(QEvent* event) override; - virtual void showEvent(QShowEvent *event) override; + void changeEvent(QEvent* event) override; + void showEvent(QShowEvent *event) override; private: - Q_DISABLE_COPY(VPDialogAbout) + // cppcheck-suppress unknownMacro + Q_DISABLE_COPY_MOVE(VPDialogAbout) // NOLINT Ui::VPDialogAbout *ui; - bool isInitialized; + bool m_isInitialized; - void FontPointSize(QWidget *w, int pointSize); + static void FontPointSize(QWidget *w, int pointSize); void RetranslateUi(); }; diff --git a/src/app/puzzle/layout/layoutdef.cpp b/src/app/puzzle/layout/layoutdef.cpp index 2b3b47df3..f6cf16d5e 100644 --- a/src/app/puzzle/layout/layoutdef.cpp +++ b/src/app/puzzle/layout/layoutdef.cpp @@ -80,13 +80,13 @@ auto StrToGrainlineType(const QString &string) -> GrainlineType //--------------------------------------------------------------------------------------------------------------------- -bool VPTransformationOrigon::operator==(const VPTransformationOrigon &origin) const +auto VPTransformationOrigon::operator==(const VPTransformationOrigon &origin) const -> bool { return this->origin == origin.origin && custom == origin.custom; } //--------------------------------------------------------------------------------------------------------------------- -bool VPTransformationOrigon::operator!=(const VPTransformationOrigon &origin) const +auto VPTransformationOrigon::operator!=(const VPTransformationOrigon &origin) const -> bool { return !VPTransformationOrigon::operator==(origin); } diff --git a/src/app/puzzle/layout/layoutdef.h b/src/app/puzzle/layout/layoutdef.h index 8d93d2211..376c6ae2d 100644 --- a/src/app/puzzle/layout/layoutdef.h +++ b/src/app/puzzle/layout/layoutdef.h @@ -55,11 +55,11 @@ auto StrToGrainlineType(const QString &string) -> GrainlineType; struct VPTransformationOrigon { - QPointF origin{}; - bool custom{false}; + QPointF origin{}; // NOLINT(misc-non-private-member-variables-in-classes) + bool custom{false}; // NOLINT(misc-non-private-member-variables-in-classes) - bool operator==(const VPTransformationOrigon &origin) const; - bool operator!=(const VPTransformationOrigon &origin) const; + auto operator==(const VPTransformationOrigon &origin) const -> bool; + auto operator!=(const VPTransformationOrigon &origin) const -> bool; }; #endif // LAYOUTDEF_H diff --git a/src/app/puzzle/layout/vplayout.cpp b/src/app/puzzle/layout/vplayout.cpp index 0dd2dfd4f..ca23b176a 100644 --- a/src/app/puzzle/layout/vplayout.cpp +++ b/src/app/puzzle/layout/vplayout.cpp @@ -39,7 +39,13 @@ #include #include -Q_LOGGING_CATEGORY(pLayout, "p.layout") +QT_WARNING_PUSH +QT_WARNING_DISABLE_CLANG("-Wmissing-prototypes") +QT_WARNING_DISABLE_INTEL(1418) + +Q_LOGGING_CATEGORY(pLayout, "p.layout") // NOLINT + +QT_WARNING_POP //--------------------------------------------------------------------------------------------------------------------- VPLayout::VPLayout(QUndoStack *undoStack) : @@ -118,13 +124,13 @@ void VPLayout::AddPiece(const VPPiecePtr &piece) } //--------------------------------------------------------------------------------------------------------------------- -const QUuid &VPLayout::Uuid() const +auto VPLayout::Uuid() const -> const QUuid & { return m_uuid; } //--------------------------------------------------------------------------------------------------------------------- -VPTileFactory *VPLayout::TileFactory() const +auto VPLayout::TileFactory() const -> VPTileFactory * { return m_tileFactory; } @@ -166,7 +172,7 @@ auto VPLayout::WatermarkData() const -> VWatermarkData data.invalidFile = true; data.opacity = 20; data.showImage = true; - data.path = "fake.png"; + data.path = QStringLiteral("fake.png"); data.showText = false; return data; } @@ -254,7 +260,7 @@ auto VPLayout::AddSheet(const VPSheetPtr &sheet) -> VPSheetPtr } //--------------------------------------------------------------------------------------------------------------------- -QList VPLayout::GetAllSheets() const +auto VPLayout::GetAllSheets() const -> QList { return m_sheets; } diff --git a/src/app/puzzle/layout/vplayout.h b/src/app/puzzle/layout/vplayout.h index 7bd2e50a8..82cf706a0 100644 --- a/src/app/puzzle/layout/vplayout.h +++ b/src/app/puzzle/layout/vplayout.h @@ -32,7 +32,6 @@ #include #include -#include "def.h" #include "vplayoutsettings.h" #include "layoutdef.h" @@ -44,9 +43,9 @@ struct VWatermarkData; class VPLayout : public QObject { - Q_OBJECT + Q_OBJECT // NOLINT public: - virtual ~VPLayout() = default; + ~VPLayout() override = default; static auto CreateLayout(QUndoStack *undoStack) -> VPLayoutPtr; static void AddPiece(const VPLayoutPtr &layout, const VPPiecePtr &piece); @@ -83,7 +82,7 @@ public: auto PiecesForSheet(const VPSheetPtr &sheet) const -> QList; auto PiecesForSheet(const QUuid &uuid) const -> QList; - QUndoStack *UndoStack() const; + auto UndoStack() const -> QUndoStack *; void SetUndoStack(QUndoStack *newUndoStack); @@ -100,7 +99,7 @@ public: auto IsSheetsUniform() const -> bool; - const QUuid &Uuid() const; + auto Uuid() const -> const QUuid &; signals: void PieceSheetChanged(const VPPiecePtr &piece); @@ -119,7 +118,8 @@ protected: void AddPiece(const VPPiecePtr &piece); private: - Q_DISABLE_COPY(VPLayout) + // cppcheck-suppress unknownMacro + Q_DISABLE_COPY_MOVE(VPLayout) // NOLINT QMap m_pieces{}; @@ -137,6 +137,6 @@ private: QUuid m_uuid{QUuid::createUuid()}; }; -Q_DECLARE_METATYPE(VPLayoutPtr) +Q_DECLARE_METATYPE(VPLayoutPtr) // NOLINT #endif // VPLAYOUT_H diff --git a/src/app/puzzle/layout/vppiece.cpp b/src/app/puzzle/layout/vppiece.cpp index 2f5120ba7..cf385fb76 100644 --- a/src/app/puzzle/layout/vppiece.cpp +++ b/src/app/puzzle/layout/vppiece.cpp @@ -29,7 +29,6 @@ #include -#include "../vmisc/def.h" #include "vpsheet.h" #include "vplayout.h" #include "../vlayout/vtextmanager.h" @@ -40,7 +39,13 @@ #include #include -Q_LOGGING_CATEGORY(pPiece, "p.piece") +QT_WARNING_PUSH +QT_WARNING_DISABLE_CLANG("-Wmissing-prototypes") +QT_WARNING_DISABLE_INTEL(1418) + +Q_LOGGING_CATEGORY(pPiece, "p.piece") // NOLINT + +QT_WARNING_POP namespace { @@ -207,7 +212,7 @@ void VPPiece::SetPosition(QPointF point) auto VPPiece::GetPosition() -> QPointF { QTransform matrix = GetMatrix(); - return QPointF(matrix.dx(), matrix.dy()); + return {matrix.dx(), matrix.dy()}; } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/puzzle/main.cpp b/src/app/puzzle/main.cpp index 13353f3c6..161bab225 100644 --- a/src/app/puzzle/main.cpp +++ b/src/app/puzzle/main.cpp @@ -30,8 +30,6 @@ #include #include "vpapplication.h" -#include "../fervor/fvupdater.h" -#include "../vmisc/vsysexits.h" #include "../vmisc/def.h" @@ -44,7 +42,7 @@ # include "../vmisc/appimage.h" #endif // defined(APPIMAGE) && defined(Q_OS_LINUX) -int main(int argc, char *argv[]) +auto main(int argc, char *argv[]) -> int { #if defined(APPIMAGE) && defined(Q_OS_LINUX) /* Fix path to ICU_DATA when run AppImage.*/ @@ -52,15 +50,15 @@ int main(int argc, char *argv[]) auto FreeMemory = qScopeGuard([exe_dir] {free(exe_dir);}); #endif // defined(APPIMAGE) && defined(Q_OS_LINUX) - Q_INIT_RESOURCE(puzzleicon); - Q_INIT_RESOURCE(theme); - Q_INIT_RESOURCE(icon); - Q_INIT_RESOURCE(schema); - Q_INIT_RESOURCE(flags); - Q_INIT_RESOURCE(style); - Q_INIT_RESOURCE(cursor); + Q_INIT_RESOURCE(puzzleicon); // NOLINT + Q_INIT_RESOURCE(theme); // NOLINT + Q_INIT_RESOURCE(icon); // NOLINT + Q_INIT_RESOURCE(schema); // NOLINT + Q_INIT_RESOURCE(flags); // NOLINT + Q_INIT_RESOURCE(style); // NOLINT + Q_INIT_RESOURCE(cursor); // NOLINT - QT_REQUIRE_VERSION(argc, argv, "5.4.0")// clazy:exclude=qstring-arg,qstring-allocations + QT_REQUIRE_VERSION(argc, argv, "5.4.0")// clazy:exclude=qstring-arg,qstring-allocations NOLINT #if defined(Q_OS_WIN) VAbstractApplication::WinAttachConsole(); @@ -82,5 +80,5 @@ int main(int argc, char *argv[]) } #endif // defined(APPIMAGE) && defined(Q_OS_LINUX) - return app.exec(); + return VPApplication::exec(); } diff --git a/src/app/puzzle/scene/vpgraphicspiece.cpp b/src/app/puzzle/scene/vpgraphicspiece.cpp index 3e8fdc4f6..3ce6de00f 100644 --- a/src/app/puzzle/scene/vpgraphicspiece.cpp +++ b/src/app/puzzle/scene/vpgraphicspiece.cpp @@ -55,12 +55,19 @@ #include "undocommands/vpundomovepieceonsheet.h" #include -Q_LOGGING_CATEGORY(pGraphicsPiece, "p.graphicsPiece") + +QT_WARNING_PUSH +QT_WARNING_DISABLE_CLANG("-Wmissing-prototypes") +QT_WARNING_DISABLE_INTEL(1418) + +Q_LOGGING_CATEGORY(pGraphicsPiece, "p.graphicsPiece") // NOLINT + +QT_WARNING_POP namespace { -QColor mainColor = Qt::black; -QColor errorColor = Qt::red; +Q_GLOBAL_STATIC_WITH_ARGS(QColor, mainColor, (Qt::black)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(QColor, errorColor, (Qt::red)) // NOLINT //--------------------------------------------------------------------------------------------------------------------- inline auto LineMatrix(const VPPiecePtr &piece, const QPointF &topLeft, qreal angle, const QPointF &linePos, @@ -135,6 +142,12 @@ inline auto LineAlign(const TextLine& tl, const QString &text, const QFontMetric return dX; } + +//--------------------------------------------------------------------------------------------------------------------- +inline auto SelectionBrush() -> QBrush +{ + return {QColor(255, 160, 160, 60)}; +} } // namespace //--------------------------------------------------------------------------------------------------------------------- @@ -229,7 +242,7 @@ void VPGraphicsPiece::mouseMoveEvent(QGraphicsSceneMouseEvent *event) GroupMove(event->pos()); m_moveStartPoint = event->pos(); - allowChangeMerge = true; + m_allowChangeMerge = true; } //--------------------------------------------------------------------------------------------------------------------- @@ -253,7 +266,7 @@ void VPGraphicsPiece::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) if (layout->LayoutSettings().GetStickyEdges() && m_hasStickyPosition) { auto *command = new VPUndoPieceMove(piece, m_stickyTranslateX, m_stickyTranslateY, - allowChangeMerge); + m_allowChangeMerge); layout->UndoStack()->push(command); SetStickyPoints(QVector()); @@ -261,7 +274,7 @@ void VPGraphicsPiece::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) } } - allowChangeMerge = false; + m_allowChangeMerge = false; m_hasStickyPosition = false; } } @@ -441,9 +454,6 @@ void VPGraphicsPiece::InitPieceLabel(const QVector &labelShape, const V //--------------------------------------------------------------------------------------------------------------------- void VPGraphicsPiece::PaintPiece(QPainter *painter) { - QBrush noBrush = m_hoverMode ? QBrush(QColor(199, 244, 249, 60)) : QBrush(Qt::NoBrush); - QBrush selectionBrush(QColor(255, 160, 160, 60)); - m_seamLine = QPainterPath(); m_cuttingLine = QPainterPath(); m_grainline = QPainterPath(); @@ -459,6 +469,29 @@ void VPGraphicsPiece::PaintPiece(QPainter *painter) } // initialises the seam line + PaintSeamLine(painter, piece); + + // initiliases the cutting line + PaintCuttingLine(painter, piece); + + // initialises the grainline + PaintGrainline(painter, piece); + + // initialises the internal paths + PaintInternalPaths(painter, piece); + + // initialises the passmarks + PaintPassmarks(painter, piece); + + // initialises the place labels (buttons etc) + PaintPlaceLabels(painter, piece); + + PaintStickyPath(painter); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VPGraphicsPiece::PaintSeamLine(QPainter *painter, const VPPiecePtr &piece) +{ if (not piece->IsHideMainPath() || not piece->IsSeamAllowance()) { QVector seamLinePoints = piece->GetMappedContourPoints(); @@ -473,14 +506,17 @@ void VPGraphicsPiece::PaintPiece(QPainter *painter) if (painter != nullptr) { painter->save(); - painter->setBrush(piece->IsSelected() ? selectionBrush : noBrush); + painter->setBrush(piece->IsSelected() ? SelectionBrush() : NoBrush()); painter->drawPath(m_seamLine); painter->restore(); } } } +} - // initiliases the cutting line +//--------------------------------------------------------------------------------------------------------------------- +void VPGraphicsPiece::PaintCuttingLine(QPainter *painter, const VPPiecePtr &piece) +{ if (piece->IsSeamAllowance() && not piece->IsSeamAllowanceBuiltIn()) { QVector cuttingLinepoints = piece->GetMappedSeamAllowancePoints(); @@ -495,14 +531,17 @@ void VPGraphicsPiece::PaintPiece(QPainter *painter) if (painter != nullptr) { painter->save(); - painter->setBrush(piece->IsSelected() ? selectionBrush : noBrush); + painter->setBrush(piece->IsSelected() ? SelectionBrush() : NoBrush()); painter->drawPath(m_cuttingLine); painter->restore(); } } } +} - // initialises the grainline +//--------------------------------------------------------------------------------------------------------------------- +void VPGraphicsPiece::PaintGrainline(QPainter *painter, const VPPiecePtr &piece) +{ if(piece->IsGrainlineEnabled()) { QVector grainLinepoints = piece->GetMappedGrainline(); @@ -519,16 +558,19 @@ void VPGraphicsPiece::PaintPiece(QPainter *painter) painter->save(); // here to fill the grainlines arrow. Not wanted for mvp // later maybe if it's configurable -// painter->setBrush(blackBrush); + // painter->setBrush(blackBrush); - painter->setBrush(noBrush); + painter->setBrush(NoBrush()); painter->drawPath(m_grainline); painter->restore(); } } } +} - // initialises the internal paths +//--------------------------------------------------------------------------------------------------------------------- +void VPGraphicsPiece::PaintInternalPaths(QPainter *painter, const VPPiecePtr &piece) +{ QVector internalPaths = piece->GetInternalPaths(); for (const auto& piecePath : internalPaths) { @@ -545,8 +587,11 @@ void VPGraphicsPiece::PaintPiece(QPainter *painter) } m_internalPaths.addPath(path); } +} - // initialises the passmarks +//--------------------------------------------------------------------------------------------------------------------- +void VPGraphicsPiece::PaintPassmarks(QPainter *painter, const VPPiecePtr &piece) +{ QVector passmarks = piece->GetMappedPassmarks(); for(auto &passmark : passmarks) { @@ -560,15 +605,18 @@ void VPGraphicsPiece::PaintPiece(QPainter *painter) if (painter != nullptr) { painter->save(); - painter->setBrush(noBrush); + painter->setBrush(NoBrush()); painter->drawPath(passmarkPath); painter->restore(); } m_passmarks.addPath(passmarkPath); } +} - // initialises the place labels (buttons etc) +//--------------------------------------------------------------------------------------------------------------------- +void VPGraphicsPiece::PaintPlaceLabels(QPainter *painter, const VPPiecePtr &piece) +{ QVector placeLabels = piece->GetMappedPlaceLabels(); for(auto &placeLabel : placeLabels) { @@ -577,14 +625,18 @@ void VPGraphicsPiece::PaintPiece(QPainter *painter) if (painter != nullptr) { painter->save(); - painter->setBrush(noBrush); + painter->setBrush(NoBrush()); painter->drawPath(path); painter->restore(); } m_placeLabels.addPath(path); } +} +//--------------------------------------------------------------------------------------------------------------------- +void VPGraphicsPiece::PaintStickyPath(QPainter *painter) +{ if (not m_stickyPoints.isEmpty()) { m_stickyPath.moveTo(ConstFirst(m_stickyPoints)); @@ -600,7 +652,7 @@ void VPGraphicsPiece::PaintPiece(QPainter *painter) QPen pen = painter->pen(); pen.setStyle(Qt::DashLine); - pen.setColor(mainColor); + pen.setColor(*mainColor); painter->setPen(pen); painter->drawPath(m_stickyPath); @@ -648,7 +700,7 @@ void VPGraphicsPiece::GroupMove(const QPointF &pos) if (pieces.size() == 1) { const VPPiecePtr &p = ConstFirst(pieces); - auto *command = new VPUndoPieceMove(piece, newPos.x(), newPos.y(), allowChangeMerge); + auto *command = new VPUndoPieceMove(piece, newPos.x(), newPos.y(), m_allowChangeMerge); layout->UndoStack()->push(command); if (layout->LayoutSettings().GetStickyEdges()) @@ -672,7 +724,7 @@ void VPGraphicsPiece::GroupMove(const QPointF &pos) } else if (pieces.size() > 1) { - auto *command = new VPUndoPiecesMove(pieces, newPos.x(), newPos.y(), allowChangeMerge); + auto *command = new VPUndoPiecesMove(pieces, newPos.x(), newPos.y(), m_allowChangeMerge); layout->UndoStack()->push(command); } } @@ -683,13 +735,13 @@ auto VPGraphicsPiece::PieceColor() const -> QColor VPPiecePtr piece = m_piece.toStrongRef(); if (piece.isNull()) { - return mainColor; + return *mainColor; } VPLayoutPtr layout = piece->Layout(); if (layout.isNull()) { - return mainColor; + return *mainColor; } bool outOfBound = false; @@ -706,10 +758,16 @@ auto VPGraphicsPiece::PieceColor() const -> QColor if (outOfBound || superposition) { - return errorColor; + return *errorColor; } - return mainColor; + return *mainColor; +} + +//--------------------------------------------------------------------------------------------------------------------- +auto VPGraphicsPiece::NoBrush() const -> QBrush +{ + return m_hoverMode ? QBrush(QColor(199, 244, 249, 60)) : QBrush(Qt::NoBrush); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/puzzle/scene/vpgraphicspiece.h b/src/app/puzzle/scene/vpgraphicspiece.h index d217ef6ee..fca20b39a 100644 --- a/src/app/puzzle/scene/vpgraphicspiece.h +++ b/src/app/puzzle/scene/vpgraphicspiece.h @@ -100,7 +100,7 @@ private: QPointF m_moveStartPoint{}; QPointF m_rotationStartPoint{}; - bool allowChangeMerge{false}; + bool m_allowChangeMerge{false}; QVector m_stickyPoints{}; QPainterPath m_stickyPath{}; @@ -119,10 +119,19 @@ private: void InitLabels(); void InitPieceLabel(const QVector &labelShape, const VTextManager &tm); void PaintPiece(QPainter *painter=nullptr); + void PaintSeamLine(QPainter *painter, const VPPiecePtr &piece); + void PaintCuttingLine(QPainter *painter, const VPPiecePtr &piece); + void PaintGrainline(QPainter *painter, const VPPiecePtr &piece); + void PaintInternalPaths(QPainter *painter, const VPPiecePtr &piece); + void PaintPassmarks(QPainter *painter, const VPPiecePtr &piece); + void PaintPlaceLabels(QPainter *painter, const VPPiecePtr &piece); + void PaintStickyPath(QPainter *painter); void GroupMove(const QPointF &pos); auto PieceColor() const -> QColor; + + auto NoBrush() const -> QBrush; }; #endif // VPGRAPHICSPIECE_H diff --git a/src/app/puzzle/scene/vpgraphicspiececontrols.cpp b/src/app/puzzle/scene/vpgraphicspiececontrols.cpp index 85cb973c6..7e25af90d 100644 --- a/src/app/puzzle/scene/vpgraphicspiececontrols.cpp +++ b/src/app/puzzle/scene/vpgraphicspiececontrols.cpp @@ -40,6 +40,7 @@ #include "../vwidgets/global.h" #include "../layout/vplayout.h" #include "../layout/vppiece.h" +#include "../layout/vpsheet.h" #include "../undocommands/vpundopiecerotate.h" #include "../undocommands/vpundooriginmove.h" #include "qgraphicsscene.h" @@ -53,8 +54,8 @@ constexpr qreal penWidth = 2; const qreal centerRadius1 = 5; const qreal centerRadius2 = 10; -const QColor defaultColor = Qt::black; -const QColor hoverColor = Qt::green; +Q_GLOBAL_STATIC_WITH_ARGS(const QColor, defaultColor, (Qt::black)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QColor, hoverColor, (Qt::green)) // NOLINT auto TransformationOrigin(const VPLayoutPtr &layout, const QRectF &boundingRect) -> VPTransformationOrigon { @@ -83,7 +84,7 @@ auto TransformationOrigin(const VPLayoutPtr &layout, const QRectF &boundingRect) VPGraphicsTransformationOrigin::VPGraphicsTransformationOrigin(const VPLayoutPtr &layout, QGraphicsItem *parent) : QGraphicsObject(parent), m_layout(layout), - m_color(defaultColor) + m_color(*defaultColor) { SCASSERT(m_layout != nullptr) setCursor(Qt::OpenHandCursor); @@ -209,14 +210,14 @@ void VPGraphicsTransformationOrigin::mouseReleaseEvent(QGraphicsSceneMouseEvent //--------------------------------------------------------------------------------------------------------------------- void VPGraphicsTransformationOrigin::hoverEnterEvent(QGraphicsSceneHoverEvent *event) { - m_color = hoverColor; + m_color = *hoverColor; QGraphicsObject::hoverEnterEvent(event); } //--------------------------------------------------------------------------------------------------------------------- void VPGraphicsTransformationOrigin::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) { - m_color = defaultColor; + m_color = *defaultColor; QGraphicsObject::hoverEnterEvent(event); } @@ -419,7 +420,7 @@ void VPGraphicsPieceControls::mousePressEvent(QGraphicsSceneMouseEvent *event) QGraphicsView *view = ItemView(); if (view != nullptr) { - setCursor(view->viewport()->cursor()); + setCursor(view->viewport()->cursor()); // clazy:exclude=clazy-qt6-deprecated-api-fixes } event->ignore(); } @@ -502,7 +503,7 @@ void VPGraphicsPieceControls::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) QGraphicsView *view = ItemView(); if (view != nullptr) { - setCursor(view->viewport()->cursor()); + setCursor(view->viewport()->cursor()); // clazy:exclude=clazy-qt6-deprecated-api-fixes } } @@ -782,7 +783,7 @@ void VPGraphicsPieceControls::UpdateCursor(VPHandleCorner corner) QGraphicsView *view = ItemView(); if (view != nullptr) { - setCursor(view->viewport()->cursor()); + setCursor(view->viewport()->cursor()); // clazy:exclude=clazy-qt6-deprecated-api-fixes } } } diff --git a/src/app/puzzle/scene/vpgraphicspiececontrols.h b/src/app/puzzle/scene/vpgraphicspiececontrols.h index e0b5d56a5..a837b3b7b 100644 --- a/src/app/puzzle/scene/vpgraphicspiececontrols.h +++ b/src/app/puzzle/scene/vpgraphicspiececontrols.h @@ -32,7 +32,7 @@ #include #include "scenedef.h" -#include "../layout/vpsheet.h" +#include "../layout/layoutdef.h" #if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) #include "../vmisc/defglobal.h" @@ -64,6 +64,7 @@ class VPGraphicsTransformationOrigin : public QGraphicsObject Q_OBJECT // NOLINT public: explicit VPGraphicsTransformationOrigin(const VPLayoutPtr &layout, QGraphicsItem * parent = nullptr); + ~VPGraphicsTransformationOrigin() override = default; auto type() const -> int override {return Type;} enum { Type = UserType + static_cast(PGraphicsItem::TransformationOrigin)}; @@ -86,6 +87,7 @@ protected: void hoverLeaveEvent(QGraphicsSceneHoverEvent *event) override; private: + // cppcheck-suppress unknownMacro Q_DISABLE_COPY_MOVE(VPGraphicsTransformationOrigin) // NOLINT bool m_originVisible{true}; @@ -103,6 +105,7 @@ class VPGraphicsPieceControls : public QGraphicsObject Q_OBJECT // NOLINT public: explicit VPGraphicsPieceControls(const VPLayoutPtr &layout, QGraphicsItem * parent = nullptr); + ~VPGraphicsPieceControls() override = default; auto type() const -> int override {return Type;} enum { Type = UserType + static_cast(PGraphicsItem::Handles)}; diff --git a/src/app/puzzle/scene/vpgraphicssheet.h b/src/app/puzzle/scene/vpgraphicssheet.h index 7510f53ad..f228f2fe7 100644 --- a/src/app/puzzle/scene/vpgraphicssheet.h +++ b/src/app/puzzle/scene/vpgraphicssheet.h @@ -33,6 +33,7 @@ #include #include "../layout/layoutdef.h" +#include "../vmisc/defglobal.h" class VPLayout; @@ -40,7 +41,7 @@ class VPGraphicsSheet : public QGraphicsItem { public: explicit VPGraphicsSheet(const VPLayoutPtr &layout, QGraphicsItem *parent = nullptr); - ~VPGraphicsSheet()=default; + ~VPGraphicsSheet() override =default; auto boundingRect() const -> QRectF override; void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override; @@ -63,7 +64,8 @@ public: void RefreshBoundingRect(); private: - Q_DISABLE_COPY(VPGraphicsSheet) + // cppcheck-suppress unknownMacro + Q_DISABLE_COPY_MOVE(VPGraphicsSheet) // NOLINT VPLayoutWeakPtr m_layout{}; diff --git a/src/app/puzzle/scene/vpmaingraphicsview.cpp b/src/app/puzzle/scene/vpmaingraphicsview.cpp index 32630e505..958a053e9 100644 --- a/src/app/puzzle/scene/vpmaingraphicsview.cpp +++ b/src/app/puzzle/scene/vpmaingraphicsview.cpp @@ -34,14 +34,12 @@ #include #include -#include "../vptilefactory.h" #include "../carousel/vpmimedatapiece.h" #include "../layout/vplayout.h" #include "../layout/vpsheet.h" #include "../layout/vppiece.h" #include "../vwidgets/vmaingraphicsscene.h" #include "undocommands/vpundopiecezvaluemove.h" -#include "vptilefactory.h" #include "vpgraphicspiece.h" #include "vpgraphicspiececontrols.h" @@ -53,14 +51,21 @@ #include -Q_LOGGING_CATEGORY(pMainGraphicsView, "p.mainGraphicsView") +QT_WARNING_PUSH +QT_WARNING_DISABLE_CLANG("-Wmissing-prototypes") +QT_WARNING_DISABLE_INTEL(1418) + +Q_LOGGING_CATEGORY(pMainGraphicsView, "p.mainGraphicsView") // NOLINT + +QT_WARNING_POP namespace { QT_WARNING_PUSH QT_WARNING_DISABLE_CLANG("-Wenum-enum-conversion") -const QKeySequence restoreOriginShortcut = QKeySequence(Qt::ControlModifier + Qt::Key_Asterisk); +Q_GLOBAL_STATIC_WITH_ARGS(const QKeySequence, restoreOriginShortcut, // NOLINT + (QKeySequence(Qt::ControlModifier + Qt::Key_Asterisk))) QT_WARNING_POP } @@ -82,7 +87,7 @@ VPMainGraphicsView::VPMainGraphicsView(const VPLayoutPtr &layout, QWidget *paren connect(layout.data(), &VPLayout::ActiveSheetChanged, this, &VPMainGraphicsView::on_ActiveSheetChanged); auto *restoreOrigin = new QAction(this); - restoreOrigin->setShortcut(restoreOriginShortcut); + restoreOrigin->setShortcut(*restoreOriginShortcut); connect(restoreOrigin, &QAction::triggered, this, &VPMainGraphicsView::RestoreOrigin); this->addAction(restoreOrigin); } @@ -205,194 +210,88 @@ void VPMainGraphicsView::dropEvent(QDropEvent *event) //--------------------------------------------------------------------------------------------------------------------- void VPMainGraphicsView::keyPressEvent(QKeyEvent *event) { - if(event->key() == Qt::Key_Backspace || event->key() == Qt::Key_Delete) + const bool shiftModifier = (event->modifiers() & Qt::ShiftModifier) != 0U; + const bool controlModifier = (event->modifiers() & Qt::ControlModifier) != 0U; + const bool altModifier = (event->modifiers() & Qt::AltModifier) != 0U; + + switch(event->key()) { - VPLayoutPtr layout = m_layout.toStrongRef(); - if (layout.isNull()) - { - return; - } - - VPSheetPtr sheet = layout->GetFocusedSheet(); - if (sheet.isNull()) - { - return ; - } - - const QList &graphicsPieces = sheet->SceneData()->GraphicsPieces(); - for(auto *graphicsPiece : graphicsPieces) - { - VPPiecePtr piece = graphicsPiece->GetPiece(); - - if(not piece.isNull() && piece->IsSelected()) + case Qt::Key_Backspace: + case Qt::Key_Delete: + RemovePiece(); + break; + case Qt::Key_Left: + shiftModifier ? TranslatePiecesOn(-10, 0) : TranslatePiecesOn(-1, 0); + break; + case Qt::Key_Right: + shiftModifier ? TranslatePiecesOn(10, 0) : TranslatePiecesOn(1, 0); + break; + case Qt::Key_Up: + shiftModifier ? TranslatePiecesOn(0, -10) : TranslatePiecesOn(0, -1); + break; + case Qt::Key_Down: + shiftModifier ? TranslatePiecesOn(0, 10) : TranslatePiecesOn(0, 1); + break; + case Qt::Key_BracketLeft: + if(controlModifier) { - piece->SetSelected(false); - - VPLayoutPtr layout = m_layout.toStrongRef(); - if (not layout.isNull()) - { - emit layout->PieceSelectionChanged(piece); - - auto *command = new VPUndoMovePieceOnSheet(VPSheetPtr(), piece); - layout->UndoStack()->push(command); - } + RotatePiecesByAngle(90); } - } - } - else if (event->key() == Qt::Key_Left) - { - if((event->modifiers() & Qt::ShiftModifier) != 0U) - { - TranslatePiecesOn(-10, 0); - } - else - { - TranslatePiecesOn(-1, 0); - } - } - else if (event->key() == Qt::Key_Right) - { - if((event->modifiers() & Qt::ShiftModifier) != 0U) - { - TranslatePiecesOn(10, 0); - } - else - { - TranslatePiecesOn(1, 0); - } - } - else if (event->key() == Qt::Key_Up) - { - if((event->modifiers() & Qt::ShiftModifier) != 0U) - { - TranslatePiecesOn(0, -10); - } - else - { - TranslatePiecesOn(0, -1); - } - } - else if (event->key() == Qt::Key_Down) - { - if((event->modifiers() & Qt::ShiftModifier) != 0U) - { - TranslatePiecesOn(0, 10); - } - else - { - TranslatePiecesOn(0, 1); - } - } - else if (event->key() == Qt::Key_BracketLeft) - { - if((event->modifiers() & Qt::ControlModifier) != 0U) - { - RotatePiecesByAngle(90); - } - else if((event->modifiers() & Qt::AltModifier) != 0U) - { - RotatePiecesByAngle(1); - } - else - { - RotatePiecesByAngle(15); - } - } - else if (event->key() == Qt::Key_BracketRight) - { - if((event->modifiers() & Qt::ControlModifier) != 0U) - { - RotatePiecesByAngle(-90); - } - else if((event->modifiers() & Qt::AltModifier) != 0U) - { - RotatePiecesByAngle(-1); - } - else - { - RotatePiecesByAngle(-15); - } - } - else if (event->key() == Qt::Key_Home) - { - ZValueMove(static_cast(ML::ZValueMove::Top)); - } - else if (event->key() == Qt::Key_PageUp) - { - ZValueMove(static_cast(ML::ZValueMove::Up)); - } - else if (event->key() == Qt::Key_PageDown) - { - ZValueMove(static_cast(ML::ZValueMove::Down)); - } - else if (event->key() == Qt::Key_End) - { - ZValueMove(static_cast(ML::ZValueMove::Bottom)); + else if(altModifier) + { + RotatePiecesByAngle(1); + } + else + { + RotatePiecesByAngle(15); + } + break; + case Qt::Key_BracketRight: + if(controlModifier) + { + RotatePiecesByAngle(-90); + } + else if(altModifier) + { + RotatePiecesByAngle(-1); + } + else + { + RotatePiecesByAngle(-15); + } + break; + case Qt::Key_Home: + ZValueMove(static_cast(ML::ZValueMove::Top)); + break; + case Qt::Key_PageUp: + ZValueMove(static_cast(ML::ZValueMove::Up)); + break; + case Qt::Key_PageDown: + ZValueMove(static_cast(ML::ZValueMove::Down)); + break; + case Qt::Key_End: + ZValueMove(static_cast(ML::ZValueMove::Bottom)); + break; + default: + break; } } //--------------------------------------------------------------------------------------------------------------------- void VPMainGraphicsView::keyReleaseEvent(QKeyEvent *event) { - if (event->key() == Qt::Key_Left || - event->key() == Qt::Key_Right || - event->key() == Qt::Key_Up || - event->key() == Qt::Key_Down || - event->key() == Qt::Key_BracketLeft || - event->key() == Qt::Key_BracketRight) + switch(event->key()) { - if (not event->isAutoRepeat()) - { - VPLayoutPtr layout = m_layout.toStrongRef(); - if (layout.isNull()) - { - return; - } - - VPSheetPtr sheet = layout->GetFocusedSheet(); - if (sheet.isNull()) - { - return; - } - - const QList &graphicsPieces = sheet->SceneData()->GraphicsPieces(); - if (m_hasStickyPosition && not graphicsPieces.isEmpty()) - { - if (layout->LayoutSettings().GetStickyEdges()) - { - auto PreparePieces = [layout]() - { - QList pieces; - VPSheetPtr sheet = layout->GetFocusedSheet(); - if (not sheet.isNull()) - { - pieces = sheet->GetSelectedPieces(); - } - - return pieces; - }; - - QList pieces = PreparePieces(); - if (pieces.size() == 1) - { - const VPPiecePtr &p = ConstFirst(pieces); - - auto *command = new VPUndoPieceMove(p, m_stickyTranslateX, m_stickyTranslateY, - m_allowChangeMerge); - layout->UndoStack()->push(command); - - VPGraphicsPiece * gPiece = sheet->SceneData()->ScenePiece(p); - if (gPiece != nullptr) - { - gPiece->SetStickyPoints(QVector()); - } - } - } - } - - m_allowChangeMerge = false; - m_hasStickyPosition = false; - } + case Qt::Key_Left: + case Qt::Key_Right: + case Qt::Key_Up: + case Qt::Key_Down: + case Qt::Key_BracketLeft: + case Qt::Key_BracketRight: + MovePiece(event); + break; + default: + break; } if (event->key() == Qt::Key_BracketLeft || event->key() == Qt::Key_BracketRight) @@ -440,7 +339,7 @@ void VPMainGraphicsView::contextMenuEvent(QContextMenuEvent *event) QMenu menu; QAction *restoreOriginAction = menu.addAction(tr("Restore transformation origin")); - restoreOriginAction->setShortcut(restoreOriginShortcut); + restoreOriginAction->setShortcut(*restoreOriginShortcut); restoreOriginAction->setEnabled(not sheet.isNull() && sheet->TransformationOrigin().custom); QAction *removeSheetAction = menu.addAction(QIcon::fromTheme(QStringLiteral("edit-delete")), tr("Remove sheet")); @@ -723,6 +622,99 @@ void VPMainGraphicsView::ZValueMove(int move) } } +//--------------------------------------------------------------------------------------------------------------------- +void VPMainGraphicsView::RemovePiece() const +{ + VPLayoutPtr layout = m_layout.toStrongRef(); + if (layout.isNull()) + { + return; + } + + VPSheetPtr sheet = layout->GetFocusedSheet(); + if (sheet.isNull()) + { + return ; + } + + const QList &graphicsPieces = sheet->SceneData()->GraphicsPieces(); + for(auto *graphicsPiece : graphicsPieces) + { + VPPiecePtr piece = graphicsPiece->GetPiece(); + + if(not piece.isNull() && piece->IsSelected()) + { + piece->SetSelected(false); + + VPLayoutPtr layout = m_layout.toStrongRef(); + if (not layout.isNull()) + { + emit layout->PieceSelectionChanged(piece); + + auto *command = new VPUndoMovePieceOnSheet(VPSheetPtr(), piece); + layout->UndoStack()->push(command); + } + } + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void VPMainGraphicsView::MovePiece(QKeyEvent *event) +{ + if (not event->isAutoRepeat()) + { + VPLayoutPtr layout = m_layout.toStrongRef(); + if (layout.isNull()) + { + return; + } + + VPSheetPtr sheet = layout->GetFocusedSheet(); + if (sheet.isNull()) + { + return; + } + + const QList &graphicsPieces = sheet->SceneData()->GraphicsPieces(); + if (m_hasStickyPosition && not graphicsPieces.isEmpty()) + { + if (layout->LayoutSettings().GetStickyEdges()) + { + auto PreparePieces = [layout]() + { + QList pieces; + VPSheetPtr sheet = layout->GetFocusedSheet(); + if (not sheet.isNull()) + { + pieces = sheet->GetSelectedPieces(); + } + + return pieces; + }; + + QList pieces = PreparePieces(); + if (pieces.size() == 1) + { + const VPPiecePtr &p = ConstFirst(pieces); + + auto *command = new VPUndoPieceMove(p, m_stickyTranslateX, m_stickyTranslateY, + m_allowChangeMerge); + layout->UndoStack()->push(command); + + VPGraphicsPiece * gPiece = sheet->SceneData()->ScenePiece(p); + if (gPiece != nullptr) + { + gPiece->SetStickyPoints(QVector()); + } + } + } + } + + m_allowChangeMerge = false; + m_hasStickyPosition = false; + } +} + //--------------------------------------------------------------------------------------------------------------------- void VPMainGraphicsView::on_PieceSheetChanged(const VPPiecePtr &piece) { diff --git a/src/app/puzzle/scene/vpmaingraphicsview.h b/src/app/puzzle/scene/vpmaingraphicsview.h index 19d552923..7424d2079 100644 --- a/src/app/puzzle/scene/vpmaingraphicsview.h +++ b/src/app/puzzle/scene/vpmaingraphicsview.h @@ -44,10 +44,10 @@ class VPPiece; class VPMainGraphicsView : public VMainGraphicsView { - Q_OBJECT + Q_OBJECT // NOLINT public: VPMainGraphicsView(const VPLayoutPtr &layout, QWidget *parent); - ~VPMainGraphicsView() = default; + ~VPMainGraphicsView() override = default; /** * @brief RefreshLayout Refreshes the rectangles for the layout border and the margin @@ -91,7 +91,8 @@ private slots: void on_SceneMouseMove(const QPointF &scenePos); private: - Q_DISABLE_COPY(VPMainGraphicsView) + // cppcheck-suppress unknownMacro + Q_DISABLE_COPY_MOVE(VPMainGraphicsView) // NOLINT VPLayoutWeakPtr m_layout; @@ -110,6 +111,9 @@ private: void ClearSelection(); void ZValueMove(int move); + + void RemovePiece() const; + void MovePiece(QKeyEvent *event); }; #endif // VPMAINGRAPHICSVIEW_H diff --git a/src/app/puzzle/undocommands/vpundoaddsheet.h b/src/app/puzzle/undocommands/vpundoaddsheet.h index 52a135fdf..156ab271e 100644 --- a/src/app/puzzle/undocommands/vpundoaddsheet.h +++ b/src/app/puzzle/undocommands/vpundoaddsheet.h @@ -34,17 +34,17 @@ class VPUndoAddSheet : public VPUndoCommand { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit VPUndoAddSheet(const VPSheetPtr &sheet, QUndoCommand *parent = nullptr); - virtual ~VPUndoAddSheet()=default; + ~VPUndoAddSheet() override =default; - virtual void undo() override; - virtual void redo() override; - virtual auto id() const -> int override; + void undo() override; + void redo() override; + auto id() const -> int override; private: - Q_DISABLE_COPY(VPUndoAddSheet) + Q_DISABLE_COPY_MOVE(VPUndoAddSheet) // NOLINT VPSheetWeakPtr m_sheet; }; diff --git a/src/app/puzzle/undocommands/vpundocommand.cpp b/src/app/puzzle/undocommands/vpundocommand.cpp index fa6774290..afefc5d3e 100644 --- a/src/app/puzzle/undocommands/vpundocommand.cpp +++ b/src/app/puzzle/undocommands/vpundocommand.cpp @@ -27,7 +27,13 @@ *************************************************************************/ #include "vpundocommand.h" -Q_LOGGING_CATEGORY(vpUndo, "vp.undo") +QT_WARNING_PUSH +QT_WARNING_DISABLE_CLANG("-Wmissing-prototypes") +QT_WARNING_DISABLE_INTEL(1418) + +Q_LOGGING_CATEGORY(vpUndo, "vp.undo") // NOLINT + +QT_WARNING_POP //--------------------------------------------------------------------------------------------------------------------- VPUndoCommand::VPUndoCommand(QUndoCommand *parent) diff --git a/src/app/puzzle/undocommands/vpundomovepieceonsheet.h b/src/app/puzzle/undocommands/vpundomovepieceonsheet.h index abaa42e29..318452be6 100644 --- a/src/app/puzzle/undocommands/vpundomovepieceonsheet.h +++ b/src/app/puzzle/undocommands/vpundomovepieceonsheet.h @@ -34,17 +34,17 @@ class VPUndoMovePieceOnSheet : public VPUndoCommand { - Q_OBJECT + Q_OBJECT // NOLINT public: VPUndoMovePieceOnSheet(const VPSheetPtr &sheet, const VPPiecePtr &piece, QUndoCommand *parent = nullptr); - virtual ~VPUndoMovePieceOnSheet()=default; + ~VPUndoMovePieceOnSheet() override =default; - virtual void undo() override; - virtual void redo() override; - virtual auto id() const -> int override; + void undo() override; + void redo() override; + auto id() const -> int override; private: - Q_DISABLE_COPY(VPUndoMovePieceOnSheet) + Q_DISABLE_COPY_MOVE(VPUndoMovePieceOnSheet) // NOLINT VPSheetWeakPtr m_oldSheet{}; VPSheetWeakPtr m_sheet; diff --git a/src/app/puzzle/undocommands/vpundooriginmove.cpp b/src/app/puzzle/undocommands/vpundooriginmove.cpp index 49601235a..e8149bc43 100644 --- a/src/app/puzzle/undocommands/vpundooriginmove.cpp +++ b/src/app/puzzle/undocommands/vpundooriginmove.cpp @@ -65,7 +65,7 @@ void VPUndoOriginMove::undo() } sheet->SetTransformationOrigin(m_oldOrigin); - layout->TransformationOriginChanged(); + emit layout->TransformationOriginChanged(); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/puzzle/undocommands/vpundooriginmove.h b/src/app/puzzle/undocommands/vpundooriginmove.h index 837092508..34d18342e 100644 --- a/src/app/puzzle/undocommands/vpundooriginmove.h +++ b/src/app/puzzle/undocommands/vpundooriginmove.h @@ -34,23 +34,23 @@ class VPUndoOriginMove : public VPUndoCommand { - Q_OBJECT + Q_OBJECT // NOLINT public: VPUndoOriginMove(const VPSheetPtr &sheet, const VPTransformationOrigon &origin, bool allowMerge = false, QUndoCommand *parent = nullptr); - virtual ~VPUndoOriginMove()=default; + ~VPUndoOriginMove() override =default; - virtual void undo() override; - virtual void redo() override; + void undo() override; + void redo() override; // cppcheck-suppress unusedFunction - virtual auto mergeWith(const QUndoCommand *command) -> bool override; - virtual auto id() const -> int override; + auto mergeWith(const QUndoCommand *command) -> bool override; + auto id() const -> int override; auto Sheet() const -> VPSheetWeakPtr; auto Origin() const -> const VPTransformationOrigon &; private: - Q_DISABLE_COPY(VPUndoOriginMove) + Q_DISABLE_COPY_MOVE(VPUndoOriginMove) // NOLINT VPSheetWeakPtr m_sheet; VPTransformationOrigon m_oldOrigin{}; diff --git a/src/app/puzzle/undocommands/vpundopiecemove.cpp b/src/app/puzzle/undocommands/vpundopiecemove.cpp index fb2ca8fc9..4a9782e2f 100644 --- a/src/app/puzzle/undocommands/vpundopiecemove.cpp +++ b/src/app/puzzle/undocommands/vpundopiecemove.cpp @@ -162,7 +162,7 @@ void VPUndoPiecesMove::undo() layout->SetFocusedSheet(sheet); } - for (const auto& piece : m_pieces) + for (const auto& piece : qAsConst(m_pieces)) { VPPiecePtr p = piece.toStrongRef(); if (not p.isNull()) @@ -196,7 +196,7 @@ void VPUndoPiecesMove::redo() layout->SetFocusedSheet(sheet); } - for (const auto& piece : m_pieces) + for (const auto& piece : qAsConst(m_pieces)) { VPPiecePtr p = piece.toStrongRef(); if (not p.isNull()) diff --git a/src/app/puzzle/undocommands/vpundopiecemove.h b/src/app/puzzle/undocommands/vpundopiecemove.h index fe84e3413..d8b0e414a 100644 --- a/src/app/puzzle/undocommands/vpundopiecemove.h +++ b/src/app/puzzle/undocommands/vpundopiecemove.h @@ -36,24 +36,24 @@ class VPUndoPieceMove : public VPUndoCommand { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit VPUndoPieceMove(const VPPiecePtr &piece, qreal dx, qreal dy, bool allowMerge = false, QUndoCommand *parent = nullptr); - virtual ~VPUndoPieceMove()=default; + ~VPUndoPieceMove() override =default; - virtual void undo() override; - virtual void redo() override; + void undo() override; + void redo() override; // cppcheck-suppress unusedFunction - virtual auto mergeWith(const QUndoCommand *command) -> bool override; - virtual auto id() const -> int override ; + auto mergeWith(const QUndoCommand *command) -> bool override; + auto id() const -> int override; auto Piece() const -> VPPiecePtr; auto Dx() const -> qreal; auto Dy() const -> qreal; private: - Q_DISABLE_COPY(VPUndoPieceMove) + Q_DISABLE_COPY_MOVE(VPUndoPieceMove) // NOLINT VPPieceWeakPtr m_piece; QTransform m_oldTransform{}; @@ -82,24 +82,24 @@ inline auto VPUndoPieceMove::Dy() const -> qreal // Move pieces class VPUndoPiecesMove : public VPUndoCommand { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit VPUndoPiecesMove(const QList &pieces, qreal dx, qreal dy, bool allowMerge = false, QUndoCommand *parent = nullptr); - virtual ~VPUndoPiecesMove()=default; + ~VPUndoPiecesMove() override =default; - virtual void undo() override; - virtual void redo() override; + void undo() override; + void redo() override; // cppcheck-suppress unusedFunction - virtual auto mergeWith(const QUndoCommand *command) -> bool override; - virtual auto id() const -> int override ; + auto mergeWith(const QUndoCommand *command) -> bool override; + auto id() const -> int override ; auto PieceIds() const -> QSet; auto Dx() const -> qreal; auto Dy() const -> qreal; private: - Q_DISABLE_COPY(VPUndoPiecesMove) + Q_DISABLE_COPY_MOVE(VPUndoPiecesMove) // NOLINT QVector m_pieces{}; QMap m_oldTransforms{}; diff --git a/src/app/puzzle/undocommands/vpundopiecerotate.cpp b/src/app/puzzle/undocommands/vpundopiecerotate.cpp index fc209a272..6476aebe6 100644 --- a/src/app/puzzle/undocommands/vpundopiecerotate.cpp +++ b/src/app/puzzle/undocommands/vpundopiecerotate.cpp @@ -213,7 +213,7 @@ void VPUndoPiecesRotate::undo() layout->SetFocusedSheet(sheet); } - for (const auto& piece : m_pieces) + for (const auto& piece : qAsConst(m_pieces)) { VPPiecePtr p = piece.toStrongRef(); if (not p.isNull()) @@ -247,7 +247,7 @@ void VPUndoPiecesRotate::redo() layout->SetFocusedSheet(sheet); } - for (const auto& piece : m_pieces) + for (const auto& piece : qAsConst(m_pieces)) { VPPiecePtr p = piece.toStrongRef(); if (not p.isNull()) diff --git a/src/app/puzzle/undocommands/vpundopiecerotate.h b/src/app/puzzle/undocommands/vpundopiecerotate.h index 769862cad..c21639fe1 100644 --- a/src/app/puzzle/undocommands/vpundopiecerotate.h +++ b/src/app/puzzle/undocommands/vpundopiecerotate.h @@ -36,27 +36,27 @@ class VPUndoPieceRotate : public VPUndoCommand { - Q_OBJECT + Q_OBJECT // NOLINT public: VPUndoPieceRotate(const VPPiecePtr &piece, const VPTransformationOrigon &origin, qreal angle, qreal angleSum, bool allowMerge = false, QUndoCommand *parent = nullptr); - virtual ~VPUndoPieceRotate()=default; + ~VPUndoPieceRotate() override =default; - virtual void undo() override; - virtual void redo() override; + void undo() override; + void redo() override; // cppcheck-suppress unusedFunction - virtual auto mergeWith(const QUndoCommand *command) -> bool override; - virtual auto id() const -> int override ; + auto mergeWith(const QUndoCommand *command) -> bool override; + auto id() const -> int override; auto Piece() const -> VPPiecePtr; auto Origin() const -> VPTransformationOrigon; auto Angle() const -> qreal; - bool FollowGrainline() const; + auto FollowGrainline() const -> bool; private: - Q_DISABLE_COPY(VPUndoPieceRotate) + Q_DISABLE_COPY_MOVE(VPUndoPieceRotate) // NOLINT bool m_firstCall{true}; VPPieceWeakPtr m_piece; @@ -94,17 +94,17 @@ inline auto VPUndoPieceRotate::FollowGrainline() const -> bool // Rotate pieces class VPUndoPiecesRotate : public VPUndoCommand { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit VPUndoPiecesRotate(const QList &pieces, const VPTransformationOrigon &origin, qreal angle, qreal angleSum, bool allowMerge = false, QUndoCommand *parent = nullptr); - virtual ~VPUndoPiecesRotate()=default; + ~VPUndoPiecesRotate() override =default; - virtual void undo() override; - virtual void redo() override; + void undo() override; + void redo() override; // cppcheck-suppress unusedFunction - virtual auto mergeWith(const QUndoCommand *command) -> bool override; - virtual auto id() const -> int override ; + auto mergeWith(const QUndoCommand *command) -> bool override; + auto id() const -> int override; auto PieceIds() const -> QSet; auto Origin() const -> VPTransformationOrigon; @@ -112,7 +112,7 @@ public: auto FollowGrainline() const -> bool; private: - Q_DISABLE_COPY(VPUndoPiecesRotate) + Q_DISABLE_COPY_MOVE(VPUndoPiecesRotate) // NOLINT bool m_firstCall{true}; QVector m_pieces{}; diff --git a/src/app/puzzle/undocommands/vpundopiecezvaluemove.cpp b/src/app/puzzle/undocommands/vpundopiecezvaluemove.cpp index d3c423522..bd9cea733 100644 --- a/src/app/puzzle/undocommands/vpundopiecezvaluemove.cpp +++ b/src/app/puzzle/undocommands/vpundopiecezvaluemove.cpp @@ -254,7 +254,7 @@ auto VPUndoPieceZValueMove::Levels(const QList &pieces, bool skip) c } } - return levels.values(); + return levels.values(); // clazy:exclude=clazy-qt6-deprecated-api-fixes } //--------------------------------------------------------------------------------------------------------------------- @@ -497,11 +497,11 @@ auto VPUndoPiecesZValueMove::Levels(const QList &allPieces, const QV } } - return levels.values(); + return levels.values(); // clazy:exclude=clazy-qt6-deprecated-api-fixes } //--------------------------------------------------------------------------------------------------------------------- -auto VPUndoPiecesZValueMove::LevelStep(const QList &pieces) const -> qreal +auto VPUndoPiecesZValueMove::LevelStep(const QList &pieces) -> qreal { QList> levels = Levels(pieces, QVector(), false); if (levels.isEmpty()) diff --git a/src/app/puzzle/undocommands/vpundopiecezvaluemove.h b/src/app/puzzle/undocommands/vpundopiecezvaluemove.h index 55a86b84a..355721d5a 100644 --- a/src/app/puzzle/undocommands/vpundopiecezvaluemove.h +++ b/src/app/puzzle/undocommands/vpundopiecezvaluemove.h @@ -48,6 +48,7 @@ enum class ZValueMove class VPUndoPieceZValueMove : public VPUndoCommand { + Q_OBJECT // NOLINT public: VPUndoPieceZValueMove(const VPPiecePtr &piece, ML::ZValueMove move, QUndoCommand *parent = nullptr); ~VPUndoPieceZValueMove() override =default; @@ -72,6 +73,7 @@ private: class VPUndoPiecesZValueMove : public VPUndoCommand { + Q_OBJECT // NOLINT public: VPUndoPiecesZValueMove(const QList &pieces, ML::ZValueMove move, QUndoCommand *parent = nullptr); ~VPUndoPiecesZValueMove() override =default; @@ -93,7 +95,7 @@ private: auto PieceIds() const -> QVector; static auto Levels(const QList &allPieces, const QVector &skipPieces, bool skip) -> QList>; - auto LevelStep(const QList &pieces) const -> qreal; + static auto LevelStep(const QList &pieces) -> qreal; }; #endif // VPUNDOPIECEZVALUEMOVE_H diff --git a/src/app/puzzle/undocommands/vpundoremovesheet.cpp b/src/app/puzzle/undocommands/vpundoremovesheet.cpp index 316754b11..b82522850 100644 --- a/src/app/puzzle/undocommands/vpundoremovesheet.cpp +++ b/src/app/puzzle/undocommands/vpundoremovesheet.cpp @@ -39,7 +39,8 @@ VPUndoRemoveSheet::VPUndoRemoveSheet(const VPSheetPtr &sheet, QUndoCommand *pare SCASSERT(not sheet.isNull()) QList pieces = sheet->GetPieces(); - for (auto piece : pieces) + m_pieces.reserve(pieces.size()); + for (const auto &piece : pieces) { m_pieces.append(piece); } @@ -60,7 +61,7 @@ void VPUndoRemoveSheet::undo() { sheet->SetVisible(true); - for (const auto &piece : m_pieces) + for (const auto &piece : qAsConst(m_pieces)) { VPPiecePtr p = piece.toStrongRef(); if (not p.isNull()) @@ -93,7 +94,7 @@ void VPUndoRemoveSheet::redo() { sheet->SetVisible(false); - for (const auto &piece : m_pieces) + for (const auto &piece : qAsConst(m_pieces)) { VPPiecePtr p = piece.toStrongRef(); if (not p.isNull()) diff --git a/src/app/puzzle/undocommands/vpundoremovesheet.h b/src/app/puzzle/undocommands/vpundoremovesheet.h index 33277a2f4..c351fd103 100644 --- a/src/app/puzzle/undocommands/vpundoremovesheet.h +++ b/src/app/puzzle/undocommands/vpundoremovesheet.h @@ -34,17 +34,17 @@ class VPUndoRemoveSheet : public VPUndoCommand { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit VPUndoRemoveSheet(const VPSheetPtr &sheet, QUndoCommand *parent = nullptr); - virtual ~VPUndoRemoveSheet()=default; + ~VPUndoRemoveSheet() override =default; - virtual void undo() override; - virtual void redo() override; - virtual auto id() const -> int override; + void undo() override; + void redo() override; + auto id() const -> int override; private: - Q_DISABLE_COPY(VPUndoRemoveSheet) + Q_DISABLE_COPY_MOVE(VPUndoRemoveSheet) // NOLINT QList m_pieces{}; VPSheetWeakPtr m_sheet; diff --git a/src/app/puzzle/vpapplication.cpp b/src/app/puzzle/vpapplication.cpp index 8c63b5452..3bb6f0370 100644 --- a/src/app/puzzle/vpapplication.cpp +++ b/src/app/puzzle/vpapplication.cpp @@ -61,7 +61,7 @@ QT_WARNING_POP #include //--------------------------------------------------------------------------------------------------------------------- -inline void noisyFailureMsgHandler(QtMsgType type, const QMessageLogContext &context, const QString &msg) +inline void noisyFailureMsgHandler(QtMsgType type, const QMessageLogContext &context, const QString &msg) // NOLINT(readability-function-cognitive-complexity) { // only the GUI thread should display message boxes. If you are // writing a multithreaded application and the error happens on @@ -315,7 +315,7 @@ auto VPApplication::notify(QObject *receiver, QEvent *event) -> bool catch (const VExceptionToolWasDeleted &e) { qCCritical(pApp, "%s\n\n%s\n\n%s", - qUtf8Printable("Unhadled deleting tool. Continue use object after deleting!"), + qUtf8Printable(QStringLiteral("Unhadled deleting tool. Continue use object after deleting!")), qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation())); exit(V_EX_DATAERR); } @@ -534,7 +534,7 @@ auto VPApplication::event(QEvent *e) -> bool // Mac specific). case QEvent::FileOpen: { - auto *fileOpenEvent = static_cast(e); + auto *fileOpenEvent = static_cast(e); // NOLINT(cppcoreguidelines-pro-type-static-cast-downcast) const QString macFileOpen = fileOpenEvent->file(); if(not macFileOpen.isEmpty()) { @@ -670,7 +670,7 @@ auto VPApplication::StartWithFiles(const VPCommandLinePtr &cmd, const QStringLis cmd.get()->parser.showHelp(V_EX_USAGE); } - for (const auto &arg : args) + for (const auto &arg : args) // NOLINT(readability-use-anyofallof) { NewMainWindow(cmd); if (not MainWindow()->LoadFile(arg)) diff --git a/src/app/puzzle/vpcommandline.cpp b/src/app/puzzle/vpcommandline.cpp index 95d530af1..56b7702d8 100644 --- a/src/app/puzzle/vpcommandline.cpp +++ b/src/app/puzzle/vpcommandline.cpp @@ -31,12 +31,12 @@ #include "../vmisc/literals.h" #include -std::shared_ptr VPCommandLine::instance = nullptr; +std::shared_ptr VPCommandLine::instance = nullptr; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables) -#define translate(context, source) QCoreApplication::translate((context), source) +#define translate(context, source) QCoreApplication::translate((context), source)// NOLINT(cppcoreguidelines-macro-usage) //------------------------------------------------------------------------------------------------ -bool VPCommandLine::IsExportEnabled() const +auto VPCommandLine::IsExportEnabled() const -> bool { const bool result = IsOptionSet(LONG_OPTION_EXPORT_FILE); int argSize = parser.positionalArguments().size(); @@ -49,7 +49,7 @@ bool VPCommandLine::IsExportEnabled() const } //---------------------------------------------------------------------------------------------- -QString VPCommandLine::OptionExportFile() const +auto VPCommandLine::OptionExportFile() const -> QString { QString path; if (IsExportEnabled()) @@ -61,13 +61,13 @@ QString VPCommandLine::OptionExportFile() const } //--------------------------------------------------------------------------------------------------------------------- -QStringList VPCommandLine::OptionRawLayouts() const +auto VPCommandLine::OptionRawLayouts() const -> QStringList { return OptionValues(LONG_OPTION_RAW_LAYOUT); } //-------------------------------------------------------------------------------------------- -bool VPCommandLine::IsTestModeEnabled() const +auto VPCommandLine::IsTestModeEnabled() const -> bool { const bool r = IsOptionSet(LONG_OPTION_TEST); if (r && parser.positionalArguments().size() != 1) @@ -79,19 +79,19 @@ bool VPCommandLine::IsTestModeEnabled() const } //-------------------------------------------------------------------------------------------- -bool VPCommandLine::IsGuiEnabled() const +auto VPCommandLine::IsGuiEnabled() const -> bool { return isGuiEnabled; } //-------------------------------------------------------------------------------------------- -QStringList VPCommandLine::OptionFileNames() const +auto VPCommandLine::OptionFileNames() const -> QStringList { return parser.positionalArguments(); } //------------------------------------------------------------------------------------------- -bool VPCommandLine::IsNoScalingEnabled() const +auto VPCommandLine::IsNoScalingEnabled() const -> bool { return IsOptionSet(LONG_OPTION_NO_HDPI_SCALING); } @@ -103,9 +103,7 @@ void VPCommandLine::ShowHelp(int exitCode) } //---------------------------------------------------------------------------------------------- -VPCommandLine::VPCommandLine(): - parser(), - isGuiEnabled(false) +VPCommandLine::VPCommandLine() { parser.setApplicationDescription(translate("Puzzle", "Valentina's manual layout editor.")); parser.addHelpOption(); @@ -116,7 +114,7 @@ VPCommandLine::VPCommandLine(): } //------------------------------------------------------------------------------------------- -VPCommandLinePtr VPCommandLine::Instance() +auto VPCommandLine::Instance() -> VPCommandLinePtr { VPCommandLine::ProcessInstance(instance, QCoreApplication::arguments()); return instance; @@ -193,19 +191,19 @@ void VPCommandLine::InitCommandLineOptions() } //-------------------------------------------------------------------------------------------- -bool VPCommandLine::IsOptionSet(const QString &option) const +auto VPCommandLine::IsOptionSet(const QString &option) const -> bool { return parser.isSet(option); } //------------------------------------------------------------------------------------------- -QString VPCommandLine::OptionValue(const QString &option) const +auto VPCommandLine::OptionValue(const QString &option) const -> QString { return parser.value(option); } //-------------------------------------------------------------------------------------------- -QStringList VPCommandLine::OptionValues(const QString &option) const +auto VPCommandLine::OptionValues(const QString &option) const -> QStringList { return parser.values(option); } diff --git a/src/app/puzzle/vpcommandline.h b/src/app/puzzle/vpcommandline.h index 259c858d9..b0a13fa4f 100644 --- a/src/app/puzzle/vpcommandline.h +++ b/src/app/puzzle/vpcommandline.h @@ -33,56 +33,59 @@ #include #include +#include "../vmisc/defglobal.h" + class VPCommandLine; using VPCommandLinePtr = std::shared_ptr; class VPCommandLine: public QObject { - Q_OBJECT -public: - virtual ~VPCommandLine() = default; + Q_OBJECT // NOLINT +public: + ~VPCommandLine() override = default; /** @brief if user enabled export from cmd */ - bool IsExportEnabled() const; + auto IsExportEnabled() const -> bool; /** @brief path to export file or empty string if not */ - QString OptionExportFile() const; + auto OptionExportFile() const -> QString; /** @brief list with paths to the raw layout data files */ - QStringList OptionRawLayouts() const; + auto OptionRawLayouts() const -> QStringList; /** @brief if user enabled test mode from cmd */ - bool IsTestModeEnabled() const; + auto IsTestModeEnabled() const -> bool; /** @brief if gui enabled or not */ - bool IsGuiEnabled() const; + auto IsGuiEnabled() const -> bool; /** @brief the file name which should be loaded */ - QStringList OptionFileNames() const; + auto OptionFileNames() const -> QStringList; /** @brief if high dpi scaling is enabled */ - bool IsNoScalingEnabled() const; + auto IsNoScalingEnabled() const -> bool; Q_NORETURN void ShowHelp(int exitCode = 0); protected: VPCommandLine(); /** @brief create the single instance of the class inside vpapplication */ - static VPCommandLinePtr Instance(); + static auto Instance() -> VPCommandLinePtr; static void ProcessInstance(VPCommandLinePtr &instance, const QStringList &arguments); private: - Q_DISABLE_COPY(VPCommandLine) - static VPCommandLinePtr instance; - QCommandLineParser parser; - bool isGuiEnabled; + // cppcheck-suppress unknownMacro + Q_DISABLE_COPY_MOVE(VPCommandLine) // NOLINT + static VPCommandLinePtr instance; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables) + QCommandLineParser parser{}; + bool isGuiEnabled{false}; friend class VPApplication; /** @brief add options to the QCommandLineParser that there are in the cmd can be */ void InitCommandLineOptions(); - bool IsOptionSet(const QString &option)const; - QString OptionValue(const QString &option) const; - QStringList OptionValues(const QString &option) const; + auto IsOptionSet(const QString &option)const -> bool; + auto OptionValue(const QString &option) const -> QString; + auto OptionValues(const QString &option) const -> QStringList; }; #endif // VPCOMMANDLINE_H diff --git a/src/app/puzzle/vpcommands.cpp b/src/app/puzzle/vpcommands.cpp index b10c0d1d3..21c66a383 100644 --- a/src/app/puzzle/vpcommands.cpp +++ b/src/app/puzzle/vpcommands.cpp @@ -29,41 +29,41 @@ #include -const QString LONG_OPTION_EXPORT_FILE = QStringLiteral("exportFile"); -const QString SINGLE_OPTION_EXPORT_FILE = QStringLiteral("e"); +const QString LONG_OPTION_EXPORT_FILE = QStringLiteral("exportFile"); // NOLINT +const QString SINGLE_OPTION_EXPORT_FILE = QStringLiteral("e"); // NOLINT -const QString LONG_OPTION_TEST = QStringLiteral("test"); -const QString SINGLE_OPTION_TEST = QStringLiteral("t"); +const QString LONG_OPTION_TEST = QStringLiteral("test"); // NOLINT +const QString SINGLE_OPTION_TEST = QStringLiteral("t"); // NOLINT -const QString LONG_OPTION_RAW_LAYOUT = QStringLiteral("rawLayout"); -const QString SINGLE_OPTION_RAW_LAYOUT = QStringLiteral("r"); +const QString LONG_OPTION_RAW_LAYOUT = QStringLiteral("rawLayout"); // NOLINT +const QString SINGLE_OPTION_RAW_LAYOUT = QStringLiteral("r"); // NOLINT -const QString LONG_OPTION_EXP2FORMAT = QStringLiteral("format"); -const QString SINGLE_OPTION_EXP2FORMAT = QStringLiteral("f"); +const QString LONG_OPTION_EXP2FORMAT = QStringLiteral("format"); // NOLINT +const QString SINGLE_OPTION_EXP2FORMAT = QStringLiteral("f"); // NOLINT -const QString LONG_OPTION_BINARYDXF = QStringLiteral("bdxf"); -const QString LONG_OPTION_TEXT2PATHS = QStringLiteral("text2paths"); +const QString LONG_OPTION_BINARYDXF = QStringLiteral("bdxf"); // NOLINT +const QString LONG_OPTION_TEXT2PATHS = QStringLiteral("text2paths"); // NOLINT -const QString LONG_OPTION_CROP_LENGTH = QStringLiteral("crop"); -const QString SINGLE_OPTION_CROP_LENGTH = QStringLiteral("c"); +const QString LONG_OPTION_CROP_LENGTH = QStringLiteral("crop"); // NOLINT +const QString SINGLE_OPTION_CROP_LENGTH = QStringLiteral("c"); // NOLINT -const QString LONG_OPTION_CROP_WIDTH = QStringLiteral("cropWidth"); +const QString LONG_OPTION_CROP_WIDTH = QStringLiteral("cropWidth"); // NOLINT -const QString LONG_OPTION_TILED_PDF_PAGE_TEMPLATE = QStringLiteral("tiledPageformat"); -const QString LONG_OPTION_TILED_PDF_LEFT_MARGIN = QStringLiteral("tiledlmargin"); -const QString LONG_OPTION_TILED_PDF_RIGHT_MARGIN = QStringLiteral("tiledrmargin"); -const QString LONG_OPTION_TILED_PDF_TOP_MARGIN = QStringLiteral("tiledtmargin"); -const QString LONG_OPTION_TILED_PDF_BOTTOM_MARGIN = QStringLiteral("tiledbmargin"); -const QString LONG_OPTION_TILED_PDF_LANDSCAPE = QStringLiteral("tiledLandscape"); +const QString LONG_OPTION_TILED_PDF_PAGE_TEMPLATE = QStringLiteral("tiledPageformat"); // NOLINT +const QString LONG_OPTION_TILED_PDF_LEFT_MARGIN = QStringLiteral("tiledlmargin"); // NOLINT +const QString LONG_OPTION_TILED_PDF_RIGHT_MARGIN = QStringLiteral("tiledrmargin"); // NOLINT +const QString LONG_OPTION_TILED_PDF_TOP_MARGIN = QStringLiteral("tiledtmargin"); // NOLINT +const QString LONG_OPTION_TILED_PDF_BOTTOM_MARGIN = QStringLiteral("tiledbmargin"); // NOLINT +const QString LONG_OPTION_TILED_PDF_LANDSCAPE = QStringLiteral("tiledLandscape"); // NOLINT //--------------------------------------------------------------------------------------------------------------------- /** * @brief AllKeys return list with all command line keys (short and long forms). Used for testing on conflicts. * @return list with all command line keys */ -QStringList AllKeys() +auto AllKeys() -> QStringList { - return QStringList + return { LONG_OPTION_EXPORT_FILE, SINGLE_OPTION_EXPORT_FILE, diff --git a/src/app/puzzle/vpcommands.h b/src/app/puzzle/vpcommands.h index 4db42b939..875d886d5 100644 --- a/src/app/puzzle/vpcommands.h +++ b/src/app/puzzle/vpcommands.h @@ -58,6 +58,6 @@ extern const QString LONG_OPTION_TILED_PDF_TOP_MARGIN; extern const QString LONG_OPTION_TILED_PDF_BOTTOM_MARGIN; extern const QString LONG_OPTION_TILED_PDF_LANDSCAPE; -QStringList AllKeys(); +auto AllKeys() -> QStringList; #endif // VPCOMMANDS_H diff --git a/src/app/puzzle/vpmainwindow.cpp b/src/app/puzzle/vpmainwindow.cpp index 2c759ca2d..603f2e285 100644 --- a/src/app/puzzle/vpmainwindow.cpp +++ b/src/app/puzzle/vpmainwindow.cpp @@ -38,6 +38,7 @@ #include #include #include +#include #include "ui_vpmainwindow.h" #include "dialogs/vpdialogabout.h" @@ -63,6 +64,8 @@ #include "../vdxf/libdxfrw/drw_base.h" #include "../vmisc/dialogs/dialogselectlanguage.h" #include "../vmisc/lambdaconstants.h" +#include "vptilefactory.h" +#include "layout/vppiece.h" #if QT_VERSION < QT_VERSION_CHECK(5, 12, 0) #include "../vmisc/backport/qscopeguard.h" @@ -78,10 +81,12 @@ QT_WARNING_PUSH QT_WARNING_DISABLE_CLANG("-Wmissing-prototypes") QT_WARNING_DISABLE_INTEL(1418) -Q_LOGGING_CATEGORY(pWindow, "p.window") +Q_LOGGING_CATEGORY(pWindow, "p.window") // NOLINT QT_WARNING_POP +using namespace std::chrono_literals; + namespace { //--------------------------------------------------------------------------------------------------------------------- @@ -165,7 +170,7 @@ auto PreparePrinter(const QPrinterInfo &info, QPrinter::PrinterMode mode) -> QSh const QStringList list = QPrinterInfo::availablePrinterNames(); if(list.isEmpty()) { - return QSharedPointer(); + return {}; } tmpInfo = QPrinterInfo::printerInfo(ConstFirst(list)); @@ -378,7 +383,7 @@ VPMainWindow::VPMainWindow(const VPCommandLinePtr &cmd, QWidget *parent) : if (m_cmd->IsGuiEnabled()) { - QTimer::singleShot(1000, this, &VPMainWindow::SetDefaultGUILanguage); + QTimer::singleShot(1s, this, &VPMainWindow::SetDefaultGUILanguage); } } @@ -397,14 +402,14 @@ auto VPMainWindow::CurrentFile() const -> QString } //--------------------------------------------------------------------------------------------------------------------- -auto VPMainWindow::LoadFile(QString path) -> bool +auto VPMainWindow::LoadFile(const QString& path) -> bool { if (not QFileInfo::exists(path)) { qCCritical(pWindow, "%s", qUtf8Printable(tr("File '%1' doesn't exist!").arg(path))); if (m_cmd->IsTestModeEnabled()) { - qApp->exit(V_EX_NOINPUT); + QCoreApplication::exit(V_EX_NOINPUT); } return false; } @@ -456,7 +461,7 @@ auto VPMainWindow::LoadFile(QString path) -> bool if (m_cmd->IsTestModeEnabled()) { - qApp->exit(V_EX_NOINPUT); + QCoreApplication::exit(V_EX_NOINPUT); } return false; } @@ -568,48 +573,12 @@ auto VPMainWindow::SaveLayout(const QString &path, QString &error) -> bool //--------------------------------------------------------------------------------------------------------------------- void VPMainWindow::ImportRawLayouts(const QStringList &rawLayouts) { - VRawLayout rawLayoutReader; for(const auto &path : rawLayouts) { - VRawLayoutData data; - if (rawLayoutReader.ReadFile(path, data)) + if (not ImportRawLayout(path)) { - for (const auto& rawPiece : data.pieces) - { - for (quint16 i = 1; i <= rawPiece.GetQuantity(); ++i) - { - VPPiecePtr piece(new VPPiece(rawPiece)); - piece->SetCopyNumber(i); - - if (not piece->IsValid()) - { - qCCritical(pWindow) << qPrintable(tr("Piece %1 invalid.").arg(piece->GetName())); - - if (m_cmd != nullptr && not m_cmd->IsGuiEnabled()) - { - QGuiApplication::exit(V_EX_DATAERR); - return; - } - } - - piece->SetSheet(VPSheetPtr()); // just in case - VPLayout::AddPiece(m_layout, piece); - } - } - - m_carrousel->Refresh(); - m_layout->CheckPiecesPositionValidity(); - LayoutWasSaved(false); - } - else - { - qCCritical(pWindow, "%s\n", qPrintable(tr("Could not extract data from file '%1'. %2") - .arg(path, rawLayoutReader.ErrorString()))); - if (m_cmd != nullptr && not m_cmd->IsGuiEnabled()) - { - m_cmd->ShowHelp(V_EX_DATAERR); - } + return; } } } @@ -679,13 +648,13 @@ void VPMainWindow::SetupMenu() // Add Undo/Redo actions. undoAction = m_layout->UndoStack()->createUndoAction(this, tr("&Undo")); undoAction->setShortcuts(QKeySequence::Undo); - undoAction->setIcon(QIcon::fromTheme("edit-undo")); + undoAction->setIcon(QIcon::fromTheme(QStringLiteral("edit-undo"))); ui->menuSheet->addAction(undoAction); ui->toolBarUndoCommands->addAction(undoAction); redoAction = m_layout->UndoStack()->createRedoAction(this, tr("&Redo")); redoAction->setShortcuts(QKeySequence::Redo); - redoAction->setIcon(QIcon::fromTheme("edit-redo")); + redoAction->setIcon(QIcon::fromTheme(QStringLiteral("edit-redo"))); ui->menuSheet->addAction(redoAction); ui->toolBarUndoCommands->addAction(redoAction); @@ -872,10 +841,22 @@ void VPMainWindow::InitPropertyTabCurrentSheet() connect(ui->comboBoxSheetTemplates, QOverload::of(&QComboBox::currentIndexChanged), this, [this]{SheetSize(SheetTemplate());}); - // -------------------- paper size --------------------------- - MinimumSheetPaperSize(); - const QString suffix = " " + UnitsToStr(LayoutUnit(), true); + // -------------------- paper size --------------------------- + InitPaperSizeData(suffix); + + // -------------------- margins ------------------------ + InitMarginsData(suffix); + + ui->groupBoxSheetGrid->setVisible(false); // temporary hide + + connect(ui->pushButtonSheetExport, &QPushButton::clicked, this, &VPMainWindow::on_ExportSheet); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VPMainWindow::InitPaperSizeData(const QString &suffix) +{ + MinimumSheetPaperSize(); ui->doubleSpinBoxSheetPaperWidth->setSuffix(suffix); ui->doubleSpinBoxSheetPaperHeight->setSuffix(suffix); @@ -949,8 +930,11 @@ void VPMainWindow::InitPropertyTabCurrentSheet() } } }); +} - // -------------------- margins ------------------------ +//--------------------------------------------------------------------------------------------------------------------- +void VPMainWindow::InitMarginsData(const QString &suffix) +{ ui->doubleSpinBoxSheetMarginLeft->setSuffix(suffix); ui->doubleSpinBoxSheetMarginRight->setSuffix(suffix); ui->doubleSpinBoxSheetMarginTop->setSuffix(suffix); @@ -986,10 +970,6 @@ void VPMainWindow::InitPropertyTabCurrentSheet() } } }); - - ui->groupBoxSheetGrid->setVisible(false); // temporary hide - - connect(ui->pushButtonSheetExport, &QPushButton::clicked, this, &VPMainWindow::on_ExportSheet); } //--------------------------------------------------------------------------------------------------------------------- @@ -1114,42 +1094,10 @@ void VPMainWindow::InitPropertyTabLayout() } }); - connect(ui->checkBoxLayoutWarningPiecesSuperposition, &QCheckBox::toggled, this, [this](bool checked) - { - if (not m_layout.isNull()) - { - m_layout->LayoutSettings().SetWarningSuperpositionOfPieces(checked); - LayoutWasSaved(false); - if (checked) - { - VPSheetPtr sheet = m_layout->GetFocusedSheet(); - if (not sheet.isNull()) - { - sheet->ValidateSuperpositionOfPieces(); - } - } - m_graphicsView->RefreshPieces(); - } - }); - - connect(ui->checkBoxLayoutWarningPiecesOutOfBound, &QCheckBox::toggled, this, [this](bool checked) - { - if (not m_layout.isNull()) - { - m_layout->LayoutSettings().SetWarningPiecesOutOfBound(checked); - LayoutWasSaved(false); - - if (checked) - { - VPSheetPtr sheet = m_layout->GetFocusedSheet(); - if (not sheet.isNull()) - { - sheet->ValidatePiecesOutOfBound(); - } - } - m_graphicsView->RefreshPieces(); - } - }); + connect(ui->checkBoxLayoutWarningPiecesSuperposition, &QCheckBox::toggled, this, + &VPMainWindow::LayoutWarningPiecesSuperposition_toggled); + connect(ui->checkBoxLayoutWarningPiecesOutOfBound, &QCheckBox::toggled, this, + &VPMainWindow::LayoutWarningPiecesOutOfBound_toggled); connect(ui->checkBoxSheetStickyEdges, &QCheckBox::toggled, this, [this](bool checked) { @@ -1197,57 +1145,9 @@ void VPMainWindow::InitPropertyTabLayout() }); connect(ui->doubleSpinBoxHorizontalScale, QOverload::of(&QDoubleSpinBox::valueChanged), - this, [this](double d) - { - if (m_layout.isNull()) - { - return; - } - - m_layout->LayoutSettings().SetHorizontalScale(d / 100.); - - if (m_scaleConnected) - { - ui->doubleSpinBoxVerticalScale->blockSignals(true); - ui->doubleSpinBoxVerticalScale->setValue(d); - ui->doubleSpinBoxVerticalScale->blockSignals(false); - - m_layout->LayoutSettings().SetVerticalScale(d / 100.); - } - - LayoutWasSaved(false); - m_layout->TileFactory()->RefreshTileInfos(); - m_graphicsView->RefreshLayout(); - - VMainGraphicsView::NewSceneRect(m_graphicsView->scene(), m_graphicsView); - }); - + this, &VPMainWindow::HorizontalScaleChanged); connect(ui->doubleSpinBoxVerticalScale, QOverload::of(&QDoubleSpinBox::valueChanged), - this, [this](double d) - { - if (m_layout.isNull()) - { - return; - } - - m_layout->LayoutSettings().SetVerticalScale(d / 100.); - - if (m_scaleConnected) - { - ui->doubleSpinBoxHorizontalScale->blockSignals(true); - ui->doubleSpinBoxHorizontalScale->setValue(d); - ui->doubleSpinBoxHorizontalScale->blockSignals(false); - - m_layout->LayoutSettings().SetHorizontalScale(d / 100.); - } - - LayoutWasSaved(false); - m_layout->TileFactory()->RefreshTileInfos(); - m_graphicsView->RefreshLayout(); - - VMainGraphicsView::NewSceneRect(m_graphicsView->scene(), m_graphicsView); - }); - + this, &VPMainWindow::VerticalScaleChanged); connect(ui->pushButtonLayoutExport, &QPushButton::clicked, this, &VPMainWindow::on_ExportLayout); } @@ -1912,13 +1812,13 @@ auto VPMainWindow::SelectedPieces() const -> QList } //--------------------------------------------------------------------------------------------------------------------- -Unit VPMainWindow::TranslateUnit() const +auto VPMainWindow::TranslateUnit() const -> Unit { return StrToUnits(ui->comboBoxTranslateUnit->currentData().toString()); } //--------------------------------------------------------------------------------------------------------------------- -Unit VPMainWindow::LayoutUnit() const +auto VPMainWindow::LayoutUnit() const -> Unit { return StrToUnits(ui->comboBoxLayoutUnit->currentData().toString()); } @@ -2283,7 +2183,7 @@ void VPMainWindow::ExportData(const VPExportData &data) //--------------------------------------------------------------------------------------------------------------------- void VPMainWindow::ExportApparelLayout(const VPExportData &data, const QVector &details, - const QString &name, const QSize &size) const + const QString &name, const QSize &size) { const QString path = data.path; bool usedNotExistedDir = CreateLayoutPath(path); @@ -2763,13 +2663,12 @@ void VPMainWindow::UpdateScaleConnection() const //--------------------------------------------------------------------------------------------------------------------- void VPMainWindow::OpenWatermark(const QString &path) { - QList>::const_iterator i; - for (i = m_watermarkEditors.begin(); i != m_watermarkEditors.end(); ++i) + for (const auto & m_watermarkEditor : qAsConst(m_watermarkEditors)) { - if (not (*i).isNull() && not (*i)->CurrentFile().isEmpty() - && (*i)->CurrentFile() == AbsoluteMPath(curFile, path)) + if (not m_watermarkEditor.isNull() && not m_watermarkEditor->CurrentFile().isEmpty() + && m_watermarkEditor->CurrentFile() == AbsoluteMPath(curFile, path)) { - (*i)->show(); + m_watermarkEditor->show(); return; } } @@ -2797,14 +2696,15 @@ void VPMainWindow::CleanWaterkmarkEditors() } //--------------------------------------------------------------------------------------------------------------------- -void VPMainWindow::DrawTilesScheme(QPrinter *printer, QPainter *painter, const VPSheetPtr &sheet, bool &firstPage) +auto VPMainWindow::DrawTilesScheme(QPrinter *printer, QPainter *painter, const VPSheetPtr &sheet, + bool firstPage) -> bool { SCASSERT(printer != nullptr) SCASSERT(painter != nullptr) if (sheet.isNull()) { - return; + return false; } if(not firstPage) @@ -2814,7 +2714,7 @@ void VPMainWindow::DrawTilesScheme(QPrinter *printer, QPainter *painter, const V if (not printer->newPage()) { qWarning("failed in flushing page to disk, disk full?"); - return; + return false; } } @@ -2877,72 +2777,95 @@ void VPMainWindow::DrawTilesScheme(QPrinter *printer, QPainter *painter, const V sheet->SceneData()->ClearTilesScheme(); - firstPage = false; + return true; } //--------------------------------------------------------------------------------------------------------------------- auto VPMainWindow::AskLayoutIsInvalid(const QList &sheets) -> bool { - if (m_layout->LayoutSettings().GetWarningPiecesOutOfBound() || - m_layout->LayoutSettings().GetWarningSuperpositionOfPieces()) + if (not m_layout->LayoutSettings().GetWarningPiecesOutOfBound() && + not m_layout->LayoutSettings().GetWarningSuperpositionOfPieces()) { - for (const auto &sheet : sheets) + return true; + } + + for (const auto &sheet : sheets) + { + bool outOfBoundChecked = false; + bool pieceSuperpositionChecked = false; + + QList pieces = sheet->GetPieces(); + for (const auto& piece :pieces) { - bool outOfBoundChecked = false; - bool pieceSuperpositionChecked = false; - - QList pieces = sheet->GetPieces(); - for (const auto& piece :pieces) + if(not CheckPiecesOutOfBound(piece, outOfBoundChecked)) { - if (m_layout->LayoutSettings().GetWarningPiecesOutOfBound()) - { - if (not outOfBoundChecked && not piece.isNull() && piece->OutOfBound()) - { - QMessageBox msgBox(this); - msgBox.setIcon(QMessageBox::Question); - msgBox.setWindowTitle(tr("The layout is invalid.")); - msgBox.setText(tr("The layout is invalid. Piece out of bound. Do you want to continue export?")); - msgBox.setStandardButtons(QMessageBox::Yes|QMessageBox::No); - msgBox.setDefaultButton(QMessageBox::No); - const int width = 500; - auto* horizontalSpacer = new QSpacerItem(width, 0, QSizePolicy::Minimum, QSizePolicy::Expanding); - auto* layout = qobject_cast(msgBox.layout()); - SCASSERT(layout != nullptr) - layout->addItem(horizontalSpacer, layout->rowCount(), 0, 1, layout->columnCount()); - if (msgBox.exec() == QMessageBox::No) - { - return false; - } - - outOfBoundChecked = true; // no need to ask more - } - } - - if (m_layout->LayoutSettings().GetWarningSuperpositionOfPieces()) - { - if (not pieceSuperpositionChecked && not piece.isNull() && piece->HasSuperpositionWithPieces()) - { - QMessageBox msgBox(this); - msgBox.setIcon(QMessageBox::Question); - msgBox.setWindowTitle(tr("The layout is invalid.")); - msgBox.setText(tr("The layout is invalid. Pieces superposition. Do you want to continue " - "export?")); - msgBox.setStandardButtons(QMessageBox::Yes|QMessageBox::No); - msgBox.setDefaultButton(QMessageBox::No); - const int width = 500; - auto* horizontalSpacer = new QSpacerItem(width, 0, QSizePolicy::Minimum, QSizePolicy::Expanding); - auto* layout = qobject_cast(msgBox.layout()); - SCASSERT(layout != nullptr) - layout->addItem(horizontalSpacer, layout->rowCount(), 0, 1, layout->columnCount()); - if (msgBox.exec() == QMessageBox::No) - { - return false; - } - - pieceSuperpositionChecked = true; // no need to ask more - } - } + return false; } + + if (not CheckSuperpositionOfPieces(piece, pieceSuperpositionChecked)) + { + return false; + } + } + } + + return true; +} + +//--------------------------------------------------------------------------------------------------------------------- +auto VPMainWindow::CheckPiecesOutOfBound(const VPPiecePtr &piece, bool &outOfBoundChecked) -> bool +{ + if (m_layout->LayoutSettings().GetWarningPiecesOutOfBound()) + { + if (not outOfBoundChecked && not piece.isNull() && piece->OutOfBound()) + { + QMessageBox msgBox(this); + msgBox.setIcon(QMessageBox::Question); + msgBox.setWindowTitle(tr("The layout is invalid.")); + msgBox.setText(tr("The layout is invalid. Piece out of bound. Do you want to continue export?")); + msgBox.setStandardButtons(QMessageBox::Yes|QMessageBox::No); + msgBox.setDefaultButton(QMessageBox::No); + const int width = 500; + auto* horizontalSpacer = new QSpacerItem(width, 0, QSizePolicy::Minimum, QSizePolicy::Expanding); + auto* layout = qobject_cast(msgBox.layout()); + SCASSERT(layout != nullptr) + layout->addItem(horizontalSpacer, layout->rowCount(), 0, 1, layout->columnCount()); + if (msgBox.exec() == QMessageBox::No) + { + return false; + } + + outOfBoundChecked = true; // no need to ask more + } + } + return true; +} + +//--------------------------------------------------------------------------------------------------------------------- +auto VPMainWindow::CheckSuperpositionOfPieces(const VPPiecePtr &piece, bool &pieceSuperpositionChecked) -> bool +{ + if (m_layout->LayoutSettings().GetWarningSuperpositionOfPieces()) + { + if (not pieceSuperpositionChecked && not piece.isNull() && piece->HasSuperpositionWithPieces()) + { + QMessageBox msgBox(this); + msgBox.setIcon(QMessageBox::Question); + msgBox.setWindowTitle(tr("The layout is invalid.")); + msgBox.setText(tr("The layout is invalid. Pieces superposition. Do you want to continue " + "export?")); + msgBox.setStandardButtons(QMessageBox::Yes|QMessageBox::No); + msgBox.setDefaultButton(QMessageBox::No); + const int width = 500; + auto* horizontalSpacer = new QSpacerItem(width, 0, QSizePolicy::Minimum, QSizePolicy::Expanding); + auto* layout = qobject_cast(msgBox.layout()); + SCASSERT(layout != nullptr) + layout->addItem(horizontalSpacer, layout->rowCount(), 0, 1, layout->columnCount()); + if (msgBox.exec() == QMessageBox::No) + { + return false; + } + + pieceSuperpositionChecked = true; // no need to ask more } } @@ -2979,9 +2902,18 @@ void VPMainWindow::PrintLayoutSheets(QPrinter *printer, const QList } QPainter painter; - bool firstPage = true; - qreal xScale = m_layout->LayoutSettings().HorizontalScale(); - qreal yScale = m_layout->LayoutSettings().VerticalScale(); + + if (not painter.begin(printer)) + { // failed to open file + qCritical() << tr("Failed to open file, is it writable?"); + return; + } + + painter.setRenderHint(QPainter::Antialiasing, true); + painter.setPen(QPen(Qt::black, VAbstractApplication::VApp()->Settings()->WidthHairLine(), + Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin)); + painter.setBrush(QBrush(Qt::NoBrush)); + painter.scale(m_layout->LayoutSettings().HorizontalScale(), m_layout->LayoutSettings().VerticalScale()); for (int i = 0; i < copyCount; ++i) { @@ -2995,93 +2927,53 @@ void VPMainWindow::PrintLayoutSheets(QPrinter *printer, const QList continue; } - if (firstPage) + if (not PrintLayoutSheetPage(printer, painter, sheet)) { - if (not painter.begin(printer)) - { // failed to open file - qCritical() << tr("Failed to open file, is it writable?"); - return; - } - - painter.setRenderHint(QPainter::Antialiasing, true); - painter.setPen(QPen(Qt::black, VAbstractApplication::VApp()->Settings()->WidthHairLine(), - Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin)); - painter.setBrush(QBrush(Qt::NoBrush)); - painter.scale(xScale, yScale); + return; } - else - { - printer->setPageOrientation(sheet->GetSheetOrientation()); - printer->setFullPage(sheet->IgnoreMargins()); - - if (not sheet->IgnoreMargins()) - { - QMarginsF margins = sheet->GetSheetMargins(); - if (not printer->setPageMargins(UnitConvertor(margins, Unit::Px, Unit::Mm), - QPageLayout::Millimeter)) - { - qWarning() << QObject::tr("Cannot set printer margins"); - } - } - - if (not printer->newPage()) - { - qCritical() << tr("Failed in flushing page to disk, disk full?"); - return; - } - } - - sheet->SceneData()->PrepareForExport(); - QRectF imageRect = sheet->GetMarginsRect(); - sheet->SceneData()->Scene()->render(&painter, VPrintLayout::SceneTargetRect(printer, imageRect), - imageRect, Qt::IgnoreAspectRatio); - sheet->SceneData()->CleanAfterExport(); - - firstPage = false; } } } +//--------------------------------------------------------------------------------------------------------------------- +auto VPMainWindow::PrintLayoutSheetPage(QPrinter *printer, QPainter &painter, const VPSheetPtr& sheet) -> bool +{ + SCASSERT(printer != nullptr) + + printer->setPageOrientation(sheet->GetSheetOrientation()); + printer->setFullPage(sheet->IgnoreMargins()); + + if (not sheet->IgnoreMargins()) + { + QMarginsF margins = sheet->GetSheetMargins(); + if (not printer->setPageMargins(UnitConvertor(margins, Unit::Px, Unit::Mm), + QPageLayout::Millimeter)) + { + qWarning() << QObject::tr("Cannot set printer margins"); + } + } + + if (not printer->newPage()) + { + qCritical() << tr("Failed in flushing page to disk, disk full?"); + return false; + } + + sheet->SceneData()->PrepareForExport(); + QRectF imageRect = sheet->GetMarginsRect(); + sheet->SceneData()->Scene()->render(&painter, VPrintLayout::SceneTargetRect(printer, imageRect), + imageRect, Qt::IgnoreAspectRatio); + sheet->SceneData()->CleanAfterExport(); + + return true; +} + //--------------------------------------------------------------------------------------------------------------------- void VPMainWindow::PrintLayoutTiledSheets(QPrinter *printer, const QList &sheets) { SCASSERT(printer != nullptr) - struct VPLayoutPrinterPage - { - VPSheetPtr sheet{}; - bool tilesScheme{false}; - int tileRow{-1}; - int tileCol{-1}; - }; - - QVector pages; - - for (const auto& sheet : sheets) - { - if (m_layout->LayoutSettings().GetPrintTilesScheme()) - { - VPLayoutPrinterPage page; - page.sheet = sheet; - page.tilesScheme = true; - - pages.append(page); - } - - for(int row=0; row < m_layout->TileFactory()->RowNb(sheet); row++) // for each row of the tiling grid - { - for(int col=0; col < m_layout->TileFactory()->ColNb(sheet); col++) // for each column of tiling grid - { - VPLayoutPrinterPage page; - page.sheet = sheet; - page.tilesScheme = false; - page.tileRow = row; - page.tileCol = col; - - pages.append(page); - } - } - } + const QVector pages = PrepareLayoutTilePages(sheets); // Handle the fromPage(), toPage(), supportsMultipleCopies(), and numCopies() values from QPrinter. int firstPageNumber = printer->fromPage() - 1; @@ -3120,59 +3012,103 @@ void VPMainWindow::PrintLayoutTiledSheets(QPrinter *printer, const QListpageOrder() == QPrinter::FirstPageFirst ? firstPageNumber + j : lastPageNumber - j; const VPLayoutPrinterPage &page = pages.at(index); - page.sheet->SceneData()->PrepareForExport(); - page.sheet->SceneData()->SetTextAsPaths(false); - - if (firstPage) + if (not PrintLayoutTiledSheetPage(printer, painter, page, firstPage)) { - if (page.tilesScheme) - { - printer->setPageOrientation(page.sheet->GetSheetOrientation()); - } - else - { - printer->setPageOrientation(m_layout->LayoutSettings().GetTilesOrientation()); - } - - if (not painter.begin(printer)) - { // failed to open file - qCritical() << tr("Failed to open file, is it writable?"); - return; - } - - painter.setPen(QPen(Qt::black, VAbstractApplication::VApp()->Settings()->WidthMainLine(), Qt::SolidLine, - Qt::RoundCap, Qt::RoundJoin)); - painter.setBrush(QBrush(Qt::NoBrush)); - painter.setRenderHint(QPainter::Antialiasing, true); + return; } - if (page.tilesScheme) - { - DrawTilesScheme(printer, &painter, page.sheet, firstPage); - } - else - { - if(not firstPage) - { - printer->setPageOrientation(m_layout->LayoutSettings().GetTilesOrientation()); - - if (not printer->newPage()) - { - qWarning("failed in flushing page to disk, disk full?"); - return; - } - } - - m_layout->TileFactory()->drawTile(&painter, printer, page.sheet, page.tileRow, page.tileCol); - - firstPage = false; - } - - page.sheet->SceneData()->CleanAfterExport(); + firstPage = false; } } } +//--------------------------------------------------------------------------------------------------------------------- +auto VPMainWindow::PrepareLayoutTilePages(const QList &sheets) -> QVector +{ + QVector pages; + + for (const auto& sheet : sheets) + { + if (m_layout->LayoutSettings().GetPrintTilesScheme()) + { + VPLayoutPrinterPage page; + page.sheet = sheet; + page.tilesScheme = true; + + pages.append(page); + } + + for(int row=0; row < m_layout->TileFactory()->RowNb(sheet); row++) // for each row of the tiling grid + { + for(int col=0; col < m_layout->TileFactory()->ColNb(sheet); col++) // for each column of tiling grid + { + VPLayoutPrinterPage page; + page.sheet = sheet; + page.tilesScheme = false; + page.tileRow = row; + page.tileCol = col; + + pages.append(page); + } + } + } + + return pages; +} + +//--------------------------------------------------------------------------------------------------------------------- +auto VPMainWindow::PrintLayoutTiledSheetPage(QPrinter *printer, QPainter &painter, const VPLayoutPrinterPage &page, + bool firstPage) -> bool +{ + page.sheet->SceneData()->PrepareForExport(); + page.sheet->SceneData()->SetTextAsPaths(false); + + auto clean = qScopeGuard([page](){ page.sheet->SceneData()->CleanAfterExport(); }); + + if (firstPage) + { + if (page.tilesScheme) + { + printer->setPageOrientation(page.sheet->GetSheetOrientation()); + } + else + { + printer->setPageOrientation(m_layout->LayoutSettings().GetTilesOrientation()); + } + + if (not painter.begin(printer)) + { // failed to open file + qCritical() << tr("Failed to open file, is it writable?"); + return false; + } + + painter.setPen(QPen(Qt::black, VAbstractApplication::VApp()->Settings()->WidthMainLine(), Qt::SolidLine, + Qt::RoundCap, Qt::RoundJoin)); + painter.setBrush(QBrush(Qt::NoBrush)); + painter.setRenderHint(QPainter::Antialiasing, true); + } + + if (page.tilesScheme) + { + return DrawTilesScheme(printer, &painter, page.sheet, firstPage); + } + + if(not firstPage) + { + printer->setPageOrientation(m_layout->LayoutSettings().GetTilesOrientation()); + + if (not printer->newPage()) + { + qWarning("failed in flushing page to disk, disk full?"); + return false; + } + } + + m_layout->TileFactory()->drawTile(&painter, printer, page.sheet, page.tileRow, page.tileCol); + + return true; +} + //--------------------------------------------------------------------------------------------------------------------- void VPMainWindow::ZValueMove(int move) { @@ -3207,7 +3143,204 @@ void VPMainWindow::ZValueMove(int move) } //--------------------------------------------------------------------------------------------------------------------- -void VPMainWindow::on_actionNew_triggered() +auto VPMainWindow::ImportRawLayout(const QString &rawLayout) -> bool +{ + VRawLayout rawLayoutReader; + VRawLayoutData data; + if (rawLayoutReader.ReadFile(rawLayout, data)) + { + return AddLayoutPieces(data.pieces); + } + + qCCritical(pWindow, "%s\n", qPrintable(tr("Could not extract data from file '%1'. %2") + .arg(rawLayout, rawLayoutReader.ErrorString()))); + if (m_cmd != nullptr && not m_cmd->IsGuiEnabled()) + { + m_cmd->ShowHelp(V_EX_DATAERR); + return false; + } + + return true; +} + +//--------------------------------------------------------------------------------------------------------------------- +auto VPMainWindow::AddLayoutPieces(const QVector &pieces) -> bool +{ + for (const auto& rawPiece : pieces) + { + for (quint16 i = 1; i <= rawPiece.GetQuantity(); ++i) + { + VPPiecePtr piece(new VPPiece(rawPiece)); + piece->SetCopyNumber(i); + + if (not piece->IsValid()) + { + qCCritical(pWindow) << qPrintable(tr("Piece %1 invalid.").arg(piece->GetName())); + + if (m_cmd != nullptr && not m_cmd->IsGuiEnabled()) + { + QGuiApplication::exit(V_EX_DATAERR); + return false; + } + } + + piece->SetSheet(VPSheetPtr()); // just in case + VPLayout::AddPiece(m_layout, piece); + } + } + + m_carrousel->Refresh(); + m_layout->CheckPiecesPositionValidity(); + LayoutWasSaved(false); + + return true; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VPMainWindow::TranslatePieces() +{ + QList selectedPieces = SelectedPieces(); + if (selectedPieces.isEmpty()) + { + return; + } + + const qreal dx = UnitConvertor(ui->doubleSpinBoxCurrentPieceBoxPositionX->value(), TranslateUnit(), Unit::Px); + const qreal dy = UnitConvertor(ui->doubleSpinBoxCurrentPieceBoxPositionY->value(), TranslateUnit(), Unit::Px); + + if (ui->checkBoxRelativeTranslation->isChecked()) + { + if (ui->checkBoxTransformSeparately->isChecked()) + { + if (selectedPieces.size() > 1) + { + m_layout->UndoStack()->beginMacro(tr("translate pieces")); + } + + QRectF rect = PiecesBoundingRect(selectedPieces); + for (const auto& piece : qAsConst(selectedPieces)) + { + TranslatePieceRelatively(piece, rect, selectedPieces.size(), dx, dy); + } + + if (selectedPieces.size() > 1) + { + m_layout->UndoStack()->endMacro(); + } + } + else + { + auto *command = new VPUndoPiecesMove(selectedPieces, dx, dy); + m_layout->UndoStack()->push(command); + } + } + else + { + QRectF rect = PiecesBoundingRect(selectedPieces); + qreal pieceDx = dx - rect.topLeft().x(); + qreal pieceDy = dy - rect.topLeft().y(); + + if (selectedPieces.size() == 1) + { + auto *command = new VPUndoPieceMove(ConstFirst(selectedPieces), pieceDx, pieceDy); + m_layout->UndoStack()->push(command); + } + else + { + auto *command = new VPUndoPiecesMove(selectedPieces, pieceDx, pieceDy); + m_layout->UndoStack()->push(command); + } + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void VPMainWindow::TranslatePieceRelatively(const VPPiecePtr &piece, const QRectF &rect, int selectedPiecesCount, + qreal dx, qreal dy) +{ + if (not piece.isNull()) + { + const QRectF pieceRect = piece->MappedDetailBoundingRect(); + qreal pieceDx = dx; + qreal pieceDy = dy; + + if (not qFuzzyIsNull(rect.width())) + { + pieceDx += dx*((pieceRect.topLeft().x()-rect.topLeft().x())/rect.width())*2.; + } + + if (not qFuzzyIsNull(rect.height())) + { + pieceDy += dy*((pieceRect.topLeft().y()-rect.topLeft().y())/rect.height())*2.; + } + + auto *command = new VPUndoPieceMove(piece, pieceDx, pieceDy); + m_layout->UndoStack()->push(command); + + if (m_layout->LayoutSettings().GetStickyEdges()) + { + qreal stickyTranslateX = 0; + qreal stickyTranslateY = 0; + if (piece->StickyPosition(stickyTranslateX, stickyTranslateY)) + { + bool allowMerge = selectedPiecesCount == 1; + auto *stickyCommand = new VPUndoPieceMove(piece, stickyTranslateX, stickyTranslateY, allowMerge); + m_layout->UndoStack()->push(stickyCommand); + } + } + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void VPMainWindow::RotatePieces() +{ + qreal angle = ui->doubleSpinBoxCurrentPieceAngle->value(); + + if (ui->toolButtonCurrentPieceRotationClockwise->isChecked()) + { + angle *= -1; + } + + QList selectedPieces = SelectedPieces(); + if (selectedPieces.isEmpty()) + { + return; + } + + if (ui->checkBoxTransformSeparately->isChecked()) + { + m_layout->UndoStack()->beginMacro(tr("rotate pieces")); + for (const auto& piece : selectedPieces) + { + if (not piece.isNull()) + { + const QRectF rect = piece->MappedDetailBoundingRect(); + + VPTransformationOrigon origin; + origin.origin = rect.center(); + origin.custom = true; + + auto *command = new VPUndoPieceRotate(piece, origin, angle, angle); + m_layout->UndoStack()->push(command); + } + } + m_layout->UndoStack()->endMacro(); + } + else + { + VPSheetPtr sheet = m_layout->GetFocusedSheet(); + if (sheet.isNull()) + { + return; + } + + VPTransformationOrigon origin = sheet->TransformationOrigin(); + auto *command = new VPUndoPiecesRotate(selectedPieces, origin, angle, angle); + m_layout->UndoStack()->push(command); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void VPMainWindow::on_actionNew_triggered() // NOLINT(readability-convert-member-functions-to-static) { VPApplication::VApp()->NewMainWindow(); } @@ -3261,7 +3394,7 @@ void VPMainWindow::changeEvent(QEvent *event) } //--------------------------------------------------------------------------------------------------------------------- -QStringList VPMainWindow::RecentFileList() const +auto VPMainWindow::RecentFileList() const -> QStringList { return VPApplication::VApp()->PuzzleSettings()->GetRecentFileList(); } @@ -3271,7 +3404,7 @@ void VPMainWindow::on_actionOpen_triggered() { qCDebug(pWindow, "Openning puzzle layout file."); - const QString filter(tr("Layout files") + QLatin1String(" (*.vlt)")); + const QString filter(tr("Layout files") + QStringLiteral(" (*.vlt)")); //Use standard path to individual measurements const QString pathTo = VPApplication::VApp()->PuzzleSettings()->GetPathManualLayouts(); @@ -3297,7 +3430,7 @@ void VPMainWindow::on_actionOpen_triggered() } //--------------------------------------------------------------------------------------------------------------------- -bool VPMainWindow::on_actionSave_triggered() +auto VPMainWindow::on_actionSave_triggered() -> bool { if (curFile.isEmpty() || IsLayoutReadOnly()) { @@ -3335,7 +3468,7 @@ bool VPMainWindow::on_actionSave_triggered() } //--------------------------------------------------------------------------------------------------------------------- -bool VPMainWindow::on_actionSaveAs_triggered() +auto VPMainWindow::on_actionSaveAs_triggered() -> bool { QString filters = tr("Layout files") + QStringLiteral(" (*.vlt)"); QString suffix = QStringLiteral("vlt"); @@ -3433,7 +3566,7 @@ bool VPMainWindow::on_actionSaveAs_triggered() //--------------------------------------------------------------------------------------------------------------------- void VPMainWindow::on_actionImportRawLayout_triggered() { - const QString filter(tr("Raw Layout files") + QLatin1String(" (*.rld)")); + const QString filter(tr("Raw Layout files") + QStringLiteral(" (*.rld)")); const QString filePath = QFileDialog::getOpenFileName(this, tr("Open file"), QDir::homePath(), filter, nullptr, VAbstractApplication::VApp()->NativeFileDialog()); @@ -3506,7 +3639,7 @@ void VPMainWindow::on_SheetOrientationChanged(bool checked) VPSheetPtr sheet = m_layout->GetFocusedSheet(); if (not sheet.isNull()) { - sheet->SetSheetSizeConverted(height, width); + sheet->SetSheetSizeConverted(height, width); // NOLINT(readability-suspicious-call-argument) } SheetPaperSizeChanged(); @@ -3589,7 +3722,7 @@ void VPMainWindow::on_TilesOrientationChanged(bool checked) SetDoubleSpinBoxValue(ui->doubleSpinBoxTilePaperWidth, height); SetDoubleSpinBoxValue(ui->doubleSpinBoxTilePaperHeight, width); - m_layout->LayoutSettings().SetTilesSizeConverted(height, width); + m_layout->LayoutSettings().SetTilesSizeConverted(height, width); // NOLINT(readability-suspicious-call-argument) TilePaperSizeChanged(); CorrectMaxMargins(); @@ -3682,7 +3815,7 @@ void VPMainWindow::ShowWindow() const } //--------------------------------------------------------------------------------------------------------------------- -void VPMainWindow::on_actionPreferences_triggered() +void VPMainWindow::on_actionPreferences_triggered() // NOLINT(readability-convert-member-functions-to-static) { // Calling constructor of the dialog take some time. Because of this user have time to call the dialog twice. QSharedPointer preferences = VPApplication::VApp()->PreferencesDialog(); @@ -3741,137 +3874,12 @@ void VPMainWindow::on_ApplyPieceTransformation() } const int index = ui->tabWidgetPieceTransformation->currentIndex(); if (ui->tabWidgetPieceTransformation->indexOf(ui->tabTranslate) == index) - { // translate - const qreal dx = UnitConvertor(ui->doubleSpinBoxCurrentPieceBoxPositionX->value(), TranslateUnit(), Unit::Px); - const qreal dy = UnitConvertor(ui->doubleSpinBoxCurrentPieceBoxPositionY->value(), TranslateUnit(), Unit::Px); - - QList selectedPieces = SelectedPieces(); - if (selectedPieces.isEmpty()) - { - return; - } - - if (ui->checkBoxRelativeTranslation->isChecked()) - { - if (ui->checkBoxTransformSeparately->isChecked()) - { - if (selectedPieces.size() > 1) - { - m_layout->UndoStack()->beginMacro(tr("translate pieces")); - } - - QRectF rect = PiecesBoundingRect(selectedPieces); - for (const auto& piece : selectedPieces) - { - if (not piece.isNull()) - { - const QRectF pieceRect = piece->MappedDetailBoundingRect(); - qreal pieceDx = dx; - qreal pieceDy = dy; - - if (not qFuzzyIsNull(rect.width())) - { - pieceDx += dx*((pieceRect.topLeft().x()-rect.topLeft().x())/rect.width())*2.; - } - - if (not qFuzzyIsNull(rect.height())) - { - pieceDy += dy*((pieceRect.topLeft().y()-rect.topLeft().y())/rect.height())*2.; - } - - auto *command = new VPUndoPieceMove(piece, pieceDx, pieceDy); - m_layout->UndoStack()->push(command); - - if (m_layout->LayoutSettings().GetStickyEdges()) - { - qreal stickyTranslateX = 0; - qreal stickyTranslateY = 0; - if (piece->StickyPosition(stickyTranslateX, stickyTranslateY)) - { - bool allowMerge = selectedPieces.size() == 1; - auto *stickyCommand = new VPUndoPieceMove(piece, stickyTranslateX, stickyTranslateY, - allowMerge); - m_layout->UndoStack()->push(stickyCommand); - } - } - } - } - - if (selectedPieces.size() > 1) - { - m_layout->UndoStack()->endMacro(); - } - } - else - { - auto *command = new VPUndoPiecesMove(selectedPieces, dx, dy); - m_layout->UndoStack()->push(command); - } - } - else - { - QRectF rect = PiecesBoundingRect(selectedPieces); - qreal pieceDx = dx - rect.topLeft().x(); - qreal pieceDy = dy - rect.topLeft().y(); - - if (selectedPieces.size() == 1) - { - auto *command = new VPUndoPieceMove(ConstFirst(selectedPieces), pieceDx, pieceDy); - m_layout->UndoStack()->push(command); - } - else - { - auto *command = new VPUndoPiecesMove(selectedPieces, pieceDx, pieceDy); - m_layout->UndoStack()->push(command); - } - } + { + TranslatePieces(); } else if (ui->tabWidgetPieceTransformation->indexOf(ui->tabRotate) == index) - { // rotate - qreal angle = ui->doubleSpinBoxCurrentPieceAngle->value(); - - if (ui->toolButtonCurrentPieceRotationClockwise->isChecked()) - { - angle *= -1; - } - - QList selectedPieces = SelectedPieces(); - if (selectedPieces.isEmpty()) - { - return; - } - - if (ui->checkBoxTransformSeparately->isChecked()) - { - m_layout->UndoStack()->beginMacro(tr("rotate pieces")); - for (const auto& piece : selectedPieces) - { - if (not piece.isNull()) - { - const QRectF rect = piece->MappedDetailBoundingRect(); - - VPTransformationOrigon origin; - origin.origin = rect.center(); - origin.custom = true; - - auto *command = new VPUndoPieceRotate(piece, origin, angle, angle); - m_layout->UndoStack()->push(command); - } - } - m_layout->UndoStack()->endMacro(); - } - else - { - VPSheetPtr sheet = m_layout->GetFocusedSheet(); - if (sheet.isNull()) - { - return; - } - - VPTransformationOrigon origin = sheet->TransformationOrigin(); - auto *command = new VPUndoPiecesRotate(selectedPieces, origin, angle, angle); - m_layout->UndoStack()->push(command); - } + { + RotatePieces(); } } @@ -4101,65 +4109,6 @@ void VPMainWindow::on_ExportSheet() return; } - if (m_layout->LayoutSettings().GetWarningPiecesOutOfBound() || - m_layout->LayoutSettings().GetWarningSuperpositionOfPieces()) - { - bool outOfBoundChecked = false; - bool pieceSuperpositionChecked = false; - - QList pieces = sheet->GetPieces(); - for (const auto& piece :pieces) - { - if (m_layout->LayoutSettings().GetWarningPiecesOutOfBound()) - { - if (not outOfBoundChecked && not piece.isNull() && piece->OutOfBound()) - { - QMessageBox msgBox(this); - msgBox.setIcon(QMessageBox::Question); - msgBox.setWindowTitle(tr("The layout is invalid.")); - msgBox.setText(tr("The layout is invalid. Piece out of bound. Do you want to continue export?")); - msgBox.setStandardButtons(QMessageBox::Yes|QMessageBox::No); - msgBox.setDefaultButton(QMessageBox::No); - const int width = 500; - auto* horizontalSpacer = new QSpacerItem(width, 0, QSizePolicy::Minimum, QSizePolicy::Expanding); - auto* layout = qobject_cast(msgBox.layout()); - SCASSERT(layout != nullptr) - layout->addItem(horizontalSpacer, layout->rowCount(), 0, 1, layout->columnCount()); - if (msgBox.exec() == QMessageBox::No) - { - return; - } - - outOfBoundChecked = true; // no need to ask more - } - } - - if (m_layout->LayoutSettings().GetWarningSuperpositionOfPieces()) - { - if (not pieceSuperpositionChecked && not piece.isNull() && piece->HasSuperpositionWithPieces()) - { - QMessageBox msgBox(this); - msgBox.setIcon(QMessageBox::Question); - msgBox.setWindowTitle(tr("The layout is invalid.")); - msgBox.setText(tr("The layout is invalid. Pieces superposition. Do you want to continue export?")); - msgBox.setStandardButtons(QMessageBox::Yes|QMessageBox::No); - msgBox.setDefaultButton(QMessageBox::No); - const int width = 500; - auto* horizontalSpacer = new QSpacerItem(width, 0, QSizePolicy::Minimum, QSizePolicy::Expanding); - auto* layout = qobject_cast(msgBox.layout()); - SCASSERT(layout != nullptr) - layout->addItem(horizontalSpacer, layout->rowCount(), 0, 1, layout->columnCount()); - if (msgBox.exec() == QMessageBox::No) - { - return; - } - - pieceSuperpositionChecked = true; // no need to ask more - } - } - } - } - const QString sheetTitle = sheet->GetName(); const QString fileName = sheetTitle.isEmpty() ? QFileInfo(curFile).baseName() : sheetTitle; @@ -4564,7 +4513,7 @@ void VPMainWindow::EditCurrentWatermark() //--------------------------------------------------------------------------------------------------------------------- void VPMainWindow::LoadWatermark() { - const QString filter(tr("Watermark files") + QLatin1String(" (*.vwm)")); + const QString filter(tr("Watermark files") + QStringLiteral(" (*.vwm)")); QString dir = QDir::homePath(); qDebug("Run QFileDialog::getOpenFileName: dir = %s.", qUtf8Printable(dir)); const QString filePath = QFileDialog::getOpenFileName(this, tr("Open file"), dir, filter, nullptr, @@ -4625,6 +4574,97 @@ void VPMainWindow::SetDefaultGUILanguage() } } +//--------------------------------------------------------------------------------------------------------------------- +void VPMainWindow::HorizontalScaleChanged(double value) +{ + if (m_layout.isNull()) + { + return; + } + + m_layout->LayoutSettings().SetHorizontalScale(value / 100.); + + if (m_scaleConnected) + { + ui->doubleSpinBoxVerticalScale->blockSignals(true); + ui->doubleSpinBoxVerticalScale->setValue(value); + ui->doubleSpinBoxVerticalScale->blockSignals(false); + + m_layout->LayoutSettings().SetVerticalScale(value / 100.); + } + + LayoutWasSaved(false); + m_layout->TileFactory()->RefreshTileInfos(); + m_graphicsView->RefreshLayout(); + + VMainGraphicsView::NewSceneRect(m_graphicsView->scene(), m_graphicsView); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VPMainWindow::VerticalScaleChanged(double value) +{ + if (m_layout.isNull()) + { + return; + } + + m_layout->LayoutSettings().SetVerticalScale(value / 100.); + + if (m_scaleConnected) + { + ui->doubleSpinBoxHorizontalScale->blockSignals(true); + ui->doubleSpinBoxHorizontalScale->setValue(value); + ui->doubleSpinBoxHorizontalScale->blockSignals(false); + + m_layout->LayoutSettings().SetHorizontalScale(value / 100.); + } + + LayoutWasSaved(false); + m_layout->TileFactory()->RefreshTileInfos(); + m_graphicsView->RefreshLayout(); + + VMainGraphicsView::NewSceneRect(m_graphicsView->scene(), m_graphicsView); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VPMainWindow::LayoutWarningPiecesSuperposition_toggled(bool checked) +{ + if (not m_layout.isNull()) + { + m_layout->LayoutSettings().SetWarningSuperpositionOfPieces(checked); + LayoutWasSaved(false); + if (checked) + { + VPSheetPtr sheet = m_layout->GetFocusedSheet(); + if (not sheet.isNull()) + { + sheet->ValidateSuperpositionOfPieces(); + } + } + m_graphicsView->RefreshPieces(); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void VPMainWindow::LayoutWarningPiecesOutOfBound_toggled(bool checked) +{ + if (not m_layout.isNull()) + { + m_layout->LayoutSettings().SetWarningPiecesOutOfBound(checked); + LayoutWasSaved(false); + + if (checked) + { + VPSheetPtr sheet = m_layout->GetFocusedSheet(); + if (not sheet.isNull()) + { + sheet->ValidatePiecesOutOfBound(); + } + } + m_graphicsView->RefreshPieces(); + } +} + //--------------------------------------------------------------------------------------------------------------------- #if defined(Q_OS_MAC) void VPMainWindow::AboutToShowDockMenu() diff --git a/src/app/puzzle/vpmainwindow.h b/src/app/puzzle/vpmainwindow.h index bb9a01bad..52d40c736 100644 --- a/src/app/puzzle/vpmainwindow.h +++ b/src/app/puzzle/vpmainwindow.h @@ -37,11 +37,8 @@ #include "carousel/vpcarrousel.h" #include "scene/vpmaingraphicsview.h" #include "layout/vplayout.h" -#include "layout/vppiece.h" #include "../vlayout/vlayoutpiece.h" -#include "vptilefactory.h" #include "vpcommandline.h" -#include "../vlayout/vlayoutdef.h" #include "../vwidgets/vabstractmainwindow.h" #include "../vmisc/vlockguard.h" #include "../vlayout/dialogs/vabstractlayoutdialog.h" @@ -59,13 +56,13 @@ class WatermarkWindow; class VPMainWindow : public VAbstractMainWindow { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit VPMainWindow(const VPCommandLinePtr &cmd, QWidget *parent = nullptr); - virtual ~VPMainWindow(); + ~VPMainWindow() override; - QString CurrentFile() const; + auto CurrentFile() const -> QString; /** * @brief LoadFile Loads the layout file of given path in m_layout. @@ -73,7 +70,7 @@ public: * @param path path to layout * @return true if success */ - bool LoadFile(QString path); + auto LoadFile(const QString& path) -> bool; void LayoutWasSaved(bool saved); void SetCurrentFile(const QString &fileName); @@ -83,7 +80,7 @@ public: * @param path path to layout file * @return true if success */ - bool SaveLayout(const QString &path, QString &error); + auto SaveLayout(const QString &path, QString &error) -> bool; /** * @brief ImportRawLayouts The function imports the raw layouts of given paths @@ -105,12 +102,12 @@ public slots: */ void on_actionNew_triggered(); - virtual void ShowToolTip(const QString &toolTip) override; + void ShowToolTip(const QString &toolTip) override; protected: - virtual void closeEvent(QCloseEvent *event) override; - virtual void changeEvent(QEvent* event) override; - virtual QStringList RecentFileList() const override; + void closeEvent(QCloseEvent *event) override; + void changeEvent(QEvent* event) override; + auto RecentFileList() const -> QStringList override; private slots: /** @@ -125,14 +122,14 @@ private slots: * triggered. * The slot is automatically connected through name convention. */ - bool on_actionSave_triggered(); + bool on_actionSave_triggered(); //NOLINT(modernize-use-trailing-return-type) /** * @brief on_actionSaveAs_triggered When the menu action File > Save As * is triggered. * The slot is automatically connected through name convention. */ - bool on_actionSaveAs_triggered(); + bool on_actionSaveAs_triggered(); //NOLINT(modernize-use-trailing-return-type) /** * @brief on_actionImportRawLayout_triggered When the menu action @@ -291,8 +288,14 @@ private slots: void SetDefaultGUILanguage(); + void HorizontalScaleChanged(double value); + void VerticalScaleChanged(double value); + + void LayoutWarningPiecesSuperposition_toggled(bool checked); + void LayoutWarningPiecesOutOfBound_toggled(bool checked); + private: - Q_DISABLE_COPY(VPMainWindow) + Q_DISABLE_COPY_MOVE(VPMainWindow) // NOLINT Ui::VPMainWindow *ui; VPCarrousel *m_carrousel{nullptr}; @@ -336,6 +339,14 @@ private: QFileSystemWatcher *m_watermarkWatcher{nullptr}; + struct VPLayoutPrinterPage + { + VPSheetPtr sheet{}; + bool tilesScheme{false}; + int tileRow{-1}; + int tileCol{-1}; + }; + /** * @brief InitMenuBar Inits the menu bar (File, Edit, Help ...) */ @@ -356,6 +367,9 @@ private: */ void InitPropertyTabCurrentSheet(); + void InitPaperSizeData(const QString &suffix); + void InitMarginsData(const QString &suffix); + /** * @brief InitPropertyTabLayout Inits the layout tab in the properties */ @@ -432,9 +446,9 @@ private: auto TranslateUnit() const -> Unit; auto LayoutUnit() const -> Unit; - QSizeF Template(VAbstractLayoutDialog::PaperSizeTemplate t) const; - QSizeF SheetTemplate() const; - QSizeF TileTemplate() const; + auto Template(VAbstractLayoutDialog::PaperSizeTemplate t) const -> QSizeF; + auto SheetTemplate() const -> QSizeF; + auto TileTemplate() const -> QSizeF; void SheetSize(const QSizeF &size); void TileSize(const QSizeF &size); @@ -458,12 +472,12 @@ private: void RotatePiecesToGrainline(); void ExportData(const VPExportData &data); - void ExportApparelLayout(const VPExportData &data, const QVector &details, const QString &name, - const QSize &size) const; + static void ExportApparelLayout(const VPExportData &data, const QVector &details, const QString &name, + const QSize &size) ; void ExportFlatLayout(const VPExportData &data); void ExportScene(const VPExportData &data); - void ExportUnifiedPdfFile(const VPExportData &data); - void GenerateUnifiedPdfFile(const VPExportData &data, const QString &name); + static void ExportUnifiedPdfFile(const VPExportData &data); + static void GenerateUnifiedPdfFile(const VPExportData &data, const QString &name); void ExportPdfTiledFile(const VPExportData &data); void GeneratePdfTiledFile(const VPSheetPtr &sheet, bool showTilesScheme, QPainter *painter, const QSharedPointer &printer, bool &firstPage); @@ -473,14 +487,28 @@ private: void OpenWatermark(const QString &path = QString()); void CleanWaterkmarkEditors(); - void DrawTilesScheme(QPrinter *printer, QPainter *painter, const VPSheetPtr &sheet, bool &firstPage); + auto DrawTilesScheme(QPrinter *printer, QPainter *painter, const VPSheetPtr &sheet, bool firstPage) -> bool; auto AskLayoutIsInvalid(const QList &sheets) -> bool; + auto CheckPiecesOutOfBound(const VPPiecePtr &piece, bool &outOfBoundChecked) -> bool; + auto CheckSuperpositionOfPieces(const VPPiecePtr &piece, bool &pieceSuperpositionChecked) -> bool; void PrintLayoutSheets(QPrinter *printer, const QList &sheets); + static auto PrintLayoutSheetPage(QPrinter *printer, QPainter &painter, const VPSheetPtr& sheet) -> bool; void PrintLayoutTiledSheets(QPrinter *printer, const QList &sheets); + auto PrepareLayoutTilePages(const QList &sheets) -> QVector; + auto PrintLayoutTiledSheetPage(QPrinter *printer, QPainter &painter, const VPLayoutPrinterPage &page, + bool firstPage) -> bool; void ZValueMove(int move); + + auto ImportRawLayout(const QString &rawLayout) -> bool; + auto AddLayoutPieces(const QVector &pieces) -> bool; + + void TranslatePieces(); + void TranslatePieceRelatively(const VPPiecePtr &piece, const QRectF &rect, int selectedPiecesCount, qreal dx, + qreal dy); + void RotatePieces(); }; #endif // VPMAINWINDOW_H diff --git a/src/app/puzzle/vpsettings.cpp b/src/app/puzzle/vpsettings.cpp index a6ce86dd7..24c6c4030 100644 --- a/src/app/puzzle/vpsettings.cpp +++ b/src/app/puzzle/vpsettings.cpp @@ -26,34 +26,33 @@ ** *************************************************************************/ #include "vpsettings.h" -#include "qglobal.h" #include namespace { -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingDockWidgetPropertiesActive, (QLatin1String("dockWidget/properties"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingDockPropertiesContentsActive, (QLatin1String("dockWidget/contents"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutUnit, (QLatin1String("layout/unit"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutSheetPaperWidth, (QLatin1String("layout/sheetPaperWidth"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutSheetPaperHeight, (QLatin1String("layout/sheetPaperHeight"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutTilePaperWidth, (QLatin1String("layout/tilePaperWidth"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutTilePaperHeight, (QLatin1String("layout/tilePaperHeight"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutSheetMargins, (QLatin1String("layout/sheetMargins"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutTileMargins, (QLatin1String("layout/tileMargins"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutSheetIgnoreMargins, (QLatin1String("layout/sheetIgnoreMargins"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutTileIgnoreMargins, (QLatin1String("layout/tileIgnoreMargins"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutTileShowTiles, (QLatin1String("layout/tileShowTiles"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutTileShowWatermark, (QLatin1String("layout/tileShowWatermark"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutWarningPiecesSuperposition, +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingDockWidgetPropertiesActive, (QLatin1String("dockWidget/properties"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingDockPropertiesContentsActive, (QLatin1String("dockWidget/contents"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutUnit, (QLatin1String("layout/unit"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutSheetPaperWidth, (QLatin1String("layout/sheetPaperWidth"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutSheetPaperHeight, (QLatin1String("layout/sheetPaperHeight"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutTilePaperWidth, (QLatin1String("layout/tilePaperWidth"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutTilePaperHeight, (QLatin1String("layout/tilePaperHeight"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutSheetMargins, (QLatin1String("layout/sheetMargins"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutTileMargins, (QLatin1String("layout/tileMargins"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutSheetIgnoreMargins, (QLatin1String("layout/sheetIgnoreMargins"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutTileIgnoreMargins, (QLatin1String("layout/tileIgnoreMargins"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutTileShowTiles, (QLatin1String("layout/tileShowTiles"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutTileShowWatermark, (QLatin1String("layout/tileShowWatermark"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutWarningPiecesSuperposition, // NOLINT (QLatin1String("layout/warningPiecesSuperposition"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutStickyEdges, (QLatin1String("layout/stickyEdges"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutWarningPiecesOutOfBound, +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutStickyEdges, (QLatin1String("layout/stickyEdges"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutWarningPiecesOutOfBound, // NOLINT (QLatin1String("layout/warningPiecesOutOfBound"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutFollowGrainline, (QLatin1String("layout/followGrainline"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutPieceGap, (QLatin1String("layout/pieceGap"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutExportFormat, (QLatin1String("layout/exportFormat"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutLineWidth, (QLatin1String("layout/lineWidth"))) +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutFollowGrainline, (QLatin1String("layout/followGrainline"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutPieceGap, (QLatin1String("layout/pieceGap"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutExportFormat, (QLatin1String("layout/exportFormat"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutLineWidth, (QLatin1String("layout/lineWidth"))) // NOLINT int cachedLineWidth = -1; } // namespace diff --git a/src/app/puzzle/vpsettings.h b/src/app/puzzle/vpsettings.h index 742ac0d6d..6492b2679 100644 --- a/src/app/puzzle/vpsettings.h +++ b/src/app/puzzle/vpsettings.h @@ -34,7 +34,7 @@ class VPSettings : public VCommonSettings { - Q_OBJECT + Q_OBJECT // NOLINT public: VPSettings(Format format, Scope scope, const QString &organization, const QString &application = QString(), QObject *parent = nullptr); @@ -104,7 +104,7 @@ public: void SetLayoutLineWidth(int width); private: - Q_DISABLE_COPY(VPSettings) + Q_DISABLE_COPY_MOVE(VPSettings) // NOLINT }; #endif // VPSETTINGS_H diff --git a/src/app/puzzle/xml/vplayoutfilereader.cpp b/src/app/puzzle/xml/vplayoutfilereader.cpp index 7b650995f..5ca1aa484 100644 --- a/src/app/puzzle/xml/vplayoutfilereader.cpp +++ b/src/app/puzzle/xml/vplayoutfilereader.cpp @@ -31,19 +31,22 @@ #include #include #include "vplayoutfilereader.h" -#include "vplayoutfilewriter.h" #include "vplayoutliterals.h" #include "../layout/vpsheet.h" #include "../vlayout/vlayoutpiecepath.h" #include "../vlayout/vtextmanager.h" #include "../ifc/exception/vexception.h" #include "../ifc/exception/vexceptionconversionerror.h" +#include "../vpatterndb/floatItemData/floatitemdef.h" +#include "../vgeometry/vgeometrydef.h" +#include "../layout/vplayout.h" +#include "../layout/vppiece.h" QT_WARNING_PUSH QT_WARNING_DISABLE_CLANG("-Wmissing-prototypes") QT_WARNING_DISABLE_INTEL(1418) -Q_LOGGING_CATEGORY(MLReader, "mlReader") +Q_LOGGING_CATEGORY(MLReader, "mlReader") // NOLINT QT_WARNING_POP @@ -88,6 +91,7 @@ auto StringToPath(const QString &path) -> QVector { QVector p; QStringList points = path.split(ML::pointsSep); + p.reserve(points.size()); for (const auto& point : points) { p.append(StringToPoint(point)); @@ -140,6 +144,7 @@ auto StringToLines(const QString &string) -> QVector { QStringList lines = string.split(ML::itemsSep); QVector path; + path.reserve(lines.size()); for (const auto& line : lines) { @@ -170,6 +175,7 @@ auto StringToMarkerShape(const QString &string) -> PlaceLabelImg { PlaceLabelImg shape; QStringList paths = string.split(ML::itemsSep); + shape.reserve(paths.size()); for (const auto& path : paths) { shape.append(StringToPath(path)); @@ -956,7 +962,7 @@ auto VPLayoutFileReader::ReadAttributeBool(const QXmlStreamAttributes &attribs, { VExceptionConversionError excep(message, name); excep.AddMoreInformation(e.ErrorMessage()); - throw excep; + throw excep; // NOLINT(cert-err09-cpp) } return val; @@ -983,7 +989,7 @@ auto VPLayoutFileReader::ReadAttributeDouble(const QXmlStreamAttributes &attribs { VExceptionConversionError excep(message, name); excep.AddMoreInformation(e.ErrorMessage()); - throw excep; + throw excep; // NOLINT(cert-err09-cpp) } return param; } @@ -1009,7 +1015,7 @@ auto VPLayoutFileReader::ReadAttributeUInt(const QXmlStreamAttributes &attribs, { VExceptionConversionError excep(message, name); excep.AddMoreInformation(e.ErrorMessage()); - throw excep; + throw excep; // NOLINT(cert-err09-cpp) } return param; } @@ -1035,7 +1041,7 @@ auto VPLayoutFileReader::ReadAttributeInt(const QXmlStreamAttributes &attribs, c { VExceptionConversionError excep(message, name); excep.AddMoreInformation(e.ErrorMessage()); - throw excep; + throw excep; // NOLINT(cert-err09-cpp) } return param; } diff --git a/src/app/puzzle/xml/vplayoutfilereader.h b/src/app/puzzle/xml/vplayoutfilereader.h index e2a25b5c6..33adf99fa 100644 --- a/src/app/puzzle/xml/vplayoutfilereader.h +++ b/src/app/puzzle/xml/vplayoutfilereader.h @@ -31,18 +31,22 @@ #include #include "../ifc/xml/vabstractconverter.h" -#include "../layout/vplayout.h" -#include "../layout/vppiece.h" +#include "../layout/layoutdef.h" +#include "../vmisc/defglobal.h" #include -Q_DECLARE_LOGGING_CATEGORY(MLReader) +Q_DECLARE_LOGGING_CATEGORY(MLReader) // NOLINT struct TextLine; +struct VLayoutPassmark; +struct VLayoutPlaceLabel; +class VLayoutPiecePath; +class VTextManager; class VPLayoutFileReader : public QXmlStreamReader { - Q_DECLARE_TR_FUNCTIONS(VPLayoutFileReader) + Q_DECLARE_TR_FUNCTIONS(VPLayoutFileReader) // NOLINT public: VPLayoutFileReader()=default; ~VPLayoutFileReader()=default; @@ -50,7 +54,8 @@ public: auto ReadFile(const VPLayoutPtr &layout, QFile *file) -> bool; private: - Q_DISABLE_COPY(VPLayoutFileReader) + // cppcheck-suppress unknownMacro + Q_DISABLE_COPY_MOVE(VPLayoutFileReader) // NOLINT void ReadLayout(const VPLayoutPtr &layout); void ReadProperties(const VPLayoutPtr &layout); diff --git a/src/app/puzzle/xml/vplayoutfilewriter.cpp b/src/app/puzzle/xml/vplayoutfilewriter.cpp index c8e9d2155..974cac5dd 100644 --- a/src/app/puzzle/xml/vplayoutfilewriter.cpp +++ b/src/app/puzzle/xml/vplayoutfilewriter.cpp @@ -74,6 +74,7 @@ auto PointToString(const QPointF &p) -> QString auto PathToString(const QVector &pathPoints) -> QString { QStringList path; + path.reserve(pathPoints.size()); for (auto point : pathPoints) { @@ -96,6 +97,7 @@ auto RectToString(const QRectF &r) -> QString auto MarkerShapeToString(const PlaceLabelImg &shape) -> QString { QStringList s; + s.reserve(shape.size()); for (const auto& path : shape) { s.append(PathToString(path)); @@ -113,6 +115,7 @@ auto LineToString(const QLineF &line) -> QString auto LinesToString(const QVector &lines) -> QString { QStringList l; + l.reserve(lines.size()); for (auto line : lines) { l.append(LineToString(line)); diff --git a/src/app/puzzle/xml/vplayoutfilewriter.h b/src/app/puzzle/xml/vplayoutfilewriter.h index 50a8c7342..93099a2a9 100644 --- a/src/app/puzzle/xml/vplayoutfilewriter.h +++ b/src/app/puzzle/xml/vplayoutfilewriter.h @@ -36,6 +36,7 @@ #include #include "../vmisc/literals.h" +#include "../vmisc/defglobal.h" #include "../layout/layoutdef.h" class VPLayout; @@ -48,7 +49,7 @@ class VTextManager; class VPLayoutFileWriter : public QXmlStreamWriter { - Q_DECLARE_TR_FUNCTIONS(VPLayoutFileWriter) + Q_DECLARE_TR_FUNCTIONS(VPLayoutFileWriter) // NOLINT public: VPLayoutFileWriter()= default; ~VPLayoutFileWriter()= default; @@ -56,6 +57,8 @@ public: void WriteFile(const VPLayoutPtr &layout, QIODevice *file); private: + // cppcheck-suppress unknownMacro + Q_DISABLE_COPY_MOVE(VPLayoutFileWriter) // NOLINT void WriteLayout(const VPLayoutPtr &layout); void WriteLayoutProperties(const VPLayoutPtr &layout); void WriteSheets(const VPLayoutPtr &layout); @@ -73,7 +76,7 @@ private: void SetAttribute(const QString &name, const T &value); template - void SetAttribute(const QString &name, const char (&value)[N]); + void SetAttribute(const QString &name, const char (&value)[N]); //NOLINT(cppcoreguidelines-avoid-c-arrays) NOLINT(hicpp-avoid-c-arrays) NOLINT(modernize-avoid-c-arrays) template void SetAttributeOrRemoveIf(const QString &name, const T &value, @@ -112,7 +115,7 @@ inline void VPLayoutFileWriter::SetAttribute(const QString &name, const bo //--------------------------------------------------------------------------------------------------------------------- template -inline void VPLayoutFileWriter::SetAttribute(const QString &name, const char (&value)[N]) +inline void VPLayoutFileWriter::SetAttribute(const QString &name, const char (&value)[N]) //NOLINT(cppcoreguidelines-avoid-c-arrays) NOLINT(hicpp-avoid-c-arrays) NOLINT(modernize-avoid-c-arrays) { writeAttribute(name, QString(value)); } diff --git a/src/app/puzzle/xml/vplayoutliterals.cpp b/src/app/puzzle/xml/vplayoutliterals.cpp index 4be6d42f2..e2b46d682 100644 --- a/src/app/puzzle/xml/vplayoutliterals.cpp +++ b/src/app/puzzle/xml/vplayoutliterals.cpp @@ -29,89 +29,89 @@ namespace ML // Manual layout { -const QString TagLayout = QStringLiteral("layout"); -const QString TagProperties = QStringLiteral("properties"); -const QString TagUnit = QStringLiteral("unit"); -const QString TagTitle = QStringLiteral("title"); -const QString TagDescription = QStringLiteral("description"); -const QString TagSize = QStringLiteral("size"); -const QString TagMargin = QStringLiteral("margin"); -const QString TagControl = QStringLiteral("control"); -const QString TagTiles = QStringLiteral("tiles"); -const QString TagUnplacedPieces = QStringLiteral("unplacedPieces"); -const QString TagPieces = QStringLiteral("pieces"); -const QString TagPiece = QStringLiteral("piece"); -const QString TagSheets = QStringLiteral("sheets"); -const QString TagSheet = QStringLiteral("sheet"); -const QString TagName = QStringLiteral("name"); -const QString TagSeamLine = QStringLiteral("seamLine"); -const QString TagSeamAllowance = QStringLiteral("seamAllowance"); -const QString TagGrainline = QStringLiteral("grainline"); -const QString TagNotches = QStringLiteral("notches"); -const QString TagNotch = QStringLiteral("notch"); -const QString TagInternalPaths = QStringLiteral("internalPaths"); -const QString TagInternalPath = QStringLiteral("internalPath"); -const QString TagMarkers = QStringLiteral("markers"); -const QString TagMarker = QStringLiteral("marker"); -const QString TagLabels = QStringLiteral("labels"); -const QString TagPieceLabel = QStringLiteral("pieceLabel"); -const QString TagPatternLabel = QStringLiteral("patternLabel"); -const QString TagLines = QStringLiteral("lines"); -const QString TagLine = QStringLiteral("line"); -const QString TagScale = QStringLiteral("scale"); -const QString TagWatermark = QStringLiteral("watermark"); +const QString TagLayout = QStringLiteral("layout"); // NOLINT(cert-err58-cpp) +const QString TagProperties = QStringLiteral("properties"); // NOLINT(cert-err58-cpp) +const QString TagUnit = QStringLiteral("unit"); // NOLINT(cert-err58-cpp) +const QString TagTitle = QStringLiteral("title"); // NOLINT(cert-err58-cpp) +const QString TagDescription = QStringLiteral("description"); // NOLINT(cert-err58-cpp) +const QString TagSize = QStringLiteral("size"); // NOLINT(cert-err58-cpp) +const QString TagMargin = QStringLiteral("margin"); // NOLINT(cert-err58-cpp) +const QString TagControl = QStringLiteral("control"); // NOLINT(cert-err58-cpp) +const QString TagTiles = QStringLiteral("tiles"); // NOLINT(cert-err58-cpp) +const QString TagUnplacedPieces = QStringLiteral("unplacedPieces"); // NOLINT(cert-err58-cpp) +const QString TagPieces = QStringLiteral("pieces"); // NOLINT(cert-err58-cpp) +const QString TagPiece = QStringLiteral("piece"); // NOLINT(cert-err58-cpp) +const QString TagSheets = QStringLiteral("sheets"); // NOLINT(cert-err58-cpp) +const QString TagSheet = QStringLiteral("sheet"); // NOLINT(cert-err58-cpp) +const QString TagName = QStringLiteral("name"); // NOLINT(cert-err58-cpp) +const QString TagSeamLine = QStringLiteral("seamLine"); // NOLINT(cert-err58-cpp) +const QString TagSeamAllowance = QStringLiteral("seamAllowance"); // NOLINT(cert-err58-cpp) +const QString TagGrainline = QStringLiteral("grainline"); // NOLINT(cert-err58-cpp) +const QString TagNotches = QStringLiteral("notches"); // NOLINT(cert-err58-cpp) +const QString TagNotch = QStringLiteral("notch"); // NOLINT(cert-err58-cpp) +const QString TagInternalPaths = QStringLiteral("internalPaths"); // NOLINT(cert-err58-cpp) +const QString TagInternalPath = QStringLiteral("internalPath"); // NOLINT(cert-err58-cpp) +const QString TagMarkers = QStringLiteral("markers"); // NOLINT(cert-err58-cpp) +const QString TagMarker = QStringLiteral("marker"); // NOLINT(cert-err58-cpp) +const QString TagLabels = QStringLiteral("labels"); // NOLINT(cert-err58-cpp) +const QString TagPieceLabel = QStringLiteral("pieceLabel"); // NOLINT(cert-err58-cpp) +const QString TagPatternLabel = QStringLiteral("patternLabel"); // NOLINT(cert-err58-cpp) +const QString TagLines = QStringLiteral("lines"); // NOLINT(cert-err58-cpp) +const QString TagLine = QStringLiteral("line"); // NOLINT(cert-err58-cpp) +const QString TagScale = QStringLiteral("scale"); // NOLINT(cert-err58-cpp) +const QString TagWatermark = QStringLiteral("watermark"); // NOLINT(cert-err58-cpp) -const QString AttrWarningSuperposition = QStringLiteral("warningSuperposition"); -const QString AttrWarningOutOfBound = QStringLiteral("warningOutOfBound"); -const QString AttrStickyEdges = QStringLiteral("stickyEdges"); -const QString AttrPiecesGap = QStringLiteral("piecesGap"); -const QString AttrVisible = QStringLiteral("visible"); -const QString AttrMatchingMarks = QStringLiteral("matchingMarks"); -const QString AttrName = QStringLiteral("name"); -const QString AttrLeft = QStringLiteral("left"); -const QString AttrTop = QStringLiteral("top"); -const QString AttrRight = QStringLiteral("right"); -const QString AttrBottom = QStringLiteral("bottom"); -const QString AttrWidth = QStringLiteral("width"); -const QString AttrLength = QStringLiteral("length"); -const QString AttrFollowGrainline = QStringLiteral("followGrainline"); -const QString AttrID = QStringLiteral("id"); -const QString AttrMirrored = QStringLiteral("mirrored"); -const QString AttrForbidFlipping = QStringLiteral("forbidFlipping"); -const QString AttrForceFlipping = QStringLiteral("forceFlipping"); -const QString AttrTransform = QStringLiteral("transform"); -const QString AttrShowSeamline = QStringLiteral("showSeamline"); -const QString AttrEnabled = QStringLiteral("enabled"); -const QString AttrBuiltIn = QStringLiteral("builtIn"); -const QString AttrAngle = QStringLiteral("angle"); -const QString AttrArrowDirection = QStringLiteral("arrowDirection"); -const QString AttrType = QStringLiteral("type"); -const QString AttrBaseLine = QStringLiteral("baseLine"); -const QString AttrPath = QStringLiteral("path"); -const QString AttrCut = QStringLiteral("cut"); -const QString AttrPenStyle = QStringLiteral("penStyle"); -const QString AttrCenter = QStringLiteral("center"); -const QString AttrBox = QStringLiteral("box"); -const QString AttrShape = QStringLiteral("shape"); -const QString AttrFont = QStringLiteral("font"); -const QString AttrFontSize = QStringLiteral("fontSize"); -const QString AttrBold = QStringLiteral("bold"); -const QString AttrItalic = QStringLiteral("italic"); -const QString AttrAlignment = QStringLiteral("alignment"); -const QString AttrGradationLabel = QStringLiteral("gradationLabel"); -const QString AttrCopyNumber = QStringLiteral("copyNumber"); -const QString AttrGrainlineType = QStringLiteral("grainlineType"); -const QString AttrXScale = QStringLiteral("xScale"); -const QString AttrYScale = QStringLiteral("yScale"); -const QString AttrIgnoreMargins = QStringLiteral("ignoreMargins"); -const QString AttrShowPreview = QStringLiteral("showPreview"); -const QString AttrPrintScheme = QStringLiteral("printScheme"); -const QString AttrTileNumber = QStringLiteral("tileNumber"); -const QString AttrZValue = QStringLiteral("zValue"); +const QString AttrWarningSuperposition = QStringLiteral("warningSuperposition"); // NOLINT(cert-err58-cpp) +const QString AttrWarningOutOfBound = QStringLiteral("warningOutOfBound"); // NOLINT(cert-err58-cpp) +const QString AttrStickyEdges = QStringLiteral("stickyEdges"); // NOLINT(cert-err58-cpp) +const QString AttrPiecesGap = QStringLiteral("piecesGap"); // NOLINT(cert-err58-cpp) +const QString AttrVisible = QStringLiteral("visible"); // NOLINT(cert-err58-cpp) +const QString AttrMatchingMarks = QStringLiteral("matchingMarks"); // NOLINT(cert-err58-cpp) +const QString AttrName = QStringLiteral("name"); // NOLINT(cert-err58-cpp) +const QString AttrLeft = QStringLiteral("left"); // NOLINT(cert-err58-cpp) +const QString AttrTop = QStringLiteral("top"); // NOLINT(cert-err58-cpp) +const QString AttrRight = QStringLiteral("right"); // NOLINT(cert-err58-cpp) +const QString AttrBottom = QStringLiteral("bottom"); // NOLINT(cert-err58-cpp) +const QString AttrWidth = QStringLiteral("width"); // NOLINT(cert-err58-cpp) +const QString AttrLength = QStringLiteral("length"); // NOLINT(cert-err58-cpp) +const QString AttrFollowGrainline = QStringLiteral("followGrainline"); // NOLINT(cert-err58-cpp) +const QString AttrID = QStringLiteral("id"); // NOLINT(cert-err58-cpp) +const QString AttrMirrored = QStringLiteral("mirrored"); // NOLINT(cert-err58-cpp) +const QString AttrForbidFlipping = QStringLiteral("forbidFlipping"); // NOLINT(cert-err58-cpp) +const QString AttrForceFlipping = QStringLiteral("forceFlipping"); // NOLINT(cert-err58-cpp) +const QString AttrTransform = QStringLiteral("transform"); // NOLINT(cert-err58-cpp) +const QString AttrShowSeamline = QStringLiteral("showSeamline"); // NOLINT(cert-err58-cpp) +const QString AttrEnabled = QStringLiteral("enabled"); // NOLINT(cert-err58-cpp) +const QString AttrBuiltIn = QStringLiteral("builtIn"); // NOLINT(cert-err58-cpp) +const QString AttrAngle = QStringLiteral("angle"); // NOLINT(cert-err58-cpp) +const QString AttrArrowDirection = QStringLiteral("arrowDirection"); // NOLINT(cert-err58-cpp) +const QString AttrType = QStringLiteral("type"); // NOLINT(cert-err58-cpp) +const QString AttrBaseLine = QStringLiteral("baseLine"); // NOLINT(cert-err58-cpp) +const QString AttrPath = QStringLiteral("path"); // NOLINT(cert-err58-cpp) +const QString AttrCut = QStringLiteral("cut"); // NOLINT(cert-err58-cpp) +const QString AttrPenStyle = QStringLiteral("penStyle"); // NOLINT(cert-err58-cpp) +const QString AttrCenter = QStringLiteral("center"); // NOLINT(cert-err58-cpp) +const QString AttrBox = QStringLiteral("box"); // NOLINT(cert-err58-cpp) +const QString AttrShape = QStringLiteral("shape"); // NOLINT(cert-err58-cpp) +const QString AttrFont = QStringLiteral("font"); // NOLINT(cert-err58-cpp) +const QString AttrFontSize = QStringLiteral("fontSize"); // NOLINT(cert-err58-cpp) +const QString AttrBold = QStringLiteral("bold"); // NOLINT(cert-err58-cpp) +const QString AttrItalic = QStringLiteral("italic"); // NOLINT(cert-err58-cpp) +const QString AttrAlignment = QStringLiteral("alignment"); // NOLINT(cert-err58-cpp) +const QString AttrGradationLabel = QStringLiteral("gradationLabel"); // NOLINT(cert-err58-cpp) +const QString AttrCopyNumber = QStringLiteral("copyNumber"); // NOLINT(cert-err58-cpp) +const QString AttrGrainlineType = QStringLiteral("grainlineType"); // NOLINT(cert-err58-cpp) +const QString AttrXScale = QStringLiteral("xScale"); // NOLINT(cert-err58-cpp) +const QString AttrYScale = QStringLiteral("yScale"); // NOLINT(cert-err58-cpp) +const QString AttrIgnoreMargins = QStringLiteral("ignoreMargins"); // NOLINT(cert-err58-cpp) +const QString AttrShowPreview = QStringLiteral("showPreview"); // NOLINT(cert-err58-cpp) +const QString AttrPrintScheme = QStringLiteral("printScheme"); // NOLINT(cert-err58-cpp) +const QString AttrTileNumber = QStringLiteral("tileNumber"); // NOLINT(cert-err58-cpp) +const QString AttrZValue = QStringLiteral("zValue"); // NOLINT(cert-err58-cpp) -const QString atFrontStr = QStringLiteral("atFront"); -const QString atRearStr = QStringLiteral("atRear"); -const QString atBothStr = QStringLiteral("atBoth"); +const QString atFrontStr = QStringLiteral("atFront"); // NOLINT(cert-err58-cpp) +const QString atRearStr = QStringLiteral("atRear"); // NOLINT(cert-err58-cpp) +const QString atBothStr = QStringLiteral("atBoth"); // NOLINT(cert-err58-cpp) const QChar groupSep = QLatin1Char(';'); const QChar coordintatesSep = QLatin1Char(','); diff --git a/src/app/puzzle/xml/vplayoutliterals.h b/src/app/puzzle/xml/vplayoutliterals.h index 12488150f..818dbbb2e 100644 --- a/src/app/puzzle/xml/vplayoutliterals.h +++ b/src/app/puzzle/xml/vplayoutliterals.h @@ -122,7 +122,7 @@ extern const QChar groupSep; extern const QChar coordintatesSep; extern const QChar pointsSep; extern const QChar itemsSep; -} +} // namespace ML #endif // VPLAYOUTLITERALS_H diff --git a/src/app/tape/dialogs/configpages/tapepreferencesconfigurationpage.cpp b/src/app/tape/dialogs/configpages/tapepreferencesconfigurationpage.cpp index d779294ed..daa272bbe 100644 --- a/src/app/tape/dialogs/configpages/tapepreferencesconfigurationpage.cpp +++ b/src/app/tape/dialogs/configpages/tapepreferencesconfigurationpage.cpp @@ -30,7 +30,6 @@ #include "ui_tapepreferencesconfigurationpage.h" #include "../../mapplication.h" #include "../../vtapesettings.h" -#include "../vpatterndb/variables/vmeasurement.h" #include "../vpatterndb/pmsystems.h" //--------------------------------------------------------------------------------------------------------------------- @@ -100,7 +99,7 @@ TapePreferencesConfigurationPage::~TapePreferencesConfigurationPage() } //--------------------------------------------------------------------------------------------------------------------- -QStringList TapePreferencesConfigurationPage::Apply() +auto TapePreferencesConfigurationPage::Apply() -> QStringList { QStringList preferences; VTapeSettings *settings = MApplication::VApp()->TapeSettings(); @@ -121,16 +120,16 @@ QStringList TapePreferencesConfigurationPage::Apply() if (m_langChanged || m_systemChanged) { - const QString locale = qvariant_cast(ui->langCombo->currentData()); + const auto locale = qvariant_cast(ui->langCombo->currentData()); settings->SetLocale(locale); m_langChanged = false; - const QString code = qvariant_cast(ui->systemCombo->currentData()); + const auto code = qvariant_cast(ui->systemCombo->currentData()); settings->SetPMSystemCode(code); m_systemChanged = false; VAbstractApplication::VApp()->LoadTranslation(locale); - qApp->processEvents();// force to call changeEvent + QCoreApplication::processEvents();// force to call changeEvent // Part about measurments will not be updated automatically MApplication::VApp()->RetranslateTables(); @@ -164,7 +163,7 @@ void TapePreferencesConfigurationPage::RetranslateUi() ui->osOptionCheck->setText(tr("With OS options") + QStringLiteral(" (%1)").arg(QLocale().decimalPoint())); { - const QString code = qvariant_cast(ui->systemCombo->currentData()); + const auto code = qvariant_cast(ui->systemCombo->currentData()); ui->systemCombo->blockSignals(true); ui->systemCombo->clear(); InitPMSystems(ui->systemCombo); diff --git a/src/app/tape/dialogs/configpages/tapepreferencesconfigurationpage.h b/src/app/tape/dialogs/configpages/tapepreferencesconfigurationpage.h index 26e2931ae..b9ec8c17b 100644 --- a/src/app/tape/dialogs/configpages/tapepreferencesconfigurationpage.h +++ b/src/app/tape/dialogs/configpages/tapepreferencesconfigurationpage.h @@ -31,6 +31,8 @@ #include +#include "../vmisc/defglobal.h" + namespace Ui { class TapePreferencesConfigurationPage; @@ -38,17 +40,18 @@ namespace Ui class TapePreferencesConfigurationPage : public QWidget { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit TapePreferencesConfigurationPage(QWidget *parent = nullptr); - virtual ~TapePreferencesConfigurationPage(); + ~TapePreferencesConfigurationPage() override; - QStringList Apply(); + auto Apply() -> QStringList; protected: - virtual void changeEvent(QEvent* event) override; + void changeEvent(QEvent* event) override; private: - Q_DISABLE_COPY(TapePreferencesConfigurationPage) + // cppcheck-suppress unknownMacro + Q_DISABLE_COPY_MOVE(TapePreferencesConfigurationPage) // NOLINT Ui::TapePreferencesConfigurationPage *ui; bool m_langChanged; bool m_systemChanged; diff --git a/src/app/tape/dialogs/configpages/tapepreferencespathpage.cpp b/src/app/tape/dialogs/configpages/tapepreferencespathpage.cpp index 0b958396d..dafa9975f 100644 --- a/src/app/tape/dialogs/configpages/tapepreferencespathpage.cpp +++ b/src/app/tape/dialogs/configpages/tapepreferencespathpage.cpp @@ -185,35 +185,35 @@ void TapePreferencesPathPage::InitTable() { ui->pathTable->setItem(0, 0, new QTableWidgetItem(tr("My Individual Measurements"))); - QTableWidgetItem *item = new QTableWidgetItem(settings->GetPathIndividualMeasurements()); + auto *item = new QTableWidgetItem(settings->GetPathIndividualMeasurements()); item->setToolTip(settings->GetPathIndividualMeasurements()); ui->pathTable->setItem(0, 1, item); } { ui->pathTable->setItem(1, 0, new QTableWidgetItem(tr("My Multisize Measurements"))); - QTableWidgetItem *item = new QTableWidgetItem(settings->GetPathMultisizeMeasurements()); + auto *item = new QTableWidgetItem(settings->GetPathMultisizeMeasurements()); item->setToolTip(settings->GetPathMultisizeMeasurements()); ui->pathTable->setItem(1, 1, item); } { ui->pathTable->setItem(2, 0, new QTableWidgetItem(tr("My Patterns"))); - QTableWidgetItem *item = new QTableWidgetItem(settings->GetPathPattern()); + auto *item = new QTableWidgetItem(settings->GetPathPattern()); item->setToolTip(settings->GetPathPattern()); ui->pathTable->setItem(2, 1, item); } { ui->pathTable->setItem(3, 0, new QTableWidgetItem(tr("My Templates"))); - QTableWidgetItem *item = new QTableWidgetItem(settings->GetPathTemplate()); + auto *item = new QTableWidgetItem(settings->GetPathTemplate()); item->setToolTip(settings->GetPathTemplate()); ui->pathTable->setItem(3, 1, item); } { ui->pathTable->setItem(4, 0, new QTableWidgetItem(tr("My Layouts"))); - QTableWidgetItem *item = new QTableWidgetItem(settings->GetPathManualLayouts()); + auto *item = new QTableWidgetItem(settings->GetPathManualLayouts()); item->setToolTip(settings->GetPathManualLayouts()); ui->pathTable->setItem(4, 1, item); } diff --git a/src/app/tape/dialogs/configpages/tapepreferencespathpage.h b/src/app/tape/dialogs/configpages/tapepreferencespathpage.h index dafe80a1d..8b8a8d389 100644 --- a/src/app/tape/dialogs/configpages/tapepreferencespathpage.h +++ b/src/app/tape/dialogs/configpages/tapepreferencespathpage.h @@ -31,6 +31,8 @@ #include +#include "../vmisc/defglobal.h" + namespace Ui { class TapePreferencesPathPage; @@ -38,20 +40,21 @@ namespace Ui class TapePreferencesPathPage : public QWidget { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit TapePreferencesPathPage(QWidget *parent = nullptr); - virtual ~TapePreferencesPathPage(); + ~TapePreferencesPathPage() override; void Apply(); protected: - virtual void changeEvent(QEvent* event) override; + void changeEvent(QEvent* event) override; private slots: void DefaultPath(); void EditPath(); private: - Q_DISABLE_COPY(TapePreferencesPathPage) + // cppcheck-suppress unknownMacro + Q_DISABLE_COPY_MOVE(TapePreferencesPathPage) // NOLINT Ui::TapePreferencesPathPage *ui; void InitTable(); diff --git a/src/app/tape/dialogs/dialogabouttape.cpp b/src/app/tape/dialogs/dialogabouttape.cpp index 8e077fe6a..f2c64bd9b 100644 --- a/src/app/tape/dialogs/dialogabouttape.cpp +++ b/src/app/tape/dialogs/dialogabouttape.cpp @@ -28,8 +28,8 @@ #include "dialogabouttape.h" #include "ui_dialogabouttape.h" -#include "../version.h" #include "../vmisc/def.h" +#include "../vmisc/projectversion.h" #include "../fervor/fvupdater.h" #include @@ -43,7 +43,7 @@ DialogAboutTape::DialogAboutTape(QWidget *parent) :QDialog(parent), ui(new Ui::DialogAboutTape), - isInitialized(false) + m_isInitialized(false) { ui->setupUi(this); @@ -52,7 +52,8 @@ DialogAboutTape::DialogAboutTape(QWidget *parent) RetranslateUi(); connect(ui->pushButton_Web_Site, &QPushButton::clicked, this, []() { - if (not QDesktopServices::openUrl(QUrl(QStringLiteral("https://%1").arg(VER_COMPANYDOMAIN_STR)))) + if (not QDesktopServices::openUrl( + QUrl(QStringLiteral("https://%1").arg(QStringLiteral(VER_COMPANYDOMAIN_STR))))) { qWarning() << tr("Cannot open your default browser"); } @@ -100,7 +101,7 @@ void DialogAboutTape::showEvent(QShowEvent *event) return; } - if (isInitialized) + if (m_isInitialized) { return; } @@ -109,7 +110,7 @@ void DialogAboutTape::showEvent(QShowEvent *event) setMaximumSize(size()); setMinimumSize(size()); - isInitialized = true;//first show windows are held + m_isInitialized = true;//first show windows are held } //--------------------------------------------------------------------------------------------------------------------- @@ -125,17 +126,17 @@ void DialogAboutTape::FontPointSize(QWidget *w, int pointSize) //--------------------------------------------------------------------------------------------------------------------- void DialogAboutTape::RetranslateUi() { - ui->label_Tape_Version->setText(QString("Tape %1").arg(APP_VERSION_STR)); - ui->labelBuildRevision->setText(tr("Build revision: %1").arg(BUILD_REVISION)); + ui->label_Tape_Version->setText(QStringLiteral("Tape %1").arg(APP_VERSION_STR)); + ui->labelBuildRevision->setText(tr("Build revision: %1").arg(QStringLiteral(BUILD_REVISION))); ui->label_QT_Version->setText(buildCompatibilityString()); - const QDate date = QLocale::c().toDate(QString(__DATE__).simplified(), QLatin1String("MMM d yyyy")); - ui->label_Tape_Built->setText(tr("Built on %1 at %2").arg(date.toString(), __TIME__)); + const QDate date = QLocale::c().toDate(QStringLiteral(__DATE__).simplified(), QStringLiteral("MMM d yyyy")); + ui->label_Tape_Built->setText(tr("Built on %1 at %2").arg(date.toString(), QStringLiteral(__TIME__))); ui->label_Legal_Stuff->setText(QApplication::translate("InternalStrings", "The program is provided AS IS with NO WARRANTY OF ANY " "KIND, INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY " "AND FITNESS FOR A PARTICULAR PURPOSE.")); - ui->pushButton_Web_Site->setText(tr("Web site : %1").arg(VER_COMPANYDOMAIN_STR)); + ui->pushButton_Web_Site->setText(tr("Web site : %1").arg(QStringLiteral(VER_COMPANYDOMAIN_STR))); } diff --git a/src/app/tape/dialogs/dialogabouttape.h b/src/app/tape/dialogs/dialogabouttape.h index f27cea6f5..7f92576de 100644 --- a/src/app/tape/dialogs/dialogabouttape.h +++ b/src/app/tape/dialogs/dialogabouttape.h @@ -31,6 +31,8 @@ #include +#include "../vmisc/defglobal.h" + namespace Ui { class DialogAboutTape; @@ -38,22 +40,23 @@ namespace Ui class DialogAboutTape : public QDialog { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit DialogAboutTape(QWidget *parent = nullptr); - virtual ~DialogAboutTape(); + ~DialogAboutTape() override; protected: - virtual void changeEvent(QEvent* event) override; - virtual void showEvent(QShowEvent *event) override; + void changeEvent(QEvent* event) override; + void showEvent(QShowEvent *event) override; private: - Q_DISABLE_COPY(DialogAboutTape) + // cppcheck-suppress unknownMacro + Q_DISABLE_COPY_MOVE(DialogAboutTape) // NOLINT Ui::DialogAboutTape *ui; - bool isInitialized; + bool m_isInitialized; - void FontPointSize(QWidget *w, int pointSize); + static void FontPointSize(QWidget *w, int pointSize); void RetranslateUi(); }; diff --git a/src/app/tape/dialogs/dialogdimensioncustomnames.cpp b/src/app/tape/dialogs/dialogdimensioncustomnames.cpp index 9afe6c867..bf873c616 100644 --- a/src/app/tape/dialogs/dialogdimensioncustomnames.cpp +++ b/src/app/tape/dialogs/dialogdimensioncustomnames.cpp @@ -46,7 +46,7 @@ DialogDimensionCustomNames::~DialogDimensionCustomNames() } //--------------------------------------------------------------------------------------------------------------------- -QMap DialogDimensionCustomNames::CustomNames() const +auto DialogDimensionCustomNames::CustomNames() const -> QMap { QMap names; diff --git a/src/app/tape/dialogs/dialogdimensionlabels.h b/src/app/tape/dialogs/dialogdimensionlabels.h index 8fc2890ee..81365e286 100644 --- a/src/app/tape/dialogs/dialogdimensionlabels.h +++ b/src/app/tape/dialogs/dialogdimensionlabels.h @@ -42,24 +42,25 @@ class QTableWidgetItem; class DialogDimensionLabels : public QDialog { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit DialogDimensionLabels(const QMap &dimensions, bool fullCircumference, QWidget *parent = nullptr); - virtual ~DialogDimensionLabels(); + ~DialogDimensionLabels() override; auto Labels() const -> QMap; protected: - virtual void changeEvent(QEvent* event) override; + void changeEvent(QEvent* event) override; private slots: void DimensionChanged(); void LabelChanged(QTableWidgetItem *item); private: - Q_DISABLE_COPY(DialogDimensionLabels) + // cppcheck-suppress unknownMacro + Q_DISABLE_COPY_MOVE(DialogDimensionLabels) // NOLINT Ui::DialogDimensionLabels *ui; QMap m_dimensions; diff --git a/src/app/tape/dialogs/dialogmdatabase.cpp b/src/app/tape/dialogs/dialogmdatabase.cpp index 418baca62..9871b910e 100644 --- a/src/app/tape/dialogs/dialogmdatabase.cpp +++ b/src/app/tape/dialogs/dialogmdatabase.cpp @@ -41,25 +41,7 @@ DialogMDataBase::DialogMDataBase(const QStringList &list, QWidget *parent) :QDialog(parent), ui(new Ui::DialogMDataBase), - selectMode(true), - list(list), - groupA(nullptr), - groupB(nullptr), - groupC(nullptr), - groupD(nullptr), - groupE(nullptr), - groupF(nullptr), - groupG(nullptr), - groupH(nullptr), - groupI(nullptr), - groupJ(nullptr), - groupK(nullptr), - groupL(nullptr), - groupM(nullptr), - groupN(nullptr), - groupO(nullptr), - groupP(nullptr), - groupQ(nullptr) + m_selectMode(true) { ui->setupUi(this); @@ -83,26 +65,7 @@ DialogMDataBase::DialogMDataBase(const QStringList &list, QWidget *parent) DialogMDataBase::DialogMDataBase(QWidget *parent) :QDialog(parent), ui(new Ui::DialogMDataBase), - selectMode(false), - list(), - groupA(nullptr), - groupB(nullptr), - groupC(nullptr), - groupD(nullptr), - groupE(nullptr), - groupF(nullptr), - groupG(nullptr), - groupH(nullptr), - groupI(nullptr), - groupJ(nullptr), - groupK(nullptr), - groupL(nullptr), - groupM(nullptr), - groupN(nullptr), - groupO(nullptr), - groupP(nullptr), - groupQ(nullptr) - + m_selectMode(false) { ui->setupUi(this); @@ -130,9 +93,9 @@ DialogMDataBase::~DialogMDataBase() } //--------------------------------------------------------------------------------------------------------------------- -QStringList DialogMDataBase::GetNewNames() const +auto DialogMDataBase::GetNewNames() const -> QStringList { - if (selectMode) + if (m_selectMode) { QStringList newNames; QTreeWidgetItemIterator it(ui->treeWidget, @@ -140,7 +103,7 @@ QStringList DialogMDataBase::GetNewNames() const while (*it) { const QString name = (*it)->data(0, Qt::UserRole).toString(); - if (not list.contains(name)) + if (not m_list.contains(name)) { newNames.append(name); } @@ -148,41 +111,39 @@ QStringList DialogMDataBase::GetNewNames() const } return newNames; } - else - { - return QStringList(); - } + + return {}; } //--------------------------------------------------------------------------------------------------------------------- void DialogMDataBase::RetranslateGroups() { - RetranslateGroup(groupA, "A. " + tr("Direct Height", "Measurement section"), ListGroupA()); - RetranslateGroup(groupB, "B. " + tr("Direct Width", "Measurement section"), ListGroupB()); - RetranslateGroup(groupC, "C. " + tr("Indentation", "Measurement section"), ListGroupC()); - RetranslateGroup(groupD, "D. " + tr("Hand", "Measurement section"), ListGroupD()); - RetranslateGroup(groupE, "E. " + tr("Foot", "Measurement section"), ListGroupE()); - RetranslateGroup(groupF, "F. " + tr("Head", "Measurement section"), ListGroupF()); - RetranslateGroup(groupG, "G. " + tr("Circumference and Arc", "Measurement section"), ListGroupG()); - RetranslateGroup(groupH, "H. " + tr("Vertical", "Measurement section"), ListGroupH()); - RetranslateGroup(groupI, "I. " + tr("Horizontal", "Measurement section"), ListGroupI()); - RetranslateGroup(groupJ, "J. " + tr("Bust", "Measurement section"), ListGroupJ()); - RetranslateGroup(groupK, "K. " + tr("Balance", "Measurement section"), ListGroupK()); - RetranslateGroup(groupL, "L. " + tr("Arm", "Measurement section"), ListGroupL()); - RetranslateGroup(groupM, "M. " + tr("Leg", "Measurement section"), ListGroupM()); - RetranslateGroup(groupN, "N. " + tr("Crotch and Rise", "Measurement section"), ListGroupN()); - RetranslateGroup(groupO, "O. " + tr("Men & Tailoring", "Measurement section"), ListGroupO()); - RetranslateGroup(groupP, "P. " + tr("Historical & Specialty", "Measurement section"), ListGroupP()); - RetranslateGroup(groupQ, "Q. " + tr("Patternmaking measurements", "Measurement section"), ListGroupQ()); + RetranslateGroup(m_groupA, "A. " + tr("Direct Height", "Measurement section"), ListGroupA()); + RetranslateGroup(m_groupB, "B. " + tr("Direct Width", "Measurement section"), ListGroupB()); + RetranslateGroup(m_groupC, "C. " + tr("Indentation", "Measurement section"), ListGroupC()); + RetranslateGroup(m_groupD, "D. " + tr("Hand", "Measurement section"), ListGroupD()); + RetranslateGroup(m_groupE, "E. " + tr("Foot", "Measurement section"), ListGroupE()); + RetranslateGroup(m_groupF, "F. " + tr("Head", "Measurement section"), ListGroupF()); + RetranslateGroup(m_groupG, "G. " + tr("Circumference and Arc", "Measurement section"), ListGroupG()); + RetranslateGroup(m_groupH, "H. " + tr("Vertical", "Measurement section"), ListGroupH()); + RetranslateGroup(m_groupI, "I. " + tr("Horizontal", "Measurement section"), ListGroupI()); + RetranslateGroup(m_groupJ, "J. " + tr("Bust", "Measurement section"), ListGroupJ()); + RetranslateGroup(m_groupK, "K. " + tr("Balance", "Measurement section"), ListGroupK()); + RetranslateGroup(m_groupL, "L. " + tr("Arm", "Measurement section"), ListGroupL()); + RetranslateGroup(m_groupM, "M. " + tr("Leg", "Measurement section"), ListGroupM()); + RetranslateGroup(m_groupN, "N. " + tr("Crotch and Rise", "Measurement section"), ListGroupN()); + RetranslateGroup(m_groupO, "O. " + tr("Men & Tailoring", "Measurement section"), ListGroupO()); + RetranslateGroup(m_groupP, "P. " + tr("Historical & Specialty", "Measurement section"), ListGroupP()); + RetranslateGroup(m_groupQ, "Q. " + tr("Patternmaking measurements", "Measurement section"), ListGroupQ()); ShowDescription(ui->treeWidget->currentItem(), 0); } //--------------------------------------------------------------------------------------------------------------------- -QString DialogMDataBase::ImgTag(const QString &number) +auto DialogMDataBase::ImgTag(const QString &number) -> QString { - QString imgUrl(""); // In case of error - const QString filePath = QString("://diagrams/%1.svg") + QString imgUrl(QStringLiteral("")); // In case of error + const QString filePath = QStringLiteral("://diagrams/%1.svg") .arg(MapDiagrams(VAbstractApplication::VApp()->TrVars(), number)); if (QFileInfo::exists(filePath)) { @@ -213,7 +174,8 @@ QString DialogMDataBase::ImgTag(const QString &number) QByteArray byteArray; QBuffer buffer(&byteArray); scaledImg.save(&buffer, "PNG"); - imgUrl = QString(""; + imgUrl = QStringLiteral(""); } } } @@ -235,11 +197,11 @@ void DialogMDataBase::changeEvent(QEvent *event) } //--------------------------------------------------------------------------------------------------------------------- -bool DialogMDataBase::eventFilter(QObject *target, QEvent *event) +auto DialogMDataBase::eventFilter(QObject *target, QEvent *event) -> bool { if (target == ui->treeWidget && event->type() == QEvent::KeyPress) { - QKeyEvent *keyEvent = static_cast(event); + auto *keyEvent = static_cast(event); // NOLINT(cppcoreguidelines-pro-type-static-cast-downcast) switch(keyEvent->key()) { case Qt::Key_Up: @@ -278,13 +240,13 @@ void DialogMDataBase::UpdateChecks(QTreeWidgetItem *item, int column) Qt::CheckState checkState = item->checkState(0); for (int i = 0; i < item->childCount(); ++i) { - if (not list.contains(item->child(i)->data(0, Qt::UserRole).toString())) + if (not m_list.contains(item->child(i)->data(0, Qt::UserRole).toString())) { item->child(i)->setCheckState(0, checkState); flag = true; } - if (flag == false) // All child in the list + if (not flag) // All child in the list { item->setCheckState(0, Qt::Checked); } @@ -338,22 +300,22 @@ void DialogMDataBase::TreeMenu(const QPoint &pos) QTreeWidgetItem *item = ui->treeWidget->currentItem(); ShowDescription(item, model.column()); - QAction *actionCollapseAll = new QAction(tr("Collapse All"), this); + auto *actionCollapseAll = new QAction(tr("Collapse All"), this); connect(actionCollapseAll, &QAction::triggered, ui->treeWidget, &QTreeWidget::collapseAll); - QAction *actionExpandeAll = new QAction(tr("Expand All"), this); + auto *actionExpandeAll = new QAction(tr("Expand All"), this); connect(actionExpandeAll, &QAction::triggered, ui->treeWidget, &QTreeWidget::expandAll); QMenu menu(this); menu.addAction(actionCollapseAll); menu.addAction(actionExpandeAll); - if (selectMode) + if (m_selectMode) { QString actionName; GlobalCheckState() == Qt::Checked ? actionName = tr("Check all") : actionName = tr("Uncheck all"); - QAction *actionRecheck = new QAction(actionName, this); + auto *actionRecheck = new QAction(actionName, this); connect(actionRecheck, &QAction::triggered, this, &DialogMDataBase::Recheck); menu.addAction(actionRecheck); @@ -364,50 +326,50 @@ void DialogMDataBase::TreeMenu(const QPoint &pos) //--------------------------------------------------------------------------------------------------------------------- void DialogMDataBase::Recheck() { - if (selectMode) + if (m_selectMode) { const Qt::CheckState check = GlobalCheckState(); - ChangeCheckState(groupA, check); - ChangeCheckState(groupB, check); - ChangeCheckState(groupC, check); - ChangeCheckState(groupD, check); - ChangeCheckState(groupE, check); - ChangeCheckState(groupF, check); - ChangeCheckState(groupG, check); - ChangeCheckState(groupH, check); - ChangeCheckState(groupI, check); - ChangeCheckState(groupJ, check); - ChangeCheckState(groupK, check); - ChangeCheckState(groupL, check); - ChangeCheckState(groupM, check); - ChangeCheckState(groupN, check); - ChangeCheckState(groupO, check); - ChangeCheckState(groupP, check); - ChangeCheckState(groupQ, check); + ChangeCheckState(m_groupA, check); + ChangeCheckState(m_groupB, check); + ChangeCheckState(m_groupC, check); + ChangeCheckState(m_groupD, check); + ChangeCheckState(m_groupE, check); + ChangeCheckState(m_groupF, check); + ChangeCheckState(m_groupG, check); + ChangeCheckState(m_groupH, check); + ChangeCheckState(m_groupI, check); + ChangeCheckState(m_groupJ, check); + ChangeCheckState(m_groupK, check); + ChangeCheckState(m_groupL, check); + ChangeCheckState(m_groupM, check); + ChangeCheckState(m_groupN, check); + ChangeCheckState(m_groupO, check); + ChangeCheckState(m_groupP, check); + ChangeCheckState(m_groupQ, check); } } //--------------------------------------------------------------------------------------------------------------------- void DialogMDataBase::FilterMeasurements(const QString &search) { - FilterGroup(groupA, search); - FilterGroup(groupB, search); - FilterGroup(groupC, search); - FilterGroup(groupD, search); - FilterGroup(groupE, search); - FilterGroup(groupF, search); - FilterGroup(groupG, search); - FilterGroup(groupH, search); - FilterGroup(groupI, search); - FilterGroup(groupJ, search); - FilterGroup(groupK, search); - FilterGroup(groupL, search); - FilterGroup(groupM, search); - FilterGroup(groupN, search); - FilterGroup(groupO, search); - FilterGroup(groupP, search); - FilterGroup(groupQ, search); + FilterGroup(m_groupA, search); + FilterGroup(m_groupB, search); + FilterGroup(m_groupC, search); + FilterGroup(m_groupD, search); + FilterGroup(m_groupE, search); + FilterGroup(m_groupF, search); + FilterGroup(m_groupG, search); + FilterGroup(m_groupH, search); + FilterGroup(m_groupI, search); + FilterGroup(m_groupJ, search); + FilterGroup(m_groupK, search); + FilterGroup(m_groupL, search); + FilterGroup(m_groupM, search); + FilterGroup(m_groupN, search); + FilterGroup(m_groupO, search); + FilterGroup(m_groupP, search); + FilterGroup(m_groupQ, search); const QList list = ui->treeWidget->selectedItems(); list.isEmpty() ? ShowDescription(nullptr, -1) : ShowDescription(ConstFirst(list), 0); @@ -416,23 +378,23 @@ void DialogMDataBase::FilterMeasurements(const QString &search) //--------------------------------------------------------------------------------------------------------------------- void DialogMDataBase::InitDataBase(const QStringList &list) { - InitGroup(&groupA, "A. " + tr("Direct Height", "Measurement section"), ListGroupA(), list); - InitGroup(&groupB, "B. " + tr("Direct Width", "Measurement section"), ListGroupB(), list); - InitGroup(&groupC, "C. " + tr("Indentation", "Measurement section"), ListGroupC(), list); - InitGroup(&groupD, "D. " + tr("Hand", "Measurement section"), ListGroupD(), list); - InitGroup(&groupE, "E. " + tr("Foot", "Measurement section"), ListGroupE(), list); - InitGroup(&groupF, "F. " + tr("Head", "Measurement section"), ListGroupF(), list); - InitGroup(&groupG, "G. " + tr("Circumference and Arc", "Measurement section"), ListGroupG(), list); - InitGroup(&groupH, "H. " + tr("Vertical", "Measurement section"), ListGroupH(), list); - InitGroup(&groupI, "I. " + tr("Horizontal", "Measurement section"), ListGroupI(), list); - InitGroup(&groupJ, "J. " + tr("Bust", "Measurement section"), ListGroupJ(), list); - InitGroup(&groupK, "K. " + tr("Balance", "Measurement section"), ListGroupK(), list); - InitGroup(&groupL, "L. " + tr("Arm", "Measurement section"), ListGroupL(), list); - InitGroup(&groupM, "M. " + tr("Leg", "Measurement section"), ListGroupM(), list); - InitGroup(&groupN, "N. " + tr("Crotch and Rise", "Measurement section"), ListGroupN(), list); - InitGroup(&groupO, "O. " + tr("Men & Tailoring", "Measurement section"), ListGroupO(), list); - InitGroup(&groupP, "P. " + tr("Historical & Specialty", "Measurement section"), ListGroupP(), list); - InitGroup(&groupQ, "Q. " + tr("Patternmaking measurements", "Measurement section"), ListGroupQ(), list); + InitGroup(&m_groupA, "A. " + tr("Direct Height", "Measurement section"), ListGroupA(), list); + InitGroup(&m_groupB, "B. " + tr("Direct Width", "Measurement section"), ListGroupB(), list); + InitGroup(&m_groupC, "C. " + tr("Indentation", "Measurement section"), ListGroupC(), list); + InitGroup(&m_groupD, "D. " + tr("Hand", "Measurement section"), ListGroupD(), list); + InitGroup(&m_groupE, "E. " + tr("Foot", "Measurement section"), ListGroupE(), list); + InitGroup(&m_groupF, "F. " + tr("Head", "Measurement section"), ListGroupF(), list); + InitGroup(&m_groupG, "G. " + tr("Circumference and Arc", "Measurement section"), ListGroupG(), list); + InitGroup(&m_groupH, "H. " + tr("Vertical", "Measurement section"), ListGroupH(), list); + InitGroup(&m_groupI, "I. " + tr("Horizontal", "Measurement section"), ListGroupI(), list); + InitGroup(&m_groupJ, "J. " + tr("Bust", "Measurement section"), ListGroupJ(), list); + InitGroup(&m_groupK, "K. " + tr("Balance", "Measurement section"), ListGroupK(), list); + InitGroup(&m_groupL, "L. " + tr("Arm", "Measurement section"), ListGroupL(), list); + InitGroup(&m_groupM, "M. " + tr("Leg", "Measurement section"), ListGroupM(), list); + InitGroup(&m_groupN, "N. " + tr("Crotch and Rise", "Measurement section"), ListGroupN(), list); + InitGroup(&m_groupO, "O. " + tr("Men & Tailoring", "Measurement section"), ListGroupO(), list); + InitGroup(&m_groupP, "P. " + tr("Historical & Specialty", "Measurement section"), ListGroupP(), list); + InitGroup(&m_groupQ, "Q. " + tr("Patternmaking measurements", "Measurement section"), ListGroupQ(), list); } //--------------------------------------------------------------------------------------------------------------------- @@ -440,7 +402,7 @@ void DialogMDataBase::InitGroup(QTreeWidgetItem **group, const QString &groupNam const QStringList &list) { *group = AddGroup(groupName); - for (auto &m : mList) + for (const auto &m : mList) { AddMeasurement(*group, m, list); } @@ -472,13 +434,13 @@ void DialogMDataBase::FilterGroup(QTreeWidgetItem *group, const QString &search) } //--------------------------------------------------------------------------------------------------------------------- -QTreeWidgetItem *DialogMDataBase::AddGroup(const QString &text) +auto DialogMDataBase::AddGroup(const QString &text) -> QTreeWidgetItem * { - QTreeWidgetItem *group = new QTreeWidgetItem(ui->treeWidget); + auto *group = new QTreeWidgetItem(ui->treeWidget); group->setText(0, text); group->setToolTip(0, text); group->setExpanded(true); - if (selectMode) + if (m_selectMode) { group->setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled); group->setCheckState(0, Qt::Unchecked); @@ -492,9 +454,9 @@ void DialogMDataBase::AddMeasurement(QTreeWidgetItem *group, const QString &name { SCASSERT(group != nullptr) - QTreeWidgetItem *m = new QTreeWidgetItem(group); + auto *m = new QTreeWidgetItem(group); - if (selectMode) + if (m_selectMode) { if (list.contains(name)) { @@ -530,17 +492,17 @@ void DialogMDataBase::WriteSettings() } //--------------------------------------------------------------------------------------------------------------------- -QString DialogMDataBase::ItemFullDescription(QTreeWidgetItem *item, bool showImage) const +auto DialogMDataBase::ItemFullDescription(QTreeWidgetItem *item, bool showImage) -> QString { if (item == nullptr || item->childCount() != 0) { - return QString(); + return {}; } const QString name = item->data(0, Qt::UserRole).toString(); if (name.isEmpty()) { - return QString(); + return {}; } const QString number = VAbstractApplication::VApp()->TrVars()->MNumber(name); @@ -592,65 +554,66 @@ void DialogMDataBase::ChangeCheckState(QTreeWidgetItem *group, Qt::CheckState ch } //--------------------------------------------------------------------------------------------------------------------- -Qt::CheckState DialogMDataBase::GlobalCheckState() const +auto DialogMDataBase::GlobalCheckState() const -> Qt::CheckState { - SCASSERT(groupA != nullptr) - SCASSERT(groupB != nullptr) - SCASSERT(groupC != nullptr) - SCASSERT(groupD != nullptr) - SCASSERT(groupE != nullptr) - SCASSERT(groupF != nullptr) - SCASSERT(groupG != nullptr) - SCASSERT(groupH != nullptr) - SCASSERT(groupI != nullptr) - SCASSERT(groupJ != nullptr) - SCASSERT(groupK != nullptr) - SCASSERT(groupL != nullptr) - SCASSERT(groupM != nullptr) - SCASSERT(groupN != nullptr) - SCASSERT(groupO != nullptr) - SCASSERT(groupP != nullptr) - SCASSERT(groupQ != nullptr) + SCASSERT(m_groupA != nullptr) + SCASSERT(m_groupB != nullptr) + SCASSERT(m_groupC != nullptr) + SCASSERT(m_groupD != nullptr) + SCASSERT(m_groupE != nullptr) + SCASSERT(m_groupF != nullptr) + SCASSERT(m_groupG != nullptr) + SCASSERT(m_groupH != nullptr) + SCASSERT(m_groupI != nullptr) + SCASSERT(m_groupJ != nullptr) + SCASSERT(m_groupK != nullptr) + SCASSERT(m_groupL != nullptr) + SCASSERT(m_groupM != nullptr) + SCASSERT(m_groupN != nullptr) + SCASSERT(m_groupO != nullptr) + SCASSERT(m_groupP != nullptr) + SCASSERT(m_groupQ != nullptr) - if (selectMode) + if (m_selectMode) { - if (groupA->checkState(0) == Qt::Unchecked && - groupB->checkState(0) == Qt::Unchecked && - groupC->checkState(0) == Qt::Unchecked && - groupD->checkState(0) == Qt::Unchecked && - groupE->checkState(0) == Qt::Unchecked && - groupF->checkState(0) == Qt::Unchecked && - groupG->checkState(0) == Qt::Unchecked && - groupH->checkState(0) == Qt::Unchecked && - groupI->checkState(0) == Qt::Unchecked && - groupJ->checkState(0) == Qt::Unchecked && - groupK->checkState(0) == Qt::Unchecked && - groupL->checkState(0) == Qt::Unchecked && - groupM->checkState(0) == Qt::Unchecked && - groupN->checkState(0) == Qt::Unchecked && - groupO->checkState(0) == Qt::Unchecked && - groupP->checkState(0) == Qt::Unchecked && - groupQ->checkState(0) == Qt::Unchecked) + if (m_groupA->checkState(0) == Qt::Unchecked && + m_groupB->checkState(0) == Qt::Unchecked && + m_groupC->checkState(0) == Qt::Unchecked && + m_groupD->checkState(0) == Qt::Unchecked && + m_groupE->checkState(0) == Qt::Unchecked && + m_groupF->checkState(0) == Qt::Unchecked && + m_groupG->checkState(0) == Qt::Unchecked && + m_groupH->checkState(0) == Qt::Unchecked && + m_groupI->checkState(0) == Qt::Unchecked && + m_groupJ->checkState(0) == Qt::Unchecked && + m_groupK->checkState(0) == Qt::Unchecked && + m_groupL->checkState(0) == Qt::Unchecked && + m_groupM->checkState(0) == Qt::Unchecked && + m_groupN->checkState(0) == Qt::Unchecked && + m_groupO->checkState(0) == Qt::Unchecked && + m_groupP->checkState(0) == Qt::Unchecked && + m_groupQ->checkState(0) == Qt::Unchecked) { return Qt::Checked; } - else if (groupA->checkState(0) == Qt::Checked && - groupB->checkState(0) == Qt::Checked && - groupC->checkState(0) == Qt::Checked && - groupD->checkState(0) == Qt::Checked && - groupE->checkState(0) == Qt::Checked && - groupF->checkState(0) == Qt::Checked && - groupG->checkState(0) == Qt::Checked && - groupH->checkState(0) == Qt::Checked && - groupI->checkState(0) == Qt::Checked && - groupJ->checkState(0) == Qt::Checked && - groupK->checkState(0) == Qt::Checked && - groupL->checkState(0) == Qt::Checked && - groupM->checkState(0) == Qt::Checked && - groupN->checkState(0) == Qt::Checked && - groupO->checkState(0) == Qt::Checked && - groupP->checkState(0) == Qt::Checked && - groupQ->checkState(0) == Qt::Checked) + + if (m_groupA->checkState(0) == Qt::Checked && + m_groupB->checkState(0) == Qt::Checked && + m_groupC->checkState(0) == Qt::Checked && + m_groupD->checkState(0) == Qt::Checked && + m_groupE->checkState(0) == Qt::Checked && + m_groupF->checkState(0) == Qt::Checked && + m_groupG->checkState(0) == Qt::Checked && + m_groupH->checkState(0) == Qt::Checked && + m_groupI->checkState(0) == Qt::Checked && + m_groupJ->checkState(0) == Qt::Checked && + m_groupK->checkState(0) == Qt::Checked && + m_groupL->checkState(0) == Qt::Checked && + m_groupM->checkState(0) == Qt::Checked && + m_groupN->checkState(0) == Qt::Checked && + m_groupO->checkState(0) == Qt::Checked && + m_groupP->checkState(0) == Qt::Checked && + m_groupQ->checkState(0) == Qt::Checked) { return Qt::Unchecked; } diff --git a/src/app/tape/dialogs/dialogmdatabase.h b/src/app/tape/dialogs/dialogmdatabase.h index bfa7a05ba..cced0993b 100644 --- a/src/app/tape/dialogs/dialogmdatabase.h +++ b/src/app/tape/dialogs/dialogmdatabase.h @@ -31,6 +31,8 @@ #include +#include "../vmisc/defglobal.h" + namespace Ui { class DialogMDataBase; @@ -40,22 +42,22 @@ class QTreeWidgetItem; class DialogMDataBase : public QDialog { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit DialogMDataBase(const QStringList &list, QWidget *parent = nullptr); explicit DialogMDataBase(QWidget *parent = nullptr); - virtual ~DialogMDataBase() override; + ~DialogMDataBase() override; - QStringList GetNewNames() const; + auto GetNewNames() const -> QStringList; void RetranslateGroups(); - static QString ImgTag(const QString &number); + static auto ImgTag(const QString &number) -> QString; protected: - virtual void changeEvent(QEvent* event) override; - virtual bool eventFilter(QObject *target, QEvent *event) override; + void changeEvent(QEvent* event) override; + auto eventFilter(QObject *target, QEvent *event) -> bool override; private slots: void UpdateChecks(QTreeWidgetItem *item, int column); @@ -65,48 +67,49 @@ private slots: void FilterMeasurements(const QString &search); private: - Q_DISABLE_COPY(DialogMDataBase) + // cppcheck-suppress unknownMacro + Q_DISABLE_COPY_MOVE(DialogMDataBase) // NOLINT Ui::DialogMDataBase *ui; - bool selectMode; - QStringList list; + bool m_selectMode; + QStringList m_list{}; - QTreeWidgetItem *groupA; - QTreeWidgetItem *groupB; - QTreeWidgetItem *groupC; - QTreeWidgetItem *groupD; - QTreeWidgetItem *groupE; - QTreeWidgetItem *groupF; - QTreeWidgetItem *groupG; - QTreeWidgetItem *groupH; - QTreeWidgetItem *groupI; - QTreeWidgetItem *groupJ; - QTreeWidgetItem *groupK; - QTreeWidgetItem *groupL; - QTreeWidgetItem *groupM; - QTreeWidgetItem *groupN; - QTreeWidgetItem *groupO; - QTreeWidgetItem *groupP; - QTreeWidgetItem *groupQ; + QTreeWidgetItem *m_groupA{nullptr}; + QTreeWidgetItem *m_groupB{nullptr}; + QTreeWidgetItem *m_groupC{nullptr}; + QTreeWidgetItem *m_groupD{nullptr}; + QTreeWidgetItem *m_groupE{nullptr}; + QTreeWidgetItem *m_groupF{nullptr}; + QTreeWidgetItem *m_groupG{nullptr}; + QTreeWidgetItem *m_groupH{nullptr}; + QTreeWidgetItem *m_groupI{nullptr}; + QTreeWidgetItem *m_groupJ{nullptr}; + QTreeWidgetItem *m_groupK{nullptr}; + QTreeWidgetItem *m_groupL{nullptr}; + QTreeWidgetItem *m_groupM{nullptr}; + QTreeWidgetItem *m_groupN{nullptr}; + QTreeWidgetItem *m_groupO{nullptr}; + QTreeWidgetItem *m_groupP{nullptr}; + QTreeWidgetItem *m_groupQ{nullptr}; void InitDataBase(const QStringList &list = QStringList()); void InitGroup(QTreeWidgetItem **group, const QString &groupName, const QStringList &mList, const QStringList &list = QStringList()); - void FilterGroup(QTreeWidgetItem *group, const QString &search); + static void FilterGroup(QTreeWidgetItem *group, const QString &search); - Q_REQUIRED_RESULT QTreeWidgetItem *AddGroup(const QString &text); + Q_REQUIRED_RESULT auto AddGroup(const QString &text) -> QTreeWidgetItem *; void AddMeasurement(QTreeWidgetItem *group, const QString &name, const QStringList &list); void ReadSettings(); void WriteSettings(); - QString ItemFullDescription(QTreeWidgetItem *item, bool showImage = true) const; + static auto ItemFullDescription(QTreeWidgetItem *item, bool showImage = true) -> QString; - void RetranslateGroup(QTreeWidgetItem *group, const QString &groupText, const QStringList &list); - void RetranslateMeasurement(QTreeWidgetItem *group, int index, const QString &name); + static void RetranslateGroup(QTreeWidgetItem *group, const QString &groupText, const QStringList &list); + static void RetranslateMeasurement(QTreeWidgetItem *group, int index, const QString &name); - void ChangeCheckState(QTreeWidgetItem *group, Qt::CheckState check); - Qt::CheckState GlobalCheckState() const; + static void ChangeCheckState(QTreeWidgetItem *group, Qt::CheckState check); + auto GlobalCheckState() const -> Qt::CheckState; }; #endif // DIALOGMDATABASE_H diff --git a/src/app/tape/dialogs/dialogmeasurementscsvcolumns.cpp b/src/app/tape/dialogs/dialogmeasurementscsvcolumns.cpp index 2e90ef0e4..e8998b914 100644 --- a/src/app/tape/dialogs/dialogmeasurementscsvcolumns.cpp +++ b/src/app/tape/dialogs/dialogmeasurementscsvcolumns.cpp @@ -120,7 +120,7 @@ void DialogMeasurementsCSVColumns::showEvent(QShowEvent *event) if (m_type == MeasurementsType::Multisize) { - if (m_dimensions.size() > 0) + if (not m_dimensions.empty()) { connect(ui->comboBoxShiftA, QOverload::of(&QComboBox::currentIndexChanged), this, &DialogMeasurementsCSVColumns::ColumnChanged); @@ -203,27 +203,25 @@ void DialogMeasurementsCSVColumns::ColumnChanged() } //--------------------------------------------------------------------------------------------------------------------- -bool DialogMeasurementsCSVColumns::ColumnMandatory(int column) const +auto DialogMeasurementsCSVColumns::ColumnMandatory(int column) const -> bool { if (m_type == MeasurementsType::Individual) { return column < static_cast(IndividualMeasurementsColumns::FullName); } - else + + int mandatory = 3; + + if (m_dimensions.size() > 1) { - int mandatory = 3; - - if (m_dimensions.size() > 1) - { - mandatory += qMin(m_dimensions.size(), 2); - } - - return static_cast(column) < mandatory; + mandatory += qMin(m_dimensions.size(), 2); } + + return static_cast(column) < mandatory; } //--------------------------------------------------------------------------------------------------------------------- -QString DialogMeasurementsCSVColumns::ColumnHeader(int column) const +auto DialogMeasurementsCSVColumns::ColumnHeader(int column) const -> QString { if (m_type == MeasurementsType::Individual) { @@ -239,7 +237,7 @@ QString DialogMeasurementsCSVColumns::ColumnHeader(int column) const case IndividualMeasurementsColumns::Description: return tr("Description", "measurement column"); default: - return QString(); + return {}; } } else @@ -252,14 +250,14 @@ QString DialogMeasurementsCSVColumns::ColumnHeader(int column) const case MultisizeMeasurementsColumns::BaseValue: return tr("Base value", "measurement column"); case MultisizeMeasurementsColumns::ShiftA: - if (m_dimensions.size() > 0) + if (not m_dimensions.empty()) { MeasurementDimension_p dimension = m_dimensions.at(0); return tr("Shift (%1):", "measurement column").arg(dimension->Name()); } else { - return "Shift A"; + return QStringLiteral("Shift A"); } case MultisizeMeasurementsColumns::ShiftB: if (m_dimensions.size() > 1) @@ -269,7 +267,7 @@ QString DialogMeasurementsCSVColumns::ColumnHeader(int column) const } else { - return "Shift B"; + return QStringLiteral("Shift B"); } case MultisizeMeasurementsColumns::ShiftC: if (m_dimensions.size() > 2) @@ -279,7 +277,7 @@ QString DialogMeasurementsCSVColumns::ColumnHeader(int column) const } else { - return "Shift C"; + return QStringLiteral("Shift C"); } case MultisizeMeasurementsColumns::FullName: return tr("Full name", "measurement column"); @@ -292,62 +290,38 @@ QString DialogMeasurementsCSVColumns::ColumnHeader(int column) const } //--------------------------------------------------------------------------------------------------------------------- -int DialogMeasurementsCSVColumns::ImportColumnCount() const +auto DialogMeasurementsCSVColumns::ImportColumnCount() const -> int { if (m_type == MeasurementsType::Individual) { return static_cast(IndividualMeasurementsColumns::LAST_DO_NOT_USE); } - else - { - return static_cast(MultisizeMeasurementsColumns::LAST_DO_NOT_USE); - } + + return static_cast(MultisizeMeasurementsColumns::LAST_DO_NOT_USE); } //--------------------------------------------------------------------------------------------------------------------- -int DialogMeasurementsCSVColumns::MinimumColumns() const +auto DialogMeasurementsCSVColumns::MinimumColumns() const -> int { if (m_type == MeasurementsType::Individual) { return 2; } - else + + int mandatory = 3; + + if (m_dimensions.size() > 1) { - int mandatory = 3; - - if (m_dimensions.size() > 1) - { - mandatory += qMin(m_dimensions.size(), 2); - } - - return mandatory; + mandatory += qMin(m_dimensions.size(), 2); } + + return mandatory; } //--------------------------------------------------------------------------------------------------------------------- auto DialogMeasurementsCSVColumns::ColumnsValid() -> bool { - ChangeColor(ui->labelName, OkColor(this)); - ChangeColor(ui->labelValue, OkColor(this)); - if (m_type == MeasurementsType::Multisize) - { - if (not m_dimensions.empty()) - { - ChangeColor(ui->labelShiftA, OkColor(this)); - } - - if (m_dimensions.size() > 1) - { - ChangeColor(ui->labelShiftB, OkColor(this)); - } - - if (m_dimensions.size() > 2) - { - ChangeColor(ui->labelShiftC, OkColor(this)); - } - } - ChangeColor(ui->labelFullName, OkColor(this)); - ChangeColor(ui->labelDescription, OkColor(this)); + ClearColumnCollor(); bool columnNameFlag = true; bool columnValueFlag = true; @@ -359,20 +333,22 @@ auto DialogMeasurementsCSVColumns::ColumnsValid() -> bool const QColor errorColor = Qt::red; - if (m_type == MeasurementsType::Multisize ? not ColumnValid(MultisizeMeasurementsColumns::Name) - : not ColumnValid(IndividualMeasurementsColumns::Name)) + auto ChangeColumnColor = [this, errorColor] + (QLabel *label, bool &columnFlag, MultisizeMeasurementsColumns multisizeColumn, + IndividualMeasurementsColumns individualColumn) { - ChangeColor(ui->labelName, errorColor); - columnNameFlag = false; - } + if (m_type == MeasurementsType::Multisize ? not ColumnValid(multisizeColumn) + : not ColumnValid(individualColumn)) + { + ChangeColor(label, errorColor); + columnFlag = false; + } + }; - - if (m_type == MeasurementsType::Multisize ? not ColumnValid(MultisizeMeasurementsColumns::BaseValue) - : not ColumnValid(IndividualMeasurementsColumns::Value)) - { - ChangeColor(ui->labelValue, errorColor); - columnValueFlag = false; - } + ChangeColumnColor(ui->labelName, columnNameFlag, MultisizeMeasurementsColumns::Name, + IndividualMeasurementsColumns::Name); + ChangeColumnColor(ui->labelValue, columnValueFlag, MultisizeMeasurementsColumns::BaseValue, + IndividualMeasurementsColumns::Value); if (m_type == MeasurementsType::Multisize) { @@ -404,24 +380,41 @@ auto DialogMeasurementsCSVColumns::ColumnsValid() -> bool } } - if (m_type == MeasurementsType::Multisize ? not ColumnValid(MultisizeMeasurementsColumns::FullName) - : not ColumnValid(IndividualMeasurementsColumns::FullName)) - { - ChangeColor(ui->labelFullName, errorColor); - columnFullNameFlag = false; - } - - if (m_type == MeasurementsType::Multisize ? not ColumnValid(MultisizeMeasurementsColumns::Description) - : not ColumnValid(IndividualMeasurementsColumns::Description)) - { - ChangeColor(ui->labelDescription, errorColor); - columnDescriptionFlag = false; - } + ChangeColumnColor(ui->labelFullName, columnFullNameFlag, MultisizeMeasurementsColumns::FullName, + IndividualMeasurementsColumns::FullName); + ChangeColumnColor(ui->labelDescription, columnDescriptionFlag, MultisizeMeasurementsColumns::Description, + IndividualMeasurementsColumns::Description); return columnNameFlag && columnValueFlag && columnShiftAFlag && columnShiftBFlag && columnShiftCFlag && columnFullNameFlag && columnDescriptionFlag; } +//--------------------------------------------------------------------------------------------------------------------- +void DialogMeasurementsCSVColumns::ClearColumnCollor() +{ + ChangeColor(ui->labelName, OkColor(this)); + ChangeColor(ui->labelValue, OkColor(this)); + if (m_type == MeasurementsType::Multisize) + { + if (not m_dimensions.empty()) + { + ChangeColor(ui->labelShiftA, OkColor(this)); + } + + if (m_dimensions.size() > 1) + { + ChangeColor(ui->labelShiftB, OkColor(this)); + } + + if (m_dimensions.size() > 2) + { + ChangeColor(ui->labelShiftC, OkColor(this)); + } + } + ChangeColor(ui->labelFullName, OkColor(this)); + ChangeColor(ui->labelDescription, OkColor(this)); +} + //--------------------------------------------------------------------------------------------------------------------- void DialogMeasurementsCSVColumns::InitColumnsMap() { @@ -537,7 +530,7 @@ void DialogMeasurementsCSVColumns::InitColumnsControls() InitControl(ui->comboBoxName, static_cast(MultisizeMeasurementsColumns::Name)); InitControl(ui->comboBoxValue, static_cast(MultisizeMeasurementsColumns::BaseValue)); - if (m_dimensions.size() > 0) + if (not m_dimensions.empty()) { InitControl(ui->comboBoxShiftA, static_cast(MultisizeMeasurementsColumns::ShiftA)); } @@ -572,7 +565,7 @@ void DialogMeasurementsCSVColumns::InitImportHeaders() auto AddHeader = [this](int column, bool visible=true) { - QTableWidgetItem *header = new QTableWidgetItem(ColumnHeader(column)); + auto *header = new QTableWidgetItem(ColumnHeader(column)); ui->tableWidgetImport->setHorizontalHeaderItem(column, header); ui->tableWidgetImport->setColumnHidden(column, not visible); }; @@ -588,7 +581,7 @@ void DialogMeasurementsCSVColumns::InitImportHeaders() { AddHeader(static_cast(MultisizeMeasurementsColumns::Name)); AddHeader(static_cast(MultisizeMeasurementsColumns::BaseValue)); - AddHeader(static_cast(MultisizeMeasurementsColumns::ShiftA), m_dimensions.size() > 0); + AddHeader(static_cast(MultisizeMeasurementsColumns::ShiftA), not m_dimensions.empty()); AddHeader(static_cast(MultisizeMeasurementsColumns::ShiftB), m_dimensions.size() > 1); AddHeader(static_cast(MultisizeMeasurementsColumns::ShiftC), m_dimensions.size() > 2); AddHeader(static_cast(MultisizeMeasurementsColumns::FullName)); @@ -597,7 +590,7 @@ void DialogMeasurementsCSVColumns::InitImportHeaders() } //--------------------------------------------------------------------------------------------------------------------- -QSharedPointer DialogMeasurementsCSVColumns::CSVModel() const +auto DialogMeasurementsCSVColumns::CSVModel() const -> QSharedPointer { return QSharedPointer::create(m_fileName, nullptr, m_withHeader, m_separator, m_codec); } @@ -624,7 +617,7 @@ void DialogMeasurementsCSVColumns::ShowInputPreview() { for(int column=0; columnheaderText(column)); + auto *header = new QTableWidgetItem(csv->headerText(column)); header->setToolTip(QString::number(column+1)); ui->tableWidgetInput->setHorizontalHeaderItem(column, header); } @@ -635,7 +628,7 @@ void DialogMeasurementsCSVColumns::ShowInputPreview() for(int column=0; columntext(row, column); - QTableWidgetItem *item = new QTableWidgetItem(text); + auto *item = new QTableWidgetItem(text); item->setToolTip(text); // set the item non-editable (view only), and non-selectable @@ -676,7 +669,7 @@ void DialogMeasurementsCSVColumns::ShowImportPreview() if (tableColumn >= 0 && tableColumn < columns) { const QString text = csv->text(row, tableColumn); - QTableWidgetItem *item = new QTableWidgetItem(text); + auto *item = new QTableWidgetItem(text); item->setToolTip(text); // set the item non-editable (view only), and non-selectable @@ -735,7 +728,7 @@ void DialogMeasurementsCSVColumns::RetranslateLabels() { ui->labelValue->setText(tr("Base value") + "*:"); - if (m_dimensions.size() > 0) + if (not m_dimensions.empty()) { MeasurementDimension_p dimension = m_dimensions.at(0); ui->labelShiftA->setText(tr("Shift (%1)*:").arg(dimension->Name())); @@ -781,7 +774,7 @@ void DialogMeasurementsCSVColumns::SetDefaultColumns() SetDefault(ui->comboBoxName, static_cast(MultisizeMeasurementsColumns::Name)); SetDefault(ui->comboBoxValue, static_cast(MultisizeMeasurementsColumns::BaseValue)); - if (m_dimensions.size() > 0) + if (not m_dimensions.empty()) { SetDefault(ui->comboBoxShiftA, static_cast(MultisizeMeasurementsColumns::ShiftA)); } diff --git a/src/app/tape/dialogs/dialogmeasurementscsvcolumns.h b/src/app/tape/dialogs/dialogmeasurementscsvcolumns.h index e2ecf4a86..456aeb82f 100644 --- a/src/app/tape/dialogs/dialogmeasurementscsvcolumns.h +++ b/src/app/tape/dialogs/dialogmeasurementscsvcolumns.h @@ -62,29 +62,30 @@ class DialogMeasurementsCSVColumns; class DialogMeasurementsCSVColumns : public QDialog { - Q_OBJECT + Q_OBJECT // NOLINT public: DialogMeasurementsCSVColumns(const QString &filename, MeasurementsType type, QWidget *parent = nullptr); DialogMeasurementsCSVColumns(const QString &filename, MeasurementsType type, const QList &dimensions, QWidget *parent = nullptr); - virtual ~DialogMeasurementsCSVColumns(); + ~DialogMeasurementsCSVColumns() override; - QVector ColumnsMap() const; + auto ColumnsMap() const -> QVector; void SetWithHeader(bool withHeader); void SetSeparator(const QChar &separator); void SetCodec(QTextCodec *codec); protected: - virtual void changeEvent(QEvent* event) override; - virtual void showEvent(QShowEvent *event) override; + void changeEvent(QEvent* event) override; + void showEvent(QShowEvent *event) override; private slots: void ColumnChanged(); private: - Q_DISABLE_COPY(DialogMeasurementsCSVColumns) + // cppcheck-suppress unknownMacro + Q_DISABLE_COPY_MOVE(DialogMeasurementsCSVColumns) // NOLINT Ui::DialogMeasurementsCSVColumns *ui; bool m_isInitialized{false}; QString m_fileName; @@ -96,17 +97,18 @@ private: QList m_dimensions{}; QVector m_hackedWidgets{}; - bool ColumnMandatory(int column) const; - QString ColumnHeader(int column) const; - int ImportColumnCount() const; - int MinimumColumns() const; - bool ColumnsValid(); + auto ColumnMandatory(int column) const -> bool; + auto ColumnHeader(int column) const -> QString; + auto ImportColumnCount() const -> int; + auto MinimumColumns() const -> int; + auto ColumnsValid() -> bool; + void ClearColumnCollor(); void InitColumnsMap(); void InitColumnsControls(); void InitImportHeaders(); - QSharedPointer CSVModel() const; + auto CSVModel() const -> QSharedPointer; void ShowInputPreview(); void ShowImportPreview(); @@ -129,7 +131,7 @@ private: }; //--------------------------------------------------------------------------------------------------------------------- -inline QVector DialogMeasurementsCSVColumns::ColumnsMap() const +inline auto DialogMeasurementsCSVColumns::ColumnsMap() const -> QVector { return m_columnsMap; } diff --git a/src/app/tape/dialogs/dialognewmeasurements.cpp b/src/app/tape/dialogs/dialognewmeasurements.cpp index 7a2c83e79..5835629ce 100644 --- a/src/app/tape/dialogs/dialognewmeasurements.cpp +++ b/src/app/tape/dialogs/dialognewmeasurements.cpp @@ -29,17 +29,13 @@ #include "dialognewmeasurements.h" #include "ui_dialognewmeasurements.h" -#include "../vpatterndb/variables/vmeasurement.h" -#include "../vtapesettings.h" -#include "../mapplication.h" - #include //--------------------------------------------------------------------------------------------------------------------- DialogNewMeasurements::DialogNewMeasurements(QWidget *parent) :QDialog(parent), ui(new Ui::DialogNewMeasurements), - isInitialized(false) + m_isInitialized(false) { ui->setupUi(this); @@ -54,13 +50,13 @@ DialogNewMeasurements::~DialogNewMeasurements() } //--------------------------------------------------------------------------------------------------------------------- -MeasurementsType DialogNewMeasurements::Type() const +auto DialogNewMeasurements::Type() const -> MeasurementsType { return static_cast(ui->comboBoxMType->currentData().toInt()); } //--------------------------------------------------------------------------------------------------------------------- -Unit DialogNewMeasurements::MUnit() const +auto DialogNewMeasurements::MUnit() const -> Unit { return static_cast(ui->comboBoxUnit->currentData().toInt()); } @@ -89,7 +85,7 @@ void DialogNewMeasurements::showEvent(QShowEvent *event) return; } - if (isInitialized) + if (m_isInitialized) { return; } @@ -98,7 +94,7 @@ void DialogNewMeasurements::showEvent(QShowEvent *event) setMaximumSize(size()); setMinimumSize(size()); - isInitialized = true;//first show windows are held + m_isInitialized = true;//first show windows are held } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/tape/dialogs/dialognewmeasurements.h b/src/app/tape/dialogs/dialognewmeasurements.h index 9b301a4d1..756c46914 100644 --- a/src/app/tape/dialogs/dialognewmeasurements.h +++ b/src/app/tape/dialogs/dialognewmeasurements.h @@ -40,23 +40,24 @@ namespace Ui class DialogNewMeasurements : public QDialog { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit DialogNewMeasurements(QWidget *parent = nullptr); - ~DialogNewMeasurements(); + ~DialogNewMeasurements() override; - MeasurementsType Type() const; - Unit MUnit() const; + auto Type() const -> MeasurementsType; + auto MUnit() const -> Unit; protected: - virtual void changeEvent(QEvent* event) override; - virtual void showEvent(QShowEvent *event) override; + void changeEvent(QEvent* event) override; + void showEvent(QShowEvent *event) override; private: - Q_DISABLE_COPY(DialogNewMeasurements) + // cppcheck-suppress unknownMacro + Q_DISABLE_COPY_MOVE(DialogNewMeasurements) // NOLINT Ui::DialogNewMeasurements *ui; - bool isInitialized; + bool m_isInitialized; void InitMTypes(); void InitUnits(); diff --git a/src/app/tape/dialogs/dialogrestrictdimension.cpp b/src/app/tape/dialogs/dialogrestrictdimension.cpp index cfe7f89a6..087f5537f 100644 --- a/src/app/tape/dialogs/dialogrestrictdimension.cpp +++ b/src/app/tape/dialogs/dialogrestrictdimension.cpp @@ -76,6 +76,53 @@ auto FilterByMaximum(const QVector &base, qreal restriction) -> QVector &bases, + const VDimensionRestriction &restriction) +{ + if (not dimension.isNull()) + { + min = bases.indexOf(restriction.GetMin()) != -1 ? restriction.GetMin() : dimension->MinValue(); + max = bases.indexOf(restriction.GetMax()) != -1 ? restriction.GetMax() : dimension->MaxValue(); + + if (max < min) + { + min = dimension->MinValue(); + max = dimension->MaxValue(); + } + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void SetCellIcon(QTableWidgetItem *item, const QVector &validRows, qreal rowValue, qreal columnValue, + const VDimensionRestriction &restriction, qreal min, qreal max) +{ + if (validRows.contains(rowValue)) + { + const bool leftRestriction = columnValue >= min; + const bool rightRestriction = columnValue <= max; + + if (leftRestriction && rightRestriction) + { + item->setIcon(QIcon(restriction.GetExcludeValues().contains(columnValue) + ? QStringLiteral("://icon/24x24/close.png") + : QStringLiteral("://icon/24x24/star.png"))); + } + else + { + item->setIcon(QIcon(QStringLiteral("://icon/24x24/close.png"))); + } + } + else + { + item->setIcon(QIcon(QStringLiteral("://icon/24x24/close.png"))); + + Qt::ItemFlags flags = item->flags(); + flags &= ~(Qt::ItemIsEnabled); + item->setFlags(flags); + } +} } // namespace //--------------------------------------------------------------------------------------------------------------------- @@ -299,104 +346,94 @@ void DialogRestrictDimension::MaxRestrictionChanged() void DialogRestrictDimension::CellContextMenu(QPoint pos) { QTableWidgetItem *item = ui->tableWidget->itemAt(pos); - if (item != nullptr && (item->flags() & Qt::ItemIsEnabled) != 0U) + if (item == nullptr || not static_cast((item->flags() & Qt::ItemIsEnabled))) { - qreal columnValue = 0; - QString coordinates; - MeasurementDimension_p dimension; + return; + } - if (m_restrictionType == RestrictDimension::First) - { - if (not m_dimensions.empty()) - { - columnValue = m_dimensions.at(0)->ValidBases().at(item->column()); - coordinates = QChar('0'); - } - else - { - return; - } - } - else if (m_restrictionType == RestrictDimension::Second) - { - if (m_dimensions.size() >= 2) - { - dimension = m_dimensions.at(1); - columnValue = dimension->ValidBases().at(item->column()); - qreal base1 = m_dimensions.at(0)->ValidBases().at(item->row()); - coordinates = VMeasurement::CorrectionHash(base1); - } - else - { - return; - } - } - else if (m_restrictionType == RestrictDimension::Third) - { - if (m_dimensions.size() >= 3) - { - dimension = m_dimensions.at(2); - columnValue = dimension->ValidBases().at(item->column()); - qreal base1 = ui->comboBoxDimensionA->currentData().toDouble(); - qreal base2 = m_dimensions.at(1)->ValidBases().at(item->row()); - coordinates = VMeasurement::CorrectionHash(base1, base2); - } - else - { - return; - } - } - else + qreal columnValue = 0; + QString coordinates; + MeasurementDimension_p dimension; + + if (m_restrictionType == RestrictDimension::First) + { + if (m_dimensions.empty()) { return; } - VDimensionRestriction restriction = m_restrictions.value(coordinates); - bool exclude = not restriction.GetExcludeValues().contains(columnValue); - QScopedPointer menu(new QMenu()); - QAction *actionExclude = menu->addAction(exclude ? tr("Exclude") : tr("Include")); - - if (m_restrictionType == RestrictDimension::Second || m_restrictionType == RestrictDimension::Third) + columnValue = m_dimensions.at(0)->ValidBases().at(item->column()); + coordinates = QChar('0'); + } + else if (m_restrictionType == RestrictDimension::Second) + { + if (m_dimensions.size() < 2) { - if (dimension != nullptr) - { - qreal min = restriction.GetMin(); - if (qFuzzyIsNull(min)) - { - min = dimension->MinValue(); - } - - qreal max = restriction.GetMax(); - if (qFuzzyIsNull(max)) - { - max = dimension->MaxValue(); - } - - actionExclude->setEnabled(columnValue >= min && columnValue <= max); - } - else - { - return; - } + return; } - QAction *selectedAction = menu->exec(ui->tableWidget->viewport()->mapToGlobal(pos)); - if (selectedAction == actionExclude) + dimension = m_dimensions.at(1); + columnValue = dimension->ValidBases().at(item->column()); + qreal base1 = m_dimensions.at(0)->ValidBases().at(item->row()); + coordinates = VMeasurement::CorrectionHash(base1); + } + else if (m_restrictionType == RestrictDimension::Third) + { + if (m_dimensions.size() < 3) { - QSet list = restriction.GetExcludeValues(); - if (exclude) - { - list.insert(columnValue); - item->setIcon(QIcon(QStringLiteral("://icon/24x24/close.png"))); - } - else - { - list.remove(columnValue); - item->setIcon(QIcon(QStringLiteral("://icon/24x24/star.png"))); - } - restriction.SetExcludeValues(list); - m_restrictions[coordinates] = restriction; + return; } + + dimension = m_dimensions.at(2); + columnValue = dimension->ValidBases().at(item->column()); + qreal base1 = ui->comboBoxDimensionA->currentData().toDouble(); + qreal base2 = m_dimensions.at(1)->ValidBases().at(item->row()); + coordinates = VMeasurement::CorrectionHash(base1, base2); + } + + VDimensionRestriction restriction = m_restrictions.value(coordinates); + bool exclude = not restriction.GetExcludeValues().contains(columnValue); + QScopedPointer menu(new QMenu()); + QAction *actionExclude = menu->addAction(exclude ? tr("Exclude") : tr("Include")); + + if (m_restrictionType == RestrictDimension::Second || m_restrictionType == RestrictDimension::Third) + { + if (dimension.isNull()) + { + return; + } + + qreal min = restriction.GetMin(); + if (qFuzzyIsNull(min)) + { + min = dimension->MinValue(); + } + + qreal max = restriction.GetMax(); + if (qFuzzyIsNull(max)) + { + max = dimension->MaxValue(); + } + + actionExclude->setEnabled(columnValue >= min && columnValue <= max); + } + + QAction *selectedAction = menu->exec(ui->tableWidget->viewport()->mapToGlobal(pos)); + if (selectedAction == actionExclude) + { + QSet list = restriction.GetExcludeValues(); + if (exclude) + { + list.insert(columnValue); + item->setIcon(QIcon(QStringLiteral("://icon/24x24/close.png"))); + } + else + { + list.remove(columnValue); + item->setIcon(QIcon(QStringLiteral("://icon/24x24/star.png"))); + } + restriction.SetExcludeValues(list); + m_restrictions[coordinates] = restriction; } } @@ -611,14 +648,9 @@ void DialogRestrictDimension::AddCell(int row, int column, qreal rowValue, qreal if (m_restrictionType == RestrictDimension::First) { VDimensionRestriction restriction = m_restrictions.value(QChar('0')); - if (restriction.GetExcludeValues().contains(columnValue)) - { - item->setIcon(QIcon(QStringLiteral("://icon/24x24/close.png"))); - } - else - { - item->setIcon(QIcon(QStringLiteral("://icon/24x24/star.png"))); - } + item->setIcon(QIcon(restriction.GetExcludeValues().contains(columnValue) + ? QStringLiteral("://icon/24x24/close.png") + : QStringLiteral("://icon/24x24/star.png"))); } else { @@ -656,47 +688,8 @@ void DialogRestrictDimension::AddCell(int row, int column, qreal rowValue, qreal qreal min = INT32_MIN; qreal max = INT32_MAX; - if (not dimension.isNull()) - { - min = bases.indexOf(restriction.GetMin()) != -1 ? restriction.GetMin() : dimension->MinValue(); - max = bases.indexOf(restriction.GetMax()) != -1 ? restriction.GetMax() : dimension->MaxValue(); - - if (max < min) - { - min = dimension->MinValue(); - max = dimension->MaxValue(); - } - } - - if (validRows.contains(rowValue)) - { - const bool leftRestriction = columnValue >= min; - const bool rightRestriction = columnValue <= max; - - if (leftRestriction && rightRestriction) - { - if (restriction.GetExcludeValues().contains(columnValue)) - { - item->setIcon(QIcon(QStringLiteral("://icon/24x24/close.png"))); - } - else - { - item->setIcon(QIcon(QStringLiteral("://icon/24x24/star.png"))); - } - } - else - { - item->setIcon(QIcon(QStringLiteral("://icon/24x24/close.png"))); - } - } - else - { - item->setIcon(QIcon(QStringLiteral("://icon/24x24/close.png"))); - - Qt::ItemFlags flags = item->flags(); - flags &= ~(Qt::ItemIsEnabled); - item->setFlags(flags); - } + InitMinMax(min, max, dimension, bases, restriction); + SetCellIcon(item, validRows, rowValue, columnValue, restriction, min, max); } // set the item non-editable (view only), and non-selectable @@ -784,6 +777,88 @@ void DialogRestrictDimension::FillBases(const QVector &bases, const Measu } } +//--------------------------------------------------------------------------------------------------------------------- +auto DialogRestrictDimension::FillDimensionXBases(const QVector &bases, + const MeasurementDimension_p &dimension) -> QStringList +{ + const bool showUnits = dimension->IsBodyMeasurement() || dimension->Type() == MeasurementDimension::X; + const QString units = showUnits ? UnitsToStr(dimension->Units(), true) : QString(); + const DimesionLabels dimensionLabels = dimension->Labels(); + + QStringList labels; + + for(auto base : bases) + { + if (dimensionLabels.contains(base) && not dimensionLabels.value(base).isEmpty()) + { + labels.append(dimensionLabels.value(base)); + } + else + { + labels.append(QStringLiteral("%1 %2").arg(base).arg(units)); + } + } + + return labels; +} + +//--------------------------------------------------------------------------------------------------------------------- +auto DialogRestrictDimension::FillDimensionYBases(const QVector &bases, + const MeasurementDimension_p &dimension) const -> QStringList +{ + const bool showUnits = dimension->IsBodyMeasurement() || dimension->Type() == MeasurementDimension::X; + const QString units = showUnits ? UnitsToStr(dimension->Units(), true) : QString(); + const DimesionLabels dimensionLabels = dimension->Labels(); + + QStringList labels; + + for(auto base : bases) + { + if (dimensionLabels.contains(base) && not dimensionLabels.value(base).isEmpty()) + { + labels.append(dimensionLabels.value(base)); + } + else + { + if (dimension->IsBodyMeasurement()) + { + labels.append(QStringLiteral("%1 %2").arg(m_fullCircumference ? base*2 : base).arg(units)); + } + else + { + labels.append(QString::number(base)); + } + } + } + + return labels; +} + +//--------------------------------------------------------------------------------------------------------------------- +auto DialogRestrictDimension::FillDimensionWZBases(const QVector &bases, + const MeasurementDimension_p &dimension) const -> QStringList +{ + const bool showUnits = dimension->IsBodyMeasurement() || dimension->Type() == MeasurementDimension::X; + const QString units = showUnits ? UnitsToStr(dimension->Units(), true) : QString(); + const DimesionLabels dimensionLabels = dimension->Labels(); + + QStringList labels; + + for(auto base : bases) + { + if (dimensionLabels.contains(base) && not dimensionLabels.value(base).isEmpty()) + { + labels.append(dimensionLabels.value(base)); + } + else + { + labels.append(QStringLiteral("%1 %2").arg(m_fullCircumference ? base*2 : base).arg(units)); + } + } + + return labels; +} + //--------------------------------------------------------------------------------------------------------------------- auto DialogRestrictDimension::DimensionLabels(const QVector &bases, const MeasurementDimension_p &dimension) const -> QStringList @@ -796,52 +871,15 @@ auto DialogRestrictDimension::DimensionLabels(const QVector &bases, if (dimension->Type() == MeasurementDimension::X) { - for(auto base : bases) - { - if (dimensionLabels.contains(base) && not dimensionLabels.value(base).isEmpty()) - { - labels.append(dimensionLabels.value(base)); - } - else - { - labels.append(QStringLiteral("%1 %2").arg(base).arg(units)); - } - } + labels = FillDimensionXBases(bases, dimension); } else if (dimension->Type() == MeasurementDimension::Y) { - for(auto base : bases) - { - if (dimensionLabels.contains(base) && not dimensionLabels.value(base).isEmpty()) - { - labels.append(dimensionLabels.value(base)); - } - else - { - if (dimension->IsBodyMeasurement()) - { - labels.append(QStringLiteral("%1 %2").arg(m_fullCircumference ? base*2 : base).arg(units)); - } - else - { - labels.append(QString::number(base)); - } - } - } + labels = FillDimensionYBases(bases, dimension); } else if (dimension->Type() == MeasurementDimension::W || dimension->Type() == MeasurementDimension::Z) { - for(auto base : bases) - { - if (dimensionLabels.contains(base) && not dimensionLabels.value(base).isEmpty()) - { - labels.append(dimensionLabels.value(base)); - } - else - { - labels.append(QStringLiteral("%1 %2").arg(m_fullCircumference ? base*2 : base).arg(units)); - } - } + labels = FillDimensionWZBases(bases, dimension); } return labels; diff --git a/src/app/tape/dialogs/dialogrestrictdimension.h b/src/app/tape/dialogs/dialogrestrictdimension.h index 39741c22e..0d2d604ca 100644 --- a/src/app/tape/dialogs/dialogrestrictdimension.h +++ b/src/app/tape/dialogs/dialogrestrictdimension.h @@ -50,18 +50,18 @@ enum class RestrictDimension: qint8 class DialogRestrictDimension : public QDialog { - Q_OBJECT + Q_OBJECT // NOLINT public: DialogRestrictDimension(const QList &dimensions, const QMap &restrictions, RestrictDimension restrictionType, bool fullCircumference, QWidget *parent = nullptr); - virtual ~DialogRestrictDimension(); + ~DialogRestrictDimension() override; auto Restrictions() const -> QMap; protected: - virtual void changeEvent(QEvent* event) override; + void changeEvent(QEvent* event) override; protected slots: void RowSelected(); @@ -73,7 +73,8 @@ private slots: void CellContextMenu(QPoint pos); private: - Q_DISABLE_COPY(DialogRestrictDimension) + // cppcheck-suppress unknownMacro + Q_DISABLE_COPY_MOVE(DialogRestrictDimension) // NOLINT Ui::DialogRestrictDimension *ui; RestrictDimension m_restrictionType; @@ -92,6 +93,11 @@ private: void EnableRestrictionControls(bool enable); void FillBases(const QVector &bases, const MeasurementDimension_p &dimension, QComboBox *control) const; + static auto FillDimensionXBases(const QVector &bases, + const MeasurementDimension_p &dimension) -> QStringList; + auto FillDimensionYBases(const QVector &bases, const MeasurementDimension_p &dimension) const -> QStringList; + auto FillDimensionWZBases(const QVector &bases, + const MeasurementDimension_p &dimension) const -> QStringList; auto DimensionLabels(const QVector &bases, const MeasurementDimension_p &dimension) const -> QStringList; auto DimensionRestrictedValues(const MeasurementDimension_p &dimension) const -> QVector; diff --git a/src/app/tape/dialogs/dialogsetupmultisize.cpp b/src/app/tape/dialogs/dialogsetupmultisize.cpp index 41e8e7f87..811647df9 100644 --- a/src/app/tape/dialogs/dialogsetupmultisize.cpp +++ b/src/app/tape/dialogs/dialogsetupmultisize.cpp @@ -32,7 +32,9 @@ #include #include "../mapplication.h" +#if QT_VERSION < QT_VERSION_CHECK(5, 7, 0) #include "../vmisc/backport/qoverload.h" +#endif // QT_VERSION < QT_VERSION_CHECK(5, 7, 0) namespace { diff --git a/src/app/tape/dialogs/dialogtapepreferences.cpp b/src/app/tape/dialogs/dialogtapepreferences.cpp index 8be017276..f1350f802 100644 --- a/src/app/tape/dialogs/dialogtapepreferences.cpp +++ b/src/app/tape/dialogs/dialogtapepreferences.cpp @@ -40,7 +40,6 @@ DialogTapePreferences::DialogTapePreferences(QWidget *parent) :QDialog(parent), ui(new Ui::DialogTapePreferences), - m_isInitialized(false), m_configurationPage(new TapePreferencesConfigurationPage), m_pathPage(new TapePreferencesPathPage) { diff --git a/src/app/tape/dialogs/dialogtapepreferences.h b/src/app/tape/dialogs/dialogtapepreferences.h index e5fbca14d..d263b367c 100644 --- a/src/app/tape/dialogs/dialogtapepreferences.h +++ b/src/app/tape/dialogs/dialogtapepreferences.h @@ -31,6 +31,8 @@ #include +#include "../vmisc/defglobal.h" + namespace Ui { class DialogTapePreferences; @@ -42,25 +44,26 @@ class QListWidgetItem; class DialogTapePreferences : public QDialog { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit DialogTapePreferences(QWidget *parent = nullptr); - virtual ~DialogTapePreferences(); + ~DialogTapePreferences() override; signals: void UpdateProperties(); protected: - virtual void showEvent(QShowEvent *event) override; - virtual void resizeEvent(QResizeEvent *event) override; - virtual void changeEvent(QEvent* event) override; + void showEvent(QShowEvent *event) override; + void resizeEvent(QResizeEvent *event) override; + void changeEvent(QEvent* event) override; private slots: void Apply(); void Ok(); void PageChanged(QListWidgetItem *current, QListWidgetItem *previous); private: - Q_DISABLE_COPY(DialogTapePreferences) + // cppcheck-suppress unknownMacro + Q_DISABLE_COPY_MOVE(DialogTapePreferences) // NOLINT Ui::DialogTapePreferences *ui; - bool m_isInitialized; + bool m_isInitialized{false}; TapePreferencesConfigurationPage *m_configurationPage; TapePreferencesPathPage *m_pathPage; }; diff --git a/src/app/tape/main.cpp b/src/app/tape/main.cpp index f60bee8af..0db4e342b 100644 --- a/src/app/tape/main.cpp +++ b/src/app/tape/main.cpp @@ -26,10 +26,7 @@ ** *************************************************************************/ -#include "tmainwindow.h" #include "mapplication.h" -#include "../fervor/fvupdater.h" -#include "../vmisc/vsysexits.h" #include // For QT_REQUIRE_VERSION #include @@ -43,7 +40,7 @@ # include "../vmisc/appimage.h" #endif // defined(APPIMAGE) && defined(Q_OS_LINUX) -int main(int argc, char *argv[]) +auto main(int argc, char *argv[]) -> int { #if defined(APPIMAGE) && defined(Q_OS_LINUX) /* Fix path to ICU_DATA when run AppImage.*/ @@ -51,14 +48,14 @@ int main(int argc, char *argv[]) auto FreeMemory = qScopeGuard([exe_dir] {free(exe_dir);}); #endif // defined(APPIMAGE) && defined(Q_OS_LINUX) - Q_INIT_RESOURCE(tapeicon); - Q_INIT_RESOURCE(theme); - Q_INIT_RESOURCE(icon); - Q_INIT_RESOURCE(schema); - Q_INIT_RESOURCE(flags); - Q_INIT_RESOURCE(style); + Q_INIT_RESOURCE(tapeicon); // NOLINT + Q_INIT_RESOURCE(theme); // NOLINT + Q_INIT_RESOURCE(icon); // NOLINT + Q_INIT_RESOURCE(schema); // NOLINT + Q_INIT_RESOURCE(flags); // NOLINT + Q_INIT_RESOURCE(style); // NOLINT - QT_REQUIRE_VERSION(argc, argv, "5.4.0")// clazy:exclude=qstring-arg,qstring-allocations + QT_REQUIRE_VERSION(argc, argv, "5.4.0")// clazy:exclude=qstring-arg,qstring-allocations NOLINT #if defined(Q_OS_WIN) VAbstractApplication::WinAttachConsole(); @@ -80,5 +77,5 @@ int main(int argc, char *argv[]) } #endif // defined(APPIMAGE) && defined(Q_OS_LINUX) - return app.exec(); + return MApplication::exec(); } diff --git a/src/app/tape/mapplication.cpp b/src/app/tape/mapplication.cpp index ee4d4d8a3..fe1c12bde 100644 --- a/src/app/tape/mapplication.cpp +++ b/src/app/tape/mapplication.cpp @@ -35,6 +35,7 @@ #include "../ifc/exception/vexceptionemptyparameter.h" #include "../ifc/exception/vexceptionwrongid.h" #include "../vmisc/vsysexits.h" +#include "../vmisc/projectversion.h" #if QT_VERSION < QT_VERSION_CHECK(5, 5, 0) #include "../vmisc/diagnostic.h" @@ -357,7 +358,7 @@ auto MApplication::notify(QObject *receiver, QEvent *event) -> bool catch (const VExceptionToolWasDeleted &e) { qCCritical(mApp, "%s\n\n%s\n\n%s", - qUtf8Printable("Unhadled deleting tool. Continue use object after deleting!"), + qUtf8Printable(QStringLiteral("Unhadled deleting tool. Continue use object after deleting!")), qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation())); exit(V_EX_DATAERR); } @@ -473,7 +474,7 @@ void MApplication::ActivateDarkMode() { f.open(QFile::ReadOnly | QFile::Text); QTextStream ts(&f); - qApp->setStyleSheet(ts.readAll()); + qApp->setStyleSheet(ts.readAll()); // NOLINT(cppcoreguidelines-pro-type-static-cast-downcast) } } @@ -501,7 +502,7 @@ auto MApplication::event(QEvent *e) -> bool // Mac specific). case QEvent::FileOpen: { - auto *fileOpenEvent = static_cast(e); + auto *fileOpenEvent = static_cast(e); // NOLINT(cppcoreguidelines-pro-type-static-cast-downcast) const QString macFileOpen = fileOpenEvent->file(); if(not macFileOpen.isEmpty()) { diff --git a/src/app/tape/tmainwindow.cpp b/src/app/tape/tmainwindow.cpp index baebe1145..36e508fad 100644 --- a/src/app/tape/tmainwindow.cpp +++ b/src/app/tape/tmainwindow.cpp @@ -52,7 +52,6 @@ #include "vlitepattern.h" #include "../qmuparser/qmudef.h" #include "../vtools/dialogs/support/dialogeditwrongformula.h" -#include "version.h" #include "../vmisc/dialogs/dialogselectlanguage.h" #include "mapplication.h" // Should be last because of definning qApp @@ -70,27 +69,112 @@ #include #include #include +#include + +using namespace std::chrono_literals; #if defined(Q_OS_MAC) #include #include #endif //defined(Q_OS_MAC) -#define DIALOG_MAX_FORMULA_HEIGHT 64 +constexpr int DIALOG_MAX_FORMULA_HEIGHT = 64; QT_WARNING_PUSH QT_WARNING_DISABLE_CLANG("-Wmissing-prototypes") QT_WARNING_DISABLE_INTEL(1418) -Q_LOGGING_CATEGORY(tMainWindow, "t.mainwindow") +Q_LOGGING_CATEGORY(tMainWindow, "t.mainwindow") // NOLINT QT_WARNING_POP namespace { enum class MUnits : qint8 { Table, Degrees}; + +//--------------------------------------------------------------------------------------------------------------------- +auto SaveDirPath(const QString &curFile, MeasurementsType mType) -> QString +{ + QString dir; + if (curFile.isEmpty()) + { + if (mType == MeasurementsType::Individual) + { + dir = MApplication::VApp()->TapeSettings()->GetPathIndividualMeasurements(); + } + else + { + dir = MApplication::VApp()->TapeSettings()->GetPathMultisizeMeasurements(); + dir = VCommonSettings::PrepareMultisizeTables(dir); + } + } + else + { + dir = QFileInfo(curFile).absolutePath(); + } + + return dir; } +//--------------------------------------------------------------------------------------------------------------------- +void InitDimensionXItems(const QVector &bases, const DimesionLabels &labels, QComboBox *control, + const QString &unit) +{ + SCASSERT(control != nullptr) + + for(auto base : bases) + { + if (labels.contains(base) && not labels.value(base).isEmpty()) + { + control->addItem(labels.value(base), base); + } + else + { + control->addItem(QStringLiteral("%1 %2").arg(base).arg(unit), base); + } + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void InitDimensionYWZItems(const QVector &bases, const DimesionLabels &labels, QComboBox *control, + const QString &unit, bool bodyMeasurement, bool fc) +{ + for(auto base : bases) + { + if (labels.contains(base) && not labels.value(base).isEmpty()) + { + control->addItem(labels.value(base), base); + } + else + { + if (bodyMeasurement) + { + control->addItem(QStringLiteral("%1 %2").arg(fc ? base*2 : base).arg(unit), base); + } + else + { + control->addItem(QString::number(base), base); + } + } + } +} + +//--------------------------------------------------------------------------------------------------------------------- +auto ConverToDouble(QString text, const QString &error) +{ + text.replace(QStringLiteral(" "), QString()); + text = VTranslateVars::TryFormulaFromUser(text, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); + bool ok = false; + + const qreal value = QLocale::c().toDouble(text, &ok); + if (not ok) + { + throw VException(error); + } + return value; +} +} // namespace + // We need this enum in case we will add or delete a column. And also make code more readable. enum { ColumnName = 0, @@ -108,8 +192,8 @@ enum { TMainWindow::TMainWindow(QWidget *parent) : VAbstractMainWindow(parent), ui(new Ui::TMainWindow), - formulaBaseHeight(0), - gradation(new QTimer(this)), + m_formulaBaseHeight(0), + m_gradation(new QTimer(this)), m_searchHistory(new QMenu(this)) { ui->setupUi(this); @@ -132,7 +216,7 @@ TMainWindow::TMainWindow(QWidget *parent) m_recentFileActs.fill(nullptr); - connect(gradation, &QTimer::timeout, this, &TMainWindow::GradationChanged); + connect(m_gradation, &QTimer::timeout, this, &TMainWindow::GradationChanged); SetupMenu(); @@ -153,7 +237,7 @@ TMainWindow::TMainWindow(QWidget *parent) if (MApplication::VApp()->IsAppInGUIMode()) { - QTimer::singleShot(1000, this, &TMainWindow::SetDefaultGUILanguage); + QTimer::singleShot(1s, this, &TMainWindow::SetDefaultGUILanguage); } } @@ -161,22 +245,22 @@ TMainWindow::TMainWindow(QWidget *parent) TMainWindow::~TMainWindow() { ui->lineEditFind->blockSignals(true); // prevents crash - delete data; - delete m; - qDeleteAll(hackedWidgets); + delete m_data; + delete m_m; + qDeleteAll(m_hackedWidgets); delete ui; } //--------------------------------------------------------------------------------------------------------------------- -QString TMainWindow::CurrentFile() const +auto TMainWindow::CurrentFile() const -> QString { - return curFile; + return m_curFile; } //--------------------------------------------------------------------------------------------------------------------- void TMainWindow::RetranslateTable() { - if (m != nullptr) + if (m_m != nullptr) { const int row = ui->tableWidget->currentRow(); RefreshTable(); @@ -186,9 +270,9 @@ void TMainWindow::RetranslateTable() } //--------------------------------------------------------------------------------------------------------------------- -bool TMainWindow::SetDimensionABase(int base) +auto TMainWindow::SetDimensionABase(int base) -> bool { - const QList dimensions = m->Dimensions().values(); + const QList dimensions = m_m->Dimensions().values(); if (dimensions.isEmpty()) { @@ -196,13 +280,13 @@ bool TMainWindow::SetDimensionABase(int base) return false; } - const qint32 i = gradationDimensionA->findData(base); + const qint32 i = m_gradationDimensionA->findData(base); if (i != -1) { - gradationDimensionA->setCurrentIndex(i); + m_gradationDimensionA->setCurrentIndex(i); } - if (not VFuzzyComparePossibleNulls(base, currentDimensionA)) + if (not VFuzzyComparePossibleNulls(base, m_currentDimensionA)) { qCCritical(tMainWindow, "%s\n", qPrintable(tr("Invalid base value for dimension A"))); return false; @@ -211,9 +295,9 @@ bool TMainWindow::SetDimensionABase(int base) } //--------------------------------------------------------------------------------------------------------------------- -bool TMainWindow::SetDimensionBBase(int base) +auto TMainWindow::SetDimensionBBase(int base) -> bool { - const QList dimensions = m->Dimensions().values(); + const QList dimensions = m_m->Dimensions().values(); if (dimensions.size() <= 1) { @@ -221,13 +305,13 @@ bool TMainWindow::SetDimensionBBase(int base) return false; } - const qint32 i = gradationDimensionB->findData(base); + const qint32 i = m_gradationDimensionB->findData(base); if (i != -1) { - gradationDimensionB->setCurrentIndex(i); + m_gradationDimensionB->setCurrentIndex(i); } - if (not VFuzzyComparePossibleNulls(base, currentDimensionB)) + if (not VFuzzyComparePossibleNulls(base, m_currentDimensionB)) { qCCritical(tMainWindow, "%s\n", qPrintable(tr("Invalid base value for dimension B"))); return false; @@ -237,9 +321,9 @@ bool TMainWindow::SetDimensionBBase(int base) } //--------------------------------------------------------------------------------------------------------------------- -bool TMainWindow::SetDimensionCBase(int base) +auto TMainWindow::SetDimensionCBase(int base) -> bool { - const QList dimensions = m->Dimensions().values(); + const QList dimensions = m_m->Dimensions().values(); if (dimensions.size() <= 2) { @@ -247,13 +331,13 @@ bool TMainWindow::SetDimensionCBase(int base) return false; } - const qint32 i = gradationDimensionC->findData(base); + const qint32 i = m_gradationDimensionC->findData(base); if (i != -1) { - gradationDimensionC->setCurrentIndex(i); + m_gradationDimensionC->setCurrentIndex(i); } - if (not VFuzzyComparePossibleNulls(base, currentDimensionC)) + if (not VFuzzyComparePossibleNulls(base, m_currentDimensionC)) { qCCritical(tMainWindow, "%s\n", qPrintable(tr("Invalid base value for dimension C"))); return false; @@ -264,132 +348,130 @@ bool TMainWindow::SetDimensionCBase(int base) //--------------------------------------------------------------------------------------------------------------------- void TMainWindow::SetPUnit(Unit unit) { - pUnit = unit; + m_pUnit = unit; SetCurrentPatternUnit(); UpdatePatternUnit(); } //--------------------------------------------------------------------------------------------------------------------- -bool TMainWindow::LoadFile(const QString &path) +auto TMainWindow::LoadFile(const QString &path) -> bool { - if (m == nullptr) + if (m_m != nullptr) { - if (not QFileInfo::exists(path)) + return MApplication::VApp()->NewMainWindow()->LoadFile(path); + } + + if (not QFileInfo::exists(path)) + { + qCCritical(tMainWindow, "%s", qUtf8Printable(tr("File '%1' doesn't exist!").arg(path))); + if (MApplication::VApp()->IsTestMode()) { - qCCritical(tMainWindow, "%s", qUtf8Printable(tr("File '%1' doesn't exist!").arg(path))); - if (MApplication::VApp()->IsTestMode()) - { - qApp->exit(V_EX_NOINPUT); - } - return false; + QCoreApplication::exit(V_EX_NOINPUT); } + return false; + } - // Check if file already opened - const QList list = MApplication::VApp()->MainWindows(); - auto w = std::find_if(list.begin(), list.end(), - [path](TMainWindow *window) { return window->CurrentFile() == path; }); - if (w != list.end()) + // Check if file already opened + const QList list = MApplication::VApp()->MainWindows(); + auto w = std::find_if(list.begin(), list.end(), + [path](TMainWindow *window) { return window->CurrentFile() == path; }); + if (w != list.end()) + { + (*w)->activateWindow(); + close(); + return false; + } + + VlpCreateLock(m_lock, path); + + if (not m_lock->IsLocked()) + { + if (not IgnoreLocking(m_lock->GetLockError(), path, MApplication::VApp()->IsAppInGUIMode())) { - (*w)->activateWindow(); - close(); - return false; - } - - VlpCreateLock(lock, path); - - if (not lock->IsLocked()) - { - if (not IgnoreLocking(lock->GetLockError(), path, MApplication::VApp()->IsAppInGUIMode())) - { - return false; - } - } - - try - { - data = new VContainer(VAbstractApplication::VApp()->TrVars(), &mUnit, VContainer::UniqueNamespace()); - - m = new VMeasurements(data); - m->setXMLContent(path); - - mType = m->Type(); - - if (mType == MeasurementsType::Unknown) - { - throw VException(tr("File has unknown format.")); - } - - if (mType == MeasurementsType::Multisize) - { - VVSTConverter converter(path); - m_curFileFormatVersion = converter.GetCurrentFormatVersion(); - m_curFileFormatVersionStr = converter.GetFormatVersionStr(); - m->setXMLContent(converter.Convert());// Read again after conversion - } - else - { - VVITConverter converter(path); - m_curFileFormatVersion = converter.GetCurrentFormatVersion(); - m_curFileFormatVersionStr = converter.GetFormatVersionStr(); - m->setXMLContent(converter.Convert());// Read again after conversion - } - - if (not m->IsDefinedKnownNamesValid()) - { - throw VException(tr("File contains invalid known measurement(s).")); - } - - mUnit = m->Units(); - pUnit = mUnit; - - currentDimensionA = m->DimensionABase(); - currentDimensionB = m->DimensionBBase(); - currentDimensionC = m->DimensionCBase(); - - ui->labelToolTip->setVisible(false); - ui->tabWidget->setVisible(true); - - mIsReadOnly = m->IsReadOnly(); - UpdatePadlock(mIsReadOnly); - - SetCurrentFile(path); - - InitWindow(); - - const bool freshCall = true; - RefreshData(freshCall); - - if (ui->tableWidget->rowCount() > 0) - { - ui->tableWidget->selectRow(0); - } - - MeasurementGUI(); - - ui->actionImportFromCSV->setEnabled(true); - } - catch (VException &e) - { - qCCritical(tMainWindow, "%s\n\n%s\n\n%s", qUtf8Printable(tr("File error.")), - qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation())); - ui->labelToolTip->setVisible(true); - ui->tabWidget->setVisible(false); - delete m; - m = nullptr; - delete data; - data = nullptr; - lock.reset(); - - if (MApplication::VApp()->IsTestMode()) - { - qApp->exit(V_EX_NOINPUT); - } return false; } } - else + + try { - return MApplication::VApp()->NewMainWindow()->LoadFile(path); + m_data = new VContainer(VAbstractApplication::VApp()->TrVars(),&m_mUnit, VContainer::UniqueNamespace()); + + m_m = new VMeasurements(m_data); + m_m->setXMLContent(path); + + m_mType = m_m->Type(); + + if (m_mType == MeasurementsType::Unknown) + { + throw VException(tr("File has unknown format.")); + } + + if (m_mType == MeasurementsType::Multisize) + { + VVSTConverter converter(path); + m_curFileFormatVersion = converter.GetCurrentFormatVersion(); + m_curFileFormatVersionStr = converter.GetFormatVersionStr(); + m_m->setXMLContent(converter.Convert());// Read again after conversion + } + else + { + VVITConverter converter(path); + m_curFileFormatVersion = converter.GetCurrentFormatVersion(); + m_curFileFormatVersionStr = converter.GetFormatVersionStr(); + m_m->setXMLContent(converter.Convert());// Read again after conversion + } + + if (not m_m->IsDefinedKnownNamesValid()) + { + throw VException(tr("File contains invalid known measurement(s).")); + } + + m_mUnit = m_m->Units(); + m_pUnit = m_mUnit; + + m_currentDimensionA = m_m->DimensionABase(); + m_currentDimensionB = m_m->DimensionBBase(); + m_currentDimensionC = m_m->DimensionCBase(); + + ui->labelToolTip->setVisible(false); + ui->tabWidget->setVisible(true); + + m_mIsReadOnly = m_m->IsReadOnly(); + UpdatePadlock(m_mIsReadOnly); + + SetCurrentFile(path); + + InitWindow(); + + const bool freshCall = true; + RefreshData(freshCall); + + if (ui->tableWidget->rowCount() > 0) + { + ui->tableWidget->selectRow(0); + } + + MeasurementGUI(); + + ui->actionImportFromCSV->setEnabled(true); + } + catch (VException &e) + { + qCCritical(tMainWindow, "%s\n\n%s\n\n%s", qUtf8Printable(tr("File error.")), + qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation())); + ui->labelToolTip->setVisible(true); + ui->tabWidget->setVisible(false); + delete m_m; + m_m = nullptr; + delete m_data; + m_data = nullptr; + m_lock.reset(); + + if (MApplication::VApp()->IsTestMode()) + { + QCoreApplication::exit(V_EX_NOINPUT); + } + return false; } return true; @@ -398,7 +480,7 @@ bool TMainWindow::LoadFile(const QString &path) //--------------------------------------------------------------------------------------------------------------------- void TMainWindow::FileNew() { - if (m == nullptr) + if (m_m == nullptr) { DialogNewMeasurements measurements(this); if (measurements.exec() == QDialog::Rejected) @@ -406,25 +488,25 @@ void TMainWindow::FileNew() return; } - mUnit = measurements.MUnit(); - pUnit = mUnit; - mType = measurements.Type(); + m_mUnit = measurements.MUnit(); + m_pUnit = m_mUnit; + m_mType = measurements.Type(); - if (mType == MeasurementsType::Multisize) + if (m_mType == MeasurementsType::Multisize) { - DialogSetupMultisize setup(mUnit, this); + DialogSetupMultisize setup(m_mUnit, this); if (setup.exec() == QDialog::Rejected) { - mUnit = Unit::Cm; - pUnit = mUnit; - mType = MeasurementsType::Individual; + m_mUnit = Unit::Cm; + m_pUnit = m_mUnit; + m_mType = MeasurementsType::Individual; return; } - data = new VContainer(VAbstractApplication::VApp()->TrVars(), &mUnit, VContainer::UniqueNamespace()); + m_data = new VContainer(VAbstractApplication::VApp()->TrVars(), &m_mUnit, VContainer::UniqueNamespace()); - m = new VMeasurements(mUnit, setup.Dimensions(), data); - m->SetFullCircumference(setup.FullCircumference()); + m_m = new VMeasurements(m_mUnit, setup.Dimensions(), m_data); + m_m->SetFullCircumference(setup.FullCircumference()); m_curFileFormatVersion = VVSTConverter::MeasurementMaxVer; m_curFileFormatVersionStr = VVSTConverter::MeasurementMaxVerStr; @@ -432,15 +514,15 @@ void TMainWindow::FileNew() } else { - data = new VContainer(VAbstractApplication::VApp()->TrVars(), &mUnit, VContainer::UniqueNamespace()); + m_data = new VContainer(VAbstractApplication::VApp()->TrVars(), &m_mUnit, VContainer::UniqueNamespace()); - m = new VMeasurements(mUnit, data); + m_m = new VMeasurements(m_mUnit, m_data); m_curFileFormatVersion = VVITConverter::MeasurementMaxVer; m_curFileFormatVersionStr = VVITConverter::MeasurementMaxVerStr; } - mIsReadOnly = m->IsReadOnly(); - UpdatePadlock(mIsReadOnly); + m_mIsReadOnly = m_m->IsReadOnly(); + UpdatePadlock(m_mIsReadOnly); SetCurrentFile(QString()); MeasurementsWereSaved(false); @@ -502,10 +584,10 @@ void TMainWindow::OpenTemplate() pathTo = VCommonSettings::PrepareStandardTemplates(pathTo); Open(pathTo, filter); - if (m != nullptr) + if (m_m != nullptr) {// The file was opened. SetCurrentFile(QString()); // Force user to to save new file - lock.reset();// remove lock from template + m_lock.reset();// remove lock from template } } @@ -520,7 +602,7 @@ void TMainWindow::CreateFromExisting() if (not mPath.isEmpty()) { - if (m == nullptr) + if (m_m == nullptr) { LoadFromExistingFile(mPath); } @@ -599,7 +681,7 @@ void TMainWindow::changeEvent(QEvent *event) InitMeasurementUnits(); - if (mType == MeasurementsType::Multisize) + if (m_mType == MeasurementsType::Multisize) { ui->labelMType->setText(tr("Multisize measurements")); @@ -632,19 +714,19 @@ void TMainWindow::changeEvent(QEvent *event) } { - if (labelPatternUnit) + if (m_labelPatternUnit) { - labelPatternUnit->setText(tr("Pattern unit:")); + m_labelPatternUnit->setText(tr("Pattern unit:")); } - if (comboBoxUnits) + if (m_comboBoxUnits) { - const qint32 index = comboBoxUnits->currentIndex(); - comboBoxUnits->blockSignals(true); - comboBoxUnits->clear(); + const qint32 index = m_comboBoxUnits->currentIndex(); + m_comboBoxUnits->blockSignals(true); + m_comboBoxUnits->clear(); InitComboBoxUnits(); - comboBoxUnits->setCurrentIndex(index); - comboBoxUnits->blockSignals(false); + m_comboBoxUnits->setCurrentIndex(index); + m_comboBoxUnits->blockSignals(false); } } } @@ -654,14 +736,14 @@ void TMainWindow::changeEvent(QEvent *event) } //--------------------------------------------------------------------------------------------------------------------- -bool TMainWindow::eventFilter(QObject *object, QEvent *event) +auto TMainWindow::eventFilter(QObject *object, QEvent *event) -> bool { if (auto *plainTextEdit = qobject_cast(object)) { if (event->type() == QEvent::KeyPress) { - auto *keyEvent = static_cast(event); - if ((keyEvent->key() == Qt::Key_Period) && ((keyEvent->modifiers() & Qt::KeypadModifier) != 0u)) + auto *keyEvent = static_cast(event); // NOLINT(cppcoreguidelines-pro-type-static-cast-downcast) + if ((keyEvent->key() == Qt::Key_Period) && ((keyEvent->modifiers() & Qt::KeypadModifier) != 0U)) { if (VAbstractApplication::VApp()->Settings()->GetOsSeparator()) { @@ -679,8 +761,8 @@ bool TMainWindow::eventFilter(QObject *object, QEvent *event) { if (event->type() == QEvent::KeyPress) { - auto *keyEvent = static_cast(event); - if ((keyEvent->key() == Qt::Key_Period) && ((keyEvent->modifiers() & Qt::KeypadModifier) != 0u)) + auto *keyEvent = static_cast(event); // NOLINT(cppcoreguidelines-pro-type-static-cast-downcast) + if ((keyEvent->key() == Qt::Key_Period) && ((keyEvent->modifiers() & Qt::KeypadModifier) != 0U)) { if (VAbstractApplication::VApp()->Settings()->GetOsSeparator()) { @@ -750,40 +832,40 @@ void TMainWindow::ExportToCSVData(const QString &fileName, bool withHeader, int } //--------------------------------------------------------------------------------------------------------------------- -QStringList TMainWindow::RecentFileList() const +auto TMainWindow::RecentFileList() const -> QStringList { return MApplication::VApp()->TapeSettings()->GetRecentFileList(); } //--------------------------------------------------------------------------------------------------------------------- -bool TMainWindow::FileSave() +auto TMainWindow::FileSave() -> bool { - if (curFile.isEmpty() || mIsReadOnly) + if (m_curFile.isEmpty() || m_mIsReadOnly) { return FileSaveAs(); } - if (mType == MeasurementsType::Multisize + if (m_mType == MeasurementsType::Multisize && m_curFileFormatVersion < VVSTConverter::MeasurementMaxVer && not ContinueFormatRewrite(m_curFileFormatVersionStr, VVSTConverter::MeasurementMaxVerStr)) { return false; } - if (mType == MeasurementsType::Individual + if (m_mType == MeasurementsType::Individual && m_curFileFormatVersion < VVITConverter::MeasurementMaxVer && not ContinueFormatRewrite(m_curFileFormatVersionStr, VVITConverter::MeasurementMaxVerStr)) { return false; } - if (not CheckFilePermissions(curFile, this)) + if (not CheckFilePermissions(m_curFile, this)) { return false; } QString error; - if (not SaveMeasurements(curFile, error)) + if (not SaveMeasurements(m_curFile, error)) { QMessageBox messageBox; messageBox.setIcon(QMessageBox::Warning); @@ -795,7 +877,7 @@ bool TMainWindow::FileSave() return false; } - if (mType == MeasurementsType::Multisize) + if (m_mType == MeasurementsType::Multisize) { m_curFileFormatVersion = VVSTConverter::MeasurementMaxVer; m_curFileFormatVersionStr = VVSTConverter::MeasurementMaxVerStr; @@ -810,42 +892,25 @@ bool TMainWindow::FileSave() } //--------------------------------------------------------------------------------------------------------------------- -bool TMainWindow::FileSaveAs() +auto TMainWindow::FileSaveAs() -> bool { QString filters; QString fName = tr("measurements"); QString suffix; - if (mType == MeasurementsType::Individual) + if (m_mType == MeasurementsType::Individual) { filters = tr("Individual measurements") + QStringLiteral(" (*.vit)"); suffix = QStringLiteral("vit"); - fName += QChar('.') + suffix; } else { filters = tr("Multisize measurements") + QStringLiteral(" (*.vst)"); suffix = QStringLiteral("vst"); - fName += QChar('.') + suffix; } - QString dir; - if (curFile.isEmpty()) - { - if (mType == MeasurementsType::Individual) - { - dir = MApplication::VApp()->TapeSettings()->GetPathIndividualMeasurements(); - } - else - { - dir = MApplication::VApp()->TapeSettings()->GetPathMultisizeMeasurements(); - dir = VCommonSettings::PrepareMultisizeTables(dir); - } - } - else - { - dir = QFileInfo(curFile).absolutePath(); - } + fName += QChar('.') + suffix; + const QString dir = SaveDirPath(m_curFile, m_mType); bool usedNotExistedDir = false; QDir directory(dir); if (not directory.exists()) @@ -853,9 +918,9 @@ bool TMainWindow::FileSaveAs() usedNotExistedDir = directory.mkpath(QChar('.')); } - if (not curFile.isEmpty()) + if (not m_curFile.isEmpty()) { - fName = StrippedName(curFile); + fName = StrippedName(m_curFile); } QString fileName = QFileDialog::getSaveFileName(this, tr("Save as"), dir + QChar('/') + fName, filters, nullptr, @@ -880,7 +945,7 @@ bool TMainWindow::FileSaveAs() fileName += QChar('.') + suffix; } - if (QFileInfo::exists(fileName) && curFile != fileName) + if (QFileInfo::exists(fileName) && m_curFile != fileName) { // Temporary try to lock the file before saving VLockGuard tmp(fileName); @@ -893,10 +958,10 @@ bool TMainWindow::FileSaveAs() } // Need for restoring previous state in case of failure - const bool readOnly = m->IsReadOnly(); + const bool readOnly = m_m->IsReadOnly(); - m->SetReadOnly(false); - mIsReadOnly = false; + m_m->SetReadOnly(false); + m_mIsReadOnly = false; QString error; bool result = SaveMeasurements(fileName, error); @@ -911,12 +976,12 @@ bool TMainWindow::FileSaveAs() messageBox.exec(); // Restore previous state - m->SetReadOnly(readOnly); - mIsReadOnly = readOnly; + m_m->SetReadOnly(readOnly); + m_mIsReadOnly = readOnly; return false; } - if (mType == MeasurementsType::Multisize) + if (m_mType == MeasurementsType::Multisize) { m_curFileFormatVersion = VVSTConverter::MeasurementMaxVer; m_curFileFormatVersionStr = VVSTConverter::MeasurementMaxVerStr; @@ -930,12 +995,12 @@ bool TMainWindow::FileSaveAs() UpdatePadlock(false); UpdateWindowTitle(); - if (curFile == fileName && not lock.isNull()) + if (m_curFile == fileName && not m_lock.isNull()) { - lock->Unlock(); + m_lock->Unlock(); } - VlpCreateLock(lock, fileName); - if (not lock->IsLocked()) + VlpCreateLock(m_lock, fileName); + if (not m_lock->IsLocked()) { qCCritical(tMainWindow, "%s", qUtf8Printable(tr("Failed to lock. This file already opened in another window. " "Expect collissions when run 2 copies of the program."))); @@ -970,7 +1035,7 @@ void TMainWindow::ShowWindow() const //--------------------------------------------------------------------------------------------------------------------- void TMainWindow::ImportDataFromCSV() { - if (m == nullptr || m->Type() == MeasurementsType::Unknown) + if (m_m == nullptr || m_m->Type() == MeasurementsType::Unknown) { return; } @@ -1005,14 +1070,14 @@ void TMainWindow::ImportDataFromCSV() VAbstractApplication::VApp()->Settings()->SetCSVWithHeader(dialog.IsWithHeader()); QSharedPointer columns; - if (m->Type() == MeasurementsType::Multisize) + if (m_m->Type() == MeasurementsType::Multisize) { - const QList dimensions = m->Dimensions().values(); - columns = QSharedPointer::create(fileName, m->Type(), dimensions, this); + const QList dimensions = m_m->Dimensions().values(); + columns = QSharedPointer::create(fileName, m_m->Type(), dimensions, this); } else { - columns = QSharedPointer::create(fileName, m->Type(), this); + columns = QSharedPointer::create(fileName, m_m->Type(), this); } columns->SetWithHeader(dialog.IsWithHeader()); columns->SetSeparator(dialog.GetSeparator()); @@ -1024,7 +1089,7 @@ void TMainWindow::ImportDataFromCSV() QTextCodec::codecForMib(dialog.GetSelectedMib())); const QVector map = columns->ColumnsMap(); - if (m->Type() == MeasurementsType::Individual) + if (m_m->Type() == MeasurementsType::Individual) { ImportIndividualMeasurements(csv, map); } @@ -1076,9 +1141,9 @@ void TMainWindow::OpenAt(QAction *where) //--------------------------------------------------------------------------------------------------------------------- void TMainWindow::SaveCustomerName() { - if (m->Customer() != ui->lineEditCustomerName->text()) + if (m_m->Customer() != ui->lineEditCustomerName->text()) { - m->SetCustomer(ui->lineEditCustomerName->text()); + m_m->SetCustomer(ui->lineEditCustomerName->text()); MeasurementsWereSaved(false); } } @@ -1086,9 +1151,9 @@ void TMainWindow::SaveCustomerName() //--------------------------------------------------------------------------------------------------------------------- void TMainWindow::SaveEmail() { - if (m->Email() != ui->lineEditEmail->text()) + if (m_m->Email() != ui->lineEditEmail->text()) { - m->SetEmail(ui->lineEditEmail->text()); + m_m->SetEmail(ui->lineEditEmail->text()); MeasurementsWereSaved(false); } } @@ -1097,9 +1162,9 @@ void TMainWindow::SaveEmail() void TMainWindow::SaveGender(int index) { const GenderType type = static_cast(ui->comboBoxGender->itemData(index).toInt()); - if (m->Gender() != type) + if (m_m->Gender() != type) { - m->SetGender(type); + m_m->SetGender(type); MeasurementsWereSaved(false); } } @@ -1107,9 +1172,9 @@ void TMainWindow::SaveGender(int index) //--------------------------------------------------------------------------------------------------------------------- void TMainWindow::SaveBirthDate(const QDate &date) { - if (m->BirthDate() != date) + if (m_m->BirthDate() != date) { - m->SetBirthDate(date); + m_m->SetBirthDate(date); MeasurementsWereSaved(false); } } @@ -1117,9 +1182,9 @@ void TMainWindow::SaveBirthDate(const QDate &date) //--------------------------------------------------------------------------------------------------------------------- void TMainWindow::SaveNotes() { - if (m->Notes() != ui->plainTextEditNotes->toPlainText()) + if (m_m->Notes() != ui->plainTextEditNotes->toPlainText()) { - m->SetNotes(ui->plainTextEditNotes->toPlainText()); + m_m->SetNotes(ui->plainTextEditNotes->toPlainText()); MeasurementsWereSaved(false); } } @@ -1130,9 +1195,9 @@ void TMainWindow::SavePMSystem(int index) QString system = ui->comboBoxPMSystem->itemData(index).toString(); system.remove(0, 1);// clear p - if (m->PMSystem() != system) + if (m_m->PMSystem() != system) { - m->SetPMSystem(system); + m_m->SetPMSystem(system); MeasurementsWereSaved(false); } } @@ -1149,7 +1214,7 @@ void TMainWindow::Remove() } const QTableWidgetItem *nameField = ui->tableWidget->item(ui->tableWidget->currentRow(), 0); - m->Remove(nameField->data(Qt::UserRole).toString()); + m_m->Remove(nameField->data(Qt::UserRole).toString()); MeasurementsWereSaved(false); @@ -1183,7 +1248,7 @@ void TMainWindow::Remove() ui->comboBoxMUnits->setCurrentIndex(-1); ui->comboBoxMUnits->blockSignals(false); - if (mType == MeasurementsType::Multisize) + if (m_mType == MeasurementsType::Multisize) { ui->labelCalculatedValue->blockSignals(true); ui->doubleSpinBoxBaseValue->blockSignals(true); @@ -1232,7 +1297,7 @@ void TMainWindow::MoveTop() } const QTableWidgetItem *nameField = ui->tableWidget->item(row, ColumnName); - m->MoveTop(nameField->data(Qt::UserRole).toString()); + m_m->MoveTop(nameField->data(Qt::UserRole).toString()); MeasurementsWereSaved(false); RefreshData(); m_search->RefreshList(ui->lineEditFind->text()); @@ -1251,7 +1316,7 @@ void TMainWindow::MoveUp() } const QTableWidgetItem *nameField = ui->tableWidget->item(row, ColumnName); - m->MoveUp(nameField->data(Qt::UserRole).toString()); + m_m->MoveUp(nameField->data(Qt::UserRole).toString()); MeasurementsWereSaved(false); RefreshData(); m_search->RefreshList(ui->lineEditFind->text()); @@ -1270,7 +1335,7 @@ void TMainWindow::MoveDown() } const QTableWidgetItem *nameField = ui->tableWidget->item(row, ColumnName); - m->MoveDown(nameField->data(Qt::UserRole).toString()); + m_m->MoveDown(nameField->data(Qt::UserRole).toString()); MeasurementsWereSaved(false); RefreshData(); m_search->RefreshList(ui->lineEditFind->text()); @@ -1289,7 +1354,7 @@ void TMainWindow::MoveBottom() } const QTableWidgetItem *nameField = ui->tableWidget->item(row, ColumnName); - m->MoveBottom(nameField->data(Qt::UserRole).toString()); + m_m->MoveBottom(nameField->data(Qt::UserRole).toString()); MeasurementsWereSaved(false); RefreshData(); m_search->RefreshList(ui->lineEditFind->text()); @@ -1314,7 +1379,7 @@ void TMainWindow::Fx() try { // Translate to internal look. - meash = data->GetVariable(nameField->data(Qt::UserRole).toString()); + meash = m_data->GetVariable(nameField->data(Qt::UserRole).toString()); } catch(const VExceptionBadId & e) { @@ -1327,9 +1392,8 @@ void TMainWindow::Fx() auto *dialog = new DialogEditWrongFormula(meash->GetData(), NULL_ID, this); dialog->setWindowTitle(tr("Edit measurement")); dialog->SetMeasurementsMode(); - dialog->SetFormula(VAbstractApplication::VApp()->TrVars() - ->TryFormulaFromUser(ui->plainTextEditFormula->toPlainText(), true)); - const QString postfix = UnitsToStr(mUnit, true);//Show unit in dialog lable (cm, mm or inch) + dialog->SetFormula(VTranslateVars::TryFormulaFromUser(ui->plainTextEditFormula->toPlainText(), true)); + const QString postfix = UnitsToStr(m_mUnit, true);//Show unit in dialog lable (cm, mm or inch) dialog->setPostfix(postfix); if (dialog->exec() == QDialog::Accepted) @@ -1337,7 +1401,7 @@ void TMainWindow::Fx() // Fix the bug #492. https://bitbucket.org/dismine/valentina/issues/492/valentina-crashes-when-add-an-increment // Because of the bug need to take QTableWidgetItem twice time. Previous update "killed" the pointer. nameField = ui->tableWidget->item(row, ColumnName); - m->SetMValue(nameField->data(Qt::UserRole).toString(), dialog->GetFormula()); + m_m->SetMValue(nameField->data(Qt::UserRole).toString(), dialog->GetFormula()); MeasurementsWereSaved(false); @@ -1359,13 +1423,13 @@ void TMainWindow::AddCustom() if (ui->tableWidget->currentRow() == -1) { currentRow = ui->tableWidget->rowCount(); - m->AddEmpty(name); + m_m->AddEmpty(name); } else { currentRow = ui->tableWidget->currentRow()+1; const QTableWidgetItem *nameField = ui->tableWidget->item(ui->tableWidget->currentRow(), ColumnName); - m->AddEmptyAfter(nameField->data(Qt::UserRole).toString(), name); + m_m->AddEmptyAfter(nameField->data(Qt::UserRole).toString(), name); } m_search->AddRow(currentRow); @@ -1383,7 +1447,7 @@ void TMainWindow::AddCustom() //--------------------------------------------------------------------------------------------------------------------- void TMainWindow::AddKnown() { - QScopedPointer dialog (new DialogMDataBase(m->ListKnown(), this)); + QScopedPointer dialog (new DialogMDataBase(m_m->ListKnown(), this)); if (dialog->exec() == QDialog::Accepted) { qint32 currentRow; @@ -1392,15 +1456,15 @@ void TMainWindow::AddKnown() if (ui->tableWidget->currentRow() == -1) { currentRow = ui->tableWidget->rowCount() + list.size() - 1; - for (auto &name : list) + for (const auto &name : list) { - if (mType == MeasurementsType::Individual) + if (m_mType == MeasurementsType::Individual) { - m->AddEmpty(name, VAbstractApplication::VApp()->TrVars()->MFormula(name)); + m_m->AddEmpty(name, VAbstractApplication::VApp()->TrVars()->MFormula(name)); } else { - m->AddEmpty(name); + m_m->AddEmpty(name); } m_search->AddRow(currentRow); @@ -1411,15 +1475,15 @@ void TMainWindow::AddKnown() currentRow = ui->tableWidget->currentRow() + list.size(); const QTableWidgetItem *nameField = ui->tableWidget->item(ui->tableWidget->currentRow(), ColumnName); QString after = nameField->data(Qt::UserRole).toString(); - for (auto &name : list) + for (const auto &name : list) { - if (mType == MeasurementsType::Individual) + if (m_mType == MeasurementsType::Individual) { - m->AddEmptyAfter(after, name, VAbstractApplication::VApp()->TrVars()->MFormula(name)); + m_m->AddEmptyAfter(after, name, VAbstractApplication::VApp()->TrVars()->MFormula(name)); } else { - m->AddEmptyAfter(after, name); + m_m->AddEmptyAfter(after, name); } m_search->AddRow(currentRow); after = name; @@ -1447,13 +1511,13 @@ void TMainWindow::AddSeparator() if (ui->tableWidget->currentRow() == -1) { currentRow = ui->tableWidget->rowCount(); - m->AddSeparator(name); + m_m->AddSeparator(name); } else { currentRow = ui->tableWidget->currentRow()+1; const QTableWidgetItem *nameField = ui->tableWidget->item(ui->tableWidget->currentRow(), ColumnName); - m->AddSeparatorAfter(nameField->data(Qt::UserRole).toString(), name); + m_m->AddSeparatorAfter(nameField->data(Qt::UserRole).toString(), name); } m_search->AddRow(currentRow); @@ -1471,7 +1535,7 @@ void TMainWindow::AddSeparator() //--------------------------------------------------------------------------------------------------------------------- void TMainWindow::ImportFromPattern() { - if (m == nullptr) + if (m_m == nullptr) { return; } @@ -1509,7 +1573,7 @@ void TMainWindow::ImportFromPattern() return; } - measurements = FilterMeasurements(measurements, m->ListAll()); + measurements = FilterMeasurements(measurements, m_m->ListAll()); qint32 currentRow; @@ -1518,7 +1582,7 @@ void TMainWindow::ImportFromPattern() currentRow = ui->tableWidget->rowCount() + measurements.size() - 1; for (auto &mName : measurements) { - m->AddEmpty(mName); + m_m->AddEmpty(mName); } } else @@ -1528,7 +1592,7 @@ void TMainWindow::ImportFromPattern() QString after = nameField->data(Qt::UserRole).toString(); for (auto &mName : measurements) { - m->AddEmptyAfter(after, mName); + m_m->AddEmptyAfter(after, mName); after = mName; } } @@ -1545,51 +1609,51 @@ void TMainWindow::ImportFromPattern() //--------------------------------------------------------------------------------------------------------------------- void TMainWindow::DimensionABaseChanged() { - currentDimensionA = gradationDimensionA->currentData().toDouble(); + m_currentDimensionA = m_gradationDimensionA->currentData().toDouble(); - const QList dimensions = m->Dimensions().values(); + const QList dimensions = m_m->Dimensions().values(); if (dimensions.size() > 1) { MeasurementDimension_p dimension = dimensions.at(1); - InitDimensionGradation(1, dimension, gradationDimensionB); + InitDimensionGradation(1, dimension, m_gradationDimensionB); if (dimensions.size() > 2) { dimension = dimensions.at(2); - InitDimensionGradation(2, dimension, gradationDimensionC); + InitDimensionGradation(2, dimension, m_gradationDimensionC); } } - gradation->start(); + m_gradation->start(); } //--------------------------------------------------------------------------------------------------------------------- void TMainWindow::DimensionBBaseChanged() { - currentDimensionB = gradationDimensionB->currentData().toDouble(); + m_currentDimensionB = m_gradationDimensionB->currentData().toDouble(); - const QList dimensions = m->Dimensions().values(); + const QList dimensions = m_m->Dimensions().values(); if (dimensions.size() > 2) { - MeasurementDimension_p dimension = dimensions.at(2); - InitDimensionGradation(2, dimension, gradationDimensionC); + const MeasurementDimension_p& dimension = dimensions.at(2); + InitDimensionGradation(2, dimension, m_gradationDimensionC); } - gradation->start(); + m_gradation->start(); } //--------------------------------------------------------------------------------------------------------------------- void TMainWindow::DimensionCBaseChanged() { - currentDimensionC = gradationDimensionC->currentData().toDouble(); - gradation->start(); + m_currentDimensionC = m_gradationDimensionC->currentData().toDouble(); + m_gradation->start(); } //--------------------------------------------------------------------------------------------------------------------- void TMainWindow::GradationChanged() { - gradation->stop(); + m_gradation->stop(); const int row = ui->tableWidget->currentRow(); RefreshData(); m_search->RefreshList(ui->lineEditFind->text()); @@ -1605,172 +1669,171 @@ void TMainWindow::ShowMData() //--------------------------------------------------------------------------------------------------------------------- void TMainWindow::ShowNewMData(bool fresh) { - if (ui->tableWidget->rowCount() > 0) + if (ui->tableWidget->rowCount() <= 0) { - MFields(true); + MFields(false); + return; + } - if (ui->tableWidget->currentRow() == -1) - { - ui->tableWidget->blockSignals(true); - ui->tableWidget->selectRow(0); - ui->tableWidget->blockSignals(false); - } + MFields(true); - const QTableWidgetItem *nameField = ui->tableWidget->item(ui->tableWidget->currentRow(), ColumnName); // name - SCASSERT(nameField != nullptr) - QSharedPointer meash; + if (ui->tableWidget->currentRow() == -1) + { + ui->tableWidget->blockSignals(true); + ui->tableWidget->selectRow(0); + ui->tableWidget->blockSignals(false); + } - try - { - // Translate to internal look. - meash = data->GetVariable(nameField->data(Qt::UserRole).toString()); - } - catch(const VExceptionBadId &e) - { - Q_UNUSED(e) - MFields(false); - return; - } + const QTableWidgetItem *nameField = ui->tableWidget->item(ui->tableWidget->currentRow(), ColumnName); // name + SCASSERT(nameField != nullptr) + QSharedPointer meash; - ShowMDiagram(meash->GetName()); + try + { + // Translate to internal look. + meash = m_data->GetVariable(nameField->data(Qt::UserRole).toString()); + } + catch(const VExceptionBadId &e) + { + Q_UNUSED(e) + MFields(false); + return; + } - ui->labelFullName->setVisible(meash->GetType() == VarType::Measurement); - ui->lineEditFullName->setVisible(meash->GetType() == VarType::Measurement); + ShowMDiagram(meash->GetName()); - // Don't block all signal for QLineEdit. Need for correct handle with clear button. - disconnect(ui->lineEditName, &QLineEdit::textEdited, this, &TMainWindow::SaveMName); - ui->plainTextEditDescription->blockSignals(true); - if (meash->IsCustom()) - { - ui->plainTextEditDescription->setPlainText(meash->GetDescription()); - ui->lineEditFullName->setText(meash->GetGuiText()); - ui->lineEditName->setText(ClearCustomName(meash->GetName())); - } - else - { - //Show known - ui->plainTextEditDescription->setPlainText( - VAbstractApplication::VApp()->TrVars()->Description(meash->GetName())); - ui->lineEditFullName->setText(VAbstractApplication::VApp()->TrVars()->GuiText(meash->GetName())); - ui->lineEditName->setText(nameField->text()); - } - connect(ui->lineEditName, &QLineEdit::textEdited, this, &TMainWindow::SaveMName); - ui->plainTextEditDescription->blockSignals(false); + ui->labelFullName->setVisible(meash->GetType() == VarType::Measurement); + ui->lineEditFullName->setVisible(meash->GetType() == VarType::Measurement); - ui->labelMUnits->setVisible(meash->GetType() == VarType::Measurement); - ui->comboBoxMUnits->setVisible(meash->GetType() == VarType::Measurement); - - ui->comboBoxMUnits->blockSignals(true); - ui->comboBoxMUnits->setCurrentIndex( - ui->comboBoxMUnits->findData(static_cast(meash->IsSpecialUnits() ? MUnits::Degrees : MUnits::Table))); - ui->comboBoxMUnits->blockSignals(false); - - if (mType == MeasurementsType::Multisize) - { - ui->labelCalculated->setVisible(meash->GetType() == VarType::Measurement); - ui->labelCalculatedValue->setVisible(meash->GetType() == VarType::Measurement); - - ui->labelBaseValue->setVisible(meash->GetType() == VarType::Measurement); - ui->doubleSpinBoxBaseValue->setVisible(meash->GetType() == VarType::Measurement); - - ui->labelCorrection->setVisible(meash->GetType() == VarType::Measurement); - ui->doubleSpinBoxCorrection->setVisible(meash->GetType() == VarType::Measurement); - - ui->labelShiftA->setVisible(meash->GetType() == VarType::Measurement); - ui->doubleSpinBoxShiftA->setVisible(meash->GetType() == VarType::Measurement); - - const QList dimensions = m->Dimensions().values(); - - if (dimensions.size() > 1) - { - ui->labelShiftB->setVisible(meash->GetType() == VarType::Measurement); - ui->doubleSpinBoxShiftB->setVisible(meash->GetType() == VarType::Measurement); - } - - if (dimensions.size() > 2) - { - ui->labelShiftC->setVisible(meash->GetType() == VarType::Measurement); - ui->doubleSpinBoxShiftC->setVisible(meash->GetType() == VarType::Measurement); - } - - ui->labelCalculatedValue->blockSignals(true); - ui->doubleSpinBoxBaseValue->blockSignals(true); - ui->doubleSpinBoxCorrection->blockSignals(true); - ui->doubleSpinBoxShiftA->blockSignals(true); - ui->doubleSpinBoxShiftB->blockSignals(true); - ui->doubleSpinBoxShiftC->blockSignals(true); - - QString calculatedValue; - - if (meash->IsSpecialUnits()) - { - const qreal value = *data->DataVariables()->value(meash->GetName())->GetValue(); - calculatedValue = VAbstractApplication::VApp()->LocaleToString(value) + QChar(QChar::Space) + - degreeSymbol; - } - else - { - const QString postfix = UnitsToStr(pUnit);//Show unit in dialog lable (cm, mm or inch) - const qreal value = UnitConvertor(*data->DataVariables()->value(meash->GetName())->GetValue(), mUnit, - pUnit); - calculatedValue = VAbstractApplication::VApp()->LocaleToString(value) + QChar(QChar::Space) + postfix; - } - ui->labelCalculatedValue->setText(calculatedValue); - - if (fresh) - { - ui->doubleSpinBoxBaseValue->setValue(meash->GetBase()); - ui->doubleSpinBoxCorrection->setValue( - meash->GetCorrection(currentDimensionA, currentDimensionB, currentDimensionC)); - ui->doubleSpinBoxShiftA->setValue(meash->GetShiftA()); - ui->doubleSpinBoxShiftB->setValue(meash->GetShiftB()); - ui->doubleSpinBoxShiftC->setValue(meash->GetShiftC()); - } - - ui->labelCalculatedValue->blockSignals(false); - ui->doubleSpinBoxBaseValue->blockSignals(false); - ui->doubleSpinBoxCorrection->blockSignals(false); - ui->doubleSpinBoxShiftA->blockSignals(false); - ui->doubleSpinBoxShiftB->blockSignals(false); - ui->doubleSpinBoxShiftC->blockSignals(false); - } - else - { - ui->labelCalculated->setVisible(meash->GetType() == VarType::Measurement); - ui->labelCalculatedValue->setVisible(meash->GetType() == VarType::Measurement); - - ui->labelFormula->setVisible(meash->GetType() == VarType::Measurement); - ui->plainTextEditFormula->setVisible(meash->GetType() == VarType::Measurement); - ui->pushButtonGrow->setVisible(meash->GetType() == VarType::Measurement); - ui->toolButtonExpr->setVisible(meash->GetType() == VarType::Measurement); - - ui->labelDimension->setVisible(meash->GetType() == VarType::Measurement); - ui->comboBoxDimension->setVisible(meash->GetType() == VarType::Measurement); - - EvalFormula(meash->GetFormula(), false, meash->GetData(), ui->labelCalculatedValue, - meash->IsSpecialUnits()); - - ui->plainTextEditFormula->blockSignals(true); - - QString formula = - VTranslateVars::TryFormulaToUser(meash->GetFormula(), - VAbstractApplication::VApp()->Settings()->GetOsSeparator()); - - ui->plainTextEditFormula->setPlainText(formula); - ui->plainTextEditFormula->blockSignals(false); - - ui->comboBoxDimension->blockSignals(true); - ui->comboBoxDimension->setCurrentIndex( - ui->comboBoxDimension->findData(static_cast(meash->GetDimension()))); - ui->comboBoxDimension->blockSignals(false); - } - - MeasurementGUI(); + // Don't block all signal for QLineEdit. Need for correct handle with clear button. + disconnect(ui->lineEditName, &QLineEdit::textEdited, this, &TMainWindow::SaveMName); + ui->plainTextEditDescription->blockSignals(true); + if (meash->IsCustom()) + { + ui->plainTextEditDescription->setPlainText(meash->GetDescription()); + ui->lineEditFullName->setText(meash->GetGuiText()); + ui->lineEditName->setText(ClearCustomName(meash->GetName())); } else { - MFields(false); + //Show known + ui->plainTextEditDescription->setPlainText( + VAbstractApplication::VApp()->TrVars()->Description(meash->GetName())); + ui->lineEditFullName->setText(VAbstractApplication::VApp()->TrVars()->GuiText(meash->GetName())); + ui->lineEditName->setText(nameField->text()); } + connect(ui->lineEditName, &QLineEdit::textEdited, this, &TMainWindow::SaveMName); + ui->plainTextEditDescription->blockSignals(false); + + ui->labelMUnits->setVisible(meash->GetType() == VarType::Measurement); + ui->comboBoxMUnits->setVisible(meash->GetType() == VarType::Measurement); + + ui->comboBoxMUnits->blockSignals(true); + ui->comboBoxMUnits->setCurrentIndex( + ui->comboBoxMUnits->findData(static_cast(meash->IsSpecialUnits() ? MUnits::Degrees : MUnits::Table))); + ui->comboBoxMUnits->blockSignals(false); + + if (m_mType == MeasurementsType::Multisize) + { + ui->labelCalculated->setVisible(meash->GetType() == VarType::Measurement); + ui->labelCalculatedValue->setVisible(meash->GetType() == VarType::Measurement); + + ui->labelBaseValue->setVisible(meash->GetType() == VarType::Measurement); + ui->doubleSpinBoxBaseValue->setVisible(meash->GetType() == VarType::Measurement); + + ui->labelCorrection->setVisible(meash->GetType() == VarType::Measurement); + ui->doubleSpinBoxCorrection->setVisible(meash->GetType() == VarType::Measurement); + + ui->labelShiftA->setVisible(meash->GetType() == VarType::Measurement); + ui->doubleSpinBoxShiftA->setVisible(meash->GetType() == VarType::Measurement); + + const QList dimensions = m_m->Dimensions().values(); + + if (dimensions.size() > 1) + { + ui->labelShiftB->setVisible(meash->GetType() == VarType::Measurement); + ui->doubleSpinBoxShiftB->setVisible(meash->GetType() == VarType::Measurement); + } + + if (dimensions.size() > 2) + { + ui->labelShiftC->setVisible(meash->GetType() == VarType::Measurement); + ui->doubleSpinBoxShiftC->setVisible(meash->GetType() == VarType::Measurement); + } + + ui->labelCalculatedValue->blockSignals(true); + ui->doubleSpinBoxBaseValue->blockSignals(true); + ui->doubleSpinBoxCorrection->blockSignals(true); + ui->doubleSpinBoxShiftA->blockSignals(true); + ui->doubleSpinBoxShiftB->blockSignals(true); + ui->doubleSpinBoxShiftC->blockSignals(true); + + QString calculatedValue; + + if (meash->IsSpecialUnits()) + { + const qreal value = *m_data->DataVariables()->value(meash->GetName())->GetValue(); + calculatedValue = VAbstractApplication::VApp()->LocaleToString(value) + QChar(QChar::Space) + + degreeSymbol; + } + else + { + const QString postfix = UnitsToStr(m_pUnit);//Show unit in dialog lable (cm, mm or inch) + const qreal value = UnitConvertor(*m_data->DataVariables()->value(meash->GetName())->GetValue(), + m_mUnit, m_pUnit); + calculatedValue = VAbstractApplication::VApp()->LocaleToString(value) + QChar(QChar::Space) + postfix; + } + ui->labelCalculatedValue->setText(calculatedValue); + + if (fresh) + { + ui->doubleSpinBoxBaseValue->setValue(meash->GetBase()); + ui->doubleSpinBoxCorrection->setValue( + meash->GetCorrection(m_currentDimensionA, m_currentDimensionB, m_currentDimensionC)); + ui->doubleSpinBoxShiftA->setValue(meash->GetShiftA()); + ui->doubleSpinBoxShiftB->setValue(meash->GetShiftB()); + ui->doubleSpinBoxShiftC->setValue(meash->GetShiftC()); + } + + ui->labelCalculatedValue->blockSignals(false); + ui->doubleSpinBoxBaseValue->blockSignals(false); + ui->doubleSpinBoxCorrection->blockSignals(false); + ui->doubleSpinBoxShiftA->blockSignals(false); + ui->doubleSpinBoxShiftB->blockSignals(false); + ui->doubleSpinBoxShiftC->blockSignals(false); + } + else + { + ui->labelCalculated->setVisible(meash->GetType() == VarType::Measurement); + ui->labelCalculatedValue->setVisible(meash->GetType() == VarType::Measurement); + + ui->labelFormula->setVisible(meash->GetType() == VarType::Measurement); + ui->plainTextEditFormula->setVisible(meash->GetType() == VarType::Measurement); + ui->pushButtonGrow->setVisible(meash->GetType() == VarType::Measurement); + ui->toolButtonExpr->setVisible(meash->GetType() == VarType::Measurement); + + ui->labelDimension->setVisible(meash->GetType() == VarType::Measurement); + ui->comboBoxDimension->setVisible(meash->GetType() == VarType::Measurement); + + EvalFormula(meash->GetFormula(), false, meash->GetData(), ui->labelCalculatedValue, + meash->IsSpecialUnits()); + + ui->plainTextEditFormula->blockSignals(true); + + QString formula = + VTranslateVars::TryFormulaToUser(meash->GetFormula(), + VAbstractApplication::VApp()->Settings()->GetOsSeparator()); + + ui->plainTextEditFormula->setPlainText(formula); + ui->plainTextEditFormula->blockSignals(false); + + ui->comboBoxDimension->blockSignals(true); + ui->comboBoxDimension->setCurrentIndex( + ui->comboBoxDimension->findData(static_cast(meash->GetDimension()))); + ui->comboBoxDimension->blockSignals(false); + } + + MeasurementGUI(); } //--------------------------------------------------------------------------------------------------------------------- @@ -1814,7 +1877,7 @@ void TMainWindow::DeployFormula() } else { - ui->plainTextEditFormula->setFixedHeight(formulaBaseHeight); + ui->plainTextEditFormula->setFixedHeight(m_formulaBaseHeight); //Set icon from theme (internal for Windows system) ui->pushButtonGrow->setIcon(QIcon::fromTheme(QStringLiteral("go-down"), QIcon(":/icons/win.icon.theme/16x16/actions/go-down.png"))); @@ -1847,7 +1910,7 @@ void TMainWindow::SaveMName(const QString &text) try { // Translate to internal look. - meash = data->GetVariable(nameField->data(Qt::UserRole).toString()); + meash = m_data->GetVariable(nameField->data(Qt::UserRole).toString()); } catch(const VExceptionBadId &e) { @@ -1863,7 +1926,7 @@ void TMainWindow::SaveMName(const QString &text) { newName.isEmpty() ? newName = GetCustomName() : newName = CustomMSign + newName; - if (not data->IsUnique(newName)) + if (not m_data->IsUnique(newName)) { qint32 num = 2; QString name = newName; @@ -1871,11 +1934,11 @@ void TMainWindow::SaveMName(const QString &text) { name = name + QChar('_') + QString::number(num); num++; - } while (not data->IsUnique(name)); + } while (not m_data->IsUnique(name)); newName = name; } - m->SetMName(nameField->text(), newName); + m_m->SetMName(nameField->text(), newName); MeasurementsWereSaved(false); RefreshData(); m_search->RefreshList(ui->lineEditFind->text()); @@ -1908,14 +1971,14 @@ void TMainWindow::SaveMValue() if (formulaField->text() == text) { QTableWidgetItem *result = ui->tableWidget->item(row, ColumnCalcValue); - const QString postfix = UnitsToStr(mUnit);//Show unit in dialog lable (cm, mm or inch) + const QString postfix = UnitsToStr(m_mUnit);//Show unit in dialog lable (cm, mm or inch) ui->labelCalculatedValue->setText(result->text() + QChar(QChar::Space) +postfix); return; } if (text.isEmpty()) { - const QString postfix = UnitsToStr(mUnit);//Show unit in dialog lable (cm, mm or inch) + const QString postfix = UnitsToStr(m_mUnit);//Show unit in dialog lable (cm, mm or inch) ui->labelCalculatedValue->setText(tr("Error") + " (" + postfix + "). " + tr("Empty field.")); return; } @@ -1924,7 +1987,7 @@ void TMainWindow::SaveMValue() try { // Translate to internal look. - meash = data->GetVariable(nameField->data(Qt::UserRole).toString()); + meash = m_data->GetVariable(nameField->data(Qt::UserRole).toString()); } catch(const VExceptionBadId & e) { @@ -1943,7 +2006,7 @@ void TMainWindow::SaveMValue() { const QString formula = VAbstractApplication::VApp()->TrVars() ->FormulaFromUser(text, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); - m->SetMValue(nameField->data(Qt::UserRole).toString(), formula); + m_m->SetMValue(nameField->data(Qt::UserRole).toString(), formula); } catch (qmu::QmuParserError &e) // Just in case something bad will happen { @@ -1976,7 +2039,7 @@ void TMainWindow::SaveMBaseValue(double value) } const QTableWidgetItem *nameField = ui->tableWidget->item(ui->tableWidget->currentRow(), ColumnName); - m->SetMBaseValue(nameField->data(Qt::UserRole).toString(), value); + m_m->SetMBaseValue(nameField->data(Qt::UserRole).toString(), value); MeasurementsWereSaved(false); @@ -2001,7 +2064,7 @@ void TMainWindow::SaveMShiftA(double value) } const QTableWidgetItem *nameField = ui->tableWidget->item(ui->tableWidget->currentRow(), ColumnName); - m->SetMShiftA(nameField->data(Qt::UserRole).toString(), value); + m_m->SetMShiftA(nameField->data(Qt::UserRole).toString(), value); MeasurementsWereSaved(false); @@ -2026,7 +2089,7 @@ void TMainWindow::SaveMShiftB(double value) } const QTableWidgetItem *nameField = ui->tableWidget->item(ui->tableWidget->currentRow(), ColumnName); - m->SetMShiftB(nameField->data(Qt::UserRole).toString(), value); + m_m->SetMShiftB(nameField->data(Qt::UserRole).toString(), value); MeasurementsWereSaved(false); @@ -2051,7 +2114,7 @@ void TMainWindow::SaveMShiftC(double value) } const QTableWidgetItem *nameField = ui->tableWidget->item(ui->tableWidget->currentRow(), ColumnName); - m->SetMShiftC(nameField->data(Qt::UserRole).toString(), value); + m_m->SetMShiftC(nameField->data(Qt::UserRole).toString(), value); MeasurementsWereSaved(false); @@ -2076,8 +2139,8 @@ void TMainWindow::SaveMCorrectionValue(double value) } const QTableWidgetItem *nameField = ui->tableWidget->item(ui->tableWidget->currentRow(), ColumnName); - m->SetMCorrectionValue(nameField->data(Qt::UserRole).toString(), - currentDimensionA, currentDimensionB, currentDimensionC, value); + m_m->SetMCorrectionValue(nameField->data(Qt::UserRole).toString(), + m_currentDimensionA, m_currentDimensionB, m_currentDimensionC, value); MeasurementsWereSaved(false); @@ -2102,7 +2165,7 @@ void TMainWindow::SaveMDescription() } const QTableWidgetItem *nameField = ui->tableWidget->item(ui->tableWidget->currentRow(), ColumnName); - m->SetMDescription(nameField->data(Qt::UserRole).toString(), ui->plainTextEditDescription->toPlainText()); + m_m->SetMDescription(nameField->data(Qt::UserRole).toString(), ui->plainTextEditDescription->toPlainText()); MeasurementsWereSaved(false); @@ -2135,7 +2198,7 @@ void TMainWindow::SaveMFullName() try { // Translate to internal look. - meash = data->GetVariable(nameField->data(Qt::UserRole).toString()); + meash = m_data->GetVariable(nameField->data(Qt::UserRole).toString()); } catch(const VExceptionBadId &e) { @@ -2147,7 +2210,7 @@ void TMainWindow::SaveMFullName() if (meash->IsCustom()) { - m->SetMFullName(nameField->data(Qt::UserRole).toString(), ui->lineEditFullName->text()); + m_m->SetMFullName(nameField->data(Qt::UserRole).toString(), ui->lineEditFullName->text()); MeasurementsWereSaved(false); @@ -2175,7 +2238,7 @@ void TMainWindow::SaveMUnits() const QTableWidgetItem *nameField = ui->tableWidget->item(ui->tableWidget->currentRow(), ColumnName); const MUnits units = static_cast(ui->comboBoxMUnits->currentData().toInt()); - m->SetMSpecialUnits(nameField->data(Qt::UserRole).toString(), units == MUnits::Degrees); + m_m->SetMSpecialUnits(nameField->data(Qt::UserRole).toString(), units == MUnits::Degrees); MeasurementsWereSaved(false); @@ -2201,7 +2264,7 @@ void TMainWindow::SaveMDimension() const QTableWidgetItem *nameField = ui->tableWidget->item(ui->tableWidget->currentRow(), ColumnName); const IMD dimension = static_cast(ui->comboBoxDimension->currentData().toInt()); - m->SetMDimension(nameField->data(Qt::UserRole).toString(), dimension); + m_m->SetMDimension(nameField->data(Qt::UserRole).toString(), dimension); MeasurementsWereSaved(false); @@ -2218,7 +2281,7 @@ void TMainWindow::SaveMDimension() //--------------------------------------------------------------------------------------------------------------------- void TMainWindow::FullCircumferenceChanged(bool checked) { - m->SetFullCircumference(checked); + m_m->SetFullCircumference(checked); MeasurementsWereSaved(false); InitDimensionsBaseValue(); InitDimensionControls(); @@ -2228,13 +2291,13 @@ void TMainWindow::FullCircumferenceChanged(bool checked) void TMainWindow::ExportToIndividual() { QString dir; - if (curFile.isEmpty()) + if (m_curFile.isEmpty()) { dir = MApplication::VApp()->TapeSettings()->GetPathIndividualMeasurements(); } else { - dir = QFileInfo(curFile).absolutePath(); + dir = QFileInfo(m_curFile).absolutePath(); } bool usedNotExistedDir = false; @@ -2270,9 +2333,9 @@ void TMainWindow::ExportToIndividual() } QScopedPointer tmpData( - new VContainer(VAbstractApplication::VApp()->TrVars(), &mUnit, VContainer::UniqueNamespace())); + new VContainer(VAbstractApplication::VApp()->TrVars(), &m_mUnit, VContainer::UniqueNamespace())); - VMeasurements individualMeasurements(mUnit, tmpData.data()); + VMeasurements individualMeasurements(m_mUnit, tmpData.data()); const QMap > orderedTable = OrderedMeasurments(); QMap >::const_iterator iMap; @@ -2307,9 +2370,9 @@ void TMainWindow::ExportToIndividual() //--------------------------------------------------------------------------------------------------------------------- void TMainWindow::RestrictFirstDimesion() { - const QList dimensions = m->Dimensions().values(); - const QMap restrictions = m->GetRestrictions(); - bool fullCircumference = m->IsFullCircumference(); + const QList dimensions = m_m->Dimensions().values(); + const QMap restrictions = m_m->GetRestrictions(); + bool fullCircumference = m_m->IsFullCircumference(); DialogRestrictDimension dialog(dimensions, restrictions, RestrictDimension::First, fullCircumference, this); if (dialog.exec() == QDialog::Rejected) @@ -2317,21 +2380,21 @@ void TMainWindow::RestrictFirstDimesion() return; } - m->SetRestrictions(dialog.Restrictions()); + m_m->SetRestrictions(dialog.Restrictions()); MeasurementsWereSaved(false); if (not dimensions.isEmpty()) { - InitDimensionGradation(0, dimensions.at(0), gradationDimensionA); + InitDimensionGradation(0, dimensions.at(0), m_gradationDimensionA); } } //--------------------------------------------------------------------------------------------------------------------- void TMainWindow::RestrictSecondDimesion() { - const QList dimensions = m->Dimensions().values(); - const QMap restrictions = m->GetRestrictions(); - bool fullCircumference = m->IsFullCircumference(); + const QList dimensions = m_m->Dimensions().values(); + const QMap restrictions = m_m->GetRestrictions(); + bool fullCircumference = m_m->IsFullCircumference(); DialogRestrictDimension dialog(dimensions, restrictions, RestrictDimension::Second, fullCircumference, this); if (dialog.exec() == QDialog::Rejected) @@ -2339,7 +2402,7 @@ void TMainWindow::RestrictSecondDimesion() return; } - m->SetRestrictions(dialog.Restrictions()); + m_m->SetRestrictions(dialog.Restrictions()); MeasurementsWereSaved(false); DimensionABaseChanged(); // trigger refresh } @@ -2347,9 +2410,9 @@ void TMainWindow::RestrictSecondDimesion() //--------------------------------------------------------------------------------------------------------------------- void TMainWindow::RestrictThirdDimesion() { - const QList dimensions = m->Dimensions().values(); - const QMap restrictions = m->GetRestrictions(); - bool fullCircumference = m->IsFullCircumference(); + const QList dimensions = m_m->Dimensions().values(); + const QMap restrictions = m_m->GetRestrictions(); + bool fullCircumference = m_m->IsFullCircumference(); DialogRestrictDimension dialog(dimensions, restrictions, RestrictDimension::Third, fullCircumference, this); if (dialog.exec() == QDialog::Rejected) @@ -2357,7 +2420,7 @@ void TMainWindow::RestrictThirdDimesion() return; } - m->SetRestrictions(dialog.Restrictions()); + m_m->SetRestrictions(dialog.Restrictions()); MeasurementsWereSaved(false); DimensionABaseChanged(); // trigger refresh } @@ -2365,15 +2428,15 @@ void TMainWindow::RestrictThirdDimesion() //--------------------------------------------------------------------------------------------------------------------- void TMainWindow::EditDimensionLabels() { - const QMap dimensions = m->Dimensions(); + const QMap dimensions = m_m->Dimensions(); - DialogDimensionLabels dialog(dimensions, m->IsFullCircumference(), this); + DialogDimensionLabels dialog(dimensions, m_m->IsFullCircumference(), this); if (dialog.exec() == QDialog::Rejected) { return; } - m->SetDimensionLabels(dialog.Labels()); + m_m->SetDimensionLabels(dialog.Labels()); MeasurementsWereSaved(false); @@ -2384,7 +2447,7 @@ void TMainWindow::EditDimensionLabels() //--------------------------------------------------------------------------------------------------------------------- void TMainWindow::DimensionCustomNames() { - const QMap dimensions = m->Dimensions(); + const QMap dimensions = m_m->Dimensions(); DialogDimensionCustomNames dialog(dimensions, this); if (dialog.exec() == QDialog::Rejected) @@ -2392,7 +2455,7 @@ void TMainWindow::DimensionCustomNames() return; } - m->SetDimensionCustomNames(dialog.CustomNames()); + m_m->SetDimensionCustomNames(dialog.CustomNames()); MeasurementsWereSaved(false); InitDimensionControls(); @@ -2442,9 +2505,9 @@ void TMainWindow::SetupMenu() connect(ui->actionImportFromCSV, &QAction::triggered, this, &TMainWindow::ImportDataFromCSV); connect(ui->actionReadOnly, &QAction::triggered, this, [this](bool ro) { - if (not mIsReadOnly) + if (not m_mIsReadOnly) { - m->SetReadOnly(ro); + m_m->SetReadOnly(ro); MeasurementsWereSaved(false); UpdatePadlock(ro); UpdateWindowTitle(); @@ -2517,7 +2580,7 @@ void TMainWindow::SetupMenu() //--------------------------------------------------------------------------------------------------------------------- void TMainWindow::InitWindow() { - SCASSERT(m != nullptr) + SCASSERT(m_m != nullptr) ui->labelToolTip->setVisible(false); ui->tabWidget->setVisible(true); ui->tabWidget->setCurrentIndex(0); // measurements @@ -2525,7 +2588,7 @@ void TMainWindow::InitWindow() ui->plainTextEditNotes->setEnabled(true); ui->toolBarGradation->setVisible(true); - if (mType == MeasurementsType::Multisize) + if (m_mType == MeasurementsType::Multisize) { InitMenu(); ui->labelMType->setText(tr("Multisize measurements")); @@ -2597,21 +2660,21 @@ void TMainWindow::InitWindow() HackWidget(&ui->frameBaseValue); HackWidget(&ui->labelBaseValues); - ui->lineEditCustomerName->setText(m->Customer()); + ui->lineEditCustomerName->setText(m_m->Customer()); ui->comboBoxGender->clear(); InitGender(ui->comboBoxGender); - const qint32 index = ui->comboBoxGender->findData(static_cast(m->Gender())); + const qint32 index = ui->comboBoxGender->findData(static_cast(m_m->Gender())); ui->comboBoxGender->setCurrentIndex(index); { const QLocale dateLocale = QLocale(VAbstractApplication::VApp()->Settings()->GetLocale()); ui->dateEditBirthDate->setLocale(dateLocale); ui->dateEditBirthDate->setDisplayFormat(dateLocale.dateFormat()); - ui->dateEditBirthDate->setDate(m->BirthDate()); + ui->dateEditBirthDate->setDate(m_m->BirthDate()); } - ui->lineEditEmail->setText(m->Email()); + ui->lineEditEmail->setText(m_m->Email()); connect(ui->lineEditCustomerName, &QLineEdit::editingFinished, this, &TMainWindow::SaveCustomerName); connect(ui->lineEditEmail, &QLineEdit::editingFinished, this, &TMainWindow::SaveEmail); @@ -2620,7 +2683,7 @@ void TMainWindow::InitWindow() connect(ui->dateEditBirthDate, &QDateEdit::dateChanged, this, &TMainWindow::SaveBirthDate); connect(ui->pushButtonGrow, &QPushButton::clicked, this, &TMainWindow::DeployFormula); - this->formulaBaseHeight = ui->plainTextEditFormula->height(); + this->m_formulaBaseHeight = ui->plainTextEditFormula->height(); connect(ui->plainTextEditFormula, &QPlainTextEdit::textChanged, this, &TMainWindow::SaveMValue, Qt::UniqueConnection); @@ -2634,14 +2697,14 @@ void TMainWindow::InitWindow() ui->comboBoxPMSystem->setEnabled(true); ui->comboBoxPMSystem->clear(); InitPMSystems(ui->comboBoxPMSystem); - const qint32 index = ui->comboBoxPMSystem->findData(QLatin1Char('p')+m->PMSystem()); + const qint32 index = ui->comboBoxPMSystem->findData(QLatin1Char('p')+m_m->PMSystem()); ui->comboBoxPMSystem->setCurrentIndex(index); connect(ui->comboBoxPMSystem, QOverload::of(&QComboBox::currentIndexChanged), this, &TMainWindow::SavePMSystem); InitSearch(); - ui->plainTextEditNotes->setPlainText(m->Notes()); + ui->plainTextEditNotes->setPlainText(m_m->Notes()); connect(ui->plainTextEditNotes, &QPlainTextEdit::textChanged, this, &TMainWindow::SaveNotes); ui->actionAddCustom->setEnabled(true); @@ -2666,7 +2729,7 @@ void TMainWindow::InitWindow() connect(ui->pushButtonShowInExplorer, &QPushButton::clicked, this, [this]() { - ShowInGraphicalShell(curFile); + ShowInGraphicalShell(m_curFile); }); InitPatternUnits(); @@ -2684,20 +2747,20 @@ void TMainWindow::InitWindow() //--------------------------------------------------------------------------------------------------------------------- void TMainWindow::InitMenu() { - if (mType == MeasurementsType::Multisize) + if (m_mType == MeasurementsType::Multisize) { // Measurements ui->actionUseFullCircumference->setVisible(true); ui->actionUseFullCircumference->setEnabled(true); - ui->actionUseFullCircumference->setChecked(m->IsFullCircumference()); + ui->actionUseFullCircumference->setChecked(m_m->IsFullCircumference()); connect(ui->actionUseFullCircumference, &QAction::triggered, this, &TMainWindow::FullCircumferenceChanged); - QAction *separator = new QAction(this); + auto *separator = new QAction(this); separator->setSeparator(true); ui->menuMeasurements->insertAction(ui->actionUseFullCircumference, separator); - const QList dimensions = m->Dimensions().values(); - if (dimensions.size() > 0) + const QList dimensions = m_m->Dimensions().values(); + if (not dimensions.empty()) { ui->actionRestrictFirstDimension->setVisible(true); ui->actionRestrictFirstDimension->setEnabled(true); @@ -2738,9 +2801,9 @@ void TMainWindow::InitMenu() //--------------------------------------------------------------------------------------------------------------------- void TMainWindow::InitDimensionsBaseValue() { - const QList dimensions = m->Dimensions().values(); - const QString unit = UnitsToStr(m->Units(), true); - const bool fc = m->IsFullCircumference(); + const QList dimensions = m_m->Dimensions().values(); + const QString unit = UnitsToStr(m_m->Units(), true); + const bool fc = m_m->IsFullCircumference(); auto DimensionsBaseValue = [this, dimensions, unit, fc](int index, QLabel *name, QLabel *base) { @@ -2749,9 +2812,9 @@ void TMainWindow::InitDimensionsBaseValue() if (dimensions.size() > index) { - MeasurementDimension_p dimension = dimensions.at(index); + const MeasurementDimension_p& dimension = dimensions.at(index); name->setText(dimension->Name()+QChar(':')); - name->setToolTip(VAbstartMeasurementDimension::DimensionToolTip(dimension, m->IsFullCircumference())); + name->setToolTip(VAbstartMeasurementDimension::DimensionToolTip(dimension, m_m->IsFullCircumference())); DimesionLabels labels = dimension->Labels(); @@ -2765,11 +2828,11 @@ void TMainWindow::InitDimensionsBaseValue() { if (dimension->Type() != MeasurementDimension::X && fc) { - base->setText(QString("%1 %2").arg(dimension->BaseValue()*2).arg(unit)); + base->setText(QStringLiteral("%1 %2").arg(dimension->BaseValue()*2).arg(unit)); } else { - base->setText(QString("%1 %2").arg(dimension->BaseValue()).arg(unit)); + base->setText(QStringLiteral("%1 %2").arg(dimension->BaseValue()).arg(unit)); } } else @@ -2790,8 +2853,8 @@ void TMainWindow::InitDimensionGradation(int index, const MeasurementDimension_p { SCASSERT(control != nullptr) - const bool fc = m->IsFullCircumference(); - const QString unit = UnitsToStr(m->Units(), true); + const bool fc = m_m->IsFullCircumference(); + const QString unit = UnitsToStr(m_m->Units(), true); qreal current = -1; if (control->currentIndex() != -1) @@ -2807,39 +2870,12 @@ void TMainWindow::InitDimensionGradation(int index, const MeasurementDimension_p if (dimension->Type() == MeasurementDimension::X) { - for(auto base : bases) - { - if (labels.contains(base) && not labels.value(base).isEmpty()) - { - control->addItem(labels.value(base), base); - } - else - { - control->addItem(QStringLiteral("%1 %2").arg(base).arg(unit), base); - } - } + InitDimensionXItems(bases, labels, control, unit); } else if (dimension->Type() == MeasurementDimension::Y || dimension->Type() == MeasurementDimension::W || dimension->Type() == MeasurementDimension::Z) { - for(auto base : bases) - { - if (labels.contains(base) && not labels.value(base).isEmpty()) - { - control->addItem(labels.value(base), base); - } - else - { - if (dimension->IsBodyMeasurement()) - { - control->addItem(QStringLiteral("%1 %2").arg(fc ? base*2 : base).arg(unit), base); - } - else - { - control->addItem(QString::number(base), base); - } - } - } + InitDimensionYWZItems(bases, labels, control, unit, dimension->IsBodyMeasurement(), fc); } // after initialization the current index is 0. The signal for changing the index will not be triggered if not make @@ -2862,8 +2898,7 @@ void TMainWindow::InitDimensionGradation(int index, const MeasurementDimension_p //--------------------------------------------------------------------------------------------------------------------- void TMainWindow::InitDimensionControls() { - const QList dimensions = m->Dimensions().values(); - const QString unit = UnitsToStr(m->Units(), true); + const QList dimensions = m_m->Dimensions().values(); auto InitControl = [this, dimensions](int index, QLabel *&name, QComboBox *&control) { @@ -2879,7 +2914,7 @@ void TMainWindow::InitDimensionControls() { name->setText(dimension->Name()+QChar(':')); } - name->setToolTip(VAbstartMeasurementDimension::DimensionToolTip(dimension, m->IsFullCircumference())); + name->setToolTip(VAbstartMeasurementDimension::DimensionToolTip(dimension, m_m->IsFullCircumference())); if (control == nullptr) { @@ -2891,24 +2926,24 @@ void TMainWindow::InitDimensionControls() } }; - InitControl(0, labelGradationDimensionA, gradationDimensionA); - InitControl(1, labelGradationDimensionB, gradationDimensionB); - InitControl(2, labelGradationDimensionC, gradationDimensionC); + InitControl(0, m_labelGradationDimensionA, m_gradationDimensionA); + InitControl(1, m_labelGradationDimensionB, m_gradationDimensionB); + InitControl(2, m_labelGradationDimensionC, m_gradationDimensionC); } //--------------------------------------------------------------------------------------------------------------------- void TMainWindow::InitDimesionShifts() { - const QList dimensions = m->Dimensions().values(); + const QList dimensions = m_m->Dimensions().values(); auto InitShift = [this, dimensions](int index, QLabel *name) { if (dimensions.size() > index) { - MeasurementDimension_p dimension = dimensions.at(index); + const MeasurementDimension_p& dimension = dimensions.at(index); name->setText(tr("Shift (%1):").arg(dimension->Name())); - name->setToolTip(VAbstartMeasurementDimension::DimensionToolTip(dimension, m->IsFullCircumference())); + name->setToolTip(VAbstartMeasurementDimension::DimensionToolTip(dimension, m_m->IsFullCircumference())); } }; @@ -2920,7 +2955,7 @@ void TMainWindow::InitDimesionShifts() //--------------------------------------------------------------------------------------------------------------------- void TMainWindow::InitTable() { - if (mType == MeasurementsType::Multisize) + if (m_mType == MeasurementsType::Multisize) { ui->tableWidget->setColumnHidden( ColumnFormula, true );// formula @@ -2947,9 +2982,9 @@ void TMainWindow::InitTable() //--------------------------------------------------------------------------------------------------------------------- void TMainWindow::ShowUnits() { - const QString unit = UnitsToStr(mUnit); + const QString unit = UnitsToStr(m_mUnit); - ShowHeaderUnits(ui->tableWidget, ColumnCalcValue, UnitsToStr(pUnit));// calculated value + ShowHeaderUnits(ui->tableWidget, ColumnCalcValue, UnitsToStr(m_pUnit));// calculated value ShowHeaderUnits(ui->tableWidget, ColumnFormula, unit);// formula ShowHeaderUnits(ui->tableWidget, ColumnBaseValue, unit);// base value ShowHeaderUnits(ui->tableWidget, ColumnShiftA, unit); @@ -2977,14 +3012,14 @@ void TMainWindow::ShowHeaderUnits(QTableWidget *table, int column, const QString void TMainWindow::MeasurementsWereSaved(bool saved) { setWindowModified(!saved); - not mIsReadOnly ? ui->actionSave->setEnabled(!saved): ui->actionSave->setEnabled(false); + not m_mIsReadOnly ? ui->actionSave->setEnabled(!saved): ui->actionSave->setEnabled(false); } //--------------------------------------------------------------------------------------------------------------------- void TMainWindow::SetCurrentFile(const QString &fileName) { - curFile = fileName; - if (curFile.isEmpty()) + m_curFile = fileName; + if (m_curFile.isEmpty()) { ui->lineEditPathToFile->setText(QChar('<') + tr("Empty") + QChar('>')); ui->lineEditPathToFile->setToolTip(tr("File was not saved yet.")); @@ -2993,11 +3028,11 @@ void TMainWindow::SetCurrentFile(const QString &fileName) } else { - ui->lineEditPathToFile->setText(QDir::toNativeSeparators(curFile)); - ui->lineEditPathToFile->setToolTip(QDir::toNativeSeparators(curFile)); + ui->lineEditPathToFile->setText(QDir::toNativeSeparators(m_curFile)); + ui->lineEditPathToFile->setToolTip(QDir::toNativeSeparators(m_curFile)); ui->lineEditPathToFile->setCursorPosition(0); ui->pushButtonShowInExplorer->setEnabled(true); - auto settings = MApplication::VApp()->TapeSettings(); + auto *settings = MApplication::VApp()->TapeSettings(); QStringList files = settings->GetRecentFileList(); files.removeAll(fileName); files.prepend(fileName); @@ -3013,9 +3048,9 @@ void TMainWindow::SetCurrentFile(const QString &fileName) } //--------------------------------------------------------------------------------------------------------------------- -bool TMainWindow::SaveMeasurements(const QString &fileName, QString &error) +auto TMainWindow::SaveMeasurements(const QString &fileName, QString &error) -> bool { - const bool result = m->SaveDocument(fileName, error); + const bool result = m_m->SaveDocument(fileName, error); if (result) { SetCurrentFile(fileName); @@ -3025,11 +3060,11 @@ bool TMainWindow::SaveMeasurements(const QString &fileName, QString &error) } //--------------------------------------------------------------------------------------------------------------------- -bool TMainWindow::MaybeSave() +auto TMainWindow::MaybeSave() -> bool { if (this->isWindowModified()) { - if (curFile.isEmpty() && ui->tableWidget->rowCount() == 0) + if (m_curFile.isEmpty() && ui->tableWidget->rowCount() == 0) { return true;// Don't ask if file was created without modifications. } @@ -3043,7 +3078,7 @@ bool TMainWindow::MaybeSave() messageBox->setDefaultButton(QMessageBox::Yes); messageBox->setEscapeButton(QMessageBox::Cancel); - messageBox->setButtonText(QMessageBox::Yes, curFile.isEmpty() || mIsReadOnly ? tr("Save…") : tr("Save")); + messageBox->setButtonText(QMessageBox::Yes, m_curFile.isEmpty() || m_mIsReadOnly ? tr("Save…") : tr("Save")); messageBox->setButtonText(QMessageBox::No, tr("Don't Save")); messageBox->setWindowModality(Qt::ApplicationModal); @@ -3052,7 +3087,7 @@ bool TMainWindow::MaybeSave() switch (ret) { case QMessageBox::Yes: - if (mIsReadOnly) + if (m_mIsReadOnly) { return FileSaveAs(); } @@ -3072,7 +3107,7 @@ bool TMainWindow::MaybeSave() } //--------------------------------------------------------------------------------------------------------------------- -QTableWidgetItem *TMainWindow::AddCell(const QString &text, int row, int column, int aligment, bool ok) +auto TMainWindow::AddCell(const QString &text, int row, int column, int aligment, bool ok) -> QTableWidgetItem * { auto *item = new QTableWidgetItem(text); item->setTextAlignment(aligment); @@ -3096,7 +3131,8 @@ QTableWidgetItem *TMainWindow::AddCell(const QString &text, int row, int column, } //--------------------------------------------------------------------------------------------------------------------- -QTableWidgetItem *TMainWindow::AddSeparatorCell(const QString &text, int row, int column, int aligment, bool ok) +auto TMainWindow::AddSeparatorCell(const QString &text, int row, int column, int aligment, + bool ok) -> QTableWidgetItem * { QTableWidgetItem *item = AddCell(text, row, column, aligment, ok); @@ -3112,10 +3148,9 @@ void TMainWindow::RefreshData(bool freshCall) { QGuiApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); - data->ClearUniqueNames(); - data->ClearVariables({VarType::Measurement, VarType::MeasurementSeparator}); - m->ReadMeasurements(currentDimensionA, currentDimensionB, currentDimensionC); - + m_data->ClearUniqueNames(); + m_data->ClearVariables({VarType::Measurement, VarType::MeasurementSeparator}); + m_m->ReadMeasurements(m_currentDimensionA, m_currentDimensionB, m_currentDimensionC); RefreshTable(freshCall); QGuiApplication::restoreOverrideCursor(); @@ -3131,98 +3166,15 @@ void TMainWindow::RefreshTable(bool freshCall) const QMap > orderedTable = OrderedMeasurments(); qint32 currentRow = -1; - QMap >::const_iterator iMap; ui->tableWidget->setRowCount ( orderedTable.size() ); - for (iMap = orderedTable.constBegin(); iMap != orderedTable.constEnd(); ++iMap) + for (auto iMap = orderedTable.constBegin(); iMap != orderedTable.constEnd(); ++iMap) { const QSharedPointer &meash = iMap.value(); currentRow++; if (meash->GetType() == VarType::Measurement) { - if (mType == MeasurementsType::Individual) - { - QTableWidgetItem *item = AddCell(VAbstractApplication::VApp()->TrVars()->MToUser(meash->GetName()), - currentRow, ColumnName, Qt::AlignVCenter); // name - item->setData(Qt::UserRole, meash->GetName()); - - if (meash->IsCustom()) - { - AddCell(meash->GetGuiText(), currentRow, ColumnFullName, Qt::AlignVCenter); - } - else - { - AddCell(VAbstractApplication::VApp()->TrVars()->GuiText(meash->GetName()), currentRow, - ColumnFullName, Qt::AlignVCenter); - } - - QString calculatedValue; - if (meash->IsSpecialUnits()) - { - calculatedValue = locale().toString(*meash->GetValue()) + degreeSymbol; - } - else - { - calculatedValue = locale().toString(UnitConvertor(*meash->GetValue(), mUnit, pUnit)); - } - - AddCell(calculatedValue, currentRow, ColumnCalcValue, Qt::AlignHCenter | Qt::AlignVCenter, - meash->IsFormulaOk()); // calculated value - - QString formula = - VTranslateVars::TryFormulaToUser(meash->GetFormula(), - VAbstractApplication::VApp()->Settings()->GetOsSeparator()); - - AddCell(formula, currentRow, ColumnFormula, Qt::AlignVCenter); // formula - } - else - { - QTableWidgetItem *item = AddCell(VAbstractApplication::VApp()->TrVars()->MToUser(meash->GetName()), - currentRow, 0, Qt::AlignVCenter); // name - item->setData(Qt::UserRole, meash->GetName()); - - if (meash->IsCustom()) - { - AddCell(meash->GetGuiText(), currentRow, ColumnFullName, Qt::AlignVCenter); - } - else - { - AddCell(VAbstractApplication::VApp()->TrVars()->GuiText(meash->GetName()), currentRow, - ColumnFullName, Qt::AlignVCenter); - } - - QString calculatedValue; - if (meash->IsSpecialUnits()) - { - const qreal value = *data->DataVariables()->value(meash->GetName())->GetValue(); - calculatedValue = locale().toString(value) + degreeSymbol; - } - else - { - const qreal value = UnitConvertor(*data->DataVariables()->value(meash->GetName())->GetValue(), - mUnit, pUnit); - calculatedValue = locale().toString(value); - } - - AddCell(calculatedValue, currentRow, ColumnCalcValue, - Qt::AlignHCenter | Qt::AlignVCenter, meash->IsFormulaOk()); // calculated value - - AddCell(locale().toString(meash->GetBase()), currentRow, ColumnBaseValue, - Qt::AlignHCenter | Qt::AlignVCenter); // base value - - AddCell(locale().toString(meash->GetShiftA()), currentRow, ColumnShiftA, - Qt::AlignHCenter | Qt::AlignVCenter); - - AddCell(locale().toString(meash->GetShiftB()), currentRow, ColumnShiftB, - Qt::AlignHCenter | Qt::AlignVCenter); - - AddCell(locale().toString(meash->GetShiftC()), currentRow, ColumnShiftC, - Qt::AlignHCenter | Qt::AlignVCenter); - - AddCell(locale() - .toString(meash->GetCorrection(currentDimensionA, currentDimensionB, currentDimensionC)), - currentRow, ColumnCorrection, Qt::AlignHCenter | Qt::AlignVCenter); - } + RefreshMeasurementData(meash, currentRow); } else if (meash->GetType() == VarType::MeasurementSeparator) { @@ -3232,11 +3184,11 @@ void TMainWindow::RefreshTable(bool freshCall) item->setData(Qt::UserRole, meash->GetName()); AddCell(meash->GetDescription(), currentRow, ColumnFullName, Qt::AlignVCenter); // description - if (mType == MeasurementsType::Individual) + if (m_mType == MeasurementsType::Individual) { ui->tableWidget->setSpan(currentRow, 1, 1, 3); } - else if (mType == MeasurementsType::Multisize) + else if (m_mType == MeasurementsType::Multisize) { ui->tableWidget->setSpan(currentRow, 1, 1, 8); } @@ -3255,7 +3207,95 @@ void TMainWindow::RefreshTable(bool freshCall) } //--------------------------------------------------------------------------------------------------------------------- -QString TMainWindow::GetCustomName() const +void TMainWindow::RefreshMeasurementData(const QSharedPointer &meash, qint32 currentRow) +{ + if (m_mType == MeasurementsType::Individual) + { + QTableWidgetItem *item = AddCell(VAbstractApplication::VApp()->TrVars()->MToUser(meash->GetName()), + currentRow, ColumnName, Qt::AlignVCenter); // name + item->setData(Qt::UserRole, meash->GetName()); + + if (meash->IsCustom()) + { + AddCell(meash->GetGuiText(), currentRow, ColumnFullName, Qt::AlignVCenter); + } + else + { + AddCell(VAbstractApplication::VApp()->TrVars()->GuiText(meash->GetName()), currentRow, + ColumnFullName, Qt::AlignVCenter); + } + + QString calculatedValue; + if (meash->IsSpecialUnits()) + { + calculatedValue = locale().toString(*meash->GetValue()) + degreeSymbol; + } + else + { + calculatedValue = locale().toString(UnitConvertor(*meash->GetValue(), m_mUnit, m_pUnit)); + } + + AddCell(calculatedValue, currentRow, ColumnCalcValue, Qt::AlignHCenter | Qt::AlignVCenter, + meash->IsFormulaOk()); // calculated value + + QString formula = + VTranslateVars::TryFormulaToUser(meash->GetFormula(), + VAbstractApplication::VApp()->Settings()->GetOsSeparator()); + + AddCell(formula, currentRow, ColumnFormula, Qt::AlignVCenter); // formula + } + else + { + QTableWidgetItem *item = AddCell(VAbstractApplication::VApp()->TrVars()->MToUser(meash->GetName()), + currentRow, 0, Qt::AlignVCenter); // name + item->setData(Qt::UserRole, meash->GetName()); + + if (meash->IsCustom()) + { + AddCell(meash->GetGuiText(), currentRow, ColumnFullName, Qt::AlignVCenter); + } + else + { + AddCell(VAbstractApplication::VApp()->TrVars()->GuiText(meash->GetName()), currentRow, + ColumnFullName, Qt::AlignVCenter); + } + + QString calculatedValue; + if (meash->IsSpecialUnits()) + { + const qreal value = *m_data->DataVariables()->value(meash->GetName())->GetValue(); + calculatedValue = locale().toString(value) + degreeSymbol; + } + else + { + const qreal value = UnitConvertor(*m_data->DataVariables()->value(meash->GetName())->GetValue(), + m_mUnit, m_pUnit); + calculatedValue = locale().toString(value); + } + + AddCell(calculatedValue, currentRow, ColumnCalcValue, + Qt::AlignHCenter | Qt::AlignVCenter, meash->IsFormulaOk()); // calculated value + + AddCell(locale().toString(meash->GetBase()), currentRow, ColumnBaseValue, + Qt::AlignHCenter | Qt::AlignVCenter); // base value + + AddCell(locale().toString(meash->GetShiftA()), currentRow, ColumnShiftA, + Qt::AlignHCenter | Qt::AlignVCenter); + + AddCell(locale().toString(meash->GetShiftB()), currentRow, ColumnShiftB, + Qt::AlignHCenter | Qt::AlignVCenter); + + AddCell(locale().toString(meash->GetShiftC()), currentRow, ColumnShiftC, + Qt::AlignHCenter | Qt::AlignVCenter); + + AddCell(locale() + .toString(meash->GetCorrection(m_currentDimensionA, m_currentDimensionB, m_currentDimensionC)), + currentRow, ColumnCorrection, Qt::AlignHCenter | Qt::AlignVCenter); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +auto TMainWindow::GetCustomName() const -> QString { qint32 num = 1; QString name; @@ -3264,7 +3304,7 @@ QString TMainWindow::GetCustomName() const name = CustomMSign + VAbstractApplication::VApp()->TrVars()->InternalVarToUser(measurement_) + QString::number(num); num++; - } while (not data->IsUnique(name)); + } while (not m_data->IsUnique(name)); return name; } @@ -3322,7 +3362,7 @@ void TMainWindow::MFields(bool enabled) ui->lineEditFullName->setEnabled(enabled); ui->comboBoxMUnits->setEnabled(enabled); - if (mType == MeasurementsType::Multisize) + if (m_mType == MeasurementsType::Multisize) { ui->doubleSpinBoxBaseValue->setEnabled(enabled); ui->doubleSpinBoxShiftA->setEnabled(enabled); @@ -3358,16 +3398,16 @@ void TMainWindow::UpdateWindowTitle() { QString showName; bool isFileWritable = true; - if (not curFile.isEmpty()) + if (not m_curFile.isEmpty()) { //#ifdef Q_OS_WIN32 // qt_ntfs_permission_lookup++; // turn checking on //#endif /*Q_OS_WIN32*/ - isFileWritable = QFileInfo(curFile).isWritable(); + isFileWritable = QFileInfo(m_curFile).isWritable(); //#ifdef Q_OS_WIN32 // qt_ntfs_permission_lookup--; // turn it off again //#endif /*Q_OS_WIN32*/ - showName = StrippedName(curFile); + showName = StrippedName(m_curFile); } else { @@ -3380,18 +3420,18 @@ void TMainWindow::UpdateWindowTitle() { showName = tr("untitled"); } - mType == MeasurementsType::Multisize ? showName += QLatin1String(".vst") : showName += QLatin1String(".vit"); + m_mType == MeasurementsType::Multisize ? showName += QLatin1String(".vst") : showName += QLatin1String(".vit"); } showName += QLatin1String("[*]"); - if (mIsReadOnly || not isFileWritable) + if (m_mIsReadOnly || not isFileWritable) { showName += QStringLiteral(" (") + tr("read only") + QChar(')'); } setWindowTitle(showName); - setWindowFilePath(curFile); + setWindowFilePath(m_curFile); #if defined(Q_OS_MAC) static QIcon fileIcon = QIcon(QCoreApplication::applicationDirPath() + @@ -3419,7 +3459,7 @@ void TMainWindow::UpdateWindowTitle() } //--------------------------------------------------------------------------------------------------------------------- -QString TMainWindow::ClearCustomName(const QString &name) const +auto TMainWindow::ClearCustomName(const QString &name) -> QString { QString clear = name; const int index = clear.indexOf(CustomMSign); @@ -3431,10 +3471,10 @@ QString TMainWindow::ClearCustomName(const QString &name) const } //--------------------------------------------------------------------------------------------------------------------- -bool TMainWindow::EvalFormula(const QString &formula, bool fromUser, VContainer *data, QLabel *label, - bool specialUnits) +auto TMainWindow::EvalFormula(const QString &formula, bool fromUser, VContainer *data, QLabel *label, + bool specialUnits) -> bool { - const QString postfix = specialUnits ? degreeSymbol : UnitsToStr(pUnit); + const QString postfix = specialUnits ? degreeSymbol : UnitsToStr(m_pUnit); if (formula.isEmpty()) { @@ -3468,7 +3508,7 @@ bool TMainWindow::EvalFormula(const QString &formula, bool fromUser, VContainer if (not specialUnits) { - result = UnitConvertor(result, mUnit, pUnit); + result = UnitConvertor(result, m_mUnit, m_pUnit); } label->setText(VAbstractApplication::VApp()->LocaleToString(result) + QChar(QChar::Space) +postfix); @@ -3491,7 +3531,7 @@ void TMainWindow::Open(const QString &pathTo, const QString &filter) if (not mPath.isEmpty()) { - if (m == nullptr) + if (m_m == nullptr) { LoadFile(mPath); } @@ -3515,7 +3555,7 @@ void TMainWindow::UpdatePadlock(bool ro) ui->actionReadOnly->setIcon(QIcon("://tapeicon/24x24/padlock_opened.png")); } - ui->actionReadOnly->setDisabled(mIsReadOnly); + ui->actionReadOnly->setDisabled(m_mIsReadOnly); } //--------------------------------------------------------------------------------------------------------------------- @@ -3581,7 +3621,7 @@ void TMainWindow::WriteSettings() } //--------------------------------------------------------------------------------------------------------------------- -QStringList TMainWindow::FilterMeasurements(const QStringList &mNew, const QStringList &mFilter) +auto TMainWindow::FilterMeasurements(const QStringList &mNew, const QStringList &mFilter) -> QStringList { return ConvertToList(ConvertToSet(mNew).subtract(ConvertToSet(mFilter))); } @@ -3604,117 +3644,115 @@ void TMainWindow::UpdatePatternUnit() } //--------------------------------------------------------------------------------------------------------------------- -bool TMainWindow::LoadFromExistingFile(const QString &path) +auto TMainWindow::LoadFromExistingFile(const QString &path) -> bool { - if (m == nullptr) + if (m_m != nullptr) { - if (not QFileInfo::exists(path)) + return MApplication::VApp()->NewMainWindow()->LoadFile(path); + } + + if (not QFileInfo::exists(path)) + { + qCCritical(tMainWindow, "%s", qUtf8Printable(tr("File '%1' doesn't exist!").arg(path))); + if (MApplication::VApp()->IsTestMode()) { - qCCritical(tMainWindow, "%s", qUtf8Printable(tr("File '%1' doesn't exist!").arg(path))); - if (MApplication::VApp()->IsTestMode()) - { - qApp->exit(V_EX_NOINPUT); - } - return false; + QCoreApplication::exit(V_EX_NOINPUT); } + return false; + } - // Check if file already opened - const QList list = MApplication::VApp()->MainWindows(); - auto w = std::find_if(list.begin(), list.end(), - [path](TMainWindow *window) { return window->CurrentFile() == path; }); - if (w != list.end()) + // Check if file already opened + const QList list = MApplication::VApp()->MainWindows(); + auto w = std::find_if(list.begin(), list.end(), + [path](TMainWindow *window) { return window->CurrentFile() == path; }); + if (w != list.end()) + { + (*w)->activateWindow(); + close(); + return false; + } + + VlpCreateLock(m_lock, path); + + if (not m_lock->IsLocked()) + { + if (not IgnoreLocking(m_lock->GetLockError(), path, MApplication::VApp()->IsAppInGUIMode())) { - (*w)->activateWindow(); - close(); - return false; - } - - VlpCreateLock(lock, path); - - if (not lock->IsLocked()) - { - if (not IgnoreLocking(lock->GetLockError(), path, MApplication::VApp()->IsAppInGUIMode())) - { - return false; - } - } - - try - { - data = new VContainer(VAbstractApplication::VApp()->TrVars(), &mUnit, VContainer::UniqueNamespace()); - - m = new VMeasurements(data); - m->setXMLContent(path); - - mType = m->Type(); - - if (mType == MeasurementsType::Unknown) - { - throw VException(tr("File has unknown format.")); - } - - QScopedPointer converter( - (mType == MeasurementsType::Individual) ? static_cast(new VVITConverter(path)) - : static_cast(new VVSTConverter(path))); - - m_curFileFormatVersion = converter->GetCurrentFormatVersion(); - m_curFileFormatVersionStr = converter->GetFormatVersionStr(); - m->setXMLContent(converter->Convert());// Read again after conversion - - if (not m->IsDefinedKnownNamesValid()) - { - throw VException(tr("File contains invalid known measurement(s).")); - } - - mUnit = m->Units(); - pUnit = mUnit; - - currentDimensionA = m->DimensionABase(); - currentDimensionB = m->DimensionBBase(); - currentDimensionC = m->DimensionCBase(); - - ui->labelToolTip->setVisible(false); - ui->tabWidget->setVisible(true); - - InitWindow(); - - m->ClearForExport(); - const bool freshCall = true; - RefreshData(freshCall); - - if (ui->tableWidget->rowCount() > 0) - { - ui->tableWidget->selectRow(0); - } - - lock.reset();// Now we can unlock the file - - mIsReadOnly = m->IsReadOnly(); - UpdatePadlock(mIsReadOnly); - MeasurementGUI(); - } - catch (VException &e) - { - qCCritical(tMainWindow, "%s\n\n%s\n\n%s", qUtf8Printable(tr("File error.")), - qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation())); - ui->labelToolTip->setVisible(true); - ui->tabWidget->setVisible(false); - delete m; - m = nullptr; - delete data; - data = nullptr; - lock.reset(); - - if (MApplication::VApp()->IsTestMode()) - { - qApp->exit(V_EX_NOINPUT); - } return false; } } - else + + try { - return MApplication::VApp()->NewMainWindow()->LoadFile(path); + m_data = new VContainer(VAbstractApplication::VApp()->TrVars(), &m_mUnit, VContainer::UniqueNamespace()); + + m_m = new VMeasurements(m_data); + m_m->setXMLContent(path); + + m_mType = m_m->Type(); + + if (m_mType == MeasurementsType::Unknown) + { + throw VException(tr("File has unknown format.")); + } + + QScopedPointer converter( + (m_mType == MeasurementsType::Individual) ? static_cast(new VVITConverter(path)) + : static_cast(new VVSTConverter(path))); + + m_curFileFormatVersion = converter->GetCurrentFormatVersion(); + m_curFileFormatVersionStr = converter->GetFormatVersionStr(); + m_m->setXMLContent(converter->Convert());// Read again after conversion + + if (not m_m->IsDefinedKnownNamesValid()) + { + throw VException(tr("File contains invalid known measurement(s).")); + } + + m_mUnit = m_m->Units(); + m_pUnit = m_mUnit; + + m_currentDimensionA = m_m->DimensionABase(); + m_currentDimensionB = m_m->DimensionBBase(); + m_currentDimensionC = m_m->DimensionCBase(); + + ui->labelToolTip->setVisible(false); + ui->tabWidget->setVisible(true); + + InitWindow(); + + m_m->ClearForExport(); + const bool freshCall = true; + RefreshData(freshCall); + + if (ui->tableWidget->rowCount() > 0) + { + ui->tableWidget->selectRow(0); + } + + m_lock.reset();// Now we can unlock the file + + m_mIsReadOnly = m_m->IsReadOnly(); + UpdatePadlock(m_mIsReadOnly); + MeasurementGUI(); + } + catch (VException &e) + { + qCCritical(tMainWindow, "%s\n\n%s\n\n%s", qUtf8Printable(tr("File error.")), + qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation())); + ui->labelToolTip->setVisible(true); + ui->tabWidget->setVisible(false); + delete m_m; + m_m = nullptr; + delete m_data; + m_data = nullptr; + m_lock.reset(); + + if (MApplication::VApp()->IsTestMode()) + { + QCoreApplication::exit(V_EX_NOINPUT); + } + return false; } return true; @@ -3763,7 +3801,7 @@ void TMainWindow::CreateWindowMenu(QMenu *menu) //--------------------------------------------------------------------------------------------------------------------- void TMainWindow::HackDimensionBaseValue() { - const QList dimensions = m->Dimensions().values(); + const QList dimensions = m_m->Dimensions().values(); auto DimensionsBaseValue = [this, dimensions](int index, QLabel *name, QLabel *base) { @@ -3785,7 +3823,7 @@ void TMainWindow::HackDimensionBaseValue() //--------------------------------------------------------------------------------------------------------------------- void TMainWindow::HackDimensionShifts() { - const QList dimensions = m->Dimensions().values(); + const QList dimensions = m_m->Dimensions().values(); auto HackShift = [this, dimensions](int index, QLabel *&name, QDoubleSpinBox *&shift) { @@ -3805,7 +3843,7 @@ void TMainWindow::HackDimensionShifts() } //--------------------------------------------------------------------------------------------------------------------- -QString TMainWindow::CheckMName(const QString &name, const QSet &importedNames) const +auto TMainWindow::CheckMName(const QString &name, const QSet &importedNames) const -> QString { if (name.isEmpty()) { @@ -3825,7 +3863,7 @@ QString TMainWindow::CheckMName(const QString &name, const QSet &import throw VException(tr("Measurement '%1' doesn't match regex pattern.").arg(name)); } - if (not data->IsUnique(name)) + if (not m_data->IsUnique(name)) { throw VException(tr("Measurement '%1' already used in the file.").arg(name)); } @@ -3837,7 +3875,7 @@ QString TMainWindow::CheckMName(const QString &name, const QSet &import throw VException(tr("Measurement '%1' is not one of the known measurements.").arg(name)); } - if (not data->IsUnique(name)) + if (not m_data->IsUnique(name)) { throw VException(tr("Measurement '%1' already used in file.").arg(name)); } @@ -3884,17 +3922,12 @@ void TMainWindow::ImportIndividualMeasurements(const QxtCsvModel &csv, const QVe struct IndividualMeasurement { - IndividualMeasurement() - : name(), - value('0'), - fullName(), - description() - {} + IndividualMeasurement() =default; - QString name; - QString value; - QString fullName; - QString description; + QString name{}; // NOLINT(misc-non-private-member-variables-in-classes) + QString value{'0'}; // NOLINT(misc-non-private-member-variables-in-classes) + QString fullName{}; // NOLINT(misc-non-private-member-variables-in-classes) + QString description{}; // NOLINT(misc-non-private-member-variables-in-classes) }; QVector measurements; @@ -3950,18 +3983,18 @@ void TMainWindow::ImportIndividualMeasurements(const QxtCsvModel &csv, const QVe } } - for(auto &im : qAsConst(measurements)) + for(const auto &im : qAsConst(measurements)) { - m->AddEmpty(im.name, im.value); + m_m->AddEmpty(im.name, im.value); if (not im.fullName.isEmpty()) { - m->SetMFullName(im.name, im.fullName); + m_m->SetMFullName(im.name, im.fullName); } if (not im.description.isEmpty()) { - m->SetMDescription(im.name, im.description); + m_m->SetMDescription(im.name, im.description); } } @@ -3972,7 +4005,6 @@ void TMainWindow::ImportIndividualMeasurements(const QxtCsvModel &csv, const QVe void TMainWindow::ImportMultisizeMeasurements(const QxtCsvModel &csv, const QVector &map) { const int columns = csv.columnCount(); - const int rows = csv.rowCount(); if (columns < 4) { @@ -3980,104 +4012,17 @@ void TMainWindow::ImportMultisizeMeasurements(const QxtCsvModel &csv, const QVec return; } - auto ConverToDouble = [](QString text, const QString &error) - { - text.replace(" ", QString()); - text = VTranslateVars::TryFormulaFromUser(text, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); - bool ok = false; - - const qreal value = QLocale::c().toDouble(text, &ok); - if (not ok) - { - throw VException(error); - } - return value; - }; - - struct MultisizeMeasurement - { - MultisizeMeasurement() - : name(), - fullName(), - description() - {} - - QString name; - qreal base{0}; - qreal shiftA{0}; - qreal shiftB{0}; - qreal shiftC{0}; - QString fullName; - QString description; - }; - QVector measurements; QSet importedNames; - const QMap dimensions = m->Dimensions(); + const QMap dimensions = m_m->Dimensions(); + const int rows = csv.rowCount(); for(int i=0; i < rows; ++i) { try { - const int nameColumn = map.at(static_cast(MultisizeMeasurementsColumns::Name)); - const QString name = csv.text(i, nameColumn).simplified(); - if (name.isEmpty()) - { - ShowError(tr("Error in row %1. The measurement name is empty.").arg(i)); - continue; - } - - MultisizeMeasurement measurement; - const QString mName = CheckMName(VAbstractApplication::VApp()->TrVars()->MFromUser(name), importedNames); - importedNames.insert(mName); - measurement.name = mName; - - const int baseValueColumn = map.at(static_cast(MultisizeMeasurementsColumns::BaseValue)); - measurement.base = ConverToDouble(csv.text(i, baseValueColumn), - tr("Cannot convert base value to double in column 2.")); - - const int shiftAColumn = map.at(static_cast(MultisizeMeasurementsColumns::ShiftA)); - measurement.shiftA = ConverToDouble(csv.text(i, shiftAColumn), - tr("Cannot convert shift value to double in column %1.") - .arg(shiftAColumn)); - - if (dimensions.size() > 1) - { - const int shiftBColumn = map.at(static_cast(MultisizeMeasurementsColumns::ShiftB)); - measurement.shiftB = ConverToDouble(csv.text(i, shiftBColumn), - tr("Cannot convert shift value to double in column %1.") - .arg(shiftBColumn)); - } - - if (dimensions.size() > 2) - { - const int shiftCColumn = map.at(static_cast(MultisizeMeasurementsColumns::ShiftC)); - measurement.shiftC = ConverToDouble(csv.text(i, shiftCColumn), - tr("Cannot convert shift value to double in column %1.") - .arg(shiftCColumn)); - } - - const bool custom = name.startsWith(CustomMSign); - if (columns > 4 && custom) - { - const int fullNameColumn = map.at(static_cast(MultisizeMeasurementsColumns::FullName)); - if (fullNameColumn >= 0) - { - measurement.fullName = csv.text(i, fullNameColumn).simplified(); - } - } - - if (columns > 5 && custom) - { - const int descriptionColumn = map.at(static_cast(MultisizeMeasurementsColumns::Description)); - if (descriptionColumn >= 0) - { - measurement.description = csv.text(i, descriptionColumn).simplified(); - } - } - - measurements.append(measurement); + measurements.append(ImportMultisizeMeasurement(csv, i, map, dimensions.size(), importedNames)); } catch (VException &e) { @@ -4086,55 +4031,121 @@ void TMainWindow::ImportMultisizeMeasurements(const QxtCsvModel &csv, const QVec } } - for(auto &mm : qAsConst(measurements)) + for(const auto &mm : qAsConst(measurements)) { - m->AddEmpty(mm.name); - m->SetMBaseValue(mm.name, mm.base); - m->SetMShiftA(mm.name, mm.shiftA); + m_m->AddEmpty(mm.name); + m_m->SetMBaseValue(mm.name, mm.base); + m_m->SetMShiftA(mm.name, mm.shiftA); if (dimensions.size() > 1) { - m->SetMShiftB(mm.name, mm.shiftB); + m_m->SetMShiftB(mm.name, mm.shiftB); } if (dimensions.size() > 2) { - m->SetMShiftC(mm.name, mm.shiftC); + m_m->SetMShiftC(mm.name, mm.shiftC); } if (not mm.fullName.isEmpty()) { - m->SetMFullName(mm.name, mm.fullName); + m_m->SetMFullName(mm.name, mm.fullName); } if (not mm.description.isEmpty()) { - m->SetMDescription(mm.name, mm.description); + m_m->SetMDescription(mm.name, mm.description); } } RefreshDataAfterImport(); } +//--------------------------------------------------------------------------------------------------------------------- +auto TMainWindow::ImportMultisizeMeasurement( + const QxtCsvModel &csv, int i, const QVector &map,int dimensionsCount, + QSet &importedNames) -> TMainWindow::MultisizeMeasurement +{ + const int nameColumn = map.at(static_cast(MultisizeMeasurementsColumns::Name)); + const QString name = csv.text(i, nameColumn).simplified(); + if (name.isEmpty()) + { + throw VException(tr("The measurement name is empty.")); + } + + MultisizeMeasurement measurement; + + const QString mName = CheckMName(VAbstractApplication::VApp()->TrVars()->MFromUser(name), importedNames); + importedNames.insert(mName); + measurement.name = mName; + + const int baseValueColumn = map.at(static_cast(MultisizeMeasurementsColumns::BaseValue)); + measurement.base = ConverToDouble(csv.text(i, baseValueColumn), + tr("Cannot convert base value to double in column 2.")); + + const int shiftAColumn = map.at(static_cast(MultisizeMeasurementsColumns::ShiftA)); + measurement.shiftA = ConverToDouble(csv.text(i, shiftAColumn), + tr("Cannot convert shift value to double in column %1.") + .arg(shiftAColumn)); + + if (dimensionsCount > 1) + { + const int shiftBColumn = map.at(static_cast(MultisizeMeasurementsColumns::ShiftB)); + measurement.shiftB = ConverToDouble(csv.text(i, shiftBColumn), + tr("Cannot convert shift value to double in column %1.") + .arg(shiftBColumn)); + } + + if (dimensionsCount > 2) + { + const int shiftCColumn = map.at(static_cast(MultisizeMeasurementsColumns::ShiftC)); + measurement.shiftC = ConverToDouble(csv.text(i, shiftCColumn), + tr("Cannot convert shift value to double in column %1.") + .arg(shiftCColumn)); + } + + const int columns = csv.columnCount(); + const bool custom = name.startsWith(CustomMSign); + if (columns > 4 && custom) + { + const int fullNameColumn = map.at(static_cast(MultisizeMeasurementsColumns::FullName)); + if (fullNameColumn >= 0) + { + measurement.fullName = csv.text(i, fullNameColumn).simplified(); + } + } + + if (columns > 5 && custom) + { + const int descriptionColumn = map.at(static_cast(MultisizeMeasurementsColumns::Description)); + if (descriptionColumn >= 0) + { + measurement.description = csv.text(i, descriptionColumn).simplified(); + } + } + + return measurement; +} + //--------------------------------------------------------------------------------------------------------------------- void TMainWindow::SetCurrentPatternUnit() { - if (comboBoxUnits) + if (m_comboBoxUnits) { - comboBoxUnits->blockSignals(true); - const qint32 indexUnit = comboBoxUnits->findData(static_cast(pUnit)); + m_comboBoxUnits->blockSignals(true); + const qint32 indexUnit = m_comboBoxUnits->findData(static_cast(m_pUnit)); if (indexUnit != -1) { - comboBoxUnits->setCurrentIndex(indexUnit); + m_comboBoxUnits->setCurrentIndex(indexUnit); } - comboBoxUnits->blockSignals(false); + m_comboBoxUnits->blockSignals(false); } } //--------------------------------------------------------------------------------------------------------------------- void TMainWindow::ShowDimensionControls() { - const QList dimensions = m->Dimensions().values(); + const QList dimensions = m_m->Dimensions().values(); auto ShowControl = [this, dimensions](int index, QLabel *name, QComboBox *control) { @@ -4148,25 +4159,25 @@ void TMainWindow::ShowDimensionControls() } }; - ShowControl(0, labelGradationDimensionA, gradationDimensionA); - ShowControl(1, labelGradationDimensionB, gradationDimensionB); - ShowControl(2, labelGradationDimensionC, gradationDimensionC); + ShowControl(0, m_labelGradationDimensionA, m_gradationDimensionA); + ShowControl(1, m_labelGradationDimensionB, m_gradationDimensionB); + ShowControl(2, m_labelGradationDimensionC, m_gradationDimensionC); - if (gradationDimensionA) + if (m_gradationDimensionA) { - connect(gradationDimensionA, QOverload::of(&QComboBox::currentIndexChanged), + connect(m_gradationDimensionA, QOverload::of(&QComboBox::currentIndexChanged), this, &TMainWindow::DimensionABaseChanged); } - if (gradationDimensionB) + if (m_gradationDimensionB) { - connect(gradationDimensionB, QOverload::of(&QComboBox::currentIndexChanged), + connect(m_gradationDimensionB, QOverload::of(&QComboBox::currentIndexChanged), this, &TMainWindow::DimensionBBaseChanged); } - if (gradationDimensionC) + if (m_gradationDimensionC) { - connect(gradationDimensionC, QOverload::of(&QComboBox::currentIndexChanged), + connect(m_gradationDimensionC, QOverload::of(&QComboBox::currentIndexChanged), this, &TMainWindow::DimensionCBaseChanged); } } @@ -4174,24 +4185,24 @@ void TMainWindow::ShowDimensionControls() //--------------------------------------------------------------------------------------------------------------------- void TMainWindow::SetDimensionBases() { - const QList dimensions = m->Dimensions().values(); + const QList dimensions = m_m->Dimensions().values(); - if (dimensions.size() > 0) + if (not dimensions.empty()) { - MeasurementDimension_p dimension = dimensions.at(0); - currentDimensionA = dimension->BaseValue(); + const MeasurementDimension_p& dimension = dimensions.at(0); + m_currentDimensionA = dimension->BaseValue(); } if (dimensions.size() > 1) { - MeasurementDimension_p dimension = dimensions.at(1); - currentDimensionB = dimension->BaseValue(); + const MeasurementDimension_p& dimension = dimensions.at(1); + m_currentDimensionB = dimension->BaseValue(); } if (dimensions.size() > 2) { - MeasurementDimension_p dimension = dimensions.at(2); - currentDimensionC = dimension->BaseValue(); + const MeasurementDimension_p& dimension = dimensions.at(2); + m_currentDimensionC = dimension->BaseValue(); } auto SetBase = [dimensions](int index, QComboBox *control, qreal &value) @@ -4200,8 +4211,6 @@ void TMainWindow::SetDimensionBases() { SCASSERT(control != nullptr) - MeasurementDimension_p dimension = dimensions.at(index); - const qint32 i = control->findData(value); if (i != -1) { @@ -4214,45 +4223,45 @@ void TMainWindow::SetDimensionBases() } }; - SetBase(0, gradationDimensionA, currentDimensionA); - SetBase(1, gradationDimensionB, currentDimensionB); - SetBase(2, gradationDimensionC, currentDimensionC); + SetBase(0, m_gradationDimensionA, m_currentDimensionA); + SetBase(1, m_gradationDimensionB, m_currentDimensionB); + SetBase(2, m_gradationDimensionC, m_currentDimensionC); } //--------------------------------------------------------------------------------------------------------------------- void TMainWindow::SetCurrentDimensionValues() { - const QList dimensions = m->Dimensions().values(); + const QList dimensions = m_m->Dimensions().values(); auto SetDimensionValue = [dimensions](int index, qreal &value) { if (dimensions.size() > index) { - MeasurementDimension_p dimension = dimensions.at(index); + const MeasurementDimension_p& dimension = dimensions.at(index); value = dimension->BaseValue(); } }; - SetDimensionValue(0, currentDimensionA); - SetDimensionValue(1, currentDimensionB); - SetDimensionValue(2, currentDimensionC); + SetDimensionValue(0, m_currentDimensionA); + SetDimensionValue(1, m_currentDimensionB); + SetDimensionValue(2, m_currentDimensionC); } //--------------------------------------------------------------------------------------------------------------------- -QVector TMainWindow::DimensionRestrictedValues(int index, const MeasurementDimension_p &dimension) +auto TMainWindow::DimensionRestrictedValues(int index, const MeasurementDimension_p &dimension) -> QVector { VDimensionRestriction restriction; if (index == 0) { - restriction = m->Restriction(0); + restriction = m_m->Restriction(0); } else if (index == 1) { - restriction = m->Restriction(currentDimensionA); + restriction = m_m->Restriction(m_currentDimensionA); } else { - restriction = m->Restriction(currentDimensionA, currentDimensionB); + restriction = m_m->Restriction(m_currentDimensionA, m_currentDimensionB); } const QVector bases = dimension->ValidBases(); @@ -4270,9 +4279,9 @@ QVector TMainWindow::DimensionRestrictedValues(int index, const Measureme } //--------------------------------------------------------------------------------------------------------------------- -QMap > TMainWindow::OrderedMeasurments() const +auto TMainWindow::OrderedMeasurments() const -> QMap > { - const QMap > table = data->DataMeasurementsWithSeparators(); + const QMap > table = m_data->DataMeasurementsWithSeparators(); QMap > orderedTable; QMap >::const_iterator iterMap; for (iterMap = table.constBegin(); iterMap != table.constEnd(); ++iterMap) @@ -4287,7 +4296,7 @@ QMap > TMainWindow::OrderedMeasurments() const //--------------------------------------------------------------------------------------------------------------------- void TMainWindow::SetDecimals() { - switch (mUnit) + switch (m_mUnit) { case Unit::Cm: ui->doubleSpinBoxBaseValue->setDecimals(2); @@ -4345,36 +4354,36 @@ void TMainWindow::SetDecimals() //--------------------------------------------------------------------------------------------------------------------- void TMainWindow::InitPatternUnits() { - labelPatternUnit = new QLabel(tr("Pattern unit:")); - ui->toolBarGradation->addWidget(labelPatternUnit); + m_labelPatternUnit = new QLabel(tr("Pattern unit:")); + ui->toolBarGradation->addWidget(m_labelPatternUnit); - comboBoxUnits = new QComboBox(this); + m_comboBoxUnits = new QComboBox(this); InitComboBoxUnits(); SetCurrentPatternUnit(); - connect(comboBoxUnits, QOverload::of(&QComboBox::currentIndexChanged), this, [this](int index) + connect(m_comboBoxUnits, QOverload::of(&QComboBox::currentIndexChanged), this, [this](int index) { - pUnit = static_cast(comboBoxUnits->itemData(index).toInt()); + m_pUnit = static_cast(m_comboBoxUnits->itemData(index).toInt()); UpdatePatternUnit(); }); - ui->toolBarGradation->addWidget(comboBoxUnits); + ui->toolBarGradation->addWidget(m_comboBoxUnits); } //--------------------------------------------------------------------------------------------------------------------- void TMainWindow::InitComboBoxUnits() { - SCASSERT(comboBoxUnits != nullptr) - comboBoxUnits->addItem(UnitsToStr(Unit::Cm, true), QVariant(static_cast(Unit::Cm))); - comboBoxUnits->addItem(UnitsToStr(Unit::Mm, true), QVariant(static_cast(Unit::Mm))); - comboBoxUnits->addItem(UnitsToStr(Unit::Inch, true), QVariant(static_cast(Unit::Inch))); + SCASSERT(m_comboBoxUnits != nullptr) + m_comboBoxUnits->addItem(UnitsToStr(Unit::Cm, true), QVariant(static_cast(Unit::Cm))); + m_comboBoxUnits->addItem(UnitsToStr(Unit::Mm, true), QVariant(static_cast(Unit::Mm))); + m_comboBoxUnits->addItem(UnitsToStr(Unit::Inch, true), QVariant(static_cast(Unit::Inch))); } //--------------------------------------------------------------------------------------------------------------------- void TMainWindow::InitMeasurementUnits() { - if (not m) + if (not m_m) { return; } @@ -4388,7 +4397,7 @@ void TMainWindow::InitMeasurementUnits() } QString units; - switch (m->Units()) + switch (m_m->Units()) { case Unit::Mm: units = tr("Millimeters"); @@ -4479,14 +4488,14 @@ void TMainWindow::InitSearch() SaveSearchRequest(); InitSearchHistory(); m_search->FindPrevious(); - ui->labelResults->setText(QString("%1/%2").arg(m_search->MatchIndex()+1).arg(m_search->MatchCount())); + ui->labelResults->setText(QStringLiteral("%1/%2").arg(m_search->MatchIndex()+1).arg(m_search->MatchCount())); }); connect(ui->toolButtonFindNext, &QToolButton::clicked, this, [this]() { SaveSearchRequest(); InitSearchHistory(); m_search->FindNext(); - ui->labelResults->setText(QString("%1/%2").arg(m_search->MatchIndex()+1).arg(m_search->MatchCount())); + ui->labelResults->setText(QStringLiteral("%1/%2").arg(m_search->MatchIndex()+1).arg(m_search->MatchCount())); }); connect(m_search.data(), &VTableSearch::HasResult, this, [this] (bool state) @@ -4496,7 +4505,8 @@ void TMainWindow::InitSearch() if (state) { - ui->labelResults->setText(QString("%1/%2").arg(m_search->MatchIndex()+1).arg(m_search->MatchCount())); + ui->labelResults->setText(QStringLiteral("%1/%2").arg(m_search->MatchIndex()+1) + .arg(m_search->MatchCount())); } else { @@ -4636,9 +4646,9 @@ void TMainWindow::UpdateSearchControlsTooltips() //--------------------------------------------------------------------------------------------------------------------- void TMainWindow::RetranslateTableHeaders() { - if (mType == MeasurementsType::Multisize) + if (m_mType == MeasurementsType::Multisize) { - const QList< MeasurementDimension_p > dimensions = m->Dimensions().values(); + const QList< MeasurementDimension_p > dimensions = m_m->Dimensions().values(); if (not dimensions.isEmpty()) { @@ -4677,5 +4687,5 @@ void TMainWindow::HackWidget(T **widget) { delete *widget; *widget = new T(); - hackedWidgets.append(*widget); + m_hackedWidgets.append(*widget); } diff --git a/src/app/tape/tmainwindow.h b/src/app/tape/tmainwindow.h index ae3a66aa2..6575506ad 100644 --- a/src/app/tape/tmainwindow.h +++ b/src/app/tape/tmainwindow.h @@ -48,32 +48,31 @@ class VMeasurement; class TMainWindow : public VAbstractMainWindow { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit TMainWindow(QWidget *parent = nullptr); - virtual ~TMainWindow() override; + ~TMainWindow() override; - QString CurrentFile() const; + auto CurrentFile() const -> QString; void RetranslateTable(); - bool SetDimensionABase(int base); - bool SetDimensionBBase(int base); - bool SetDimensionCBase(int base); + auto SetDimensionABase(int base) -> bool; + auto SetDimensionBBase(int base) -> bool; + auto SetDimensionCBase(int base) -> bool; void SetPUnit(Unit unit); - bool LoadFile(const QString &path); + auto LoadFile(const QString &path) -> bool; void UpdateWindowTitle(); protected: - virtual void closeEvent(QCloseEvent *event) override; - virtual void changeEvent(QEvent* event) override; - virtual bool eventFilter(QObject *object, QEvent *event) override; - virtual void ExportToCSVData(const QString &fileName, bool withHeader, int mib, - const QChar &separator) final; - virtual QStringList RecentFileList() const override; + void closeEvent(QCloseEvent *event) override; + void changeEvent(QEvent* event) override; + auto eventFilter(QObject *object, QEvent *event) -> bool override; + void ExportToCSVData(const QString &fileName, bool withHeader, int mib, const QChar &separator) final; + auto RecentFileList() const -> QStringList override; private slots: void FileNew(); @@ -84,8 +83,8 @@ private slots: void Preferences(); void ToolBarStyles(); - bool FileSave(); - bool FileSaveAs(); + bool FileSave(); // NOLINT(modernize-use-trailing-return-type) + bool FileSaveAs(); // NOLINT(modernize-use-trailing-return-type) void AboutToShowWindowMenu(); void ShowWindow() const; void ImportDataFromCSV(); @@ -150,34 +149,48 @@ private slots: void SetDefaultGUILanguage(); private: - Q_DISABLE_COPY(TMainWindow) + // cppcheck-suppress unknownMacro + Q_DISABLE_COPY_MOVE(TMainWindow) // NOLINT Ui::TMainWindow *ui; - VMeasurements *m{nullptr}; - VContainer *data{nullptr}; - Unit mUnit{Unit::Cm}; - Unit pUnit{Unit::Cm}; - MeasurementsType mType{MeasurementsType::Individual}; - qreal currentDimensionA{0}; - qreal currentDimensionB{0}; - qreal currentDimensionC{0}; - QString curFile{}; - QComboBox *gradationDimensionA{nullptr}; - QComboBox *gradationDimensionB{nullptr}; - QComboBox *gradationDimensionC{nullptr}; - QComboBox *comboBoxUnits{nullptr}; - int formulaBaseHeight; - QSharedPointer> lock{nullptr}; + VMeasurements *m_m{nullptr}; + VContainer *m_data{nullptr}; + Unit m_mUnit{Unit::Cm}; + Unit m_pUnit{Unit::Cm}; + MeasurementsType m_mType{MeasurementsType::Individual}; + qreal m_currentDimensionA{0}; + qreal m_currentDimensionB{0}; + qreal m_currentDimensionC{0}; + QString m_curFile{}; + QComboBox *m_gradationDimensionA{nullptr}; + QComboBox *m_gradationDimensionB{nullptr}; + QComboBox *m_gradationDimensionC{nullptr}; + QComboBox *m_comboBoxUnits{nullptr}; + int m_formulaBaseHeight; + QSharedPointer> m_lock{nullptr}; QSharedPointer m_search{}; - QLabel *labelGradationDimensionA{nullptr}; - QLabel *labelGradationDimensionB{nullptr}; - QLabel *labelGradationDimensionC{nullptr}; - QLabel *labelPatternUnit{nullptr}; - bool isInitialized{false}; - bool mIsReadOnly{false}; - QTimer *gradation; + QLabel *m_labelGradationDimensionA{nullptr}; + QLabel *m_labelGradationDimensionB{nullptr}; + QLabel *m_labelGradationDimensionC{nullptr}; + QLabel *m_labelPatternUnit{nullptr}; + bool m_isInitialized{false}; + bool m_mIsReadOnly{false}; + QTimer *m_gradation; QMenu *m_searchHistory; - QVector hackedWidgets{}; + QVector m_hackedWidgets{}; + + struct MultisizeMeasurement + { + MultisizeMeasurement() = default; + + QString name{}; // NOLINT(misc-non-private-member-variables-in-classes) + qreal base{0}; // NOLINT(misc-non-private-member-variables-in-classes) + qreal shiftA{0}; // NOLINT(misc-non-private-member-variables-in-classes) + qreal shiftB{0}; // NOLINT(misc-non-private-member-variables-in-classes) + qreal shiftC{0}; // NOLINT(misc-non-private-member-variables-in-classes) + QString fullName{}; // NOLINT(misc-non-private-member-variables-in-classes) + QString description{}; // NOLINT(misc-non-private-member-variables-in-classes) + }; void SetupMenu(); void InitWindow(); @@ -191,7 +204,7 @@ private: void InitPatternUnits(); void InitComboBoxUnits(); void InitMeasurementUnits(); - void InitGender(QComboBox *gender); + static void InitGender(QComboBox *gender); void InitMeasurementDimension(); void InitSearch(); @@ -203,24 +216,25 @@ private: void ShowNewMData(bool fresh); void ShowUnits(); - void ShowHeaderUnits(QTableWidget *table, int column, const QString &unit); + static void ShowHeaderUnits(QTableWidget *table, int column, const QString &unit); void MeasurementsWereSaved(bool saved); void SetCurrentFile(const QString &fileName); - bool SaveMeasurements(const QString &fileName, QString &error); + auto SaveMeasurements(const QString &fileName, QString &error) -> bool; - bool MaybeSave(); + auto MaybeSave() -> bool; - QTableWidgetItem *AddCell(const QString &text, int row, int column, int aligment, bool ok = true); - QTableWidgetItem* AddSeparatorCell(const QString &text, int row, int column, int aligment, bool ok = true); + auto AddCell(const QString &text, int row, int column, int aligment, bool ok = true) -> QTableWidgetItem *; + auto AddSeparatorCell(const QString &text, int row, int column, int aligment, bool ok = true) -> QTableWidgetItem*; void RefreshData(bool freshCall = false); void RefreshTable(bool freshCall = false); + void RefreshMeasurementData(const QSharedPointer &meash, qint32 currentRow); - QString GetCustomName() const; - QString ClearCustomName(const QString &name) const; + auto GetCustomName() const -> QString; + static auto ClearCustomName(const QString &name) -> QString; - bool EvalFormula(const QString &formula, bool fromUser, VContainer *data, QLabel *label, bool specialUnits); + auto EvalFormula(const QString &formula, bool fromUser, VContainer *data, QLabel *label, bool specialUnits) -> bool; void ShowMDiagram(const QString &name); void Open(const QString &pathTo, const QString &filter); @@ -232,11 +246,11 @@ private: void ReadSettings(); void WriteSettings(); - QStringList FilterMeasurements(const QStringList &mNew, const QStringList &mFilter); + static auto FilterMeasurements(const QStringList &mNew, const QStringList &mFilter) -> QStringList; void UpdatePatternUnit(); - bool LoadFromExistingFile(const QString &path); + auto LoadFromExistingFile(const QString &path) -> bool; void CreateWindowMenu(QMenu *menu); @@ -245,12 +259,14 @@ private: void HackDimensionBaseValue(); void HackDimensionShifts(); - QString CheckMName(const QString &name, const QSet &importedNames) const; + auto CheckMName(const QString &name, const QSet &importedNames) const -> QString; void ShowError(const QString &text); void RefreshDataAfterImport(); void ImportIndividualMeasurements(const QxtCsvModel &csv, const QVector &map); void ImportMultisizeMeasurements(const QxtCsvModel &csv, const QVector &map); + auto ImportMultisizeMeasurement(const QxtCsvModel &csv, int i, const QVector &map, + int dimensionsCount, QSet &importedNames) -> MultisizeMeasurement; void SetCurrentPatternUnit(); @@ -258,9 +274,9 @@ private: void SetDimensionBases(); void SetCurrentDimensionValues(); - QVector DimensionRestrictedValues(int index, const MeasurementDimension_p &dimension); + auto DimensionRestrictedValues(int index, const MeasurementDimension_p &dimension) -> QVector; - QMap > OrderedMeasurments() const; + auto OrderedMeasurments() const -> QMap >; }; #endif // TMAINWINDOW_H diff --git a/src/app/tape/version.h b/src/app/tape/version.h index ff4a5803b..686e09ddd 100644 --- a/src/app/tape/version.h +++ b/src/app/tape/version.h @@ -29,11 +29,9 @@ #ifndef VERSION_H #define VERSION_H -#include "../../libs/vmisc/projectversion.h" - -#define VER_INTERNALNAME_STR "Tape" -#define VER_ORIGINALFILENAME_STR "tape.exe" -#define VER_PRODUCTNAME_STR "Tape" -#define VER_FILEDESCRIPTION_STR "Valentina's measurements editor." +#define VER_INTERNALNAME_STR "Tape" // NOLINT(cppcoreguidelines-macro-usage) +#define VER_ORIGINALFILENAME_STR "tape.exe" // NOLINT(cppcoreguidelines-macro-usage) +#define VER_PRODUCTNAME_STR "Tape" // NOLINT(cppcoreguidelines-macro-usage) +#define VER_FILEDESCRIPTION_STR "Valentina's measurements editor." // NOLINT(cppcoreguidelines-macro-usage) #endif // VERSION_H diff --git a/src/app/tape/vlitepattern.cpp b/src/app/tape/vlitepattern.cpp index f184a24a6..92857b854 100644 --- a/src/app/tape/vlitepattern.cpp +++ b/src/app/tape/vlitepattern.cpp @@ -52,17 +52,17 @@ void VLitePattern::DecrementReferens(quint32 id) const } //--------------------------------------------------------------------------------------------------------------------- -QString VLitePattern::GenerateLabel(const LabelType &type, const QString &reservedName) const +auto VLitePattern::GenerateLabel(const LabelType &type, const QString &reservedName) const -> QString { Q_UNUSED(type) Q_UNUSED(reservedName) - return QString(); + return {}; } //--------------------------------------------------------------------------------------------------------------------- -QString VLitePattern::GenerateSuffix() const +auto VLitePattern::GenerateSuffix() const -> QString { - return QString(); + return {}; } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/tape/vlitepattern.h b/src/app/tape/vlitepattern.h index d825ab759..26861d00d 100644 --- a/src/app/tape/vlitepattern.h +++ b/src/app/tape/vlitepattern.h @@ -33,25 +33,26 @@ class VLitePattern : public VAbstractPattern { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit VLitePattern(QObject *parent = nullptr); + ~VLitePattern() override = default; - virtual void CreateEmptyFile() override; + void CreateEmptyFile() override; - virtual void IncrementReferens(quint32 id) const override; - virtual void DecrementReferens(quint32 id) const override; + void IncrementReferens(quint32 id) const override; + void DecrementReferens(quint32 id) const override; - virtual QString GenerateLabel(const LabelType &type, const QString &reservedName = QString())const override; - virtual QString GenerateSuffix() const override; + auto GenerateLabel(const LabelType &type, const QString &reservedName = QString())const -> QString override; + auto GenerateSuffix() const -> QString override; - virtual void UpdateToolData(const quint32 &id, VContainer *data) override; + void UpdateToolData(const quint32 &id, VContainer *data) override; public slots: - virtual void LiteParseTree(const Document &parse) override; + void LiteParseTree(const Document &parse) override; private: - Q_DISABLE_COPY(VLitePattern) + Q_DISABLE_COPY_MOVE(VLitePattern) // NOLINT }; #endif // VLITEPATTERN_H diff --git a/src/app/tape/vtapesettings.cpp b/src/app/tape/vtapesettings.cpp index 7c9b80583..3daa0025a 100644 --- a/src/app/tape/vtapesettings.cpp +++ b/src/app/tape/vtapesettings.cpp @@ -36,15 +36,15 @@ namespace { -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingDataBaseGeometry, (QLatin1String("database/geometry"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchHistoryTape, (QLatin1String("searchHistory/tape"))) +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingDataBaseGeometry, (QLatin1String("database/geometry"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchHistoryTape, (QLatin1String("searchHistory/tape"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsTapeUseUnicodeProperties, +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsTapeUseUnicodeProperties, // NOLINT (QLatin1String("searchOptions/tapeUseUnicodeProperties"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsTapeWholeWord, +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsTapeWholeWord, // NOLINT (QLatin1String("searchOptions/tapeWholeWord"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsTapeRegexp, (QLatin1String("searchOptions/tapeRegexp"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsTapeMatchCase, +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsTapeRegexp, (QLatin1String("searchOptions/tapeRegexp"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsTapeMatchCase, // NOLINT (QLatin1String("searchOptions/tapeMatchCase"))) } // namespace @@ -56,7 +56,7 @@ VTapeSettings::VTapeSettings(Format format, Scope scope, const QString &organiza } //--------------------------------------------------------------------------------------------------------------------- -QByteArray VTapeSettings::GetDataBaseGeometry() const +auto VTapeSettings::GetDataBaseGeometry() const -> QByteArray { return value(*settingDataBaseGeometry).toByteArray(); } diff --git a/src/app/tape/vtapesettings.h b/src/app/tape/vtapesettings.h index 0543fe569..08f0c2780 100644 --- a/src/app/tape/vtapesettings.h +++ b/src/app/tape/vtapesettings.h @@ -41,12 +41,13 @@ class VTapeSettings : public VCommonSettings { - Q_OBJECT + Q_OBJECT // NOLINT public: VTapeSettings(Format format, Scope scope, const QString &organization, const QString &application = QString(), QObject *parent = nullptr); + ~VTapeSettings() override = default; - QByteArray GetDataBaseGeometry() const; + auto GetDataBaseGeometry() const -> QByteArray; void SetDataBaseGeometry(const QByteArray &value); auto GetTapeSearchHistory() const -> QStringList; @@ -65,7 +66,7 @@ public: void SetTapeSearchOptionMatchCase(bool value); private: - Q_DISABLE_COPY(VTapeSettings) + Q_DISABLE_COPY_MOVE(VTapeSettings) // NOLINT }; #endif // VTAPESETTINGS_H diff --git a/src/app/valentina/core/vapplication.cpp b/src/app/valentina/core/vapplication.cpp index a33470e16..593dbd1e4 100644 --- a/src/app/valentina/core/vapplication.cpp +++ b/src/app/valentina/core/vapplication.cpp @@ -37,6 +37,7 @@ #include "../qmuparser/qmuparsererror.h" #include "../mainwindow.h" #include "../vmisc/qt_dispatch/qt_dispatch.h" +#include "../vmisc/vsysexits.h" #include "vvalentinasettings.h" #include @@ -66,7 +67,7 @@ namespace { auto AppFilePath(const QString &appName) -> QString { - QString appNameExe = appName; + QString appNameExe = appName; // NOLINT(performance-unnecessary-copy-initialization) #ifdef Q_OS_WIN appNameExe += ".exe"; #endif @@ -417,7 +418,7 @@ auto VApplication::notify(QObject *receiver, QEvent *event) -> bool catch (const VExceptionToolWasDeleted &e) { qCCritical(vApp, "%s\n\n%s\n\n%s", - qUtf8Printable("Unhadled deleting tool. Continue use object after deleting"), + qUtf8Printable(QStringLiteral("Unhadled deleting tool. Continue use object after deleting")), qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation())); exit(V_EX_DATAERR); } @@ -469,7 +470,7 @@ void VApplication::ActivateDarkMode() { f.open(QFile::ReadOnly | QFile::Text); QTextStream ts(&f); - qApp->setStyleSheet(ts.readAll()); + qApp->setStyleSheet(ts.readAll()); // NOLINT(cppcoreguidelines-pro-type-static-cast-downcast) } } } @@ -550,45 +551,45 @@ void VApplication::ClearOldLogs() logsDir.setNameFilters(QStringList(QStringLiteral("*.log"))); QDir::setCurrent(LogDirPath()); + // Restore working directory + auto restore = qScopeGuard([workingDirectory] { QDir::setCurrent(workingDirectory); }); + const QStringList allFiles = logsDir.entryList(QDir::NoDotAndDotDot | QDir::Files); - if (not allFiles.isEmpty()) + if (allFiles.isEmpty()) { - qCDebug(vApp, "Clearing old logs"); - for (const auto &fn : allFiles) - { - QFileInfo info(fn); + qCDebug(vApp, "There are no old logs."); + return; + } + + qCDebug(vApp, "Clearing old logs"); + for (const auto &fn : allFiles) + { + QFileInfo info(fn); #if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0) - const QDateTime created = info.birthTime(); + const QDateTime created = info.birthTime(); #else - const QDateTime created = info.created(); + const QDateTime created = info.created(); #endif - if (created.daysTo(QDateTime::currentDateTime()) >= DAYS_TO_KEEP_LOGS) + if (created.daysTo(QDateTime::currentDateTime()) >= DAYS_TO_KEEP_LOGS) + { + VLockGuard tmp(info.absoluteFilePath(), [&fn](){return new QFile(fn);}); + if (tmp.GetProtected() != nullptr) { - VLockGuard tmp(info.absoluteFilePath(), [&fn](){return new QFile(fn);}); - if (tmp.GetProtected() != nullptr) + if (tmp.GetProtected()->remove()) { - if (tmp.GetProtected()->remove()) - { - qCDebug(vApp, "Deleted %s", qUtf8Printable(info.absoluteFilePath())); - } - else - { - qCDebug(vApp, "Could not delete %s", qUtf8Printable(info.absoluteFilePath())); - } + qCDebug(vApp, "Deleted %s", qUtf8Printable(info.absoluteFilePath())); } else { - qCDebug(vApp, "Failed to lock %s", qUtf8Printable(info.absoluteFilePath())); + qCDebug(vApp, "Could not delete %s", qUtf8Printable(info.absoluteFilePath())); } } + else + { + qCDebug(vApp, "Failed to lock %s", qUtf8Printable(info.absoluteFilePath())); + } } } - else - { - qCDebug(vApp, "There are no old logs."); - } - - QDir::setCurrent(workingDirectory); // Restore working directory } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/valentina/core/vapplication.h b/src/app/valentina/core/vapplication.h index d262f7376..1cd673aa2 100644 --- a/src/app/valentina/core/vapplication.h +++ b/src/app/valentina/core/vapplication.h @@ -43,7 +43,6 @@ class VApplication : public VAbstractValApplication { Q_OBJECT // NOLINT public: - VApplication(int &argc, char ** argv); ~VApplication() override; diff --git a/src/app/valentina/core/vcmdexport.cpp b/src/app/valentina/core/vcmdexport.cpp index b33968238..19c681de9 100644 --- a/src/app/valentina/core/vcmdexport.cpp +++ b/src/app/valentina/core/vcmdexport.cpp @@ -30,36 +30,35 @@ #include "../dialogs/dialoglayoutsettings.h" #include "../dialogs/dialogsavelayout.h" #include "../ifc/xml/vdomdocument.h" -#include "../vformat/vmeasurements.h" #include "../vmisc/commandoptions.h" +#include "../vmisc/vsysexits.h" #include "vvalentinasettings.h" #include "../vmisc/dialogs/dialogexporttocsv.h" #include "../vlayout/vlayoutgenerator.h" -#include "../vpatterndb/variables/vmeasurement.h" #include #include -VCommandLinePtr VCommandLine::instance = nullptr; +VCommandLinePtr VCommandLine::instance = nullptr; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables) -#define translate(context, source) QCoreApplication::translate((context), (source)) +#define translate(context, source) QCoreApplication::translate((context), (source)) // NOLINT(cppcoreguidelines-macro-usage) namespace { //--------------------------------------------------------------------------------------------------------------------- -qreal Lo2Px(const QString &src, const DialogLayoutSettings &converter, bool *ok) +auto Lo2Px(const QString &src, const DialogLayoutSettings &converter, bool *ok) -> qreal { return converter.LayoutToPixels(src.toDouble(ok)); } //--------------------------------------------------------------------------------------------------------------------- -qreal Pg2Px(const QString& src, const DialogLayoutSettings& converter, bool *ok) +auto Pg2Px(const QString& src, const DialogLayoutSettings& converter, bool *ok) -> qreal { return converter.PageToPixels(src.toDouble(ok)); } } // anonymous namespace //--------------------------------------------------------------------------------------------------------------------- -VCommandLine::VCommandLine() : parser(), isGuiEnabled(false) +VCommandLine::VCommandLine() { parser.setApplicationDescription(translate("VCommandLine", "Pattern making program.")); parser.addHelpOption(); @@ -70,7 +69,7 @@ VCommandLine::VCommandLine() : parser(), isGuiEnabled(false) } //--------------------------------------------------------------------------------------------------------------------- -VAbstractLayoutDialog::PaperSizeTemplate VCommandLine::FormatSize(const QString &key) const +auto VCommandLine::FormatSize(const QString &key) const -> VAbstractLayoutDialog::PaperSizeTemplate { int ppsize = 0; if (IsOptionSet(key)) @@ -81,83 +80,16 @@ VAbstractLayoutDialog::PaperSizeTemplate VCommandLine::FormatSize(const QString } //--------------------------------------------------------------------------------------------------------------------- -VLayoutGeneratorPtr VCommandLine::DefaultGenerator() const +auto VCommandLine::DefaultGenerator() const -> VLayoutGeneratorPtr { //this functions covers all options found into layout setup dialog, nothing to add here, unless dialog extended VLayoutGeneratorPtr res(new VLayoutGenerator()); DialogLayoutSettings diag(res.get(), nullptr, true); - { - //just anonymous namespace ...don' like to have a,b,c,d everywhere defined - bool x = IsOptionSet(LONG_OPTION_PAGETEMPLATE); - - bool a = IsOptionSet(LONG_OPTION_PAGEH); - bool b = IsOptionSet(LONG_OPTION_PAGEW); - bool c = IsOptionSet(LONG_OPTION_PAGEUNITS); - - if ((a || b) && x) - { - qCritical() << translate("VCommandLine", "Cannot use pageformat and page explicit size together.") - << "\n"; - const_cast(this)->parser.showHelp(V_EX_USAGE); - } - - if ((a || b || c) && !(a && b && c)) - { - qCritical() << translate("VCommandLine", "Page height, width, units must be used all 3 at once.") << "\n"; - const_cast(this)->parser.showHelp(V_EX_USAGE); - } - - } - - { - //just anonymous namespace ...don' like to have a,b,c,d everywhere defined - bool a = IsOptionSet(LONG_OPTION_GAPWIDTH); - bool b = IsOptionSet(LONG_OPTION_SHIFTUNITS); - - if ((a || b) && !(a && b)) - { - qCritical() << translate("VCommandLine", "Gap width must be used together with shift units.") << "\n"; - const_cast(this)->parser.showHelp(V_EX_USAGE); - } - } - - auto CheckKey = [this](const QString &key, const QString &message) - { - bool a = IsOptionSet(key); - bool b = IsOptionSet(LONG_OPTION_PAGEUNITS); - - if (a && !(a && b)) - { - qCritical() << message << "\n"; - const_cast(this)->parser.showHelp(V_EX_USAGE); - } - }; - - if (not IsOptionSet(LONG_OPTION_IGNORE_MARGINS)) - { - CheckKey(LONG_OPTION_LEFT_MARGIN, - translate("VCommandLine", "Left margin must be used together with page units.")); - CheckKey(LONG_OPTION_RIGHT_MARGIN, - translate("VCommandLine", "Right margin must be used together with page units.")); - CheckKey(LONG_OPTION_TOP_MARGIN, - translate("VCommandLine", "Top margin must be used together with page units.")); - CheckKey(LONG_OPTION_BOTTOM_MARGIN, - translate("VCommandLine", "Bottom margin must be used together with page units.")); - } - - if (static_cast(OptExportType()) == LayoutExportFormats::PDFTiled) - { - CheckKey(LONG_OPTION_TILED_PDF_LEFT_MARGIN, - translate("VCommandLine", "Tiled left margin must be used together with page units.")); - CheckKey(LONG_OPTION_TILED_PDF_RIGHT_MARGIN, - translate("VCommandLine", "Tiled right margin must be used together with page units.")); - CheckKey(LONG_OPTION_TILED_PDF_TOP_MARGIN, - translate("VCommandLine", "Tiled top margin must be used together with page units.")); - CheckKey(LONG_OPTION_TILED_PDF_BOTTOM_MARGIN, - translate("VCommandLine", "Tiled bottom margin must be used together with page units.")); - } + TestPageformat(); + TestGapWidth(); + TestMargins(); // if present units MUST be set before any other to keep conversions correct if (!diag.SelectTemplate(OptPaperSize())) @@ -234,57 +166,7 @@ VLayoutGeneratorPtr VCommandLine::DefaultGenerator() const diag.SetIgnoreAllFields(true); } - QMarginsF margins = diag.GetFields(); - - if (IsOptionSet(LONG_OPTION_LEFT_MARGIN)) - { - bool ok = false; - qreal margin = Pg2Px(OptionValue(LONG_OPTION_LEFT_MARGIN), diag, &ok); - if (not ok) - { - qCritical() << translate("VCommandLine", "Invalid layout page left margin.") << "\n"; - const_cast(this)->parser.showHelp(V_EX_USAGE); - } - margins.setLeft(margin); - } - - if (IsOptionSet(LONG_OPTION_RIGHT_MARGIN)) - { - bool ok = false; - qreal margin = Pg2Px(OptionValue(LONG_OPTION_RIGHT_MARGIN), diag, &ok); - if (not ok) - { - qCritical() << translate("VCommandLine", "Invalid layout page right margin.") << "\n"; - const_cast(this)->parser.showHelp(V_EX_USAGE); - } - margins.setRight(margin); - } - - if (IsOptionSet(LONG_OPTION_TOP_MARGIN)) - { - bool ok = false; - qreal margin = Pg2Px(OptionValue(LONG_OPTION_TOP_MARGIN), diag, &ok); - if (not ok) - { - qCritical() << translate("VCommandLine", "Invalid layout page top margin.") << "\n"; - const_cast(this)->parser.showHelp(V_EX_USAGE); - } - margins.setTop(margin); - } - - if (IsOptionSet(LONG_OPTION_BOTTOM_MARGIN)) - { - bool ok = false; - qreal margin = Pg2Px(OptionValue(LONG_OPTION_BOTTOM_MARGIN), diag, &ok); - if (not ok) - { - qCritical() << translate("VCommandLine", "Invalid layout page bottom margin.") << "\n"; - const_cast(this)->parser.showHelp(V_EX_USAGE); - } - margins.setBottom(margin); - } - - diag.SetFields(margins); + diag.SetFields(ParseMargins(diag)); diag.SetFollowGrainline(IsOptionSet(LONG_OPTION_FOLLOW_GRAINLINE)); diag.SetManualPriority(IsOptionSet(LONG_OPTION_MANUAL_PRIORITY)); diag.SetNestQuantity(IsOptionSet(LONG_OPTION_NEST_QUANTITY)); @@ -296,8 +178,8 @@ VLayoutGeneratorPtr VCommandLine::DefaultGenerator() const return res; } -//------------------------------------------------------------------------------------------------------ -VCommandLinePtr VCommandLine::Get(const QCoreApplication& app) +//--------------------------------------------------------------------------------------------------------------------- +auto VCommandLine::Get(const QCoreApplication& app) -> VCommandLinePtr { if (instance == nullptr) { @@ -313,14 +195,14 @@ VCommandLinePtr VCommandLine::Get(const QCoreApplication& app) return instance; } -//------------------------------------------------------------------------------------------------------ +//--------------------------------------------------------------------------------------------------------------------- void VCommandLine::Reset() { instance.reset(); } //--------------------------------------------------------------------------------------------------------------------- -bool VCommandLine::IsTestModeEnabled() const +auto VCommandLine::IsTestModeEnabled() const -> bool { const bool r = IsOptionSet(LONG_OPTION_TEST); if (r && parser.positionalArguments().size() != 1) @@ -332,20 +214,20 @@ bool VCommandLine::IsTestModeEnabled() const } //--------------------------------------------------------------------------------------------------------------------- -bool VCommandLine::IsPedantic() const +auto VCommandLine::IsPedantic() const -> bool { // Pedantic doesn't work in GUI mode return IsGuiEnabled() ? false : IsOptionSet(LONG_OPTION_PENDANTIC); } //--------------------------------------------------------------------------------------------------------------------- -bool VCommandLine::IsNoScalingEnabled() const +auto VCommandLine::IsNoScalingEnabled() const -> bool { return IsOptionSet(LONG_OPTION_NO_HDPI_SCALING); } //--------------------------------------------------------------------------------------------------------------------- -bool VCommandLine::IsExportEnabled() const +auto VCommandLine::IsExportEnabled() const -> bool { const bool r = IsOptionSet(LONG_OPTION_BASENAME); if (r && parser.positionalArguments().size() != 1) @@ -357,7 +239,7 @@ bool VCommandLine::IsExportEnabled() const } //--------------------------------------------------------------------------------------------------------------------- -bool VCommandLine::IsExportFMEnabled() const +auto VCommandLine::IsExportFMEnabled() const -> bool { const bool r = IsOptionSet(LONG_OPTION_CSVEXPORTFM); if (r && parser.positionalArguments().size() != 1) @@ -368,14 +250,14 @@ bool VCommandLine::IsExportFMEnabled() const return r; } -//------------------------------------------------------------------------------------------------------ -VAbstractLayoutDialog::PaperSizeTemplate VCommandLine::OptPaperSize() const +//--------------------------------------------------------------------------------------------------------------------- +auto VCommandLine::OptPaperSize() const -> VAbstractLayoutDialog::PaperSizeTemplate { return FormatSize(LONG_OPTION_PAGETEMPLATE); } -//------------------------------------------------------------------------------------------------------ -Cases VCommandLine::OptGroup() const +//--------------------------------------------------------------------------------------------------------------------- +auto VCommandLine::OptGroup() const -> Cases { int r = OptionValue(LONG_OPTION_GROUPPING).toInt(); if ( r < 0 || r >= static_cast(Cases::UnknownCase)) @@ -385,8 +267,8 @@ Cases VCommandLine::OptGroup() const return static_cast(r); } -//------------------------------------------------------------------------------------------------------ -QString VCommandLine::OptMeasurePath() const +//--------------------------------------------------------------------------------------------------------------------- +auto VCommandLine::OptMeasurePath() const -> QString { QString measure; if (IsOptionSet(LONG_OPTION_MEASUREFILE) @@ -401,7 +283,7 @@ QString VCommandLine::OptMeasurePath() const } //--------------------------------------------------------------------------------------------------------------------- -QString VCommandLine::OptBaseName() const +auto VCommandLine::OptBaseName() const -> QString { QString path; if (IsExportEnabled()) @@ -413,7 +295,7 @@ QString VCommandLine::OptBaseName() const } //--------------------------------------------------------------------------------------------------------------------- -QString VCommandLine::OptDestinationPath() const +auto VCommandLine::OptDestinationPath() const -> QString { QString path; if (IsExportEnabled()) @@ -425,7 +307,7 @@ QString VCommandLine::OptDestinationPath() const } //--------------------------------------------------------------------------------------------------------------------- -int VCommandLine::OptExportType() const +auto VCommandLine::OptExportType() const -> int { int r = 0; if (IsOptionSet(LONG_OPTION_EXP2FORMAT)) @@ -436,31 +318,31 @@ int VCommandLine::OptExportType() const } //--------------------------------------------------------------------------------------------------------------------- -bool VCommandLine::IsBinaryDXF() const +auto VCommandLine::IsBinaryDXF() const -> bool { return IsOptionSet(LONG_OPTION_BINARYDXF); } //--------------------------------------------------------------------------------------------------------------------- -bool VCommandLine::IsTextAsPaths() const +auto VCommandLine::IsTextAsPaths() const -> bool { return IsOptionSet(LONG_OPTION_TEXT2PATHS); } //--------------------------------------------------------------------------------------------------------------------- -bool VCommandLine::IsExportOnlyDetails() const +auto VCommandLine::IsExportOnlyDetails() const -> bool { return IsOptionSet(LONG_OPTION_EXPORTONLYDETAILS); } //--------------------------------------------------------------------------------------------------------------------- -bool VCommandLine::IsCSVWithHeader() const +auto VCommandLine::IsCSVWithHeader() const -> bool { return IsOptionSet(LONG_OPTION_CSVWITHHEADER); } //--------------------------------------------------------------------------------------------------------------------- -qreal VCommandLine::ExportXScale() const +auto VCommandLine::ExportXScale() const -> qreal { qreal xs = 1; if (IsOptionSet(LONG_OPTION_EXPXSCALE)) @@ -471,7 +353,7 @@ qreal VCommandLine::ExportXScale() const } //--------------------------------------------------------------------------------------------------------------------- -qreal VCommandLine::ExportYScale() const +auto VCommandLine::ExportYScale() const -> qreal { qreal ys = 1; if (IsOptionSet(LONG_OPTION_EXPYSCALE)) @@ -482,7 +364,7 @@ qreal VCommandLine::ExportYScale() const } //--------------------------------------------------------------------------------------------------------------------- -QString VCommandLine::OptExportSuchDetails() const +auto VCommandLine::OptExportSuchDetails() const -> QString { QString path; if (IsExportEnabled()) @@ -494,30 +376,30 @@ QString VCommandLine::OptExportSuchDetails() const } //--------------------------------------------------------------------------------------------------------------------- -QString VCommandLine::OptCSVCodecName() const +auto VCommandLine::OptCSVCodecName() const -> QString { return OptionValue(LONG_OPTION_CSVCODEC); } //--------------------------------------------------------------------------------------------------------------------- -QChar VCommandLine::OptCSVSeparator() const +auto VCommandLine::OptCSVSeparator() const -> QChar { const QString value = OptionValue(LONG_OPTION_CSVSEPARATOR); return not value.isEmpty() ? value.at(0) : QChar(); } //--------------------------------------------------------------------------------------------------------------------- -QString VCommandLine::OptExportFMTo() const +auto VCommandLine::OptExportFMTo() const -> QString { return OptionValue(LONG_OPTION_CSVEXPORTFM); } //--------------------------------------------------------------------------------------------------------------------- -QMap VCommandLine::OptUserMaterials() const +auto VCommandLine::OptUserMaterials() const -> QMap { QMap userMaterials; const QStringList values = OptionValues(LONG_OPTION_USER_MATERIAL); - for(auto &value : values) + for(const auto &value : values) { const QStringList parts = value.split('@'); if (parts.size() != 2) @@ -544,37 +426,37 @@ QMap VCommandLine::OptUserMaterials() const } //--------------------------------------------------------------------------------------------------------------------- -QStringList VCommandLine::OptInputFileNames() const +auto VCommandLine::OptInputFileNames() const -> QStringList { return parser.positionalArguments(); } //--------------------------------------------------------------------------------------------------------------------- -bool VCommandLine::IsGuiEnabled() const +auto VCommandLine::IsGuiEnabled() const -> bool { return isGuiEnabled; } //--------------------------------------------------------------------------------------------------------------------- -bool VCommandLine::IsSetDimensionA() const +auto VCommandLine::IsSetDimensionA() const -> bool { return IsOptionSet(LONG_OPTION_DIMENSION_A); } //--------------------------------------------------------------------------------------------------------------------- -bool VCommandLine::IsSetDimensionB() const +auto VCommandLine::IsSetDimensionB() const -> bool { return IsOptionSet(LONG_OPTION_DIMENSION_B); } //--------------------------------------------------------------------------------------------------------------------- -bool VCommandLine::IsSetDimensionC() const +auto VCommandLine::IsSetDimensionC() const -> bool { return IsOptionSet(LONG_OPTION_DIMENSION_C); } //--------------------------------------------------------------------------------------------------------------------- -int VCommandLine::OptDimensionA() const +auto VCommandLine::OptDimensionA() const -> int { const QString value = OptionValue(LONG_OPTION_DIMENSION_A); @@ -590,7 +472,7 @@ int VCommandLine::OptDimensionA() const } //--------------------------------------------------------------------------------------------------------------------- -int VCommandLine::OptDimensionB() const +auto VCommandLine::OptDimensionB() const -> int { const QString value = OptionValue(LONG_OPTION_DIMENSION_B); @@ -606,7 +488,7 @@ int VCommandLine::OptDimensionB() const } //--------------------------------------------------------------------------------------------------------------------- -int VCommandLine::OptDimensionC() const +auto VCommandLine::OptDimensionC() const -> int { const QString value = OptionValue(LONG_OPTION_DIMENSION_C); @@ -692,13 +574,13 @@ auto VCommandLine::TiledPageMargins() const -> QMarginsF } //--------------------------------------------------------------------------------------------------------------------- -VAbstractLayoutDialog::PaperSizeTemplate VCommandLine::OptTiledPaperSize() const +auto VCommandLine::OptTiledPaperSize() const -> VAbstractLayoutDialog::PaperSizeTemplate { return FormatSize(LONG_OPTION_TILED_PDF_PAGE_TEMPLATE); } //--------------------------------------------------------------------------------------------------------------------- -PageOrientation VCommandLine::OptTiledPageOrientation() const +auto VCommandLine::OptTiledPageOrientation() const -> PageOrientation { return static_cast(not IsOptionSet(LONG_OPTION_TILED_PDF_LANDSCAPE)); } @@ -892,25 +774,25 @@ void VCommandLine::InitCommandLineOptions() } //--------------------------------------------------------------------------------------------------------------------- -bool VCommandLine::IsOptionSet(const QString &option) const +auto VCommandLine::IsOptionSet(const QString &option) const -> bool { return parser.isSet(option); } //--------------------------------------------------------------------------------------------------------------------- -QString VCommandLine::OptionValue(const QString &option) const +auto VCommandLine::OptionValue(const QString &option) const -> QString { return parser.value(option); } //--------------------------------------------------------------------------------------------------------------------- -QStringList VCommandLine::OptionValues(const QString &option) const +auto VCommandLine::OptionValues(const QString &option) const -> QStringList { return parser.values(option); } //--------------------------------------------------------------------------------------------------------------------- -int VCommandLine::OptNestingTime() const +auto VCommandLine::OptNestingTime() const -> int { int time = VValentinaSettings::GetDefNestingTime(); if (IsOptionSet(LONG_OPTION_NESTING_TIME)) @@ -930,7 +812,7 @@ int VCommandLine::OptNestingTime() const } //--------------------------------------------------------------------------------------------------------------------- -qreal VCommandLine::OptEfficiencyCoefficient() const +auto VCommandLine::OptEfficiencyCoefficient() const -> qreal { qreal coefficient = VValentinaSettings::GetDefEfficiencyCoefficient(); if (IsOptionSet(LONG_OPTION_EFFICIENCY_COEFFICIENT)) @@ -949,4 +831,136 @@ qreal VCommandLine::OptEfficiencyCoefficient() const return coefficient; } +//--------------------------------------------------------------------------------------------------------------------- +void VCommandLine::TestPageformat() const +{ + bool x = IsOptionSet(LONG_OPTION_PAGETEMPLATE); + + bool a = IsOptionSet(LONG_OPTION_PAGEH); + bool b = IsOptionSet(LONG_OPTION_PAGEW); + bool c = IsOptionSet(LONG_OPTION_PAGEUNITS); + + if ((a || b) && x) + { + qCritical() << translate("VCommandLine", "Cannot use pageformat and page explicit size together.") + << "\n"; + const_cast(this)->parser.showHelp(V_EX_USAGE); + } + + if ((a || b || c) && !(a && b && c)) + { + qCritical() << translate("VCommandLine", "Page height, width, units must be used all 3 at once.") << "\n"; + const_cast(this)->parser.showHelp(V_EX_USAGE); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void VCommandLine::TestGapWidth() const +{ + bool a = IsOptionSet(LONG_OPTION_GAPWIDTH); + bool b = IsOptionSet(LONG_OPTION_SHIFTUNITS); + + if ((a || b) && !(a && b)) + { + qCritical() << translate("VCommandLine", "Gap width must be used together with shift units.") << "\n"; + const_cast(this)->parser.showHelp(V_EX_USAGE); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void VCommandLine::TestMargins() const +{ + auto CheckKey = [this](const QString &key, const QString &message) + { + bool a = IsOptionSet(key); + bool b = IsOptionSet(LONG_OPTION_PAGEUNITS); + + if (a && !(a && b)) + { + qCritical() << message << "\n"; + const_cast(this)->parser.showHelp(V_EX_USAGE); + } + }; + + if (not IsOptionSet(LONG_OPTION_IGNORE_MARGINS)) + { + CheckKey(LONG_OPTION_LEFT_MARGIN, + translate("VCommandLine", "Left margin must be used together with page units.")); + CheckKey(LONG_OPTION_RIGHT_MARGIN, + translate("VCommandLine", "Right margin must be used together with page units.")); + CheckKey(LONG_OPTION_TOP_MARGIN, + translate("VCommandLine", "Top margin must be used together with page units.")); + CheckKey(LONG_OPTION_BOTTOM_MARGIN, + translate("VCommandLine", "Bottom margin must be used together with page units.")); + } + + if (static_cast(OptExportType()) == LayoutExportFormats::PDFTiled) + { + CheckKey(LONG_OPTION_TILED_PDF_LEFT_MARGIN, + translate("VCommandLine", "Tiled left margin must be used together with page units.")); + CheckKey(LONG_OPTION_TILED_PDF_RIGHT_MARGIN, + translate("VCommandLine", "Tiled right margin must be used together with page units.")); + CheckKey(LONG_OPTION_TILED_PDF_TOP_MARGIN, + translate("VCommandLine", "Tiled top margin must be used together with page units.")); + CheckKey(LONG_OPTION_TILED_PDF_BOTTOM_MARGIN, + translate("VCommandLine", "Tiled bottom margin must be used together with page units.")); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +auto VCommandLine::ParseMargins(const DialogLayoutSettings &diag) const -> QMarginsF +{ + QMarginsF margins = diag.GetFields(); + + if (IsOptionSet(LONG_OPTION_LEFT_MARGIN)) + { + bool ok = false; + qreal margin = Pg2Px(OptionValue(LONG_OPTION_LEFT_MARGIN), diag, &ok); + if (not ok) + { + qCritical() << translate("VCommandLine", "Invalid layout page left margin.") << "\n"; + const_cast(this)->parser.showHelp(V_EX_USAGE); + } + margins.setLeft(margin); + } + + if (IsOptionSet(LONG_OPTION_RIGHT_MARGIN)) + { + bool ok = false; + qreal margin = Pg2Px(OptionValue(LONG_OPTION_RIGHT_MARGIN), diag, &ok); + if (not ok) + { + qCritical() << translate("VCommandLine", "Invalid layout page right margin.") << "\n"; + const_cast(this)->parser.showHelp(V_EX_USAGE); + } + margins.setRight(margin); + } + + if (IsOptionSet(LONG_OPTION_TOP_MARGIN)) + { + bool ok = false; + qreal margin = Pg2Px(OptionValue(LONG_OPTION_TOP_MARGIN), diag, &ok); + if (not ok) + { + qCritical() << translate("VCommandLine", "Invalid layout page top margin.") << "\n"; + const_cast(this)->parser.showHelp(V_EX_USAGE); + } + margins.setTop(margin); + } + + if (IsOptionSet(LONG_OPTION_BOTTOM_MARGIN)) + { + bool ok = false; + qreal margin = Pg2Px(OptionValue(LONG_OPTION_BOTTOM_MARGIN), diag, &ok); + if (not ok) + { + qCritical() << translate("VCommandLine", "Invalid layout page bottom margin.") << "\n"; + const_cast(this)->parser.showHelp(V_EX_USAGE); + } + margins.setBottom(margin); + } + + return margins; +} + #undef translate diff --git a/src/app/valentina/core/vcmdexport.h b/src/app/valentina/core/vcmdexport.h index 6bd7eb496..4d72c782d 100644 --- a/src/app/valentina/core/vcmdexport.h +++ b/src/app/valentina/core/vcmdexport.h @@ -36,7 +36,6 @@ #include #include "../dialogs/dialoglayoutsettings.h" -#include "../vmisc/vsysexits.h" class VCommandLine; using VCommandLinePtr = std::shared_ptr; @@ -54,110 +53,116 @@ public: //@brief tests if user enabled test mode from cmd, throws exception if not exactly 1 input VAL file supplied in //case test mode enabled - bool IsTestModeEnabled() const; + auto IsTestModeEnabled() const -> bool; //@brief Make all parsing warnings into errors. Have effect only in console mode. Use to force Valentina to //immediately terminate if a pattern contains a parsing warning. - bool IsPedantic() const; + auto IsPedantic() const -> bool; - bool IsNoScalingEnabled() const; + auto IsNoScalingEnabled() const -> bool; //@brief tests if user enabled export from cmd, throws exception if not exactly 1 input VAL file supplied in case //export enabled - bool IsExportEnabled() const; + auto IsExportEnabled() const -> bool; //@brief tests if user enabled export final measurements from cmd, throws exception if not exactly 1 input VAL //file supplied in case export enabled - bool IsExportFMEnabled() const; + auto IsExportFMEnabled() const -> bool; //@brief returns path to custom measure file or empty string - QString OptMeasurePath() const; + auto OptMeasurePath() const -> QString; //@brief returns the base name of layout files or empty string if not set - QString OptBaseName() const; + auto OptBaseName() const -> QString; //@brief returns the absolute path to output destination directory or path to application's current directory if //not set - QString OptDestinationPath() const; + auto OptDestinationPath() const -> QString; //@brief returns export type set, defaults 0 - svg - int OptExportType() const; + auto OptExportType() const -> int; - bool IsBinaryDXF() const; - bool IsTextAsPaths() const; - bool IsExportOnlyDetails() const; - bool IsCSVWithHeader() const; + auto IsBinaryDXF() const -> bool; + auto IsTextAsPaths() const -> bool; + auto IsExportOnlyDetails() const -> bool; + auto IsCSVWithHeader() const -> bool; - qreal ExportXScale() const; - qreal ExportYScale() const; + auto ExportXScale() const -> qreal; + auto ExportYScale() const -> qreal; //@brief returns the piece name regex or empty string if not set - QString OptExportSuchDetails() const; + auto OptExportSuchDetails() const -> QString; //@brief returns user selected csv codec or empty string if not set - QString OptCSVCodecName() const; + auto OptCSVCodecName() const -> QString; //@brief returns user selected csv separator or empty string if not set - QChar OptCSVSeparator() const; + auto OptCSVSeparator() const -> QChar; //@brief returns the destination path for export final measurements or empty string if not set - QString OptExportFMTo() const; + auto OptExportFMTo() const -> QString; //@brief returns list of user defined materials - QMap OptUserMaterials() const; + auto OptUserMaterials() const -> QMap; //generator creation is moved here ... because most options are for it only, so no need to create extra getters... //@brief creates VLayoutGenerator - VLayoutGeneratorPtr DefaultGenerator() const; + auto DefaultGenerator() const -> VLayoutGeneratorPtr; //@brief gets filenames which should be loaded - QStringList OptInputFileNames() const; + auto OptInputFileNames() const -> QStringList; - bool IsGuiEnabled()const; + auto IsGuiEnabled()const -> bool; - bool IsSetDimensionA() const; - bool IsSetDimensionB() const; - bool IsSetDimensionC() const; + auto IsSetDimensionA() const -> bool; + auto IsSetDimensionB() const -> bool; + auto IsSetDimensionC() const -> bool; - int OptDimensionA() const; - int OptDimensionB() const; - int OptDimensionC() const; + auto OptDimensionA() const -> int; + auto OptDimensionB() const -> int; + auto OptDimensionC() const -> int; - QMarginsF TiledPageMargins() const; - VAbstractLayoutDialog::PaperSizeTemplate OptTiledPaperSize() const; - PageOrientation OptTiledPageOrientation() const; + auto TiledPageMargins() const -> QMarginsF; + auto OptTiledPaperSize() const -> VAbstractLayoutDialog::PaperSizeTemplate; + auto OptTiledPageOrientation() const -> PageOrientation; protected: VCommandLine(); //@brief returns VAbstractLayoutDialog::PaperSizeTemplate - VAbstractLayoutDialog::PaperSizeTemplate OptPaperSize() const; + auto OptPaperSize() const -> VAbstractLayoutDialog::PaperSizeTemplate; - Cases OptGroup() const; + auto OptGroup() const -> Cases; //@brief: called in destructor of application, so instance destroyed and new maybe created (never happen scenario though) static void Reset(); //@brief called to create single object, by VApplication only - static VCommandLinePtr Get(const QCoreApplication& app); + static auto Get(const QCoreApplication& app) -> VCommandLinePtr; private: - Q_DISABLE_COPY(VCommandLine) - static VCommandLinePtr instance; - QCommandLineParser parser; - bool isGuiEnabled; + Q_DISABLE_COPY_MOVE(VCommandLine) // NOLINT + static VCommandLinePtr instance; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables) + QCommandLineParser parser{}; + bool isGuiEnabled{false}; friend class VApplication; - VAbstractLayoutDialog::PaperSizeTemplate FormatSize(const QString &key) const; + auto FormatSize(const QString &key) const -> VAbstractLayoutDialog::PaperSizeTemplate; void InitCommandLineOptions(); - bool IsOptionSet(const QString &option) const; - QString OptionValue(const QString &option) const; - QStringList OptionValues(const QString &option) const; + auto IsOptionSet(const QString &option) const -> bool; + auto OptionValue(const QString &option) const -> QString; + auto OptionValues(const QString &option) const -> QStringList; - int OptNestingTime() const; - qreal OptEfficiencyCoefficient() const; + auto OptNestingTime() const -> int; + auto OptEfficiencyCoefficient() const -> qreal; + + void TestPageformat() const; + void TestGapWidth() const; + void TestMargins() const; + + auto ParseMargins(const DialogLayoutSettings &diag) const -> QMarginsF; }; #endif // VCMDEXPORT_H diff --git a/src/app/valentina/core/vformulaproperty.cpp b/src/app/valentina/core/vformulaproperty.cpp index 0aba4d03e..9e64d7549 100644 --- a/src/app/valentina/core/vformulaproperty.cpp +++ b/src/app/valentina/core/vformulaproperty.cpp @@ -30,8 +30,8 @@ #include "vformulapropertyeditor.h" #include "../vpropertyexplorer/vproperty_p.h" +#include "../vpropertyexplorer/plugins/vstringproperty.h" #include "vformulapropertyeditor.h" -#include "../vpropertyexplorer/vproperties.h" #include "../vpatterndb/vformula.h" #include "../vmisc/vabstractapplication.h" @@ -41,7 +41,7 @@ VFormulaProperty::VFormulaProperty(const QString &name) { d_ptr->type = VPE::Property::Complex; - VPE::VStringProperty* tmpFormula = new VPE::VStringProperty(tr("Formula")); + auto* tmpFormula = new VPE::VStringProperty(tr("Formula")); addChild(tmpFormula); tmpFormula->setClearButtonEnable(true); tmpFormula->setUpdateBehaviour(true, false); @@ -53,41 +53,37 @@ VFormulaProperty::VFormulaProperty(const QString &name) //--------------------------------------------------------------------------------------------------------------------- //! Get the data how it should be displayed -QVariant VFormulaProperty::data (int column, int role) const +auto VFormulaProperty::data (int column, int role) const -> QVariant { if (column == DPC_Data && (Qt::DisplayRole == role || Qt::EditRole == role)) { return getValue(); } - else - { - return VProperty::data(column, role); - } + + return VProperty::data(column, role); } //--------------------------------------------------------------------------------------------------------------------- -Qt::ItemFlags VFormulaProperty::flags(int column) const +auto VFormulaProperty::flags(int column) const -> Qt::ItemFlags { if (column == DPC_Name || column == DPC_Data) { return Qt::ItemIsEnabled | Qt::ItemIsSelectable; } - else - { - return Qt::NoItemFlags; - } + + return Qt::NoItemFlags; } //--------------------------------------------------------------------------------------------------------------------- //! Returns an editor widget, or NULL if it doesn't supply one -QWidget* VFormulaProperty::createEditor(QWidget* parent, const QStyleOptionViewItem& options, - const QAbstractItemDelegate* delegate) +auto VFormulaProperty::createEditor(QWidget* parent, const QStyleOptionViewItem& options, + const QAbstractItemDelegate* delegate) -> QWidget* { Q_UNUSED(options) Q_UNUSED(delegate) - VFormula formula = VProperty::d_ptr->VariantValue.value(); - VFormulaPropertyEditor* tmpEditor = new VFormulaPropertyEditor(parent); + auto formula = VProperty::d_ptr->VariantValue.value(); + auto* tmpEditor = new VFormulaPropertyEditor(parent); tmpEditor->setLocale(parent->locale()); tmpEditor->SetFormula(formula); VProperty::d_ptr->editor = tmpEditor; @@ -96,25 +92,27 @@ QWidget* VFormulaProperty::createEditor(QWidget* parent, const QStyleOptionViewI //--------------------------------------------------------------------------------------------------------------------- //! Sets the property's data to the editor (returns false, if the standard delegate should do that) -bool VFormulaProperty::setEditorData(QWidget* editor) +auto VFormulaProperty::setEditorData(QWidget* editor) -> bool { - VFormulaPropertyEditor* tmpWidget = qobject_cast(editor); + auto* tmpWidget = qobject_cast(editor); if (tmpWidget) { - VFormula formula = VProperty::d_ptr->VariantValue.value(); + auto formula = VProperty::d_ptr->VariantValue.value(); tmpWidget->SetFormula(formula); } else + { return false; + } return true; } //--------------------------------------------------------------------------------------------------------------------- //! Gets the data from the widget -QVariant VFormulaProperty::getEditorData(const QWidget *editor) const +auto VFormulaProperty::getEditorData(const QWidget *editor) const -> QVariant { - const VFormulaPropertyEditor* tmpWidget = qobject_cast(editor); + const auto* tmpWidget = qobject_cast(editor); if (tmpWidget) { QVariant value; @@ -122,17 +120,17 @@ QVariant VFormulaProperty::getEditorData(const QWidget *editor) const return value; } - return QVariant(); + return {}; } //--------------------------------------------------------------------------------------------------------------------- -QString VFormulaProperty::type() const +auto VFormulaProperty::type() const -> QString { - return "formula"; + return QStringLiteral("formula"); } //--------------------------------------------------------------------------------------------------------------------- -VPE::VProperty *VFormulaProperty::clone(bool include_children, VProperty *container) const +auto VFormulaProperty::clone(bool include_children, VProperty *container) const -> VPE::VProperty * { if (!container) { @@ -141,7 +139,7 @@ VPE::VProperty *VFormulaProperty::clone(bool include_children, VProperty *contai if (!include_children) { const QList tmpChildren = container->getChildren(); - for (auto tmpChild : tmpChildren) + for (auto *tmpChild : tmpChildren) { container->removeChild(tmpChild); delete tmpChild; @@ -156,12 +154,12 @@ VPE::VProperty *VFormulaProperty::clone(bool include_children, VProperty *contai //--------------------------------------------------------------------------------------------------------------------- void VFormulaProperty::setValue(const QVariant &value) { - VFormula tmpFormula = value.value(); + auto tmpFormula = value.value(); SetFormula(tmpFormula); } //--------------------------------------------------------------------------------------------------------------------- -QVariant VFormulaProperty::getValue() const +auto VFormulaProperty::getValue() const -> QVariant { VFormula tmpFormula = GetFormula(); QVariant value; @@ -170,7 +168,7 @@ QVariant VFormulaProperty::getValue() const } //--------------------------------------------------------------------------------------------------------------------- -VFormula VFormulaProperty::GetFormula() const +auto VFormulaProperty::GetFormula() const -> VFormula { return VProperty::d_ptr->VariantValue.value(); } @@ -195,7 +193,7 @@ void VFormulaProperty::SetFormula(const VFormula &formula) if (VProperty::d_ptr->editor != nullptr) { - setEditorData(VProperty::d_ptr->editor); + setEditorData(VProperty::d_ptr->editor); // NOLINT(clang-analyzer-optin.cplusplus.VirtualCall) } } diff --git a/src/app/valentina/core/vformulaproperty.h b/src/app/valentina/core/vformulaproperty.h index 78e1e0ee7..a66f1adf2 100644 --- a/src/app/valentina/core/vformulaproperty.h +++ b/src/app/valentina/core/vformulaproperty.h @@ -35,56 +35,55 @@ class VFormula; class VFormulaProperty : public VPE::VProperty { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit VFormulaProperty(const QString &name); //! Get the data how it should be displayed - virtual QVariant data (int column = DPC_Name, int role = Qt::DisplayRole) const override; + auto data (int column = DPC_Name, int role = Qt::DisplayRole) const -> QVariant override; //! Returns item flags - virtual Qt::ItemFlags flags(int column = DPC_Name) const override; + auto flags(int column = DPC_Name) const -> Qt::ItemFlags override; //! Returns an editor widget, or NULL if it doesn't supply one //! \param parent The widget to which the editor will be added as a child //! \options Render options //! \delegate A pointer to the QAbstractItemDelegate requesting the editor. This can be used to connect signals and //! slots. - virtual QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& options, - const QAbstractItemDelegate* delegate) override; + auto createEditor(QWidget* parent, const QStyleOptionViewItem& options, + const QAbstractItemDelegate* delegate) -> QWidget* override; //! Sets the property's data to the editor (returns false, if the standard delegate should do that) - virtual bool setEditorData(QWidget* editor) override; + auto setEditorData(QWidget* editor) -> bool override; //! Gets the data from the widget - virtual QVariant getEditorData(const QWidget* editor) const override; + auto getEditorData(const QWidget* editor) const -> QVariant override; //! Returns a string containing the type of the property - virtual QString type() const override; + auto type() const -> QString override; //! Clones this property //! \param include_children Indicates whether to also clone the children //! \param container If a property is being passed here, no new VProperty is being created but instead it is tried //! to fill all the data into container. This can also be used when subclassing this function. //! \return Returns the newly created property (or container, if it was not NULL) - Q_REQUIRED_RESULT virtual VProperty* clone(bool include_children = true, - VProperty* container = nullptr) const override; + Q_REQUIRED_RESULT auto clone(bool include_children = true, + VProperty* container = nullptr) const -> VProperty* override; //! Sets the value of the property - virtual void setValue(const QVariant& value) override; + void setValue(const QVariant& value) override; //! Returns the value of the property as a QVariant - virtual QVariant getValue() const override; + auto getValue() const -> QVariant override; //! Returns the formula - VFormula GetFormula() const; + auto GetFormula() const -> VFormula; //! Sets the formula void SetFormula(const VFormula &formula); public slots: - virtual void ValueChildChanged(const QVariant &value, int typeForParent) override; - + void ValueChildChanged(const QVariant &value, int typeForParent) override; }; #endif // VFORMULAPROPERTY_H diff --git a/src/app/valentina/core/vformulapropertyeditor.cpp b/src/app/valentina/core/vformulapropertyeditor.cpp index b0535b502..15a3e3881 100644 --- a/src/app/valentina/core/vformulapropertyeditor.cpp +++ b/src/app/valentina/core/vformulapropertyeditor.cpp @@ -39,49 +39,49 @@ #include "../vpropertyexplorer/vproperty.h" #include "../vtools/dialogs/support/dialogeditwrongformula.h" -#include "vapplication.h" +#include "../vmisc/vabstractvalapplication.h" // VFormulaPropertyEditor //--------------------------------------------------------------------------------------------------------------------- VFormulaPropertyEditor::VFormulaPropertyEditor(QWidget *parent) - : QWidget(parent), formula(VFormula()), ToolButton(nullptr), TextLabel(nullptr) + : QWidget(parent) { setAutoFillBackground(true); // Create the tool button - ToolButton = new QToolButton(this); - ToolButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); - ToolButton->setText("..."); - ToolButton->setIcon(QIcon("://icon/16x16/fx.png")); - ToolButton->setIconSize(QSize(16, 16)); - ToolButton->setFixedSize(24, 24); - ToolButton->installEventFilter(this); - setFocusProxy(ToolButton); // Make the ToolButton the focus proxy - setFocusPolicy(ToolButton->focusPolicy()); - connect(ToolButton, &QToolButton::clicked, this, &VFormulaPropertyEditor::onToolButtonClicked); + m_ToolButton = new QToolButton(this); + m_ToolButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); + m_ToolButton->setText(QStringLiteral("...")); + m_ToolButton->setIcon(QIcon("://icon/16x16/fx.png")); + m_ToolButton->setIconSize(QSize(16, 16)); + m_ToolButton->setFixedSize(24, 24); + m_ToolButton->installEventFilter(this); + setFocusProxy(m_ToolButton); // Make the ToolButton the focus proxy + setFocusPolicy(m_ToolButton->focusPolicy()); + connect(m_ToolButton, &QToolButton::clicked, this, &VFormulaPropertyEditor::onToolButtonClicked); // Create the text label - TextLabel = new QLabel(this); - TextLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); - TextLabel->setText(formula.getStringValue()); + m_TextLabel = new QLabel(this); + m_TextLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); + m_TextLabel->setText(m_formula.getStringValue()); // The layout (a horizontal layout) - QHBoxLayout* layout = new QHBoxLayout(this); + auto* layout = new QHBoxLayout(this); layout->setSpacing(3); layout->setMargin(0); - layout->addWidget(TextLabel); + layout->addWidget(m_TextLabel); // Spacer (this is needed for proper display of the label and button) layout->addSpacerItem(new QSpacerItem(1000000000, 0, QSizePolicy::Expanding, QSizePolicy::Preferred)); - layout->addWidget(ToolButton); + layout->addWidget(m_ToolButton); } //--------------------------------------------------------------------------------------------------------------------- void VFormulaPropertyEditor::SetFormula(const VFormula& formula) { - if (this->formula != formula) + if (this->m_formula != formula) { - this->formula = formula; - TextLabel->setText(this->formula.getStringValue()); + this->m_formula = formula; + m_TextLabel->setText(this->m_formula.getStringValue()); } } @@ -89,26 +89,26 @@ void VFormulaPropertyEditor::SetFormula(const VFormula& formula) void VFormulaPropertyEditor::onToolButtonClicked() { QScopedPointer tmpWidget( - new DialogEditWrongFormula(formula.getData(), formula.getToolId(), + new DialogEditWrongFormula(m_formula.getData(), m_formula.getToolId(), VAbstractValApplication::VApp()->getMainWindow())); - tmpWidget->setCheckZero(formula.getCheckZero()); - tmpWidget->setPostfix(formula.getPostfix()); - tmpWidget->SetFormula(formula.GetFormula(FormulaType::FromUser)); + tmpWidget->setCheckZero(m_formula.getCheckZero()); + tmpWidget->setPostfix(m_formula.getPostfix()); + tmpWidget->SetFormula(m_formula.GetFormula(FormulaType::FromUser)); if (tmpWidget->exec() == QDialog::Accepted) { - formula.SetFormula(tmpWidget->GetFormula(), FormulaType::ToUser); - formula.Eval(); - TextLabel->setText(formula.getStringValue()); - emit dataChangedByUser(formula, this); + m_formula.SetFormula(tmpWidget->GetFormula(), FormulaType::ToUser); + m_formula.Eval(); + m_TextLabel->setText(m_formula.getStringValue()); + emit dataChangedByUser(m_formula, this); QCoreApplication::postEvent(this, new VPE::UserChangeEvent()); } } //--------------------------------------------------------------------------------------------------------------------- -bool VFormulaPropertyEditor::eventFilter(QObject *obj, QEvent *ev) +auto VFormulaPropertyEditor::eventFilter(QObject *obj, QEvent *ev) -> bool { - if (obj == ToolButton && ev->type() == QEvent::KeyPress) + if (obj == m_ToolButton && ev->type() == QEvent::KeyPress) { // Ignore the event, so that eventually the delegate gets the event. ev->ignore(); @@ -119,7 +119,7 @@ bool VFormulaPropertyEditor::eventFilter(QObject *obj, QEvent *ev) } //--------------------------------------------------------------------------------------------------------------------- -VFormula VFormulaPropertyEditor::GetFormula() const +auto VFormulaPropertyEditor::GetFormula() const -> VFormula { - return formula; + return m_formula; } diff --git a/src/app/valentina/core/vformulapropertyeditor.h b/src/app/valentina/core/vformulapropertyeditor.h index 67f9c6324..bb9c58eb9 100644 --- a/src/app/valentina/core/vformulapropertyeditor.h +++ b/src/app/valentina/core/vformulapropertyeditor.h @@ -35,23 +35,24 @@ #include #include "../vpatterndb/vformula.h" +#include "../vmisc/defglobal.h" class VFormulaPropertyEditor : public QWidget { - Q_OBJECT + Q_OBJECT // NOLINT public: //! Constructor taking a widget as parent explicit VFormulaPropertyEditor(QWidget *parent); //! Destructor - virtual ~VFormulaPropertyEditor() Q_DECL_EQ_DEFAULT; + ~VFormulaPropertyEditor() override Q_DECL_EQ_DEFAULT; //! Returns the formula currently set - VFormula GetFormula() const; + auto GetFormula() const -> VFormula; //! Needed for proper event handling - virtual bool eventFilter(QObject *obj, QEvent *ev) override; + auto eventFilter(QObject *obj, QEvent *ev) -> bool override; signals: //! This is emitted, when the user changes the color @@ -67,10 +68,11 @@ private slots: void onToolButtonClicked(); private: - Q_DISABLE_COPY(VFormulaPropertyEditor) - VFormula formula; - QToolButton* ToolButton; - QLabel* TextLabel; + // cppcheck-suppress unknownMacro + Q_DISABLE_COPY_MOVE(VFormulaPropertyEditor) // NOLINT + VFormula m_formula{}; + QToolButton* m_ToolButton{nullptr}; + QLabel* m_TextLabel{nullptr}; }; diff --git a/src/app/valentina/core/vtooloptionspropertybrowser.cpp b/src/app/valentina/core/vtooloptionspropertybrowser.cpp index 1b66edee2..ed6838a37 100644 --- a/src/app/valentina/core/vtooloptionspropertybrowser.cpp +++ b/src/app/valentina/core/vtooloptionspropertybrowser.cpp @@ -27,62 +27,101 @@ *************************************************************************/ #include "vtooloptionspropertybrowser.h" -#include "../vtools/tools/drawTools/drawtools.h" #include "../vtools/tools/backgroundimage/vbackgroundpixmapitem.h" #include "../vtools/tools/backgroundimage/vbackgroundsvgitem.h" -#include "../core/vapplication.h" -#include "../vwidgets/vmaingraphicsview.h" #include "../vwidgets/vgraphicssimpletextitem.h" #include "../vwidgets/vcontrolpointspline.h" #include "../vwidgets/vsimplepoint.h" #include "../vwidgets/vsimplecurve.h" -#include "../vpropertyexplorer/vproperties.h" #include "def.h" #include "vformulaproperty.h" #include "../vpatterndb/vformula.h" #include "../vgeometry/vcubicbezier.h" #include "../vgeometry/vcubicbezierpath.h" #include "../qmuparser/qmudef.h" +#include "../vpropertyexplorer/plugins/vlabelproperty.h" +#include "../vpropertyexplorer/plugins/vstringproperty.h" +#include "../vpropertyexplorer/plugins/vtextproperty.h" +#include "../vpropertyexplorer/plugins/vlinetypeproperty.h" +#include "../vpropertyexplorer/plugins/vlinecolorproperty.h" +#include "../vpropertyexplorer/plugins/vboolproperty.h" +#include "../vpropertyexplorer/plugins/venumproperty.h" +#include "../vpropertyexplorer/plugins/vnumberproperty.h" +#include "../vpropertyexplorer/plugins/vpointfproperty.h" + +#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolalongline.h" +#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolbisector.h" +#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolendline.h" +#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolnormal.h" +#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolshoulderpoint.h" +#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolheight.h" +#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoollineintersectaxis.h" +#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolcurveintersectaxis.h" +#include "../vtools/tools/drawTools/toolcurve/vtoolarc.h" +#include "../vtools/tools/drawTools/toolcurve/vtoolellipticalarc.h" +#include "../vtools/tools/drawTools/toolcurve/vtoolarcwithlength.h" +#include "../vtools/tools/drawTools/toolcurve/vtoolspline.h" +#include "../vtools/tools/drawTools/toolcurve/vtoolcubicbezier.h" +#include "../vtools/tools/drawTools/toolcurve/vtoolsplinepath.h" +#include "../vtools/tools/drawTools/toolcurve/vtoolcubicbezierpath.h" +#include "../vtools/tools/drawTools/vtoolline.h" +#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutspline.h" +#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutsplinepath.h" +#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutarc.h" +#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoollineintersect.h" +#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofcontact.h" +#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolbasepoint.h" +#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/vtooltriangle.h" +#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersection.h" +#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectionarcs.h" +#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncircles.h" +#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncurves.h" +#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromcircleandtangent.h" +#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromarcandtangent.h" +#include "../vtools/tools/drawTools/toolpoint/tooldoublepoint/vtooltruedarts.h" +#include "../vtools/tools/drawTools/operation/vtoolrotation.h" +#include "../vtools/tools/drawTools/operation/flipping/vtoolflippingbyline.h" +#include "../vtools/tools/drawTools/operation/flipping/vtoolflippingbyaxis.h" +#include "../vtools/tools/drawTools/operation/vtoolmove.h" #include #include #include #include +#include namespace { -Q_GLOBAL_STATIC_WITH_ARGS(const QString, AttrHold, (QLatin1String("hold"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, AttrVisible, (QLatin1String("visible"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, AttrOpacity, (QLatin1String("opacity"))) +Q_GLOBAL_STATIC_WITH_ARGS(const QString, AttrHold, (QLatin1String("hold"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, AttrVisible, (QLatin1String("visible"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, AttrOpacity, (QLatin1String("opacity"))) // NOLINT } //--------------------------------------------------------------------------------------------------------------------- VToolOptionsPropertyBrowser::VToolOptionsPropertyBrowser(QDockWidget *parent) - :QObject(parent), PropertyModel(nullptr), formView(nullptr), currentItem(nullptr), - propertyToId(QMap()), - idToProperty(QMap()) + :QObject(parent) { - PropertyModel = new VPE::VPropertyModel(this); - formView = new VPE::VPropertyFormView(PropertyModel, parent); - formView->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); + m_PropertyModel = new VPE::VPropertyModel(this); + m_formView = new VPE::VPropertyFormView(m_PropertyModel, parent); + m_formView->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); - QScrollArea *scroll = new QScrollArea(parent); + auto *scroll = new QScrollArea(parent); scroll->setWidgetResizable(true); - scroll->setWidget(formView); + scroll->setWidget(m_formView); parent->setWidget(scroll); - connect(PropertyModel, &VPE::VPropertyModel::onDataChangedByEditor, this, + connect(m_PropertyModel, &VPE::VPropertyModel::onDataChangedByEditor, this, &VToolOptionsPropertyBrowser::userChangedData); } //--------------------------------------------------------------------------------------------------------------------- void VToolOptionsPropertyBrowser::ClearPropertyBrowser() { - PropertyModel->clear(); - propertyToId.clear(); - idToProperty.clear(); - currentItem = nullptr; + m_PropertyModel->clear(); + m_propertyToId.clear(); + m_idToProperty.clear(); + m_currentItem = nullptr; } //--------------------------------------------------------------------------------------------------------------------- @@ -169,8 +208,8 @@ void VToolOptionsPropertyBrowser::ShowItemOptions(QGraphicsItem *item) case VControlPointSpline::Type: case VSimplePoint::Type: case VSimpleCurve::Type: - currentItem = item->parentItem(); - ShowItemOptions(currentItem); + m_currentItem = item->parentItem(); + ShowItemOptions(m_currentItem); break; case VToolLineIntersectAxis::Type: ShowOptionsToolLineIntersectAxis(item); @@ -216,7 +255,7 @@ void VToolOptionsPropertyBrowser::ShowItemOptions(QGraphicsItem *item) //--------------------------------------------------------------------------------------------------------------------- void VToolOptionsPropertyBrowser::UpdateOptions() { - if (currentItem == nullptr) + if (m_currentItem == nullptr) { return; } @@ -224,7 +263,7 @@ void VToolOptionsPropertyBrowser::UpdateOptions() // This check helps to find missed tools in the switch Q_STATIC_ASSERT_X(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 59, "Not all tools were used in switch."); - switch (currentItem->type()) + switch (m_currentItem->type()) { case VToolBasePoint::Type: UpdateOptionsToolSinglePoint(); @@ -300,7 +339,7 @@ void VToolOptionsPropertyBrowser::UpdateOptions() break; case VGraphicsSimpleTextItem::Type: case VControlPointSpline::Type: - ShowItemOptions(currentItem->parentItem()); + ShowItemOptions(m_currentItem->parentItem()); break; case VToolLineIntersectAxis::Type: UpdateOptionsToolLineIntersectAxis(); @@ -346,7 +385,7 @@ void VToolOptionsPropertyBrowser::UpdateOptions() //--------------------------------------------------------------------------------------------------------------------- void VToolOptionsPropertyBrowser::RefreshOptions() { - QGraphicsItem *item = currentItem; + QGraphicsItem *item = m_currentItem; itemClicked(nullptr);//close options itemClicked(item);//reopen options } @@ -355,19 +394,17 @@ void VToolOptionsPropertyBrowser::RefreshOptions() void VToolOptionsPropertyBrowser::userChangedData(VPE::VProperty *property) { VPE::VProperty *prop = property; - if (!propertyToId.contains(prop)) + if (!m_propertyToId.contains(prop)) { - if (!propertyToId.contains(prop->getParent()))// Maybe we know parent + if (!m_propertyToId.contains(prop->getParent()))// Maybe we know parent { return; } - else - { - prop = prop->getParent(); - } + + prop = prop->getParent(); } - if (!currentItem) + if (!m_currentItem) { return; } @@ -375,7 +412,7 @@ void VToolOptionsPropertyBrowser::userChangedData(VPE::VProperty *property) // This check helps to find missed tools in the switch Q_STATIC_ASSERT_X(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 59, "Not all tools were used in switch."); - switch (currentItem->type()) + switch (m_currentItem->type()) { case VToolBasePoint::Type: ChangeDataToolSinglePoint(prop); @@ -496,40 +533,40 @@ void VToolOptionsPropertyBrowser::itemClicked(QGraphicsItem *item) { if (item != nullptr) { - if (item->isEnabled()==false) + if (not item->isEnabled()) { return; } } - if (currentItem == item && item != nullptr) + if (m_currentItem == item && item != nullptr) { UpdateOptions(); return; } - PropertyModel->clear(); - propertyToId.clear(); - idToProperty.clear(); + m_PropertyModel->clear(); + m_propertyToId.clear(); + m_idToProperty.clear(); - if (currentItem != nullptr) + if (m_currentItem != nullptr) { - VAbstractTool *previousTool = dynamic_cast(currentItem); + auto *previousTool = dynamic_cast(m_currentItem); if (previousTool != nullptr) { previousTool->ShowVisualization(false); // hide for previous tool } } - currentItem = item; - if (currentItem == nullptr) + m_currentItem = item; + if (m_currentItem == nullptr) { - formView->setTitle(QString()); + m_formView->setTitle(QString()); return; } - ShowItemOptions(currentItem); + ShowItemOptions(m_currentItem); } //--------------------------------------------------------------------------------------------------------------------- @@ -775,7 +812,7 @@ void VToolOptionsPropertyBrowser::AddPropertyOpacity(const QString &propertyName template void VToolOptionsPropertyBrowser::SetName(VPE::VProperty *property) { - if (auto *i = qgraphicsitem_cast(currentItem)) + if (auto *i = qgraphicsitem_cast(m_currentItem)) { QString name = property->data(VPE::VProperty::DPC_Data, Qt::DisplayRole).toString(); if (name == i->name()) @@ -795,7 +832,7 @@ void VToolOptionsPropertyBrowser::SetName(VPE::VProperty *property) template void VToolOptionsPropertyBrowser::SetHold(VPE::VProperty *property) { - if (auto *i = qgraphicsitem_cast(currentItem)) + if (auto *i = qgraphicsitem_cast(m_currentItem)) { bool hold = property->data(VPE::VProperty::DPC_Data, Qt::DisplayRole).toBool(); if (hold == i->IsHold()) @@ -815,7 +852,7 @@ void VToolOptionsPropertyBrowser::SetHold(VPE::VProperty *property) template void VToolOptionsPropertyBrowser::SetVisible(VPE::VProperty *property) { - if (auto *i = qgraphicsitem_cast(currentItem)) + if (auto *i = qgraphicsitem_cast(m_currentItem)) { bool visible = property->data(VPE::VProperty::DPC_Data, Qt::DisplayRole).toBool(); if (visible == i->IsVisible()) @@ -835,7 +872,7 @@ void VToolOptionsPropertyBrowser::SetVisible(VPE::VProperty *property) template void VToolOptionsPropertyBrowser::SetOpacity(VPE::VProperty *property) { - if (auto *i = qgraphicsitem_cast(currentItem)) + if (auto *i = qgraphicsitem_cast(m_currentItem)) { const int opacity = property->data(VPE::VProperty::DPC_Data, Qt::DisplayRole).toInt(); if (VFuzzyComparePossibleNulls(opacity, i->GetOpacity())) @@ -855,7 +892,7 @@ void VToolOptionsPropertyBrowser::SetOpacity(VPE::VProperty *property) template void VToolOptionsPropertyBrowser::SetPointName(VPE::VProperty *property) { - if (auto *i = qgraphicsitem_cast(currentItem)) + if (auto *i = qgraphicsitem_cast(m_currentItem)) { QString name = property->data(VPE::VProperty::DPC_Data, Qt::DisplayRole).toString(); if (name == i->name()) @@ -864,10 +901,9 @@ void VToolOptionsPropertyBrowser::SetPointName(VPE::VProperty *property) } QRegularExpression rx(NameRegExp()); - if (name.isEmpty() || VContainer::IsUnique(name, valentinaNamespace) == false - || rx.match(name).hasMatch() == false) + if (name.isEmpty() || not VContainer::IsUnique(name, valentinaNamespace) || not rx.match(name).hasMatch()) { - idToProperty[AttrName]->setValue(i->name()); + m_idToProperty[AttrName]->setValue(i->name()); } else { @@ -884,7 +920,7 @@ void VToolOptionsPropertyBrowser::SetPointName(VPE::VProperty *property) template void VToolOptionsPropertyBrowser::SetPointName1(VPE::VProperty *property) { - if (auto *i = qgraphicsitem_cast(currentItem)) + if (auto *i = qgraphicsitem_cast(m_currentItem)) { QString name = property->data(VPE::VProperty::DPC_Data, Qt::DisplayRole).toString(); if (name == i->nameP1()) @@ -893,10 +929,9 @@ void VToolOptionsPropertyBrowser::SetPointName1(VPE::VProperty *property) } QRegularExpression rx(NameRegExp()); - if (name.isEmpty() || VContainer::IsUnique(name, valentinaNamespace) == false - || rx.match(name).hasMatch() == false) + if (name.isEmpty() || not VContainer::IsUnique(name, valentinaNamespace) || not rx.match(name).hasMatch()) { - idToProperty[AttrName1]->setValue(i->nameP1()); + m_idToProperty[AttrName1]->setValue(i->nameP1()); } else { @@ -913,7 +948,7 @@ void VToolOptionsPropertyBrowser::SetPointName1(VPE::VProperty *property) template void VToolOptionsPropertyBrowser::SetPointName2(VPE::VProperty *property) { - if (auto *i = qgraphicsitem_cast(currentItem)) + if (auto *i = qgraphicsitem_cast(m_currentItem)) { QString name = property->data(VPE::VProperty::DPC_Data, Qt::DisplayRole).toString(); if (name == i->nameP2()) @@ -922,10 +957,9 @@ void VToolOptionsPropertyBrowser::SetPointName2(VPE::VProperty *property) } QRegularExpression rx(NameRegExp()); - if (name.isEmpty() || VContainer::IsUnique(name, valentinaNamespace) == false - || rx.match(name).hasMatch() == false) + if (name.isEmpty() || not VContainer::IsUnique(name, valentinaNamespace) || not rx.match(name).hasMatch()) { - idToProperty[AttrName2]->setValue(i->nameP2()); + m_idToProperty[AttrName2]->setValue(i->nameP2()); } else { @@ -942,7 +976,7 @@ void VToolOptionsPropertyBrowser::SetPointName2(VPE::VProperty *property) template void VToolOptionsPropertyBrowser::SetOperationSuffix(VPE::VProperty *property) { - if (auto *item = qgraphicsitem_cast(currentItem)) + if (auto *item = qgraphicsitem_cast(m_currentItem)) { QString suffix = property->data(VPE::VProperty::DPC_Data, Qt::DisplayRole).toString(); @@ -953,18 +987,18 @@ void VToolOptionsPropertyBrowser::SetOperationSuffix(VPE::VProperty *property) if (suffix.isEmpty()) { - idToProperty[AttrSuffix]->setValue(item->Suffix()); + m_idToProperty[AttrSuffix]->setValue(item->Suffix()); return; } QRegularExpression rx(NameRegExp()); const QStringList uniqueNames = VContainer::AllUniqueNames(valentinaNamespace); - for (auto &uniqueName : uniqueNames) + for (const auto &uniqueName : uniqueNames) { const QString name = uniqueName + suffix; if (not rx.match(name).hasMatch() || not VContainer::IsUnique(name, valentinaNamespace)) { - idToProperty[AttrSuffix]->setValue(item->Suffix()); + m_idToProperty[AttrSuffix]->setValue(item->Suffix()); return; } } @@ -979,7 +1013,7 @@ void VToolOptionsPropertyBrowser::SetOperationSuffix(VPE::VProperty *property) //--------------------------------------------------------------------------------------------------------------------- template -Type VToolOptionsPropertyBrowser::GetCrossPoint(const QVariant &value) +auto VToolOptionsPropertyBrowser::GetCrossPoint(const QVariant &value) -> Type { bool ok = false; const int val = value.toInt(&ok); @@ -1005,7 +1039,7 @@ Type VToolOptionsPropertyBrowser::GetCrossPoint(const QVariant &value) template void VToolOptionsPropertyBrowser::SetCrossCirclesPoint(VPE::VProperty *property) { - if (auto *i = qgraphicsitem_cast(currentItem)) + if (auto *i = qgraphicsitem_cast(m_currentItem)) { const QVariant value = property->data(VPE::VProperty::DPC_Data, Qt::EditRole); i->SetCrossCirclesPoint(GetCrossPoint(value)); @@ -1020,7 +1054,7 @@ void VToolOptionsPropertyBrowser::SetCrossCirclesPoint(VPE::VProperty *property) template void VToolOptionsPropertyBrowser::SetVCrossCurvesPoint(VPE::VProperty *property) { - if (auto *i = qgraphicsitem_cast(currentItem)) + if (auto *i = qgraphicsitem_cast(m_currentItem)) { const QVariant value = property->data(VPE::VProperty::DPC_Data, Qt::EditRole); auto type = GetCrossPoint(value); @@ -1041,7 +1075,7 @@ void VToolOptionsPropertyBrowser::SetVCrossCurvesPoint(VPE::VProperty *property) template void VToolOptionsPropertyBrowser::SetHCrossCurvesPoint(VPE::VProperty *property) { - if (auto *i = qgraphicsitem_cast(currentItem)) + if (auto *i = qgraphicsitem_cast(m_currentItem)) { const QVariant value = property->data(VPE::VProperty::DPC_Data, Qt::EditRole); auto type = GetCrossPoint(value); @@ -1062,10 +1096,10 @@ void VToolOptionsPropertyBrowser::SetHCrossCurvesPoint(VPE::VProperty *property) template void VToolOptionsPropertyBrowser::SetAxisType(VPE::VProperty *property) { - if (auto *i = qgraphicsitem_cast(currentItem)) + if (auto *i = qgraphicsitem_cast(m_currentItem)) { const QVariant value = property->data(VPE::VProperty::DPC_Data, Qt::EditRole); - AxisType type = GetCrossPoint(value); + auto type = GetCrossPoint(value); if (type == i->GetAxisType()) { return; @@ -1083,7 +1117,7 @@ void VToolOptionsPropertyBrowser::SetAxisType(VPE::VProperty *property) template void VToolOptionsPropertyBrowser::SetNotes(VPE::VProperty *property) { - if (auto *i = qgraphicsitem_cast(currentItem)) + if (auto *i = qgraphicsitem_cast(m_currentItem)) { QString notes = property->data(VPE::VProperty::DPC_Data, Qt::DisplayRole).toString(); if (notes == i->GetNotes()) @@ -1103,7 +1137,7 @@ void VToolOptionsPropertyBrowser::SetNotes(VPE::VProperty *property) template void VToolOptionsPropertyBrowser::SetAlias(VPE::VProperty *property) { - if (auto *i = qgraphicsitem_cast(currentItem)) + if (auto *i = qgraphicsitem_cast(m_currentItem)) { QString notes = property->data(VPE::VProperty::DPC_Data, Qt::DisplayRole).toString(); if (notes == i->GetAliasSuffix()) @@ -1123,7 +1157,7 @@ void VToolOptionsPropertyBrowser::SetAlias(VPE::VProperty *property) template void VToolOptionsPropertyBrowser::SetAlias1(VPE::VProperty *property) { - if (auto *i = qgraphicsitem_cast(currentItem)) + if (auto *i = qgraphicsitem_cast(m_currentItem)) { QString notes = property->data(VPE::VProperty::DPC_Data, Qt::DisplayRole).toString(); if (notes == i->GetAliasSuffix1()) @@ -1143,7 +1177,7 @@ void VToolOptionsPropertyBrowser::SetAlias1(VPE::VProperty *property) template void VToolOptionsPropertyBrowser::SetAlias2(VPE::VProperty *property) { - if (auto *i = qgraphicsitem_cast(currentItem)) + if (auto *i = qgraphicsitem_cast(m_currentItem)) { QString notes = property->data(VPE::VProperty::DPC_Data, Qt::DisplayRole).toString(); if (notes == i->GetAliasSuffix2()) @@ -1163,7 +1197,7 @@ void VToolOptionsPropertyBrowser::SetAlias2(VPE::VProperty *property) template void VToolOptionsPropertyBrowser::SetLineType(VPE::VProperty *property) { - if (auto *i = qgraphicsitem_cast(currentItem)) + if (auto *i = qgraphicsitem_cast(m_currentItem)) { QString type = property->data(VPE::VProperty::DPC_Data, Qt::DisplayRole).toString(); if (type == i->getLineType()) @@ -1183,7 +1217,7 @@ void VToolOptionsPropertyBrowser::SetLineType(VPE::VProperty *property) template void VToolOptionsPropertyBrowser::SetLineColor(VPE::VProperty *property) { - if (auto *i = qgraphicsitem_cast(currentItem)) + if (auto *i = qgraphicsitem_cast(m_currentItem)) { QString color = property->data(VPE::VProperty::DPC_Data, Qt::DisplayRole).toString(); if (color == i->GetLineColor()) @@ -1203,9 +1237,9 @@ void VToolOptionsPropertyBrowser::SetLineColor(VPE::VProperty *property) template void VToolOptionsPropertyBrowser::SetFormulaLength(VPE::VProperty *property) { - if (auto *i = qgraphicsitem_cast(currentItem)) + if (auto *i = qgraphicsitem_cast(m_currentItem)) { - VFormula formula = property->data(VPE::VProperty::DPC_Data, Qt::DisplayRole).value(); + auto formula = property->data(VPE::VProperty::DPC_Data, Qt::DisplayRole).value(); if (formula == i->GetFormulaLength()) { return; @@ -1223,9 +1257,9 @@ void VToolOptionsPropertyBrowser::SetFormulaLength(VPE::VProperty *property) template void VToolOptionsPropertyBrowser::SetFormulaAngle(VPE::VProperty *property) { - if (auto *i = qgraphicsitem_cast(currentItem)) + if (auto *i = qgraphicsitem_cast(m_currentItem)) { - VFormula formula = property->data(VPE::VProperty::DPC_Data, Qt::DisplayRole).value(); + auto formula = property->data(VPE::VProperty::DPC_Data, Qt::DisplayRole).value(); if (formula == i->GetFormulaAngle()) { return; @@ -1243,9 +1277,9 @@ void VToolOptionsPropertyBrowser::SetFormulaAngle(VPE::VProperty *property) template void VToolOptionsPropertyBrowser::SetFormulaRadius(VPE::VProperty *property) { - if (auto *i = qgraphicsitem_cast(currentItem)) + if (auto *i = qgraphicsitem_cast(m_currentItem)) { - VFormula formula = property->data(VPE::VProperty::DPC_Data, Qt::DisplayRole).value(); + auto formula = property->data(VPE::VProperty::DPC_Data, Qt::DisplayRole).value(); if (formula == i->GetFormulaRadius()) { return; @@ -1263,9 +1297,9 @@ void VToolOptionsPropertyBrowser::SetFormulaRadius(VPE::VProperty *property) template void VToolOptionsPropertyBrowser::SetFormulaF1(VPE::VProperty *property) { - if (auto *i = qgraphicsitem_cast(currentItem)) + if (auto *i = qgraphicsitem_cast(m_currentItem)) { - VFormula formula = property->data(VPE::VProperty::DPC_Data, Qt::DisplayRole).value(); + auto formula = property->data(VPE::VProperty::DPC_Data, Qt::DisplayRole).value(); if (formula == i->GetFormulaF1()) { return; @@ -1283,9 +1317,9 @@ void VToolOptionsPropertyBrowser::SetFormulaF1(VPE::VProperty *property) template void VToolOptionsPropertyBrowser::SetFormulaF2(VPE::VProperty *property) { - if (auto *i = qgraphicsitem_cast(currentItem)) + if (auto *i = qgraphicsitem_cast(m_currentItem)) { - VFormula formula = property->data(VPE::VProperty::DPC_Data, Qt::DisplayRole).value(); + auto formula = property->data(VPE::VProperty::DPC_Data, Qt::DisplayRole).value(); if (formula == i->GetFormulaF2()) { return; @@ -1303,7 +1337,7 @@ void VToolOptionsPropertyBrowser::SetFormulaF2(VPE::VProperty *property) template void VToolOptionsPropertyBrowser::SetPenStyle(VPE::VProperty *property) { - if (auto *i = qgraphicsitem_cast(currentItem)) + if (auto *i = qgraphicsitem_cast(m_currentItem)) { QString pen = property->data(VPE::VProperty::DPC_Data, Qt::DisplayRole).toString(); if (pen == i->GetPenStyle()) @@ -1323,9 +1357,9 @@ void VToolOptionsPropertyBrowser::SetPenStyle(VPE::VProperty *property) template void VToolOptionsPropertyBrowser::SetFormulaRotationAngle(VPE::VProperty *property) { - if (auto *i = qgraphicsitem_cast(currentItem)) + if (auto *i = qgraphicsitem_cast(m_currentItem)) { - VFormula formula = property->data(VPE::VProperty::DPC_Data, Qt::DisplayRole).value(); + auto formula = property->data(VPE::VProperty::DPC_Data, Qt::DisplayRole).value(); if (formula == i->GetFormulaRotationAngle()) { return; @@ -1343,7 +1377,7 @@ void VToolOptionsPropertyBrowser::SetFormulaRotationAngle(VPE::VProperty *proper template void VToolOptionsPropertyBrowser::SetApproximationScale(VPE::VProperty *property) { - if (auto *i = qgraphicsitem_cast(currentItem)) + if (auto *i = qgraphicsitem_cast(m_currentItem)) { double scale = property->data(VPE::VProperty::DPC_Data, Qt::DisplayRole).toDouble(); if (VFuzzyComparePossibleNulls(scale, i->GetApproximationScale())) @@ -1362,9 +1396,9 @@ void VToolOptionsPropertyBrowser::SetApproximationScale(VPE::VProperty *property //--------------------------------------------------------------------------------------------------------------------- void VToolOptionsPropertyBrowser::AddProperty(VPE::VProperty *property, const QString &id) { - propertyToId[property] = id; - idToProperty[id] = property; - PropertyModel->addProperty(property, id); + m_propertyToId[property] = id; + m_idToProperty[id] = property; + m_PropertyModel->addProperty(property, id); } //--------------------------------------------------------------------------------------------------------------------- @@ -1372,11 +1406,11 @@ void VToolOptionsPropertyBrowser::ChangeDataToolSinglePoint(VPE::VProperty *prop { SCASSERT(property != nullptr) - const QString id = propertyToId[property]; + const QString id = m_propertyToId[property]; auto SetPosition = [this](VPE::VProperty *property) { - if (auto *i = qgraphicsitem_cast(currentItem)) + if (auto *i = qgraphicsitem_cast(m_currentItem)) { QVariant value = property->data(VPE::VProperty::DPC_Data, Qt::DisplayRole); i->SetBasePointPos(value.toPointF()); @@ -1409,7 +1443,7 @@ void VToolOptionsPropertyBrowser::ChangeDataToolEndLine(VPE::VProperty *property { SCASSERT(property != nullptr) - const QString id = propertyToId[property]; + const QString id = m_propertyToId[property]; switch (PropertiesList().indexOf(id)) { @@ -1444,7 +1478,7 @@ void VToolOptionsPropertyBrowser::ChangeDataToolAlongLine(VPE::VProperty *proper { SCASSERT(property != nullptr) - const QString id = propertyToId[property]; + const QString id = m_propertyToId[property]; switch (PropertiesList().indexOf(id)) { @@ -1477,7 +1511,7 @@ void VToolOptionsPropertyBrowser::ChangeDataToolArc(VPE::VProperty *property) { SCASSERT(property != nullptr) - const QString id = propertyToId[property]; + const QString id = m_propertyToId[property]; switch (PropertiesList().indexOf(id)) { @@ -1521,7 +1555,7 @@ void VToolOptionsPropertyBrowser::ChangeDataToolArcWithLength(VPE::VProperty *pr { SCASSERT(property != nullptr) - const QString id = propertyToId[property]; + const QString id = m_propertyToId[property]; switch (PropertiesList().indexOf(id)) { @@ -1565,7 +1599,7 @@ void VToolOptionsPropertyBrowser::ChangeDataToolBisector(VPE::VProperty *propert { SCASSERT(property != nullptr) - const QString id = propertyToId[property]; + const QString id = m_propertyToId[property]; switch (PropertiesList().indexOf(id)) { @@ -1599,7 +1633,7 @@ void VToolOptionsPropertyBrowser::ChangeDataToolTrueDarts(VPE::VProperty *proper { SCASSERT(property != nullptr) - const QString id = propertyToId[property]; + const QString id = m_propertyToId[property]; switch (PropertiesList().indexOf(id)) { @@ -1629,7 +1663,7 @@ void VToolOptionsPropertyBrowser::ChangeDataToolCutArc(VPE::VProperty *property) { SCASSERT(property != nullptr) - const QString id = propertyToId[property]; + const QString id = m_propertyToId[property]; switch (PropertiesList().indexOf(id)) { @@ -1661,7 +1695,7 @@ void VToolOptionsPropertyBrowser::ChangeDataToolCutSpline(VPE::VProperty *proper { SCASSERT(property != nullptr) - const QString id = propertyToId[property]; + const QString id = m_propertyToId[property]; switch (PropertiesList().indexOf(id)) { @@ -1693,7 +1727,7 @@ void VToolOptionsPropertyBrowser::ChangeDataToolCutSplinePath(VPE::VProperty *pr { SCASSERT(property != nullptr) - const QString id = propertyToId[property]; + const QString id = m_propertyToId[property]; switch (PropertiesList().indexOf(id)) { @@ -1725,7 +1759,7 @@ void VToolOptionsPropertyBrowser::ChangeDataToolHeight(VPE::VProperty *property) { SCASSERT(property != nullptr) - const QString id = propertyToId[property]; + const QString id = m_propertyToId[property]; switch (PropertiesList().indexOf(id)) { @@ -1756,7 +1790,7 @@ void VToolOptionsPropertyBrowser::ChangeDataToolLine(VPE::VProperty *property) { SCASSERT(property != nullptr) - const QString id = propertyToId[property]; + const QString id = m_propertyToId[property]; switch (PropertiesList().indexOf(id)) { @@ -1783,7 +1817,7 @@ void VToolOptionsPropertyBrowser::ChangeDataToolLineIntersect(VPE::VProperty *pr { SCASSERT(property != nullptr) - const QString id = propertyToId[property]; + const QString id = m_propertyToId[property]; switch (PropertiesList().indexOf(id)) { @@ -1809,11 +1843,11 @@ void VToolOptionsPropertyBrowser::ChangeDataToolNormal(VPE::VProperty *property) { SCASSERT(property != nullptr) - const QString id = propertyToId[property]; + const QString id = m_propertyToId[property]; auto SetAngle = [this](VPE::VProperty *property) { - if (auto *i = qgraphicsitem_cast(currentItem)) + if (auto *i = qgraphicsitem_cast(m_currentItem)) { double value = property->data(VPE::VProperty::DPC_Data, Qt::DisplayRole).toDouble(); if (VFuzzyComparePossibleNulls(value, i->GetAngle())) @@ -1863,13 +1897,13 @@ void VToolOptionsPropertyBrowser::ChangeDataToolPointOfContact(VPE::VProperty *p { SCASSERT(property != nullptr) - const QString id = propertyToId[property]; + const QString id = m_propertyToId[property]; auto SetArcRadius = [this](VPE::VProperty *property) { - if (auto *i = qgraphicsitem_cast(currentItem)) + if (auto *i = qgraphicsitem_cast(m_currentItem)) { - VFormula formula = property->data(VPE::VProperty::DPC_Data, Qt::DisplayRole).value(); + auto formula = property->data(VPE::VProperty::DPC_Data, Qt::DisplayRole).value(); if (formula == i->getArcRadius()) { return; @@ -1909,7 +1943,7 @@ void VToolOptionsPropertyBrowser::ChangeDataToolPointOfIntersection(VPE::VProper { SCASSERT(property != nullptr) - const QString id = propertyToId[property]; + const QString id = m_propertyToId[property]; switch (PropertiesList().indexOf(id)) { @@ -1933,7 +1967,7 @@ void VToolOptionsPropertyBrowser::ChangeDataToolPointOfIntersectionArcs(VPE::VPr { SCASSERT(property != nullptr) - const QString id = propertyToId[property]; + const QString id = m_propertyToId[property]; switch (PropertiesList().indexOf(id)) { @@ -1960,13 +1994,13 @@ void VToolOptionsPropertyBrowser::ChangeDataToolPointOfIntersectionCircles(VPE:: { SCASSERT(property != nullptr) - const QString id = propertyToId[property]; + const QString id = m_propertyToId[property]; auto SetFirstCircleRadius = [this](VPE::VProperty *property) { - if (auto *i = qgraphicsitem_cast(currentItem)) + if (auto *i = qgraphicsitem_cast(m_currentItem)) { - VFormula formula = property->data(VPE::VProperty::DPC_Data, Qt::DisplayRole).value(); + auto formula = property->data(VPE::VProperty::DPC_Data, Qt::DisplayRole).value(); if (formula == i->GetFirstCircleRadius()) { return; @@ -1982,9 +2016,9 @@ void VToolOptionsPropertyBrowser::ChangeDataToolPointOfIntersectionCircles(VPE:: auto SetSecondCircleRadius = [this](VPE::VProperty *property) { - if (auto *i = qgraphicsitem_cast(currentItem)) + if (auto *i = qgraphicsitem_cast(m_currentItem)) { - VFormula formula = property->data(VPE::VProperty::DPC_Data, Qt::DisplayRole).value(); + auto formula = property->data(VPE::VProperty::DPC_Data, Qt::DisplayRole).value(); if (formula == i->GetSecondCircleRadius()) { return; @@ -2028,7 +2062,7 @@ void VToolOptionsPropertyBrowser::ChangeDataToolPointOfIntersectionCurves(VPE::V { SCASSERT(property != nullptr) - const QString id = propertyToId[property]; + const QString id = m_propertyToId[property]; switch (PropertiesList().indexOf(id)) { @@ -2058,13 +2092,13 @@ void VToolOptionsPropertyBrowser::ChangeDataToolPointFromCircleAndTangent(VPE::V { SCASSERT(property != nullptr) - const QString id = propertyToId[property]; + const QString id = m_propertyToId[property]; auto SetCircleRadius = [this](VPE::VProperty *property) { - if (auto *i = qgraphicsitem_cast(currentItem)) + if (auto *i = qgraphicsitem_cast(m_currentItem)) { - VFormula formula = property->data(VPE::VProperty::DPC_Data, Qt::DisplayRole).value(); + auto formula = property->data(VPE::VProperty::DPC_Data, Qt::DisplayRole).value(); if (formula == i->GetCircleRadius()) { return; @@ -2106,7 +2140,7 @@ void VToolOptionsPropertyBrowser::ChangeDataToolPointFromArcAndTangent(VPE::VPro { SCASSERT(property != nullptr) - const QString id = propertyToId[property]; + const QString id = m_propertyToId[property]; switch (PropertiesList().indexOf(id)) { @@ -2133,7 +2167,7 @@ void VToolOptionsPropertyBrowser::ChangeDataToolShoulderPoint(VPE::VProperty *pr { SCASSERT(property != nullptr) - const QString id = propertyToId[property]; + const QString id = m_propertyToId[property]; switch (PropertiesList().indexOf(id)) { @@ -2168,13 +2202,13 @@ void VToolOptionsPropertyBrowser::ChangeDataToolSpline(VPE::VProperty *property) SCASSERT(property != nullptr) QVariant value = property->data(VPE::VProperty::DPC_Data, Qt::DisplayRole); - const QString id = propertyToId[property]; + const QString id = m_propertyToId[property]; - auto *i = qgraphicsitem_cast(currentItem); + auto *i = qgraphicsitem_cast(m_currentItem); SCASSERT(i != nullptr) VSpline spl = i->getSpline(); - const VFormula f = value.value(); + const auto f = value.value(); switch (PropertiesList().indexOf(id)) { @@ -2238,7 +2272,7 @@ void VToolOptionsPropertyBrowser::ChangeDataToolCubicBezier(VPE::VProperty *prop { SCASSERT(property != nullptr) - const QString id = propertyToId[property]; + const QString id = m_propertyToId[property]; switch (PropertiesList().indexOf(id)) { @@ -2253,7 +2287,7 @@ void VToolOptionsPropertyBrowser::ChangeDataToolCubicBezier(VPE::VProperty *prop break; case 60: // AttrAScale { - auto *i = qgraphicsitem_cast(currentItem); + auto *i = qgraphicsitem_cast(m_currentItem); SCASSERT(i != nullptr) const QVariant value = property->data(VPE::VProperty::DPC_Data, Qt::DisplayRole); @@ -2284,7 +2318,7 @@ void VToolOptionsPropertyBrowser::ChangeDataToolSplinePath(VPE::VProperty *prope { SCASSERT(property != nullptr) - const QString id = propertyToId[property]; + const QString id = m_propertyToId[property]; switch (PropertiesList().indexOf(id)) { @@ -2299,7 +2333,7 @@ void VToolOptionsPropertyBrowser::ChangeDataToolSplinePath(VPE::VProperty *prope break; case 60: // AttrAScale { - auto *i = qgraphicsitem_cast(currentItem); + auto *i = qgraphicsitem_cast(m_currentItem); SCASSERT(i != nullptr) QVariant value = property->data(VPE::VProperty::DPC_Data, Qt::DisplayRole); @@ -2325,7 +2359,7 @@ void VToolOptionsPropertyBrowser::ChangeDataToolCubicBezierPath(VPE::VProperty * { SCASSERT(property != nullptr) - const QString id = propertyToId[property]; + const QString id = m_propertyToId[property]; switch (PropertiesList().indexOf(id)) { @@ -2340,7 +2374,7 @@ void VToolOptionsPropertyBrowser::ChangeDataToolCubicBezierPath(VPE::VProperty * break; case 60: // AttrAScale { - auto *i = qgraphicsitem_cast(currentItem); + auto *i = qgraphicsitem_cast(m_currentItem); SCASSERT(i != nullptr) QVariant value = property->data(VPE::VProperty::DPC_Data, Qt::DisplayRole); @@ -2366,7 +2400,7 @@ void VToolOptionsPropertyBrowser::ChangeDataToolTriangle(VPE::VProperty *propert { SCASSERT(property != nullptr) - const QString id = propertyToId[property]; + const QString id = m_propertyToId[property]; switch (PropertiesList().indexOf(id)) { @@ -2392,7 +2426,7 @@ void VToolOptionsPropertyBrowser::ChangeDataToolLineIntersectAxis(VPE::VProperty { SCASSERT(property != nullptr) - const QString id = propertyToId[property]; + const QString id = m_propertyToId[property]; switch (PropertiesList().indexOf(id)) { @@ -2426,7 +2460,7 @@ void VToolOptionsPropertyBrowser::ChangeDataToolCurveIntersectAxis(VPE::VPropert { SCASSERT(property != nullptr) - const QString id = propertyToId[property]; + const QString id = m_propertyToId[property]; switch (PropertiesList().indexOf(id)) { @@ -2459,7 +2493,7 @@ void VToolOptionsPropertyBrowser::ChangeDataToolRotation(VPE::VProperty *propert { SCASSERT(property != nullptr) - const QString id = propertyToId[property]; + const QString id = m_propertyToId[property]; switch (PropertiesList().indexOf(id)) { @@ -2485,7 +2519,7 @@ void VToolOptionsPropertyBrowser::ChangeDataToolMove(VPE::VProperty *property) { SCASSERT(property != nullptr) - const QString id = propertyToId[property]; + const QString id = m_propertyToId[property]; switch (PropertiesList().indexOf(id)) { @@ -2517,7 +2551,7 @@ void VToolOptionsPropertyBrowser::ChangeDataToolFlippingByLine(VPE::VProperty *p { SCASSERT(property != nullptr) - const QString id = propertyToId[property]; + const QString id = m_propertyToId[property]; switch (PropertiesList().indexOf(id)) { @@ -2541,7 +2575,7 @@ void VToolOptionsPropertyBrowser::ChangeDataToolFlippingByAxis(VPE::VProperty *p { SCASSERT(property != nullptr) - const QString id = propertyToId[property]; + const QString id = m_propertyToId[property]; switch (PropertiesList().indexOf(id)) { @@ -2567,13 +2601,13 @@ void VToolOptionsPropertyBrowser::ChangeDataToolEllipticalArc(VPE::VProperty *pr { SCASSERT(property != nullptr) - const QString id = propertyToId[property]; + const QString id = m_propertyToId[property]; auto SetFormulaRadius1 = [this](VPE::VProperty *property) { - if (auto *i = qgraphicsitem_cast(currentItem)) + if (auto *i = qgraphicsitem_cast(m_currentItem)) { - VFormula formula = property->data(VPE::VProperty::DPC_Data, Qt::DisplayRole).value(); + auto formula = property->data(VPE::VProperty::DPC_Data, Qt::DisplayRole).value(); if (formula == i->GetFormulaRadius1()) { return; @@ -2589,9 +2623,9 @@ void VToolOptionsPropertyBrowser::ChangeDataToolEllipticalArc(VPE::VProperty *pr auto SetFormulaRadius2 = [this](VPE::VProperty *property) { - if (auto *i = qgraphicsitem_cast(currentItem)) + if (auto *i = qgraphicsitem_cast(m_currentItem)) { - VFormula formula = property->data(VPE::VProperty::DPC_Data, Qt::DisplayRole).value(); + auto formula = property->data(VPE::VProperty::DPC_Data, Qt::DisplayRole).value(); if (formula == i->GetFormulaRadius2()) { return; @@ -2650,7 +2684,7 @@ void VToolOptionsPropertyBrowser::ChangeDataBackgroundPixmapItem(VPE::VProperty { SCASSERT(property != nullptr) - const QString id = propertyToId.value(property); + const QString id = m_propertyToId.value(property); switch (PropertiesList().indexOf(id)) { @@ -2677,7 +2711,7 @@ void VToolOptionsPropertyBrowser::ChangeDataBackgroundSVGItem(VPE::VProperty *pr { SCASSERT(property != nullptr) - const QString id = propertyToId.value(property); + const QString id = m_propertyToId.value(property); switch (PropertiesList().indexOf(id)) { @@ -2704,13 +2738,13 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolSinglePoint(QGraphicsItem *item { auto *i = qgraphicsitem_cast(item); i->ShowVisualization(true); - formView->setTitle(tr("Base point")); + m_formView->setTitle(tr("Base point")); AddPropertyObjectName(i, tr("Point label:")); auto *itemPosition = new VPE::VPointFProperty(tr("Position:")); itemPosition->setValue(i->GetBasePointPos()); - AddProperty(itemPosition, QLatin1String("position")); + AddProperty(itemPosition, QStringLiteral("position")); AddPropertyText(tr("Notes:"), i->GetNotes(), AttrNotes); } @@ -2720,7 +2754,7 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolEndLine(QGraphicsItem *item) { auto *i = qgraphicsitem_cast(item); i->ShowVisualization(true); - formView->setTitle(tr("Point at distance and angle")); + m_formView->setTitle(tr("Point at distance and angle")); AddPropertyObjectName(i, tr("Point label:")); AddPropertyParentPointName(i->BasePointName(), tr("Base point:"), AttrBasePoint); @@ -2736,7 +2770,7 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolAlongLine(QGraphicsItem *item) { auto *i = qgraphicsitem_cast(item); i->ShowVisualization(true); - formView->setTitle(tr("Point at distance along line")); + m_formView->setTitle(tr("Point at distance along line")); AddPropertyObjectName(i, tr("Point label:")); AddPropertyParentPointName(i->BasePointName(), tr("First point:"), AttrBasePoint); @@ -2752,7 +2786,7 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolArc(QGraphicsItem *item) { auto *i = qgraphicsitem_cast(item); i->ShowVisualization(true); - formView->setTitle(tr("Arc")); + m_formView->setTitle(tr("Arc")); AddPropertyObjectName(i, tr("Name:"), true); AddPropertyParentPointName(i->CenterPointName(), tr("Center point:"), AttrCenter); @@ -2771,7 +2805,7 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolArcWithLength(QGraphicsItem *it { auto *i = qgraphicsitem_cast(item); i->ShowVisualization(true); - formView->setTitle(tr("Arc with given length")); + m_formView->setTitle(tr("Arc with given length")); AddPropertyObjectName(i, tr("Name:"), true); AddPropertyParentPointName(i->CenterPointName(), tr("Center point:"), AttrCenter); @@ -2790,7 +2824,7 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolBisector(QGraphicsItem *item) { auto *i = qgraphicsitem_cast(item); i->ShowVisualization(true); - formView->setTitle(tr("Point along bisector")); + m_formView->setTitle(tr("Point along bisector")); AddPropertyObjectName(i, tr("Point label:")); AddPropertyParentPointName(i->FirstPointName(), tr("First point:"), AttrFirstPoint); @@ -2807,7 +2841,7 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolTrueDarts(QGraphicsItem *item) { auto *i = qgraphicsitem_cast(item); i->ShowVisualization(true); - formView->setTitle(tr("True darts")); + m_formView->setTitle(tr("True darts")); AddPropertyPointName1(i, tr("Point 1 label:")); AddPropertyPointName2(i, tr("Point 2 label:")); @@ -2824,7 +2858,7 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolCutArc(QGraphicsItem *item) { auto *i = qgraphicsitem_cast(item); i->ShowVisualization(true); - formView->setTitle(tr("Cut arc tool")); + m_formView->setTitle(tr("Cut arc tool")); AddPropertyObjectName(i, tr("Point label:")); AddPropertyParentPointName(i->CurveName(), tr("Arc:"), AttrArc); @@ -2839,7 +2873,7 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolCutSpline(QGraphicsItem *item) { auto *i = qgraphicsitem_cast(item); i->ShowVisualization(true); - formView->setTitle(tr("Tool for segmenting a curve")); + m_formView->setTitle(tr("Tool for segmenting a curve")); AddPropertyObjectName(i, tr("Point label:")); AddPropertyParentPointName(i->CurveName(), tr("Curve:"), AttrCurve); @@ -2854,7 +2888,7 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolCutSplinePath(QGraphicsItem *it { auto *i = qgraphicsitem_cast(item); i->ShowVisualization(true); - formView->setTitle(tr("Tool segment a pathed curve")); + m_formView->setTitle(tr("Tool segment a pathed curve")); AddPropertyObjectName(i, tr("Point label:")); AddPropertyParentPointName(i->CurveName(), tr("Curve:"), AttrCurve); @@ -2869,7 +2903,7 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolHeight(QGraphicsItem *item) { auto *i = qgraphicsitem_cast(item); i->ShowVisualization(true); - formView->setTitle(tr("Perpendicular point along line")); + m_formView->setTitle(tr("Perpendicular point along line")); AddPropertyObjectName(i, tr("Point label:")); AddPropertyParentPointName(i->BasePointName(), tr("Base point:"), AttrBasePoint); @@ -2885,7 +2919,7 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolLine(QGraphicsItem *item) { auto *i = qgraphicsitem_cast(item); i->ShowVisualization(true); - formView->setTitle(tr("Line between points")); + m_formView->setTitle(tr("Line between points")); AddPropertyParentPointName(i->FirstPointName(), tr("First point:"), AttrFirstPoint); AddPropertyParentPointName(i->SecondPointName(), tr("Second point:"), AttrSecondPoint); @@ -2901,7 +2935,7 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolLineIntersect(QGraphicsItem *it { auto *i = qgraphicsitem_cast(item); i->ShowVisualization(true); - formView->setTitle(tr("Point at line intersection")); + m_formView->setTitle(tr("Point at line intersection")); AddPropertyObjectName(i, tr("Point label:")); AddPropertyParentPointName(i->Line1P1Name(), tr("First line (first point):"), AttrP1Line1); @@ -2916,7 +2950,7 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolNormal(QGraphicsItem *item) { auto *i = qgraphicsitem_cast(item); i->ShowVisualization(true); - formView->setTitle(tr("Point along perpendicular")); + m_formView->setTitle(tr("Point along perpendicular")); AddPropertyFormula(tr("Length:"), i->GetFormulaLength(), AttrLength); AddPropertyObjectName(i, tr("Point label:")); @@ -2927,9 +2961,9 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolNormal(QGraphicsItem *item) auto *itemAngle = new VPE::VDoubleProperty(tr("Additional angle degrees:")); itemAngle->setValue(i->GetAngle()); - itemAngle->setSetting("Min", -360); - itemAngle->setSetting("Max", 360); - itemAngle->setSetting("Precision", 3); + itemAngle->setSetting(QStringLiteral("Min"), -360); + itemAngle->setSetting(QStringLiteral("Max"), 360); + itemAngle->setSetting(QStringLiteral("Precision"), 3); AddProperty(itemAngle, AttrAngle); AddPropertyText(tr("Notes:"), i->GetNotes(), AttrNotes); @@ -2940,7 +2974,7 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolPointOfContact(QGraphicsItem *i { auto *i = qgraphicsitem_cast(item); i->ShowVisualization(true); - formView->setTitle(tr("Point of intersection circle and segment")); + m_formView->setTitle(tr("Point of intersection circle and segment")); AddPropertyObjectName(i, tr("Point label:")); AddPropertyParentPointName(i->ArcCenterPointName(), tr("Center of arc:"), AttrCenter); @@ -2955,7 +2989,7 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolPointOfIntersection(QGraphicsIt { auto *i = qgraphicsitem_cast(item); i->ShowVisualization(true); - formView->setTitle(tr("Tool to make point from x & y of two other points")); + m_formView->setTitle(tr("Tool to make point from x & y of two other points")); AddPropertyObjectName(i, tr("Point label:")); AddPropertyParentPointName(i->FirstPointName(), tr("X: vertical point:"), AttrFirstPoint); @@ -2968,7 +3002,7 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolPointOfIntersectionArcs(QGraphi { auto *i = qgraphicsitem_cast(item); i->ShowVisualization(true); - formView->setTitle(tr("Tool to make point from intersection two arcs")); + m_formView->setTitle(tr("Tool to make point from intersection two arcs")); AddPropertyObjectName(i, tr("Point label:")); AddPropertyParentPointName(i->FirstArcName(), tr("First arc:"), AttrFirstArc); @@ -2982,7 +3016,7 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolPointOfIntersectionCircles(QGra { auto *i = qgraphicsitem_cast(item); i->ShowVisualization(true); - formView->setTitle(tr("Tool to make point from intersection two circles")); + m_formView->setTitle(tr("Tool to make point from intersection two circles")); AddPropertyObjectName(i, tr("Point label:")); AddPropertyParentPointName(i->FirstCircleCenterPointName(), tr("Center of the first circle:"), AttrC1Center); @@ -2996,9 +3030,9 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolPointOfIntersectionCircles(QGra //--------------------------------------------------------------------------------------------------------------------- void VToolOptionsPropertyBrowser::ShowOptionsToolPointOfIntersectionCurves(QGraphicsItem *item) { - auto i = qgraphicsitem_cast(item); + auto *i = qgraphicsitem_cast(item); i->ShowVisualization(true); - formView->setTitle(tr("Tool to make point from intersection two curves")); + m_formView->setTitle(tr("Tool to make point from intersection two curves")); AddPropertyObjectName(i, tr("Point label:")); AddPropertyParentPointName(i->FirstCurveName(), tr("First curve:"), AttrCurve1); @@ -3013,7 +3047,7 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolPointFromCircleAndTangent(QGrap { auto *i = qgraphicsitem_cast(item); i->ShowVisualization(true); - formView->setTitle(tr("Tool to make point from circle and tangent")); + m_formView->setTitle(tr("Tool to make point from circle and tangent")); AddPropertyObjectName(i, tr("Point label:")); AddPropertyParentPointName(i->CircleCenterPointName(), tr("Center of the circle:"), AttrCCenter); @@ -3028,7 +3062,7 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolPointFromArcAndTangent(QGraphic { auto *i = qgraphicsitem_cast(item); i->ShowVisualization(true); - formView->setTitle(tr("Tool to make point from arc and tangent")); + m_formView->setTitle(tr("Tool to make point from arc and tangent")); AddPropertyObjectName(i, tr("Point label:")); AddPropertyParentPointName(i->TangentPointName(), tr("Tangent point:"), AttrTangent); @@ -3042,7 +3076,7 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolShoulderPoint(QGraphicsItem *it { auto *i = qgraphicsitem_cast(item); i->ShowVisualization(true); - formView->setTitle(tr("Special point on shoulder")); + m_formView->setTitle(tr("Special point on shoulder")); AddPropertyObjectName(i, tr("Point label:")); AddPropertyParentPointName(i->BasePointName(), tr("First point:"), AttrBasePoint); @@ -3057,9 +3091,9 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolShoulderPoint(QGraphicsItem *it //--------------------------------------------------------------------------------------------------------------------- void VToolOptionsPropertyBrowser::ShowOptionsToolSpline(QGraphicsItem *item) { - auto i = qgraphicsitem_cast(item); + auto *i = qgraphicsitem_cast(item); i->ShowVisualization(true); - formView->setTitle(tr("Curve tool")); + m_formView->setTitle(tr("Curve tool")); const auto spl = i->getSpline(); @@ -3103,9 +3137,9 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolSpline(QGraphicsItem *item) //--------------------------------------------------------------------------------------------------------------------- void VToolOptionsPropertyBrowser::ShowOptionsToolCubicBezier(QGraphicsItem *item) { - auto i = qgraphicsitem_cast(item); + auto *i = qgraphicsitem_cast(item); i->ShowVisualization(true); - formView->setTitle(tr("Cubic bezier curve")); + m_formView->setTitle(tr("Cubic bezier curve")); AddPropertyObjectName(i, tr("Name:"), true); AddPropertyParentPointName(i->FirstPointName(), tr("First point:"), AttrPoint1); @@ -3124,7 +3158,7 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolSplinePath(QGraphicsItem *item) { auto *i = qgraphicsitem_cast(item); i->ShowVisualization(true); - formView->setTitle(tr("Tool for path curve")); + m_formView->setTitle(tr("Tool for path curve")); AddPropertyObjectName(i, tr("Name:"), true); AddPropertyAlias(i, tr("Alias:")); @@ -3139,7 +3173,7 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolCubicBezierPath(QGraphicsItem * { auto *i = qgraphicsitem_cast(item); i->ShowVisualization(true); - formView->setTitle(tr("Tool cubic bezier curve")); + m_formView->setTitle(tr("Tool cubic bezier curve")); AddPropertyObjectName(i, tr("Name:"), true); AddPropertyAlias(i, tr("Alias:")); @@ -3154,7 +3188,7 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolTriangle(QGraphicsItem *item) { auto *i = qgraphicsitem_cast(item); i->ShowVisualization(true); - formView->setTitle(tr("Tool triangle")); + m_formView->setTitle(tr("Tool triangle")); AddPropertyObjectName(i, tr("Point label:")); AddPropertyParentPointName(i->AxisP1Name(), tr("First point of axis:"), AttrAxisP1); @@ -3169,7 +3203,7 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolLineIntersectAxis(QGraphicsItem { auto *i = qgraphicsitem_cast(item); i->ShowVisualization(true); - formView->setTitle(tr("Point intersection line and axis")); + m_formView->setTitle(tr("Point intersection line and axis")); AddPropertyObjectName(i, tr("Point label:")); AddPropertyParentPointName(i->BasePointName(), tr("Axis point:"), AttrBasePoint); @@ -3186,7 +3220,7 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolCurveIntersectAxis(QGraphicsIte { auto *i = qgraphicsitem_cast(item); i->ShowVisualization(true); - formView->setTitle(tr("Point intersection curve and axis")); + m_formView->setTitle(tr("Point intersection curve and axis")); AddPropertyObjectName(i, tr("Point label:")); AddPropertyParentPointName(i->BasePointName(), tr("Axis point:"), AttrBasePoint); @@ -3202,7 +3236,7 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolRotation(QGraphicsItem *item) { auto *i = qgraphicsitem_cast(item); i->ShowVisualization(true); - formView->setTitle(tr("Tool rotation")); + m_formView->setTitle(tr("Tool rotation")); AddPropertyOperationSuffix(i, tr("Suffix:")); AddPropertyParentPointName(i->OriginPointName(), tr("Origin point:"), AttrCenter); @@ -3215,7 +3249,7 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolMove(QGraphicsItem *item) { auto *i = qgraphicsitem_cast(item); i->ShowVisualization(true); - formView->setTitle(tr("Tool move")); + m_formView->setTitle(tr("Tool move")); AddPropertyOperationSuffix(i, tr("Suffix:")); AddPropertyFormula(tr("Angle:"), i->GetFormulaAngle(), AttrAngle); @@ -3230,7 +3264,7 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolFlippingByLine(QGraphicsItem *i { auto *i = qgraphicsitem_cast(item); i->ShowVisualization(true); - formView->setTitle(tr("Tool flipping by line")); + m_formView->setTitle(tr("Tool flipping by line")); AddPropertyOperationSuffix(i, tr("Suffix:")); AddPropertyParentPointName(i->FirstLinePointName(), tr("First line point:"), AttrFirstPoint); @@ -3243,7 +3277,7 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolFlippingByAxis(QGraphicsItem *i { auto *i = qgraphicsitem_cast(item); i->ShowVisualization(true); - formView->setTitle(tr("Tool flipping by axis")); + m_formView->setTitle(tr("Tool flipping by axis")); AddPropertyAxisType(i, tr("Axis type:")); AddPropertyOperationSuffix(i, tr("Suffix:")); @@ -3256,7 +3290,7 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolEllipticalArc(QGraphicsItem *it { auto *i = qgraphicsitem_cast(item); i->ShowVisualization(true); - formView->setTitle(tr("Elliptical arc")); + m_formView->setTitle(tr("Elliptical arc")); AddPropertyObjectName(i, tr("Name:"), true); AddPropertyParentPointName(i->CenterPointName(), tr("Center point:"), AttrCenter); @@ -3274,7 +3308,7 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolEllipticalArc(QGraphicsItem *it void VToolOptionsPropertyBrowser::ShowOptionsBackgroundPixmapItem(QGraphicsItem *item) { auto *i = qgraphicsitem_cast(item); - formView->setTitle(tr("Background image")); + m_formView->setTitle(tr("Background image")); AddPropertyObjectName(i, tr("Name:"), false); AddPropertyBool(tr("Hold:"), i->IsHold(), *AttrHold); @@ -3286,7 +3320,7 @@ void VToolOptionsPropertyBrowser::ShowOptionsBackgroundPixmapItem(QGraphicsItem void VToolOptionsPropertyBrowser::ShowOptionsBackgroundSVGItem(QGraphicsItem *item) { auto *i = qgraphicsitem_cast(item); - formView->setTitle(tr("Background image")); + m_formView->setTitle(tr("Background image")); AddPropertyObjectName(i, tr("Name:"), false); AddPropertyBool(tr("Hold:"), i->IsHold(), *AttrHold); @@ -3297,601 +3331,601 @@ void VToolOptionsPropertyBrowser::ShowOptionsBackgroundSVGItem(QGraphicsItem *it //--------------------------------------------------------------------------------------------------------------------- void VToolOptionsPropertyBrowser::UpdateOptionsToolSinglePoint() { - auto *i = qgraphicsitem_cast(currentItem); - idToProperty[AttrName]->setValue(i->name()); - idToProperty[QLatin1String("position")]->setValue(i->GetBasePointPos()); - idToProperty[AttrNotes]->setValue(i->GetNotes()); + auto *i = qgraphicsitem_cast(m_currentItem); + m_idToProperty[AttrName]->setValue(i->name()); + m_idToProperty[QStringLiteral("position")]->setValue(i->GetBasePointPos()); + m_idToProperty[AttrNotes]->setValue(i->GetNotes()); } //--------------------------------------------------------------------------------------------------------------------- void VToolOptionsPropertyBrowser::UpdateOptionsToolEndLine() { - auto *i = qgraphicsitem_cast(currentItem); - idToProperty[AttrName]->setValue(i->name()); + auto *i = qgraphicsitem_cast(m_currentItem); + m_idToProperty[AttrName]->setValue(i->name()); { const qint32 index = VPE::VLineTypeProperty::IndexOfStyle(LineStylesPics(), i->getLineType()); - idToProperty[AttrTypeLine]->setValue(index); + m_idToProperty[AttrTypeLine]->setValue(index); } { const qint32 index = VPE::VLineColorProperty::IndexOfColor(VAbstractTool::ColorsList(), i->GetLineColor()); - idToProperty[AttrLineColor]->setValue(index); + m_idToProperty[AttrLineColor]->setValue(index); } QVariant valueFormula; valueFormula.setValue(i->GetFormulaLength()); - idToProperty[AttrLength]->setValue(valueFormula); + m_idToProperty[AttrLength]->setValue(valueFormula); QVariant valueAngle; valueAngle.setValue(i->GetFormulaAngle()); - idToProperty[AttrAngle]->setValue(valueAngle); + m_idToProperty[AttrAngle]->setValue(valueAngle); QVariant valueBasePoint; valueBasePoint.setValue(i->BasePointName()); - idToProperty[AttrBasePoint]->setValue(valueBasePoint); + m_idToProperty[AttrBasePoint]->setValue(valueBasePoint); - idToProperty[AttrNotes]->setValue(i->GetNotes()); + m_idToProperty[AttrNotes]->setValue(i->GetNotes()); } //--------------------------------------------------------------------------------------------------------------------- void VToolOptionsPropertyBrowser::UpdateOptionsToolAlongLine() { - auto *i = qgraphicsitem_cast(currentItem); - idToProperty[AttrName]->setValue(i->name()); + auto *i = qgraphicsitem_cast(m_currentItem); + m_idToProperty[AttrName]->setValue(i->name()); { const qint32 index = VPE::VLineTypeProperty::IndexOfStyle(LineStylesPics(), i->getLineType()); - idToProperty[AttrTypeLine]->setValue(index); + m_idToProperty[AttrTypeLine]->setValue(index); } { const qint32 index = VPE::VLineColorProperty::IndexOfColor(VAbstractTool::ColorsList(), i->GetLineColor()); - idToProperty[AttrLineColor]->setValue(index); + m_idToProperty[AttrLineColor]->setValue(index); } QVariant valueFormula; valueFormula.setValue(i->GetFormulaLength()); - idToProperty[AttrLength]->setValue(valueFormula); + m_idToProperty[AttrLength]->setValue(valueFormula); QVariant valueBasePoint; valueBasePoint.setValue(i->BasePointName()); - idToProperty[AttrBasePoint]->setValue(valueBasePoint); + m_idToProperty[AttrBasePoint]->setValue(valueBasePoint); QVariant valueSecondPoint; valueSecondPoint.setValue(i->SecondPointName()); - idToProperty[AttrSecondPoint]->setValue(valueSecondPoint); + m_idToProperty[AttrSecondPoint]->setValue(valueSecondPoint); - idToProperty[AttrNotes]->setValue(i->GetNotes()); + m_idToProperty[AttrNotes]->setValue(i->GetNotes()); } //--------------------------------------------------------------------------------------------------------------------- void VToolOptionsPropertyBrowser::UpdateOptionsToolArc() { - auto *i = qgraphicsitem_cast(currentItem); + auto *i = qgraphicsitem_cast(m_currentItem); - idToProperty[AttrName]->setValue(i->name()); + m_idToProperty[AttrName]->setValue(i->name()); QVariant valueRadius; valueRadius.setValue(i->GetFormulaRadius()); - idToProperty[AttrRadius]->setValue(valueRadius); + m_idToProperty[AttrRadius]->setValue(valueRadius); QVariant valueFirstAngle; valueFirstAngle.setValue(i->GetFormulaF1()); - idToProperty[AttrAngle1]->setValue(valueFirstAngle); + m_idToProperty[AttrAngle1]->setValue(valueFirstAngle); QVariant valueSecondAngle; valueSecondAngle.setValue(i->GetFormulaF2()); - idToProperty[AttrAngle2]->setValue(valueSecondAngle); + m_idToProperty[AttrAngle2]->setValue(valueSecondAngle); { const qint32 index = VPE::VLineTypeProperty::IndexOfStyle(CurvePenStylesPics(), i->GetPenStyle()); - idToProperty[AttrPenStyle]->setValue(index); + m_idToProperty[AttrPenStyle]->setValue(index); } { const qint32 index = VPE::VLineColorProperty::IndexOfColor(VAbstractTool::ColorsList(), i->GetLineColor()); - idToProperty[AttrColor]->setValue(index); + m_idToProperty[AttrColor]->setValue(index); } QVariant valueCenterPoint; valueCenterPoint.setValue(i->CenterPointName()); - idToProperty[AttrCenter]->setValue(valueCenterPoint); + m_idToProperty[AttrCenter]->setValue(valueCenterPoint); QVariant valueApproximationScale; valueApproximationScale.setValue(i->GetApproximationScale()); - idToProperty[AttrAScale]->setValue(valueApproximationScale); + m_idToProperty[AttrAScale]->setValue(valueApproximationScale); - idToProperty[AttrNotes]->setValue(i->GetNotes()); + m_idToProperty[AttrNotes]->setValue(i->GetNotes()); - idToProperty[AttrAlias]->setValue(i->GetAliasSuffix()); + m_idToProperty[AttrAlias]->setValue(i->GetAliasSuffix()); } //--------------------------------------------------------------------------------------------------------------------- void VToolOptionsPropertyBrowser::UpdateOptionsToolArcWithLength() { - auto *i = qgraphicsitem_cast(currentItem); + auto *i = qgraphicsitem_cast(m_currentItem); - idToProperty[AttrName]->setValue(i->name()); + m_idToProperty[AttrName]->setValue(i->name()); QVariant valueRadius; valueRadius.setValue(i->GetFormulaRadius()); - idToProperty[AttrRadius]->setValue(valueRadius); + m_idToProperty[AttrRadius]->setValue(valueRadius); QVariant valueFirstAngle; valueFirstAngle.setValue(i->GetFormulaF1()); - idToProperty[AttrAngle1]->setValue(valueFirstAngle); + m_idToProperty[AttrAngle1]->setValue(valueFirstAngle); QVariant valueLength; valueLength.setValue(i->GetFormulaLength()); - idToProperty[AttrLength]->setValue(valueLength); + m_idToProperty[AttrLength]->setValue(valueLength); { const qint32 index = VPE::VLineTypeProperty::IndexOfStyle(CurvePenStylesPics(), i->GetPenStyle()); - idToProperty[AttrPenStyle]->setValue(index); + m_idToProperty[AttrPenStyle]->setValue(index); } { const qint32 index = VPE::VLineColorProperty::IndexOfColor(VAbstractTool::ColorsList(), i->GetLineColor()); - idToProperty[AttrColor]->setValue(index); + m_idToProperty[AttrColor]->setValue(index); } QVariant valueCenterPoint; valueCenterPoint.setValue(i->CenterPointName()); - idToProperty[AttrCenter]->setValue(valueCenterPoint); + m_idToProperty[AttrCenter]->setValue(valueCenterPoint); QVariant valueApproximationScale; valueApproximationScale.setValue(i->GetApproximationScale()); - idToProperty[AttrAScale]->setValue(valueApproximationScale); + m_idToProperty[AttrAScale]->setValue(valueApproximationScale); - idToProperty[AttrNotes]->setValue(i->GetNotes()); + m_idToProperty[AttrNotes]->setValue(i->GetNotes()); - idToProperty[AttrAlias]->setValue(i->GetAliasSuffix()); + m_idToProperty[AttrAlias]->setValue(i->GetAliasSuffix()); } //--------------------------------------------------------------------------------------------------------------------- void VToolOptionsPropertyBrowser::UpdateOptionsToolBisector() { - auto *i = qgraphicsitem_cast(currentItem); + auto *i = qgraphicsitem_cast(m_currentItem); - idToProperty[AttrName]->setValue(i->name()); + m_idToProperty[AttrName]->setValue(i->name()); QVariant valueFormula; valueFormula.setValue(i->GetFormulaLength()); - idToProperty[AttrLength]->setValue(valueFormula); + m_idToProperty[AttrLength]->setValue(valueFormula); { const qint32 index = VPE::VLineTypeProperty::IndexOfStyle(LineStylesPics(), i->getLineType()); - idToProperty[AttrTypeLine]->setValue(index); + m_idToProperty[AttrTypeLine]->setValue(index); } { const qint32 index = VPE::VLineColorProperty::IndexOfColor(VAbstractTool::ColorsList(), i->GetLineColor()); - idToProperty[AttrLineColor]->setValue(index); + m_idToProperty[AttrLineColor]->setValue(index); } QVariant valueFirstPoint; valueFirstPoint.setValue(i->FirstPointName()); - idToProperty[AttrFirstPoint]->setValue(valueFirstPoint); + m_idToProperty[AttrFirstPoint]->setValue(valueFirstPoint); QVariant valueBasePoint; valueBasePoint.setValue(i->BasePointName()); - idToProperty[AttrBasePoint]->setValue(valueBasePoint); + m_idToProperty[AttrBasePoint]->setValue(valueBasePoint); QVariant valueThirdPoint; valueThirdPoint.setValue(i->ThirdPointName()); - idToProperty[AttrThirdPoint]->setValue(valueThirdPoint); + m_idToProperty[AttrThirdPoint]->setValue(valueThirdPoint); - idToProperty[AttrNotes]->setValue(i->GetNotes()); + m_idToProperty[AttrNotes]->setValue(i->GetNotes()); } //--------------------------------------------------------------------------------------------------------------------- void VToolOptionsPropertyBrowser::UpdateOptionsToolTrueDarts() { - auto *i = qgraphicsitem_cast(currentItem); + auto *i = qgraphicsitem_cast(m_currentItem); - idToProperty[AttrName1]->setValue(i->nameP1()); - idToProperty[AttrName2]->setValue(i->nameP2()); + m_idToProperty[AttrName1]->setValue(i->nameP1()); + m_idToProperty[AttrName2]->setValue(i->nameP2()); QVariant valueFirstPoint; valueFirstPoint.setValue(i->BaseLineP1Name()); - idToProperty[AttrFirstPoint]->setValue(valueFirstPoint); + m_idToProperty[AttrFirstPoint]->setValue(valueFirstPoint); QVariant valueSecondPoint; valueSecondPoint.setValue(i->BaseLineP2Name()); - idToProperty[AttrSecondPoint]->setValue(valueSecondPoint); + m_idToProperty[AttrSecondPoint]->setValue(valueSecondPoint); QVariant valueDrartFirstPoint; valueDrartFirstPoint.setValue(i->DartP1Name()); - idToProperty[AttrDartP1]->setValue(valueDrartFirstPoint); + m_idToProperty[AttrDartP1]->setValue(valueDrartFirstPoint); QVariant valueDartSecondPoint; valueDartSecondPoint.setValue(i->DartP2Name()); - idToProperty[AttrDartP2]->setValue(valueDartSecondPoint); + m_idToProperty[AttrDartP2]->setValue(valueDartSecondPoint); QVariant valueDartThirdPoint; valueDartThirdPoint.setValue(i->DartP3Name()); - idToProperty[AttrDartP3]->setValue(valueDartThirdPoint); + m_idToProperty[AttrDartP3]->setValue(valueDartThirdPoint); - idToProperty[AttrNotes]->setValue(i->GetNotes()); + m_idToProperty[AttrNotes]->setValue(i->GetNotes()); } //--------------------------------------------------------------------------------------------------------------------- void VToolOptionsPropertyBrowser::UpdateOptionsToolCutArc() { - auto *i = qgraphicsitem_cast(currentItem); + auto *i = qgraphicsitem_cast(m_currentItem); - idToProperty[AttrName]->setValue(i->name()); + m_idToProperty[AttrName]->setValue(i->name()); QVariant valueFormula; valueFormula.setValue(i->GetFormulaLength()); - idToProperty[AttrLength]->setValue(valueFormula); + m_idToProperty[AttrLength]->setValue(valueFormula); QVariant valueArc; valueArc.setValue(i->CurveName()); - idToProperty[AttrArc]->setValue(valueArc); + m_idToProperty[AttrArc]->setValue(valueArc); - idToProperty[AttrNotes]->setValue(i->GetNotes()); + m_idToProperty[AttrNotes]->setValue(i->GetNotes()); - idToProperty[AttrAlias1]->setValue(i->GetAliasSuffix1()); - idToProperty[AttrAlias2]->setValue(i->GetAliasSuffix2()); + m_idToProperty[AttrAlias1]->setValue(i->GetAliasSuffix1()); + m_idToProperty[AttrAlias2]->setValue(i->GetAliasSuffix2()); } //--------------------------------------------------------------------------------------------------------------------- void VToolOptionsPropertyBrowser::UpdateOptionsToolCutSpline() { - auto *i = qgraphicsitem_cast(currentItem); + auto *i = qgraphicsitem_cast(m_currentItem); - idToProperty[AttrName]->setValue(i->name()); + m_idToProperty[AttrName]->setValue(i->name()); QVariant valueFormula; valueFormula.setValue(i->GetFormulaLength()); - idToProperty[AttrLength]->setValue(valueFormula); + m_idToProperty[AttrLength]->setValue(valueFormula); QVariant valueCurve; valueCurve.setValue(i->CurveName()); - idToProperty[AttrCurve]->setValue(valueCurve); + m_idToProperty[AttrCurve]->setValue(valueCurve); - idToProperty[AttrNotes]->setValue(i->GetNotes()); + m_idToProperty[AttrNotes]->setValue(i->GetNotes()); - idToProperty[AttrAlias1]->setValue(i->GetAliasSuffix1()); - idToProperty[AttrAlias2]->setValue(i->GetAliasSuffix2()); + m_idToProperty[AttrAlias1]->setValue(i->GetAliasSuffix1()); + m_idToProperty[AttrAlias2]->setValue(i->GetAliasSuffix2()); } //--------------------------------------------------------------------------------------------------------------------- void VToolOptionsPropertyBrowser::UpdateOptionsToolCutSplinePath() { - auto *i = qgraphicsitem_cast(currentItem); + auto *i = qgraphicsitem_cast(m_currentItem); - idToProperty[AttrName]->setValue(i->name()); + m_idToProperty[AttrName]->setValue(i->name()); QVariant valueFormula; valueFormula.setValue(i->GetFormulaLength()); - idToProperty[AttrLength]->setValue(valueFormula); + m_idToProperty[AttrLength]->setValue(valueFormula); QVariant valueCurve; valueCurve.setValue(i->CurveName()); - idToProperty[AttrCurve]->setValue(valueCurve); + m_idToProperty[AttrCurve]->setValue(valueCurve); - idToProperty[AttrNotes]->setValue(i->GetNotes()); + m_idToProperty[AttrNotes]->setValue(i->GetNotes()); - idToProperty[AttrAlias1]->setValue(i->GetAliasSuffix1()); - idToProperty[AttrAlias2]->setValue(i->GetAliasSuffix2()); + m_idToProperty[AttrAlias1]->setValue(i->GetAliasSuffix1()); + m_idToProperty[AttrAlias2]->setValue(i->GetAliasSuffix2()); } //--------------------------------------------------------------------------------------------------------------------- void VToolOptionsPropertyBrowser::UpdateOptionsToolHeight() { - auto *i = qgraphicsitem_cast(currentItem); + auto *i = qgraphicsitem_cast(m_currentItem); - idToProperty[AttrName]->setValue(i->name()); + m_idToProperty[AttrName]->setValue(i->name()); { const qint32 index = VPE::VLineTypeProperty::IndexOfStyle(LineStylesPics(), i->getLineType()); - idToProperty[AttrTypeLine]->setValue(index); + m_idToProperty[AttrTypeLine]->setValue(index); } { const qint32 index = VPE::VLineColorProperty::IndexOfColor(VAbstractTool::ColorsList(), i->GetLineColor()); - idToProperty[AttrLineColor]->setValue(index); + m_idToProperty[AttrLineColor]->setValue(index); } QVariant valueBasePoint; valueBasePoint.setValue(i->BasePointName()); - idToProperty[AttrBasePoint]->setValue(valueBasePoint); + m_idToProperty[AttrBasePoint]->setValue(valueBasePoint); QVariant valueFirstLinePoint; valueFirstLinePoint.setValue(i->FirstLinePointName()); - idToProperty[AttrP1Line]->setValue(valueFirstLinePoint); + m_idToProperty[AttrP1Line]->setValue(valueFirstLinePoint); QVariant valueSecondLinePoint; valueSecondLinePoint.setValue(i->SecondLinePointName()); - idToProperty[AttrP2Line]->setValue(valueSecondLinePoint); + m_idToProperty[AttrP2Line]->setValue(valueSecondLinePoint); - idToProperty[AttrNotes]->setValue(i->GetNotes()); + m_idToProperty[AttrNotes]->setValue(i->GetNotes()); } //--------------------------------------------------------------------------------------------------------------------- void VToolOptionsPropertyBrowser::UpdateOptionsToolLine() { - auto *i = qgraphicsitem_cast(currentItem); + auto *i = qgraphicsitem_cast(m_currentItem); { const qint32 index = VPE::VLineTypeProperty::IndexOfStyle(LineStylesPics(), i->getLineType()); - idToProperty[AttrTypeLine]->setValue(index); + m_idToProperty[AttrTypeLine]->setValue(index); } { const qint32 index = VPE::VLineColorProperty::IndexOfColor(VAbstractTool::ColorsList(), i->GetLineColor()); - idToProperty[AttrLineColor]->setValue(index); + m_idToProperty[AttrLineColor]->setValue(index); } QVariant valueFirstPoint; valueFirstPoint.setValue(i->FirstPointName()); - idToProperty[AttrFirstPoint]->setValue(valueFirstPoint); + m_idToProperty[AttrFirstPoint]->setValue(valueFirstPoint); QVariant valueSecondPoint; valueSecondPoint.setValue(i->SecondPointName()); - idToProperty[AttrSecondPoint]->setValue(valueSecondPoint); + m_idToProperty[AttrSecondPoint]->setValue(valueSecondPoint); - idToProperty[AttrNotes]->setValue(i->GetNotes()); + m_idToProperty[AttrNotes]->setValue(i->GetNotes()); } //--------------------------------------------------------------------------------------------------------------------- void VToolOptionsPropertyBrowser::UpdateOptionsToolLineIntersect() { - auto *i = qgraphicsitem_cast(currentItem); + auto *i = qgraphicsitem_cast(m_currentItem); - idToProperty[AttrName]->setValue(i->name()); + m_idToProperty[AttrName]->setValue(i->name()); QVariant valueLine1P1; valueLine1P1.setValue(i->Line1P1Name()); - idToProperty[AttrP1Line1]->setValue(valueLine1P1); + m_idToProperty[AttrP1Line1]->setValue(valueLine1P1); QVariant valueLine1P2; valueLine1P2.setValue(i->Line1P2Name()); - idToProperty[AttrP2Line1]->setValue(valueLine1P2); + m_idToProperty[AttrP2Line1]->setValue(valueLine1P2); QVariant valueLine2P1; valueLine2P1.setValue(i->Line2P1Name()); - idToProperty[AttrP1Line2]->setValue(valueLine2P1); + m_idToProperty[AttrP1Line2]->setValue(valueLine2P1); QVariant valueLine2P2; valueLine2P2.setValue(i->Line2P2Name()); - idToProperty[AttrP2Line2]->setValue(valueLine2P2); + m_idToProperty[AttrP2Line2]->setValue(valueLine2P2); - idToProperty[AttrNotes]->setValue(i->GetNotes()); + m_idToProperty[AttrNotes]->setValue(i->GetNotes()); } //--------------------------------------------------------------------------------------------------------------------- void VToolOptionsPropertyBrowser::UpdateOptionsToolNormal() { - auto *i = qgraphicsitem_cast(currentItem); + auto *i = qgraphicsitem_cast(m_currentItem); QVariant valueFormula; valueFormula.setValue(i->GetFormulaLength()); - idToProperty[AttrLength]->setValue(valueFormula); + m_idToProperty[AttrLength]->setValue(valueFormula); - idToProperty[AttrName]->setValue(i->name()); + m_idToProperty[AttrName]->setValue(i->name()); - idToProperty[AttrAngle]->setValue( i->GetAngle()); + m_idToProperty[AttrAngle]->setValue( i->GetAngle()); { const qint32 index = VPE::VLineTypeProperty::IndexOfStyle(LineStylesPics(), i->getLineType()); - idToProperty[AttrTypeLine]->setValue(index); + m_idToProperty[AttrTypeLine]->setValue(index); } { const qint32 index = VPE::VLineColorProperty::IndexOfColor(VAbstractTool::ColorsList(), i->GetLineColor()); - idToProperty[AttrLineColor]->setValue(index); + m_idToProperty[AttrLineColor]->setValue(index); } QVariant valueBasePoint; valueBasePoint.setValue(i->BasePointName()); - idToProperty[AttrBasePoint]->setValue(valueBasePoint); + m_idToProperty[AttrBasePoint]->setValue(valueBasePoint); QVariant valueSecondPoint; valueSecondPoint.setValue(i->SecondPointName()); - idToProperty[AttrSecondPoint]->setValue(valueSecondPoint); + m_idToProperty[AttrSecondPoint]->setValue(valueSecondPoint); - idToProperty[AttrNotes]->setValue(i->GetNotes()); + m_idToProperty[AttrNotes]->setValue(i->GetNotes()); } //--------------------------------------------------------------------------------------------------------------------- void VToolOptionsPropertyBrowser::UpdateOptionsToolPointOfContact() { - auto *i = qgraphicsitem_cast(currentItem); + auto *i = qgraphicsitem_cast(m_currentItem); QVariant valueFormula; valueFormula.setValue(i->getArcRadius()); - idToProperty[AttrRadius]->setValue(valueFormula); + m_idToProperty[AttrRadius]->setValue(valueFormula); - idToProperty[AttrName]->setValue(i->name()); + m_idToProperty[AttrName]->setValue(i->name()); QVariant valueCenterPoint; valueCenterPoint.setValue(i->ArcCenterPointName()); - idToProperty[AttrCenter]->setValue(valueCenterPoint); + m_idToProperty[AttrCenter]->setValue(valueCenterPoint); QVariant valueFirstPoint; valueFirstPoint.setValue(i->FirstPointName()); - idToProperty[AttrFirstPoint]->setValue(valueFirstPoint); + m_idToProperty[AttrFirstPoint]->setValue(valueFirstPoint); QVariant valueSecondPoint; valueSecondPoint.setValue(i->SecondPointName()); - idToProperty[AttrSecondPoint]->setValue(valueSecondPoint); + m_idToProperty[AttrSecondPoint]->setValue(valueSecondPoint); - idToProperty[AttrNotes]->setValue(i->GetNotes()); + m_idToProperty[AttrNotes]->setValue(i->GetNotes()); } //--------------------------------------------------------------------------------------------------------------------- void VToolOptionsPropertyBrowser::UpdateOptionsToolPointOfIntersection() { - auto *i = qgraphicsitem_cast(currentItem); + auto *i = qgraphicsitem_cast(m_currentItem); - idToProperty[AttrName]->setValue(i->name()); + m_idToProperty[AttrName]->setValue(i->name()); QVariant valueFirstPoint; valueFirstPoint.setValue(i->FirstPointName()); - idToProperty[AttrFirstPoint]->setValue(valueFirstPoint); + m_idToProperty[AttrFirstPoint]->setValue(valueFirstPoint); QVariant valueSecondPoint; valueSecondPoint.setValue(i->SecondPointName()); - idToProperty[AttrSecondPoint]->setValue(valueSecondPoint); + m_idToProperty[AttrSecondPoint]->setValue(valueSecondPoint); - idToProperty[AttrNotes]->setValue(i->GetNotes()); + m_idToProperty[AttrNotes]->setValue(i->GetNotes()); } //--------------------------------------------------------------------------------------------------------------------- void VToolOptionsPropertyBrowser::UpdateOptionsToolPointOfIntersectionArcs() { - auto *i = qgraphicsitem_cast(currentItem); + auto *i = qgraphicsitem_cast(m_currentItem); - idToProperty[AttrName]->setValue(i->name()); - idToProperty[AttrCrossPoint]->setValue(static_cast(i->GetCrossCirclesPoint())-1); + m_idToProperty[AttrName]->setValue(i->name()); + m_idToProperty[AttrCrossPoint]->setValue(static_cast(i->GetCrossCirclesPoint())-1); QVariant valueFirstArc; valueFirstArc.setValue(i->FirstArcName()); - idToProperty[AttrFirstArc]->setValue(valueFirstArc); + m_idToProperty[AttrFirstArc]->setValue(valueFirstArc); QVariant valueSecondArc; valueSecondArc.setValue(i->SecondArcName()); - idToProperty[AttrSecondArc]->setValue(valueSecondArc); + m_idToProperty[AttrSecondArc]->setValue(valueSecondArc); - idToProperty[AttrNotes]->setValue(i->GetNotes()); + m_idToProperty[AttrNotes]->setValue(i->GetNotes()); } //--------------------------------------------------------------------------------------------------------------------- void VToolOptionsPropertyBrowser::UpdateOptionsToolPointOfIntersectionCircles() { - auto *i = qgraphicsitem_cast(currentItem); + auto *i = qgraphicsitem_cast(m_currentItem); - idToProperty[AttrName]->setValue(i->name()); - idToProperty[AttrCrossPoint]->setValue(static_cast(i->GetCrossCirclesPoint())-1); + m_idToProperty[AttrName]->setValue(i->name()); + m_idToProperty[AttrCrossPoint]->setValue(static_cast(i->GetCrossCirclesPoint())-1); QVariant c1Radius; c1Radius.setValue(i->GetFirstCircleRadius()); - idToProperty[AttrC1Radius]->setValue(c1Radius); + m_idToProperty[AttrC1Radius]->setValue(c1Radius); QVariant c2Radius; c2Radius.setValue(i->GetSecondCircleRadius()); - idToProperty[AttrC2Radius]->setValue(c2Radius); + m_idToProperty[AttrC2Radius]->setValue(c2Radius); QVariant valueC1Center; valueC1Center.setValue(i->FirstCircleCenterPointName()); - idToProperty[AttrC1Center]->setValue(valueC1Center); + m_idToProperty[AttrC1Center]->setValue(valueC1Center); QVariant valueC2Center; valueC2Center.setValue(i->SecondCircleCenterPointName()); - idToProperty[AttrC2Center]->setValue(valueC2Center); + m_idToProperty[AttrC2Center]->setValue(valueC2Center); - idToProperty[AttrNotes]->setValue(i->GetNotes()); + m_idToProperty[AttrNotes]->setValue(i->GetNotes()); } //--------------------------------------------------------------------------------------------------------------------- void VToolOptionsPropertyBrowser::UpdateOptionsToolPointOfIntersectionCurves() { - auto *i = qgraphicsitem_cast(currentItem); + auto *i = qgraphicsitem_cast(m_currentItem); - idToProperty[AttrName]->setValue(i->name()); - idToProperty[AttrVCrossPoint]->setValue(static_cast(i->GetVCrossPoint())-1); - idToProperty[AttrHCrossPoint]->setValue(static_cast(i->GetHCrossPoint())-1); + m_idToProperty[AttrName]->setValue(i->name()); + m_idToProperty[AttrVCrossPoint]->setValue(static_cast(i->GetVCrossPoint())-1); + m_idToProperty[AttrHCrossPoint]->setValue(static_cast(i->GetHCrossPoint())-1); QVariant valueCurve1; valueCurve1.setValue(i->FirstCurveName()); - idToProperty[AttrCurve1]->setValue(valueCurve1); + m_idToProperty[AttrCurve1]->setValue(valueCurve1); QVariant valueCurve2; valueCurve2.setValue(i->SecondCurveName()); - idToProperty[AttrCurve2]->setValue(valueCurve2); + m_idToProperty[AttrCurve2]->setValue(valueCurve2); - idToProperty[AttrNotes]->setValue(i->GetNotes()); + m_idToProperty[AttrNotes]->setValue(i->GetNotes()); } //--------------------------------------------------------------------------------------------------------------------- void VToolOptionsPropertyBrowser::UpdateOptionsToolPointFromCircleAndTangent() { - auto *i = qgraphicsitem_cast(currentItem); + auto *i = qgraphicsitem_cast(m_currentItem); - idToProperty[AttrName]->setValue(i->name()); - idToProperty[AttrCrossPoint]->setValue(static_cast(i->GetCrossCirclesPoint())-1); + m_idToProperty[AttrName]->setValue(i->name()); + m_idToProperty[AttrCrossPoint]->setValue(static_cast(i->GetCrossCirclesPoint())-1); QVariant cRadius; cRadius.setValue(i->GetCircleRadius()); - idToProperty[AttrCRadius]->setValue(cRadius); + m_idToProperty[AttrCRadius]->setValue(cRadius); QVariant valueCenterPoint; valueCenterPoint.setValue(i->CircleCenterPointName()); - idToProperty[AttrCCenter]->setValue(valueCenterPoint); + m_idToProperty[AttrCCenter]->setValue(valueCenterPoint); QVariant valueTangentPoint; valueTangentPoint.setValue(i->TangentPointName()); - idToProperty[AttrTangent]->setValue(valueTangentPoint); + m_idToProperty[AttrTangent]->setValue(valueTangentPoint); - idToProperty[AttrNotes]->setValue(i->GetNotes()); + m_idToProperty[AttrNotes]->setValue(i->GetNotes()); } //--------------------------------------------------------------------------------------------------------------------- void VToolOptionsPropertyBrowser::UpdateOptionsToolPointFromArcAndTangent() { - auto *i = qgraphicsitem_cast(currentItem); + auto *i = qgraphicsitem_cast(m_currentItem); - idToProperty[AttrName]->setValue(i->name()); - idToProperty[AttrCrossPoint]->setValue(static_cast(i->GetCrossCirclesPoint())-1); + m_idToProperty[AttrName]->setValue(i->name()); + m_idToProperty[AttrCrossPoint]->setValue(static_cast(i->GetCrossCirclesPoint())-1); QVariant valueTangentPoint; valueTangentPoint.setValue(i->TangentPointName()); - idToProperty[AttrTangent]->setValue(valueTangentPoint); + m_idToProperty[AttrTangent]->setValue(valueTangentPoint); QVariant valueArc; valueArc.setValue(i->ArcName()); - idToProperty[AttrArc]->setValue(valueArc); + m_idToProperty[AttrArc]->setValue(valueArc); - idToProperty[AttrNotes]->setValue(i->GetNotes()); + m_idToProperty[AttrNotes]->setValue(i->GetNotes()); } //--------------------------------------------------------------------------------------------------------------------- void VToolOptionsPropertyBrowser::UpdateOptionsToolShoulderPoint() { - auto *i = qgraphicsitem_cast(currentItem); + auto *i = qgraphicsitem_cast(m_currentItem); QVariant valueFormula; valueFormula.setValue(i->GetFormulaLength()); - idToProperty[AttrLength]->setValue(valueFormula); + m_idToProperty[AttrLength]->setValue(valueFormula); - idToProperty[AttrName]->setValue(i->name()); + m_idToProperty[AttrName]->setValue(i->name()); { const qint32 index = VPE::VLineTypeProperty::IndexOfStyle(LineStylesPics(), i->getLineType()); - idToProperty[AttrTypeLine]->setValue(index); + m_idToProperty[AttrTypeLine]->setValue(index); } { const qint32 index = VPE::VLineColorProperty::IndexOfColor(VAbstractTool::ColorsList(), i->GetLineColor()); - idToProperty[AttrLineColor]->setValue(index); + m_idToProperty[AttrLineColor]->setValue(index); } QVariant valueBasePoint; valueBasePoint.setValue(i->BasePointName()); - idToProperty[AttrBasePoint]->setValue(valueBasePoint); + m_idToProperty[AttrBasePoint]->setValue(valueBasePoint); QVariant valueSecondPoint; valueSecondPoint.setValue(i->SecondPointName()); - idToProperty[AttrSecondPoint]->setValue(valueSecondPoint); + m_idToProperty[AttrSecondPoint]->setValue(valueSecondPoint); QVariant valueThirdPoint; valueThirdPoint.setValue(i->ShoulderPointName()); - idToProperty[AttrThirdPoint]->setValue(valueThirdPoint); + m_idToProperty[AttrThirdPoint]->setValue(valueThirdPoint); - idToProperty[AttrNotes]->setValue(i->GetNotes()); + m_idToProperty[AttrNotes]->setValue(i->GetNotes()); } //--------------------------------------------------------------------------------------------------------------------- void VToolOptionsPropertyBrowser::UpdateOptionsToolSpline() { - auto *i = qgraphicsitem_cast(currentItem); + auto *i = qgraphicsitem_cast(m_currentItem); const VSpline spl = i->getSpline(); - idToProperty[AttrName]->setValue(i->name()); + m_idToProperty[AttrName]->setValue(i->name()); VFormula angle1F(spl.GetStartAngleFormula(), i->getData()); angle1F.setCheckZero(false); @@ -3900,7 +3934,7 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolSpline() angle1F.Eval(); QVariant angle1; angle1.setValue(angle1F); - idToProperty[AttrAngle1]->setValue(angle1); + m_idToProperty[AttrAngle1]->setValue(angle1); VFormula length1F(spl.GetC1LengthFormula(), i->getData()); length1F.setCheckZero(false); @@ -3909,7 +3943,7 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolSpline() length1F.Eval(); QVariant length1; length1.setValue(length1F); - idToProperty[AttrLength1]->setValue(length1); + m_idToProperty[AttrLength1]->setValue(length1); VFormula angle2F(spl.GetEndAngleFormula(), i->getData()); angle2F.setCheckZero(false); @@ -3918,7 +3952,7 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolSpline() angle2F.Eval(); QVariant angle2; angle2.setValue(angle2F); - idToProperty[AttrAngle2]->setValue(angle2); + m_idToProperty[AttrAngle2]->setValue(angle2); VFormula length2F(spl.GetC2LengthFormula(), i->getData()); length2F.setCheckZero(false); @@ -3927,341 +3961,341 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolSpline() length2F.Eval(); QVariant length2; length2.setValue(length2F); - idToProperty[AttrLength2]->setValue(length2); + m_idToProperty[AttrLength2]->setValue(length2); { const qint32 index = VPE::VLineTypeProperty::IndexOfStyle(CurvePenStylesPics(), i->GetPenStyle()); - idToProperty[AttrPenStyle]->setValue(index); + m_idToProperty[AttrPenStyle]->setValue(index); } - idToProperty[AttrColor]->setValue(VPE::VLineColorProperty::IndexOfColor(VAbstractTool::ColorsList(), + m_idToProperty[AttrColor]->setValue(VPE::VLineColorProperty::IndexOfColor(VAbstractTool::ColorsList(), i->GetLineColor())); QVariant valueApproximationScale; valueApproximationScale.setValue(spl.GetApproximationScale()); - idToProperty[AttrAScale]->setValue(valueApproximationScale); + m_idToProperty[AttrAScale]->setValue(valueApproximationScale); - idToProperty[AttrNotes]->setValue(i->GetNotes()); + m_idToProperty[AttrNotes]->setValue(i->GetNotes()); - idToProperty[AttrAlias]->setValue(i->GetAliasSuffix()); + m_idToProperty[AttrAlias]->setValue(i->GetAliasSuffix()); } //--------------------------------------------------------------------------------------------------------------------- void VToolOptionsPropertyBrowser::UpdateOptionsToolCubicBezier() { - auto *i = qgraphicsitem_cast(currentItem); + auto *i = qgraphicsitem_cast(m_currentItem); - idToProperty[AttrName]->setValue(i->name()); + m_idToProperty[AttrName]->setValue(i->name()); { const qint32 index = VPE::VLineTypeProperty::IndexOfStyle(CurvePenStylesPics(), i->GetPenStyle()); - idToProperty[AttrPenStyle]->setValue(index); + m_idToProperty[AttrPenStyle]->setValue(index); } - idToProperty[AttrColor]->setValue(VPE::VLineColorProperty::IndexOfColor(VAbstractTool::ColorsList(), + m_idToProperty[AttrColor]->setValue(VPE::VLineColorProperty::IndexOfColor(VAbstractTool::ColorsList(), i->GetLineColor())); QVariant valueFirstPoint; valueFirstPoint.setValue(i->FirstPointName()); - idToProperty[AttrPoint1]->setValue(valueFirstPoint); + m_idToProperty[AttrPoint1]->setValue(valueFirstPoint); QVariant valueSecondPoint; valueSecondPoint.setValue(i->SecondPointName()); - idToProperty[AttrPoint2]->setValue(valueSecondPoint); + m_idToProperty[AttrPoint2]->setValue(valueSecondPoint); QVariant valueThirdPoint; valueThirdPoint.setValue(i->ThirdPointName()); - idToProperty[AttrPoint3]->setValue(valueThirdPoint); + m_idToProperty[AttrPoint3]->setValue(valueThirdPoint); QVariant valueForthPoint; valueForthPoint.setValue(i->ForthPointName()); - idToProperty[AttrPoint4]->setValue(valueForthPoint); + m_idToProperty[AttrPoint4]->setValue(valueForthPoint); QVariant valueApproximationScale; valueApproximationScale.setValue(i->getSpline().GetApproximationScale()); - idToProperty[AttrAScale]->setValue(valueApproximationScale); + m_idToProperty[AttrAScale]->setValue(valueApproximationScale); - idToProperty[AttrNotes]->setValue(i->GetNotes()); + m_idToProperty[AttrNotes]->setValue(i->GetNotes()); - idToProperty[AttrAlias]->setValue(i->GetAliasSuffix()); + m_idToProperty[AttrAlias]->setValue(i->GetAliasSuffix()); } //--------------------------------------------------------------------------------------------------------------------- void VToolOptionsPropertyBrowser::UpdateOptionsToolSplinePath() { - auto *i = qgraphicsitem_cast(currentItem); + auto *i = qgraphicsitem_cast(m_currentItem); - idToProperty[AttrName]->setValue(i->name()); + m_idToProperty[AttrName]->setValue(i->name()); { const qint32 index = VPE::VLineTypeProperty::IndexOfStyle(CurvePenStylesPics(), i->GetPenStyle()); - idToProperty[AttrPenStyle]->setValue(index); + m_idToProperty[AttrPenStyle]->setValue(index); } - idToProperty[AttrColor]->setValue(VPE::VLineColorProperty::IndexOfColor(VAbstractTool::ColorsList(), + m_idToProperty[AttrColor]->setValue(VPE::VLineColorProperty::IndexOfColor(VAbstractTool::ColorsList(), i->GetLineColor())); QVariant valueApproximationScale; valueApproximationScale.setValue(i->getSplinePath().GetApproximationScale()); - idToProperty[AttrAScale]->setValue(valueApproximationScale); + m_idToProperty[AttrAScale]->setValue(valueApproximationScale); - idToProperty[AttrNotes]->setValue(i->GetNotes()); + m_idToProperty[AttrNotes]->setValue(i->GetNotes()); - idToProperty[AttrAlias]->setValue(i->GetAliasSuffix()); + m_idToProperty[AttrAlias]->setValue(i->GetAliasSuffix()); } //--------------------------------------------------------------------------------------------------------------------- void VToolOptionsPropertyBrowser::UpdateOptionsToolCubicBezierPath() { - auto *i = qgraphicsitem_cast(currentItem); + auto *i = qgraphicsitem_cast(m_currentItem); - idToProperty[AttrName]->setValue(i->name()); + m_idToProperty[AttrName]->setValue(i->name()); { const qint32 index = VPE::VLineTypeProperty::IndexOfStyle(CurvePenStylesPics(), i->GetPenStyle()); - idToProperty[AttrPenStyle]->setValue(index); + m_idToProperty[AttrPenStyle]->setValue(index); } - idToProperty[AttrColor]->setValue(VPE::VLineColorProperty::IndexOfColor(VAbstractTool::ColorsList(), + m_idToProperty[AttrColor]->setValue(VPE::VLineColorProperty::IndexOfColor(VAbstractTool::ColorsList(), i->GetLineColor())); QVariant valueApproximationScale; valueApproximationScale.setValue(i->getSplinePath().GetApproximationScale()); - idToProperty[AttrAScale]->setValue(valueApproximationScale); + m_idToProperty[AttrAScale]->setValue(valueApproximationScale); - idToProperty[AttrNotes]->setValue(i->GetNotes()); + m_idToProperty[AttrNotes]->setValue(i->GetNotes()); - idToProperty[AttrAlias]->setValue(i->GetAliasSuffix()); + m_idToProperty[AttrAlias]->setValue(i->GetAliasSuffix()); } //--------------------------------------------------------------------------------------------------------------------- void VToolOptionsPropertyBrowser::UpdateOptionsToolTriangle() { - auto *i = qgraphicsitem_cast(currentItem); + auto *i = qgraphicsitem_cast(m_currentItem); - idToProperty[AttrName]->setValue(i->name()); + m_idToProperty[AttrName]->setValue(i->name()); QVariant valueAxisP1; valueAxisP1.setValue(i->AxisP1Name()); - idToProperty[AttrAxisP1]->setValue(valueAxisP1); + m_idToProperty[AttrAxisP1]->setValue(valueAxisP1); QVariant valueAxisP2; valueAxisP2.setValue(i->AxisP2Name()); - idToProperty[AttrAxisP2]->setValue(valueAxisP2); + m_idToProperty[AttrAxisP2]->setValue(valueAxisP2); QVariant valueFirstPoint; valueFirstPoint.setValue(i->FirstPointName()); - idToProperty[AttrFirstPoint]->setValue(valueFirstPoint); + m_idToProperty[AttrFirstPoint]->setValue(valueFirstPoint); QVariant valueSecondPoint; valueSecondPoint.setValue(i->SecondPointName()); - idToProperty[AttrSecondPoint]->setValue(valueSecondPoint); + m_idToProperty[AttrSecondPoint]->setValue(valueSecondPoint); - idToProperty[AttrNotes]->setValue(i->GetNotes()); + m_idToProperty[AttrNotes]->setValue(i->GetNotes()); } //--------------------------------------------------------------------------------------------------------------------- void VToolOptionsPropertyBrowser::UpdateOptionsToolLineIntersectAxis() { - auto *i = qgraphicsitem_cast(currentItem); - idToProperty[AttrName]->setValue(i->name()); + auto *i = qgraphicsitem_cast(m_currentItem); + m_idToProperty[AttrName]->setValue(i->name()); { const qint32 index = VPE::VLineTypeProperty::IndexOfStyle(LineStylesPics(), i->getLineType()); - idToProperty[AttrTypeLine]->setValue(index); + m_idToProperty[AttrTypeLine]->setValue(index); } { const qint32 index = VPE::VLineColorProperty::IndexOfColor(VAbstractTool::ColorsList(), i->GetLineColor()); - idToProperty[AttrLineColor]->setValue(index); + m_idToProperty[AttrLineColor]->setValue(index); } QVariant valueAngle; valueAngle.setValue(i->GetFormulaAngle()); - idToProperty[AttrAngle]->setValue(valueAngle); + m_idToProperty[AttrAngle]->setValue(valueAngle); QVariant valueBasePoint; valueBasePoint.setValue(i->BasePointName()); - idToProperty[AttrBasePoint]->setValue(valueBasePoint); + m_idToProperty[AttrBasePoint]->setValue(valueBasePoint); QVariant valueFirstPoint; valueFirstPoint.setValue(i->FirstLinePoint()); - idToProperty[AttrFirstPoint]->setValue(valueFirstPoint); + m_idToProperty[AttrFirstPoint]->setValue(valueFirstPoint); QVariant valueSecondPoint; valueSecondPoint.setValue(i->SecondLinePoint()); - idToProperty[AttrSecondPoint]->setValue(valueSecondPoint); + m_idToProperty[AttrSecondPoint]->setValue(valueSecondPoint); - idToProperty[AttrNotes]->setValue(i->GetNotes()); + m_idToProperty[AttrNotes]->setValue(i->GetNotes()); } //--------------------------------------------------------------------------------------------------------------------- void VToolOptionsPropertyBrowser::UpdateOptionsToolCurveIntersectAxis() { - auto *i = qgraphicsitem_cast(currentItem); - idToProperty[AttrName]->setValue(i->name()); + auto *i = qgraphicsitem_cast(m_currentItem); + m_idToProperty[AttrName]->setValue(i->name()); { const qint32 index = VPE::VLineTypeProperty::IndexOfStyle(LineStylesPics(), i->getLineType()); - idToProperty[AttrTypeLine]->setValue(index); + m_idToProperty[AttrTypeLine]->setValue(index); } { const qint32 index = VPE::VLineColorProperty::IndexOfColor(VAbstractTool::ColorsList(), i->GetLineColor()); - idToProperty[AttrLineColor]->setValue(index); + m_idToProperty[AttrLineColor]->setValue(index); } QVariant valueAngle; valueAngle.setValue(i->GetFormulaAngle()); - idToProperty[AttrAngle]->setValue(valueAngle); + m_idToProperty[AttrAngle]->setValue(valueAngle); QVariant valueBasePoint; valueBasePoint.setValue(i->BasePointName()); - idToProperty[AttrBasePoint]->setValue(valueBasePoint); + m_idToProperty[AttrBasePoint]->setValue(valueBasePoint); QVariant valueCurve; valueCurve.setValue(i->CurveName()); - idToProperty[AttrCurve]->setValue(valueCurve); + m_idToProperty[AttrCurve]->setValue(valueCurve); - idToProperty[AttrNotes]->setValue(i->GetNotes()); + m_idToProperty[AttrNotes]->setValue(i->GetNotes()); } //--------------------------------------------------------------------------------------------------------------------- void VToolOptionsPropertyBrowser::UpdateOptionsToolRotation() { - auto *i = qgraphicsitem_cast(currentItem); - idToProperty[AttrSuffix]->setValue(i->Suffix()); + auto *i = qgraphicsitem_cast(m_currentItem); + m_idToProperty[AttrSuffix]->setValue(i->Suffix()); QVariant valueAngle; valueAngle.setValue(i->GetFormulaAngle()); - idToProperty[AttrAngle]->setValue(valueAngle); + m_idToProperty[AttrAngle]->setValue(valueAngle); QVariant valueOriginPoint; valueOriginPoint.setValue(i->OriginPointName()); - idToProperty[AttrCenter]->setValue(valueOriginPoint); + m_idToProperty[AttrCenter]->setValue(valueOriginPoint); - idToProperty[AttrNotes]->setValue(i->GetNotes()); + m_idToProperty[AttrNotes]->setValue(i->GetNotes()); } //--------------------------------------------------------------------------------------------------------------------- void VToolOptionsPropertyBrowser::UpdateOptionsToolMove() { - auto *i = qgraphicsitem_cast(currentItem); - idToProperty[AttrSuffix]->setValue(i->Suffix()); + auto *i = qgraphicsitem_cast(m_currentItem); + m_idToProperty[AttrSuffix]->setValue(i->Suffix()); QVariant valueAngle; valueAngle.setValue(i->GetFormulaAngle()); - idToProperty[AttrAngle]->setValue(valueAngle); + m_idToProperty[AttrAngle]->setValue(valueAngle); QVariant valueLength; valueLength.setValue(i->GetFormulaLength()); - idToProperty[AttrLength]->setValue(valueLength); + m_idToProperty[AttrLength]->setValue(valueLength); QVariant valueRotationAngle; valueRotationAngle.setValue(i->GetFormulaRotationAngle()); - idToProperty[AttrRotationAngle]->setValue(valueRotationAngle); + m_idToProperty[AttrRotationAngle]->setValue(valueRotationAngle); QVariant valueRotationOriginPoint; valueRotationOriginPoint.setValue(i->OriginPointName()); - idToProperty[AttrCenter]->setValue(valueRotationOriginPoint); + m_idToProperty[AttrCenter]->setValue(valueRotationOriginPoint); - idToProperty[AttrNotes]->setValue(i->GetNotes()); + m_idToProperty[AttrNotes]->setValue(i->GetNotes()); } //--------------------------------------------------------------------------------------------------------------------- void VToolOptionsPropertyBrowser::UpdateOptionsToolFlippingByLine() { - auto *i = qgraphicsitem_cast(currentItem); - idToProperty[AttrSuffix]->setValue(i->Suffix()); + auto *i = qgraphicsitem_cast(m_currentItem); + m_idToProperty[AttrSuffix]->setValue(i->Suffix()); QVariant valueFirstPoint; valueFirstPoint.setValue(i->FirstLinePointName()); - idToProperty[AttrFirstPoint]->setValue(valueFirstPoint); + m_idToProperty[AttrFirstPoint]->setValue(valueFirstPoint); QVariant valueSecondPoint; valueSecondPoint.setValue(i->SecondLinePointName()); - idToProperty[AttrSecondPoint]->setValue(valueSecondPoint); + m_idToProperty[AttrSecondPoint]->setValue(valueSecondPoint); - idToProperty[AttrNotes]->setValue(i->GetNotes()); + m_idToProperty[AttrNotes]->setValue(i->GetNotes()); } //--------------------------------------------------------------------------------------------------------------------- void VToolOptionsPropertyBrowser::UpdateOptionsToolFlippingByAxis() { - auto *i = qgraphicsitem_cast(currentItem); - idToProperty[AttrAxisType]->setValue(static_cast(i->GetAxisType())-1); - idToProperty[AttrSuffix]->setValue(i->Suffix()); + auto *i = qgraphicsitem_cast(m_currentItem); + m_idToProperty[AttrAxisType]->setValue(static_cast(i->GetAxisType())-1); + m_idToProperty[AttrSuffix]->setValue(i->Suffix()); QVariant valueOriginPoint; valueOriginPoint.setValue(i->OriginPointName()); - idToProperty[AttrCenter]->setValue(valueOriginPoint); + m_idToProperty[AttrCenter]->setValue(valueOriginPoint); - idToProperty[AttrNotes]->setValue(i->GetNotes()); + m_idToProperty[AttrNotes]->setValue(i->GetNotes()); } //--------------------------------------------------------------------------------------------------------------------- void VToolOptionsPropertyBrowser::UpdateOptionsToolEllipticalArc() { - auto *i = qgraphicsitem_cast(currentItem); + auto *i = qgraphicsitem_cast(m_currentItem); - idToProperty[AttrName]->setValue(i->name()); + m_idToProperty[AttrName]->setValue(i->name()); QVariant valueFormulaRadius1; valueFormulaRadius1.setValue(i->GetFormulaRadius1()); - idToProperty[AttrRadius1]->setValue(valueFormulaRadius1); + m_idToProperty[AttrRadius1]->setValue(valueFormulaRadius1); QVariant valueFormulaRadius2; valueFormulaRadius2.setValue(i->GetFormulaRadius2()); - idToProperty[AttrRadius2]->setValue(valueFormulaRadius2); + m_idToProperty[AttrRadius2]->setValue(valueFormulaRadius2); QVariant valueFormulaF1; valueFormulaF1.setValue(i->GetFormulaF1()); - idToProperty[AttrAngle1]->setValue(valueFormulaF1); + m_idToProperty[AttrAngle1]->setValue(valueFormulaF1); QVariant valueFormulaF2; valueFormulaF2.setValue(i->GetFormulaF2()); - idToProperty[AttrAngle2]->setValue(valueFormulaF2); + m_idToProperty[AttrAngle2]->setValue(valueFormulaF2); QVariant valueFormulaRotationAngle; valueFormulaRotationAngle.setValue(i->GetFormulaRotationAngle()); - idToProperty[AttrRotationAngle]->setValue(valueFormulaRotationAngle); + m_idToProperty[AttrRotationAngle]->setValue(valueFormulaRotationAngle); const qint32 index = VPE::VLineColorProperty::IndexOfColor(VAbstractTool::ColorsList(), i->GetLineColor()); - idToProperty[AttrColor]->setValue(index); + m_idToProperty[AttrColor]->setValue(index); QVariant valueCenterPoint; valueCenterPoint.setValue(i->CenterPointName()); - idToProperty[AttrCenter]->setValue(valueCenterPoint); + m_idToProperty[AttrCenter]->setValue(valueCenterPoint); - idToProperty[AttrNotes]->setValue(i->GetNotes()); + m_idToProperty[AttrNotes]->setValue(i->GetNotes()); - idToProperty[AttrAlias]->setValue(i->GetAliasSuffix()); + m_idToProperty[AttrAlias]->setValue(i->GetAliasSuffix()); } //--------------------------------------------------------------------------------------------------------------------- void VToolOptionsPropertyBrowser::UpdateOptionsBackgroundPixmapItem() { - auto *i = qgraphicsitem_cast(currentItem); + auto *i = qgraphicsitem_cast(m_currentItem); - idToProperty.value(AttrName)->setValue(i->name()); - idToProperty.value(*AttrHold)->setValue(i->IsHold()); - idToProperty.value(*AttrVisible)->setValue(i->IsVisible()); - idToProperty.value(*AttrOpacity)->setValue(static_cast(i->GetOpacity()*100)); + m_idToProperty.value(AttrName)->setValue(i->name()); + m_idToProperty.value(*AttrHold)->setValue(i->IsHold()); + m_idToProperty.value(*AttrVisible)->setValue(i->IsVisible()); + m_idToProperty.value(*AttrOpacity)->setValue(static_cast(i->GetOpacity()*100)); } //--------------------------------------------------------------------------------------------------------------------- void VToolOptionsPropertyBrowser::UpdateOptionsBackgroundSVGItem() { - auto *i = qgraphicsitem_cast(currentItem); + auto *i = qgraphicsitem_cast(m_currentItem); - idToProperty.value(AttrName)->setValue(i->name()); - idToProperty.value(*AttrHold)->setValue(i->IsHold()); - idToProperty.value(*AttrVisible)->setValue(i->IsVisible()); - idToProperty.value(*AttrOpacity)->setValue(static_cast(i->GetOpacity()*100)); + m_idToProperty.value(AttrName)->setValue(i->name()); + m_idToProperty.value(*AttrHold)->setValue(i->IsHold()); + m_idToProperty.value(*AttrVisible)->setValue(i->IsVisible()); + m_idToProperty.value(*AttrOpacity)->setValue(static_cast(i->GetOpacity()*100)); } //--------------------------------------------------------------------------------------------------------------------- -QStringList VToolOptionsPropertyBrowser::PropertiesList() const +auto VToolOptionsPropertyBrowser::PropertiesList() -> QStringList { static QStringList attr{ AttrName, /* 0 */ diff --git a/src/app/valentina/core/vtooloptionspropertybrowser.h b/src/app/valentina/core/vtooloptionspropertybrowser.h index 11641bbcb..2fb9e6c88 100644 --- a/src/app/valentina/core/vtooloptionspropertybrowser.h +++ b/src/app/valentina/core/vtooloptionspropertybrowser.h @@ -43,9 +43,10 @@ class VFormula; class VToolOptionsPropertyBrowser : public QObject { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit VToolOptionsPropertyBrowser(QDockWidget *parent); + ~VToolOptionsPropertyBrowser() override =default; void ClearPropertyBrowser(); public slots: void itemClicked(QGraphicsItem *item); @@ -54,14 +55,15 @@ public slots: private slots: void userChangedData(VPE::VProperty* property); private: - Q_DISABLE_COPY(VToolOptionsPropertyBrowser) + // cppcheck-suppress unknownMacro + Q_DISABLE_COPY_MOVE(VToolOptionsPropertyBrowser) // NOLINT - VPE::VPropertyModel* PropertyModel; - VPE::VPropertyFormView* formView; + VPE::VPropertyModel* m_PropertyModel{nullptr}; + VPE::VPropertyFormView* m_formView{nullptr}; - QGraphicsItem *currentItem; - QMap propertyToId; - QMap idToProperty; + QGraphicsItem *m_currentItem{nullptr}; + QMap m_propertyToId{}; + QMap m_idToProperty{}; void AddProperty(VPE::VProperty *property, const QString &id); void ShowItemOptions(QGraphicsItem *item); @@ -91,7 +93,7 @@ private: void SetOperationSuffix(VPE::VProperty *property); template - Type GetCrossPoint(const QVariant &value); + auto GetCrossPoint(const QVariant &value) -> Type; template void SetCrossCirclesPoint(VPE::VProperty *property); @@ -198,7 +200,7 @@ private: void AddPropertyText(const QString &propertyName, const QString &text, const QString &attrName); void AddPropertyBool(const QString &propertyName, bool value, const QString &attrName); - QStringList PropertiesList() const; + static auto PropertiesList() -> QStringList; void ChangeDataToolSinglePoint(VPE::VProperty *property); void ChangeDataToolEndLine(VPE::VProperty *property); diff --git a/src/app/valentina/dialogs/configpages/preferencesconfigurationpage.cpp b/src/app/valentina/dialogs/configpages/preferencesconfigurationpage.cpp index 95f0cf175..395f6bcc2 100644 --- a/src/app/valentina/dialogs/configpages/preferencesconfigurationpage.cpp +++ b/src/app/valentina/dialogs/configpages/preferencesconfigurationpage.cpp @@ -40,11 +40,7 @@ //--------------------------------------------------------------------------------------------------------------------- PreferencesConfigurationPage::PreferencesConfigurationPage(QWidget *parent) : QWidget(parent), - ui(new Ui::PreferencesConfigurationPage), - m_langChanged(false), - m_systemChanged(), - m_unitChanged(false), - m_labelLangChanged(false) + ui(new Ui::PreferencesConfigurationPage) { ui->setupUi(this); RetranslateUi(); @@ -169,7 +165,7 @@ PreferencesConfigurationPage::~PreferencesConfigurationPage() } //--------------------------------------------------------------------------------------------------------------------- -QStringList PreferencesConfigurationPage::Apply() +auto PreferencesConfigurationPage::Apply() -> QStringList { // Tab General QStringList preferences; @@ -263,7 +259,7 @@ void PreferencesConfigurationPage::changeEvent(QEvent *event) //--------------------------------------------------------------------------------------------------------------------- void PreferencesConfigurationPage::SetLabelComboBox(const QStringList &list) { - for (auto &name : list) + for (const auto &name : list) { ui->labelCombo->addItem(QLocale(name).nativeLanguageName(), name); } @@ -284,7 +280,7 @@ void PreferencesConfigurationPage::RetranslateUi() { ui->unitCombo->blockSignals(true); - const QString unit = qvariant_cast(ui->unitCombo->currentData()); + const auto unit = qvariant_cast(ui->unitCombo->currentData()); ui->unitCombo->clear(); InitUnits(); ui->unitCombo->setCurrentIndex(ui->unitCombo->findData(unit)); @@ -292,7 +288,7 @@ void PreferencesConfigurationPage::RetranslateUi() } { - const QString code = qvariant_cast(ui->systemCombo->currentData()); + const auto code = qvariant_cast(ui->systemCombo->currentData()); ui->systemCombo->blockSignals(true); ui->systemCombo->clear(); InitPMSystems(ui->systemCombo); diff --git a/src/app/valentina/dialogs/configpages/preferencesconfigurationpage.h b/src/app/valentina/dialogs/configpages/preferencesconfigurationpage.h index e3b0e0c07..c545f12d9 100644 --- a/src/app/valentina/dialogs/configpages/preferencesconfigurationpage.h +++ b/src/app/valentina/dialogs/configpages/preferencesconfigurationpage.h @@ -31,6 +31,8 @@ #include +#include "../vmisc/defglobal.h" + namespace Ui { class PreferencesConfigurationPage; @@ -38,22 +40,23 @@ namespace Ui class PreferencesConfigurationPage : public QWidget { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit PreferencesConfigurationPage(QWidget *parent = nullptr); - virtual ~PreferencesConfigurationPage(); + ~PreferencesConfigurationPage() override; - QStringList Apply(); + auto Apply() -> QStringList; protected: - virtual void changeEvent(QEvent* event) override; + void changeEvent(QEvent* event) override; private: - Q_DISABLE_COPY(PreferencesConfigurationPage) + // cppcheck-suppress unknownMacro + Q_DISABLE_COPY_MOVE(PreferencesConfigurationPage) // NOLINT Ui::PreferencesConfigurationPage *ui; - bool m_langChanged; - bool m_systemChanged; - bool m_unitChanged; - bool m_labelLangChanged; + bool m_langChanged{false}; + bool m_systemChanged{false}; + bool m_unitChanged{false}; + bool m_labelLangChanged{false}; void SetLabelComboBox(const QStringList &list); void InitUnits(); diff --git a/src/app/valentina/dialogs/configpages/preferencespathpage.cpp b/src/app/valentina/dialogs/configpages/preferencespathpage.cpp index 92651e534..8181ad81a 100644 --- a/src/app/valentina/dialogs/configpages/preferencespathpage.cpp +++ b/src/app/valentina/dialogs/configpages/preferencespathpage.cpp @@ -29,7 +29,7 @@ #include "preferencespathpage.h" #include "ui_preferencespathpage.h" #include "../vmisc/vvalentinasettings.h" -#include "../../core/vapplication.h" +#include "../vmisc/vabstractvalapplication.h" #include #include @@ -63,7 +63,7 @@ PreferencesPathPage::~PreferencesPathPage() } //--------------------------------------------------------------------------------------------------------------------- -QStringList PreferencesPathPage::Apply() +auto PreferencesPathPage::Apply() -> QStringList { VValentinaSettings *settings = VAbstractValApplication::VApp()->ValentinaSettings(); settings->SetPathIndividualMeasurements(ui->pathTable->item(0, 1)->text()); @@ -74,7 +74,7 @@ QStringList PreferencesPathPage::Apply() settings->SetPathLabelTemplate(ui->pathTable->item(5, 1)->text()); settings->SetPathManualLayouts(ui->pathTable->item(6, 1)->text()); - return QStringList(); // No changes those require restart. + return {}; // No changes those require restart. } //--------------------------------------------------------------------------------------------------------------------- @@ -206,49 +206,49 @@ void PreferencesPathPage::InitTable() { ui->pathTable->setItem(0, 0, new QTableWidgetItem(tr("My Individual Measurements"))); - QTableWidgetItem *item = new QTableWidgetItem(settings->GetPathIndividualMeasurements()); + auto *item = new QTableWidgetItem(settings->GetPathIndividualMeasurements()); item->setToolTip(settings->GetPathIndividualMeasurements()); ui->pathTable->setItem(0, 1, item); } { ui->pathTable->setItem(1, 0, new QTableWidgetItem(tr("My Multisize Measurements"))); - QTableWidgetItem *item = new QTableWidgetItem(settings->GetPathMultisizeMeasurements()); + auto *item = new QTableWidgetItem(settings->GetPathMultisizeMeasurements()); item->setToolTip(settings->GetPathMultisizeMeasurements()); ui->pathTable->setItem(1, 1, item); } { ui->pathTable->setItem(2, 0, new QTableWidgetItem(tr("My Patterns"))); - QTableWidgetItem *item = new QTableWidgetItem(settings->GetPathPattern()); + auto *item = new QTableWidgetItem(settings->GetPathPattern()); item->setToolTip(settings->GetPathPattern()); ui->pathTable->setItem(2, 1, item); } { ui->pathTable->setItem(3, 0, new QTableWidgetItem(tr("My Layouts"))); - QTableWidgetItem *item = new QTableWidgetItem(settings->GetPathLayout()); + auto *item = new QTableWidgetItem(settings->GetPathLayout()); item->setToolTip(settings->GetPathLayout()); ui->pathTable->setItem(3, 1, item); } { ui->pathTable->setItem(4, 0, new QTableWidgetItem(tr("My Templates"))); - QTableWidgetItem *item = new QTableWidgetItem(settings->GetPathTemplate()); + auto *item = new QTableWidgetItem(settings->GetPathTemplate()); item->setToolTip(settings->GetPathTemplate()); ui->pathTable->setItem(4, 1, item); } { ui->pathTable->setItem(5, 0, new QTableWidgetItem(tr("My label templates"))); - QTableWidgetItem *item = new QTableWidgetItem(settings->GetPathLabelTemplate()); + auto *item = new QTableWidgetItem(settings->GetPathLabelTemplate()); item->setToolTip(settings->GetPathLabelTemplate()); ui->pathTable->setItem(5, 1, item); } { ui->pathTable->setItem(6, 0, new QTableWidgetItem(tr("My manual layouts"))); - QTableWidgetItem *item = new QTableWidgetItem(settings->GetPathManualLayouts()); + auto *item = new QTableWidgetItem(settings->GetPathManualLayouts()); item->setToolTip(settings->GetPathManualLayouts()); ui->pathTable->setItem(6, 1, item); } diff --git a/src/app/valentina/dialogs/configpages/preferencespathpage.h b/src/app/valentina/dialogs/configpages/preferencespathpage.h index 91c6da536..7bceac358 100644 --- a/src/app/valentina/dialogs/configpages/preferencespathpage.h +++ b/src/app/valentina/dialogs/configpages/preferencespathpage.h @@ -31,6 +31,8 @@ #include +#include "../vmisc/defglobal.h" + namespace Ui { class PreferencesPathPage; @@ -38,23 +40,24 @@ namespace Ui class PreferencesPathPage : public QWidget { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit PreferencesPathPage(QWidget *parent = nullptr); - virtual ~PreferencesPathPage(); + ~PreferencesPathPage() override; - QStringList Apply(); + auto Apply() -> QStringList; protected: - virtual void changeEvent(QEvent* event) override; + void changeEvent(QEvent* event) override; private slots: void DefaultPath(); void EditPath(); private: - Q_DISABLE_COPY(PreferencesPathPage) + // cppcheck-suppress unknownMacro + Q_DISABLE_COPY_MOVE(PreferencesPathPage) // NOLINT Ui::PreferencesPathPage *ui; void InitTable(); diff --git a/src/app/valentina/dialogs/configpages/preferencespatternpage.cpp b/src/app/valentina/dialogs/configpages/preferencespatternpage.cpp index 02e8cbc91..f2daa346e 100644 --- a/src/app/valentina/dialogs/configpages/preferencespatternpage.cpp +++ b/src/app/valentina/dialogs/configpages/preferencespatternpage.cpp @@ -41,11 +41,12 @@ namespace { -QStringList ComboBoxAllStrings(QComboBox *combo) +auto ComboBoxAllStrings(QComboBox *combo) -> QStringList { SCASSERT(combo != nullptr) QStringList itemsInComboBox; + itemsInComboBox.reserve(combo->count()); for (int index = 0; index < combo->count(); ++index) { itemsInComboBox << combo->itemText(index); @@ -53,14 +54,12 @@ QStringList ComboBoxAllStrings(QComboBox *combo) return itemsInComboBox; } -} +} // namespace //--------------------------------------------------------------------------------------------------------------------- PreferencesPatternPage::PreferencesPatternPage(QWidget *parent) : QWidget(parent), - ui(new Ui::PreferencesPatternPage), - m_knownMaterials(), - m_oldLineUnit(Unit::Mm) + ui(new Ui::PreferencesPatternPage) { ui->setupUi(this); RetranslateUi(); @@ -125,7 +124,7 @@ PreferencesPatternPage::~PreferencesPatternPage() } //--------------------------------------------------------------------------------------------------------------------- -QStringList PreferencesPatternPage::Apply() +auto PreferencesPatternPage::Apply() -> QStringList { QStringList preferences; @@ -209,7 +208,7 @@ void PreferencesPatternPage::EditDateTimeFormats() { VValentinaSettings *settings = VAbstractValApplication::VApp()->ValentinaSettings(); - QPushButton *button = qobject_cast(sender()); + auto *button = qobject_cast(sender()); if (button == ui->pushButtonEditDateFormats) { CallDateTimeFormatEditor(QDate::currentDate(), VCommonSettings::PredefinedDateFormats(), diff --git a/src/app/valentina/dialogs/configpages/preferencespatternpage.h b/src/app/valentina/dialogs/configpages/preferencespatternpage.h index dd8be7476..1b443994e 100644 --- a/src/app/valentina/dialogs/configpages/preferencespatternpage.h +++ b/src/app/valentina/dialogs/configpages/preferencespatternpage.h @@ -41,30 +41,31 @@ class QComboBox; class PreferencesPatternPage : public QWidget { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit PreferencesPatternPage(QWidget *parent = nullptr); - virtual ~PreferencesPatternPage(); + ~PreferencesPatternPage() override; - QStringList Apply(); + auto Apply() -> QStringList; void InitDefaultSeamAllowance(); protected: - virtual void changeEvent(QEvent* event) override; + void changeEvent(QEvent* event) override; private slots: void EditDateTimeFormats(); void ManageKnownMaterials(); private: - Q_DISABLE_COPY(PreferencesPatternPage) + // cppcheck-suppress unknownMacro + Q_DISABLE_COPY_MOVE(PreferencesPatternPage) // NOLINT Ui::PreferencesPatternPage *ui; - QStringList m_knownMaterials; - Unit m_oldLineUnit; + QStringList m_knownMaterials{}; + Unit m_oldLineUnit{Unit::Mm}; void InitLabelDateTimeFormats(); - void InitComboBoxFormats(QComboBox *box, const QStringList &items, const QString ¤tFormat); + static void InitComboBoxFormats(QComboBox *box, const QStringList &items, const QString ¤tFormat); void InitUnits(); void RetranslateUi(); diff --git a/src/app/valentina/dialogs/dialogaboutapp.cpp b/src/app/valentina/dialogs/dialogaboutapp.cpp index f1046c9ba..abfdfe254 100644 --- a/src/app/valentina/dialogs/dialogaboutapp.cpp +++ b/src/app/valentina/dialogs/dialogaboutapp.cpp @@ -28,32 +28,31 @@ #include "dialogaboutapp.h" #include "ui_dialogaboutapp.h" -#include "../version.h" #include #include #include #include -#include "../core/vapplication.h" #include "../fervor/fvupdater.h" +#include "../vmisc/projectversion.h" +#include "../vmisc/vabstractvalapplication.h" #include "../vmisc/vvalentinasettings.h" //--------------------------------------------------------------------------------------------------------------------- DialogAboutApp::DialogAboutApp(QWidget *parent) : QDialog(parent), - ui(new Ui::DialogAboutApp), - isInitialized(false) + ui(new Ui::DialogAboutApp) { ui->setupUi(this); VAbstractValApplication::VApp()->ValentinaSettings()->GetOsSeparator() ? setLocale(QLocale()) : setLocale(QLocale::c()); - ui->label_Valentina_Version->setText(QString("Valentina %1").arg(APP_VERSION_STR)); - ui->labelBuildRevision->setText(QString("Build revision: %1").arg(BUILD_REVISION)); + ui->label_Valentina_Version->setText(QStringLiteral("Valentina %1").arg(APP_VERSION_STR)); + ui->labelBuildRevision->setText(QStringLiteral("Build revision: %1").arg(QStringLiteral(BUILD_REVISION))); ui->label_QT_Version->setText(buildCompatibilityString()); - QDate date = QLocale::c().toDate(QString(__DATE__).simplified(), QLatin1String("MMM d yyyy")); - ui->label_Valentina_Built->setText(tr("Built on %1 at %2").arg(date.toString(), __TIME__)); + QDate date = QLocale::c().toDate(QStringLiteral(__DATE__).simplified(), QStringLiteral("MMM d yyyy")); + ui->label_Valentina_Built->setText(tr("Built on %1 at %2").arg(date.toString(), QStringLiteral(__TIME__))); ui->label_Legal_Stuff->setText(QApplication::translate("InternalStrings", "The program is provided AS IS with NO WARRANTY OF ANY " @@ -61,10 +60,11 @@ DialogAboutApp::DialogAboutApp(QWidget *parent) : "AND FITNESS FOR A PARTICULAR PURPOSE.")); - ui->pushButton_Web_Site->setText(tr("Web site : %1").arg(VER_COMPANYDOMAIN_STR)); + ui->pushButton_Web_Site->setText(tr("Web site : %1").arg(QStringLiteral(VER_COMPANYDOMAIN_STR))); connect(ui->pushButton_Web_Site, &QPushButton::clicked, this, []() { - if (not QDesktopServices::openUrl(QUrl(QStringLiteral("https://%1").arg(VER_COMPANYDOMAIN_STR)))) + if (not QDesktopServices::openUrl( + QUrl(QStringLiteral("https://%1").arg(QStringLiteral(VER_COMPANYDOMAIN_STR))))) { qWarning() << tr("Cannot open your default browser"); } @@ -99,7 +99,7 @@ void DialogAboutApp::showEvent(QShowEvent *event) return; } - if (isInitialized) + if (m_isInitialized) { return; } @@ -108,7 +108,7 @@ void DialogAboutApp::showEvent(QShowEvent *event) setMaximumSize(size()); setMinimumSize(size()); - isInitialized = true;//first show windows are held + m_isInitialized = true;//first show windows are held } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/valentina/dialogs/dialogaboutapp.h b/src/app/valentina/dialogs/dialogaboutapp.h index b2647dd72..75aa969a4 100644 --- a/src/app/valentina/dialogs/dialogaboutapp.h +++ b/src/app/valentina/dialogs/dialogaboutapp.h @@ -31,6 +31,8 @@ #include +#include "../vmisc/defglobal.h" + namespace Ui { class DialogAboutApp; @@ -38,21 +40,21 @@ namespace Ui class DialogAboutApp : public QDialog { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit DialogAboutApp(QWidget *parent = nullptr); - virtual ~DialogAboutApp(); + ~DialogAboutApp() override; protected: - virtual void showEvent(QShowEvent *event) override; + void showEvent(QShowEvent *event) override; private: Ui::DialogAboutApp *ui; - bool isInitialized; - Q_DISABLE_COPY(DialogAboutApp) + bool m_isInitialized{false}; + Q_DISABLE_COPY_MOVE(DialogAboutApp) // NOLINT - void FontPointSize(QWidget *w, int pointSize); + static void FontPointSize(QWidget *w, int pointSize); }; #endif // DIALOGABOUTAPP_H diff --git a/src/app/valentina/dialogs/dialogaddbackgroundimage.h b/src/app/valentina/dialogs/dialogaddbackgroundimage.h index 2b529927c..6f77b99b6 100644 --- a/src/app/valentina/dialogs/dialogaddbackgroundimage.h +++ b/src/app/valentina/dialogs/dialogaddbackgroundimage.h @@ -41,7 +41,7 @@ namespace Ui class DialogAddBackgroundImage : public QDialog { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit DialogAddBackgroundImage(const QString &fileName, QWidget *parent = nullptr); @@ -52,7 +52,7 @@ public: private: // cppcheck-suppress unknownMacro - Q_DISABLE_COPY_MOVE(DialogAddBackgroundImage) + Q_DISABLE_COPY_MOVE(DialogAddBackgroundImage) // NOLINT Ui::DialogAddBackgroundImage *ui; }; diff --git a/src/app/valentina/dialogs/dialogdatetimeformats.cpp b/src/app/valentina/dialogs/dialogdatetimeformats.cpp index 9cb69d123..8a6cd1262 100644 --- a/src/app/valentina/dialogs/dialogdatetimeformats.cpp +++ b/src/app/valentina/dialogs/dialogdatetimeformats.cpp @@ -37,7 +37,6 @@ DialogDateTimeFormats::DialogDateTimeFormats(const QDate &date, const QStringLis ui(new Ui::DialogDateTimeFormats), m_dateMode(true), m_date(date), - m_time(), m_predefined(predefinedFormats) { ui->setupUi(this); @@ -51,7 +50,6 @@ DialogDateTimeFormats::DialogDateTimeFormats(const QTime &time, const QStringLis : QDialog(parent), ui(new Ui::DialogDateTimeFormats), m_dateMode(false), - m_date(), m_time(time), m_predefined(predefinedFormats) { @@ -67,7 +65,7 @@ DialogDateTimeFormats::~DialogDateTimeFormats() } //--------------------------------------------------------------------------------------------------------------------- -QStringList DialogDateTimeFormats::GetFormats() const +auto DialogDateTimeFormats::GetFormats() const -> QStringList { QStringList formats; @@ -162,12 +160,12 @@ void DialogDateTimeFormats::SetFormatLines(const QStringList &predefined, const int row = -1; - for (auto &item : predefined) + for (const auto &item : predefined) { ui->listWidget->insertItem(++row, AddListLine(item)); } - for (auto &item : userDefined) + for (const auto &item : userDefined) { ui->listWidget->insertItem(++row, AddListLine(item)); } @@ -210,10 +208,10 @@ void DialogDateTimeFormats::SetupControls() } //--------------------------------------------------------------------------------------------------------------------- -QListWidgetItem *DialogDateTimeFormats::AddListLine(const QString &format) +auto DialogDateTimeFormats::AddListLine(const QString &format) -> QListWidgetItem * { const QString preview = m_dateMode ? m_date.toString(format) : m_time.toString(format); - QListWidgetItem *item = new QListWidgetItem(preview); + auto *item = new QListWidgetItem(preview); item->setData(Qt::UserRole, format); return item; } diff --git a/src/app/valentina/dialogs/dialogdatetimeformats.h b/src/app/valentina/dialogs/dialogdatetimeformats.h index 163ea0e97..52e3fdfc2 100644 --- a/src/app/valentina/dialogs/dialogdatetimeformats.h +++ b/src/app/valentina/dialogs/dialogdatetimeformats.h @@ -33,6 +33,8 @@ #include #include +#include "../vmisc/defglobal.h" + namespace Ui { class DialogDateTimeFormats; @@ -42,16 +44,16 @@ class QListWidgetItem; class DialogDateTimeFormats : public QDialog { - Q_OBJECT + Q_OBJECT // NOLINT public: DialogDateTimeFormats(const QDate &date, const QStringList &predefinedFormats, const QStringList &userDefinedFormats, QWidget *parent = nullptr); DialogDateTimeFormats(const QTime &time, const QStringList &predefinedFormats, const QStringList &userDefinedFormats, QWidget *parent = nullptr); - virtual ~DialogDateTimeFormats(); + ~DialogDateTimeFormats() override; - QStringList GetFormats() const; + auto GetFormats() const -> QStringList; private slots: void AddLine(); @@ -60,20 +62,21 @@ private slots: void ShowFormatDetails(); private: - Q_DISABLE_COPY(DialogDateTimeFormats) + // cppcheck-suppress unknownMacro + Q_DISABLE_COPY_MOVE(DialogDateTimeFormats) // NOLINT Ui::DialogDateTimeFormats *ui; bool m_dateMode; - QDate m_date; - QTime m_time; + QDate m_date{}; + QTime m_time{}; QStringList m_predefined; void Init(const QStringList &predefined, const QStringList &userDefined); void SetFormatLines(const QStringList &predefined, const QStringList &userDefined); void SetupControls(); - bool IsPredefined() const; + auto IsPredefined() const -> bool; - QListWidgetItem *AddListLine(const QString &format); + auto AddListLine(const QString &format) -> QListWidgetItem *; }; #endif // DIALOGDATETIMEFORMATS_H diff --git a/src/app/valentina/dialogs/dialogfinalmeasurements.cpp b/src/app/valentina/dialogs/dialogfinalmeasurements.cpp index 0e2db9aee..56b4b5c07 100644 --- a/src/app/valentina/dialogs/dialogfinalmeasurements.cpp +++ b/src/app/valentina/dialogs/dialogfinalmeasurements.cpp @@ -30,16 +30,14 @@ #include "ui_dialogfinalmeasurements.h" #include "../vmisc/vvalentinasettings.h" #include "../vmisc/compatibility.h" +#include "../vmisc/vabstractvalapplication.h" #include "../qmuparser/qmudef.h" -#include "../qmuparser/qmutokenparser.h" -#include "../vpatterndb/vtranslatevars.h" #include "../vpatterndb/calculator.h" #include "../vtools/dialogs/support/dialogeditwrongformula.h" -#include "../core/vapplication.h" #include #include -#define DIALOG_MAX_FORMULA_HEIGHT 64 +constexpr int DIALOG_MAX_FORMULA_HEIGHT = 64; //--------------------------------------------------------------------------------------------------------------------- DialogFinalMeasurements::DialogFinalMeasurements(VPattern *doc, QWidget *parent) @@ -74,8 +72,8 @@ DialogFinalMeasurements::DialogFinalMeasurements(VPattern *doc, QWidget *parent) connect(m_doc, &VPattern::FullUpdateFromFile, this, &DialogFinalMeasurements::FullUpdateFromFile); - ui->lineEditName->setValidator( new QRegularExpressionValidator(QRegularExpression( - QLatin1String("^$|")+NameRegExp()), this)); + ui->lineEditName->setValidator( + new QRegularExpressionValidator(QRegularExpression(QStringLiteral("^$|")+NameRegExp()), this)); connect(ui->tableWidget, &QTableWidget::itemSelectionChanged, this, &DialogFinalMeasurements::ShowFinalMeasurementDetails); @@ -136,13 +134,13 @@ void DialogFinalMeasurements::changeEvent(QEvent *event) } //--------------------------------------------------------------------------------------------------------------------- -bool DialogFinalMeasurements::eventFilter(QObject *object, QEvent *event) +auto DialogFinalMeasurements::eventFilter(QObject *object, QEvent *event) -> bool { - if (QLineEdit *textEdit = qobject_cast(object)) + if (auto *textEdit = qobject_cast(object)) { if (event->type() == QEvent::KeyPress) { - QKeyEvent *keyEvent = static_cast(event); + auto *keyEvent = static_cast(event); // NOLINT(cppcoreguidelines-pro-type-static-cast-downcast) if ((keyEvent->key() == Qt::Key_Period) && (keyEvent->modifiers() & Qt::KeypadModifier)) { if (VAbstractApplication::VApp()->Settings()->GetOsSeparator()) @@ -162,7 +160,7 @@ bool DialogFinalMeasurements::eventFilter(QObject *object, QEvent *event) // pass the event on to the parent class return QDialog::eventFilter(object, event); } - return false;// pass the event to the widget + return false;// pass the event to the widget // clazy:exclude=base-class-event } //--------------------------------------------------------------------------------------------------------------------- @@ -416,14 +414,14 @@ void DialogFinalMeasurements::DeployFormula() { ui->plainTextEditFormula->setFixedHeight(DIALOG_MAX_FORMULA_HEIGHT); //Set icon from theme (internal for Windows system) - ui->pushButtonGrow->setIcon(QIcon::fromTheme("go-next", + ui->pushButtonGrow->setIcon(QIcon::fromTheme(QStringLiteral("go-next"), QIcon(":/icons/win.icon.theme/16x16/actions/go-next.png"))); } else { ui->plainTextEditFormula->setFixedHeight(formulaBaseHeight); //Set icon from theme (internal for Windows system) - ui->pushButtonGrow->setIcon(QIcon::fromTheme("go-down", + ui->pushButtonGrow->setIcon(QIcon::fromTheme(QStringLiteral("go-down"), QIcon(":/icons/win.icon.theme/16x16/actions/go-down.png"))); } @@ -449,9 +447,8 @@ void DialogFinalMeasurements::Fx() QScopedPointer dialog(new DialogEditWrongFormula(&m_data, NULL_ID, this)); dialog->setWindowTitle(tr("Edit measurement")); - dialog->SetFormula(VAbstractApplication::VApp()->TrVars() - ->TryFormulaFromUser(ui->plainTextEditFormula->toPlainText(), - VAbstractApplication::VApp()->Settings()->GetOsSeparator())); + dialog->SetFormula(VTranslateVars::TryFormulaFromUser(ui->plainTextEditFormula->toPlainText(), + VAbstractApplication::VApp()->Settings()->GetOsSeparator())); const QString postfix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true); dialog->setPostfix(postfix);//Show unit in dialog lable (cm, mm or inch) @@ -518,14 +515,14 @@ void DialogFinalMeasurements::ShowUnits() { // calculated value const QString header = ui->tableWidget->horizontalHeaderItem(1)->text(); - const QString unitHeader = QString("%1 (%2)").arg(header, unit); + const QString unitHeader = QStringLiteral("%1 (%2)").arg(header, unit); ui->tableWidget->horizontalHeaderItem(1)->setText(unitHeader); } { // formula const QString header = ui->tableWidget->horizontalHeaderItem(2)->text(); - const QString unitHeader = QString("%1 (%2)").arg(header, unit); + const QString unitHeader = QStringLiteral("%1 (%2)").arg(header, unit); ui->tableWidget->horizontalHeaderItem(2)->setText(unitHeader); } } @@ -533,7 +530,7 @@ void DialogFinalMeasurements::ShowUnits() //--------------------------------------------------------------------------------------------------------------------- void DialogFinalMeasurements::AddCell(const QString &text, int row, int column, int aligment, bool ok) { - QTableWidgetItem *item = new QTableWidgetItem(text); + auto *item = new QTableWidgetItem(text); item->setTextAlignment(aligment); // set the item non-editable (view only), and non-selectable @@ -552,7 +549,7 @@ void DialogFinalMeasurements::AddCell(const QString &text, int row, int column, } //--------------------------------------------------------------------------------------------------------------------- -bool DialogFinalMeasurements::EvalUserFormula(const QString &formula, bool fromUser) +auto DialogFinalMeasurements::EvalUserFormula(const QString &formula, bool fromUser) -> bool { const QString postfix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits());//Show unit in dialog lable (cm, mm or inch) @@ -562,44 +559,42 @@ bool DialogFinalMeasurements::EvalUserFormula(const QString &formula, bool fromU ui->labelCalculatedValue->setToolTip(tr("Empty field")); return false; } - else + + try { - try + QString f; + // Replace line return character with spaces for calc if exist + if (fromUser) { - QString f; - // Replace line return character with spaces for calc if exist - if (fromUser) - { - f = VAbstractApplication::VApp()->TrVars() - ->FormulaFromUser(formula, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); - } - else - { - f = formula; - } - QScopedPointer cal(new Calculator()); - const qreal result = cal->EvalFormula(m_data.DataVariables(), f); - - if (qIsInf(result) || qIsNaN(result)) - { - ui->labelCalculatedValue->setText(tr("Error") + " (" + postfix + ")."); - ui->labelCalculatedValue->setToolTip(tr("Invalid result. Value is infinite or NaN. Please, check your " - "calculations.")); - return false; - } - - ui->labelCalculatedValue->setText( - VAbstractApplication::VApp()->LocaleToString(result) + QChar(QChar::Space) + postfix); - ui->labelCalculatedValue->setToolTip(tr("Value")); - return true; + f = VAbstractApplication::VApp()->TrVars() + ->FormulaFromUser(formula, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); } - catch (qmu::QmuParserError &e) + else { - ui->labelCalculatedValue->setText(tr("Error") + " (" + postfix + "). " + - tr("Parser error: %1").arg(e.GetMsg())); - ui->labelCalculatedValue->setToolTip(tr("Parser error: %1").arg(e.GetMsg())); + f = formula; + } + QScopedPointer cal(new Calculator()); + const qreal result = cal->EvalFormula(m_data.DataVariables(), f); + + if (qIsInf(result) || qIsNaN(result)) + { + ui->labelCalculatedValue->setText(tr("Error") + " (" + postfix + ")."); + ui->labelCalculatedValue->setToolTip(tr("Invalid result. Value is infinite or NaN. Please, check your " + "calculations.")); return false; } + + ui->labelCalculatedValue->setText( + VAbstractApplication::VApp()->LocaleToString(result) + QChar(QChar::Space) + postfix); + ui->labelCalculatedValue->setToolTip(tr("Value")); + return true; + } + catch (qmu::QmuParserError &e) + { + ui->labelCalculatedValue->setText(tr("Error") + " (" + postfix + "). " + + tr("Parser error: %1").arg(e.GetMsg())); + ui->labelCalculatedValue->setToolTip(tr("Parser error: %1").arg(e.GetMsg())); + return false; } } @@ -686,7 +681,7 @@ void DialogFinalMeasurements::UpdateTree() } //--------------------------------------------------------------------------------------------------------------------- -qreal DialogFinalMeasurements::EvalFormula(const QString &formula, bool &ok) +auto DialogFinalMeasurements::EvalFormula(const QString &formula, bool &ok) -> qreal { qreal result = 0; if (formula.isEmpty()) @@ -694,26 +689,24 @@ qreal DialogFinalMeasurements::EvalFormula(const QString &formula, bool &ok) ok = false; return result; } - else - { - try - { - // Replace line return character with spaces for calc if exist - QScopedPointer cal(new Calculator()); - result = cal->EvalFormula(m_data.DataVariables(), formula); - if (qIsInf(result) || qIsNaN(result)) - { - ok = false; - return 0; - } - } - catch (qmu::QmuParserError &) + try + { + // Replace line return character with spaces for calc if exist + QScopedPointer cal(new Calculator()); + result = cal->EvalFormula(m_data.DataVariables(), formula); + + if (qIsInf(result) || qIsNaN(result)) { ok = false; return 0; } } + catch (qmu::QmuParserError &) + { + ok = false; + return 0; + } ok = true; return result; @@ -746,14 +739,14 @@ void DialogFinalMeasurements::InitSearch() SaveSearchRequest(); InitSearchHistory(); m_search->FindPrevious(); - ui->labelResults->setText(QString("%1/%2").arg(m_search->MatchIndex()+1).arg(m_search->MatchCount())); + ui->labelResults->setText(QStringLiteral("%1/%2").arg(m_search->MatchIndex()+1).arg(m_search->MatchCount())); }); connect(ui->toolButtonFindNext, &QToolButton::clicked, this, [this]() { SaveSearchRequest(); InitSearchHistory(); m_search->FindNext(); - ui->labelResults->setText(QString("%1/%2").arg(m_search->MatchIndex()+1).arg(m_search->MatchCount())); + ui->labelResults->setText(QStringLiteral("%1/%2").arg(m_search->MatchIndex()+1).arg(m_search->MatchCount())); }); connect(m_search.data(), &VTableSearch::HasResult, this, [this] (bool state) @@ -763,7 +756,8 @@ void DialogFinalMeasurements::InitSearch() if (state) { - ui->labelResults->setText(QString("%1/%2").arg(m_search->MatchIndex()+1).arg(m_search->MatchCount())); + ui->labelResults->setText( + QStringLiteral("%1/%2").arg(m_search->MatchIndex()+1).arg(m_search->MatchCount())); } else { diff --git a/src/app/valentina/dialogs/dialogfinalmeasurements.h b/src/app/valentina/dialogs/dialogfinalmeasurements.h index c7408b70f..602ce464e 100644 --- a/src/app/valentina/dialogs/dialogfinalmeasurements.h +++ b/src/app/valentina/dialogs/dialogfinalmeasurements.h @@ -42,20 +42,20 @@ namespace Ui class DialogFinalMeasurements : public QDialog { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit DialogFinalMeasurements(VPattern *doc, QWidget *parent = nullptr); - virtual ~DialogFinalMeasurements(); + ~DialogFinalMeasurements() override; - QVector FinalMeasurements() const; + auto FinalMeasurements() const -> QVector; protected: - virtual void closeEvent ( QCloseEvent * event ) override; - virtual void changeEvent ( QEvent * event) override; - virtual bool eventFilter(QObject *object, QEvent *event) override; - virtual void showEvent( QShowEvent *event ) override; - virtual void resizeEvent(QResizeEvent *event) override; + void closeEvent ( QCloseEvent * event ) override; + void changeEvent ( QEvent * event) override; + auto eventFilter(QObject *object, QEvent *event) -> bool override; + void showEvent( QShowEvent *event ) override; + void resizeEvent(QResizeEvent *event) override; private slots: void ShowFinalMeasurementDetails(); void Add(); @@ -69,7 +69,7 @@ private slots: void Fx(); void FullUpdateFromFile(); private: - Q_DISABLE_COPY(DialogFinalMeasurements) + Q_DISABLE_COPY_MOVE(DialogFinalMeasurements) // NOLINT Ui::DialogFinalMeasurements *ui; /** @brief doc dom document container */ VPattern *m_doc; @@ -86,13 +86,13 @@ private: void ShowUnits(); void AddCell(const QString &text, int row, int column, int aligment, bool ok = true); - bool EvalUserFormula(const QString &formula, bool fromUser); + auto EvalUserFormula(const QString &formula, bool fromUser) -> bool; void Controls(); void EnableDetails(bool enabled); void UpdateTree(); - qreal EvalFormula(const QString &formula, bool &ok); + auto EvalFormula(const QString &formula, bool &ok) -> qreal; void InitSearch(); void InitSearchHistory(); @@ -101,7 +101,7 @@ private: }; //--------------------------------------------------------------------------------------------------------------------- -inline QVector DialogFinalMeasurements::FinalMeasurements() const +inline auto DialogFinalMeasurements::FinalMeasurements() const -> QVector { return m_measurements; } diff --git a/src/app/valentina/dialogs/dialoghistory.cpp b/src/app/valentina/dialogs/dialoghistory.cpp index 0a376b2b2..7fcf2e877 100644 --- a/src/app/valentina/dialogs/dialoghistory.cpp +++ b/src/app/valentina/dialogs/dialoghistory.cpp @@ -55,7 +55,7 @@ DialogHistory::DialogHistory(VContainer *data, VPattern *doc, QWidget *parent) :DialogTool(data, 0, parent), ui(new Ui::DialogHistory), - doc(doc), + m_doc(doc), m_searchHistory(new QMenu(this)) { ui->setupUi(this); @@ -91,7 +91,7 @@ DialogHistory::~DialogHistory() */ void DialogHistory::DialogAccepted() { - QTableWidgetItem *item = ui->tableWidget->item(cursorToolRecordRow, 0); + QTableWidgetItem *item = ui->tableWidget->item(m_cursorToolRecordRow, 0); if (item != nullptr) { auto id = qvariant_cast(item->data(Qt::UserRole)); @@ -110,25 +110,25 @@ void DialogHistory::cellClicked(int row, int column) { if (column == 0) { - QTableWidgetItem *item = ui->tableWidget->item(cursorRow, 0); + QTableWidgetItem *item = ui->tableWidget->item(m_cursorRow, 0); item->setIcon(QIcon()); item = ui->tableWidget->item(row, 0); - cursorRow = row; + m_cursorRow = row; item->setIcon(QIcon("://icon/32x32/put_after.png")); - const quint32 id = qvariant_cast(item->data(Qt::UserRole)); - doc->blockSignals(true); - row == ui->tableWidget->rowCount()-1 ? doc->setCursor(0) : doc->setCursor(id); - doc->blockSignals(false); + const auto id = qvariant_cast(item->data(Qt::UserRole)); + m_doc->blockSignals(true); + row == ui->tableWidget->rowCount()-1 ? m_doc->setCursor(0) : m_doc->setCursor(id); + m_doc->blockSignals(false); } else { - QTableWidgetItem *item = ui->tableWidget->item(cursorToolRecordRow, 0); - quint32 id = qvariant_cast(item->data(Qt::UserRole)); + QTableWidgetItem *item = ui->tableWidget->item(m_cursorToolRecordRow, 0); + auto id = qvariant_cast(item->data(Qt::UserRole)); emit ShowHistoryTool(id, false); - cursorToolRecordRow = row; - item = ui->tableWidget->item(cursorToolRecordRow, 0); + m_cursorToolRecordRow = row; + item = ui->tableWidget->item(m_cursorToolRecordRow, 0); id = qvariant_cast(item->data(Qt::UserRole)); emit ShowHistoryTool(id, true); } @@ -144,12 +144,12 @@ void DialogHistory::ChangedCursor(quint32 id) for (qint32 i = 0; i< ui->tableWidget->rowCount(); ++i) { QTableWidgetItem *item = ui->tableWidget->item(i, 0); - quint32 rId = qvariant_cast(item->data(Qt::UserRole)); + auto rId = qvariant_cast(item->data(Qt::UserRole)); if (rId == id) { - QTableWidgetItem *oldCursorItem = ui->tableWidget->item(cursorRow, 0); + QTableWidgetItem *oldCursorItem = ui->tableWidget->item(m_cursorRow, 0); oldCursorItem->setIcon(QIcon()); - cursorRow = i; + m_cursorRow = i; item->setIcon(QIcon("://icon/32x32/put_after.png")); } } @@ -174,7 +174,7 @@ void DialogHistory::UpdateHistory() void DialogHistory::FillTable() { ui->tableWidget->clear(); - QVector history = doc->getLocalHistory(); + QVector history = m_doc->getLocalHistory(); qint32 currentRow = -1; qint32 count = 0; ui->tableWidget->setRowCount(history.size());//Make row count max possible number @@ -193,15 +193,15 @@ void DialogHistory::FillTable() currentRow++; { - QTableWidgetItem *item = new QTableWidgetItem(QString()); + auto *item = new QTableWidgetItem(QString()); item->setTextAlignment(Qt::AlignHCenter); item->setData(Qt::UserRole, record.id); item->setFlags(item->flags() ^ Qt::ItemIsEditable); ui->tableWidget->setItem(currentRow, 0, item); } - QTableWidgetItem *item = new QTableWidgetItem(record.description); - item->setFont(QFont("Times", 12, QFont::Bold)); + auto *item = new QTableWidgetItem(record.description); + item->setFont(QFont(QStringLiteral("Times"), 12, QFont::Bold)); item->setFlags(item->flags() ^ Qt::ItemIsEditable); ui->tableWidget->setItem(currentRow, 1, item); ++count; @@ -210,8 +210,8 @@ void DialogHistory::FillTable() ui->tableWidget->setRowCount(count);//Real row count if (count>0) { - cursorRow = CursorRow(); - QTableWidgetItem *item = ui->tableWidget->item(cursorRow, 0); + m_cursorRow = CursorRow(); + QTableWidgetItem *item = ui->tableWidget->item(m_cursorRow, 0); // cppcheck-suppress unknownMacro SCASSERT(item != nullptr) item->setIcon(QIcon("://icon/32x32/put_after.png")); @@ -229,254 +229,22 @@ QT_WARNING_DISABLE_GCC("-Wswitch-default") * @param tool record data * @return description */ -HistoryRecord DialogHistory::Record(const VToolRecord &tool) const +auto DialogHistory::Record(const VToolRecord &tool) const -> HistoryRecord { - // This check helps to find missed tools in the switch - Q_STATIC_ASSERT_X(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 59, "Not all tools were used in history."); - HistoryRecord record; record.id = tool.getId(); bool updateCache = false; - const QDomElement domElem = doc->elementById(tool.getId(), QString(), updateCache); - if (domElem.isElement() == false) + const QDomElement domElem = m_doc->elementById(tool.getId(), QString(), updateCache); + if (not domElem.isElement()) { qDebug()<<"Can't find element by id" << record.id << Q_FUNC_INFO; return record; } + try { - switch ( tool.getTypeTool() ) - { - case Tool::Arrow: - case Tool::SinglePoint: - case Tool::DoublePoint: - case Tool::LinePoint: - case Tool::AbstractSpline: - case Tool::Cut: - case Tool::Midpoint:// Same as Tool::AlongLine, but tool will never has such type - case Tool::ArcIntersectAxis:// Same as Tool::CurveIntersectAxis, but tool will never has such type - case Tool::BackgroundImage: - case Tool::BackgroundImageControls: - case Tool::BackgroundPixmapImage: - case Tool::BackgroundSVGImage: - case Tool::LAST_ONE_DO_NOT_USE: - Q_UNREACHABLE(); //-V501 - break; - case Tool::BasePoint: - record.description = tr("%1 - Base point").arg(PointName(tool.getId())); - return record; - case Tool::EndLine: - record.description = tr("%1_%2 - Line from point %1 to point %2") - .arg(PointName(AttrUInt(domElem, AttrBasePoint)), PointName(tool.getId())); - return record; - case Tool::Line: - record.description = tr("%1_%2 - Line from point %1 to point %2") - .arg(PointName(AttrUInt(domElem, AttrFirstPoint)), - PointName(AttrUInt(domElem, AttrSecondPoint))); - return record; - case Tool::AlongLine: - record.description = tr("%3 - Point along line %1_%2") - .arg(PointName(AttrUInt(domElem, AttrFirstPoint)), - PointName(AttrUInt(domElem, AttrSecondPoint)), PointName(tool.getId())); - return record; - case Tool::ShoulderPoint: - record.description = tr("%1 - Point of shoulder").arg(PointName(tool.getId())); - return record; - case Tool::Normal: - record.description = tr("%3 - normal to line %1_%2") - .arg(PointName(AttrUInt(domElem, AttrFirstPoint)), - PointName(AttrUInt(domElem, AttrSecondPoint)), PointName(tool.getId())); - return record; - case Tool::Bisector: - record.description = tr("%4 - bisector of angle %1_%2_%3") - .arg(PointName(AttrUInt(domElem, AttrFirstPoint)), - PointName(AttrUInt(domElem, AttrSecondPoint)), - PointName(AttrUInt(domElem, AttrThirdPoint)), PointName(tool.getId())); - return record; - case Tool::LineIntersect: - record.description = tr("%5 - intersection of lines %1_%2 and %3_%4") - .arg(PointName(AttrUInt(domElem, AttrP1Line1)), - PointName(AttrUInt(domElem, AttrP2Line1)), - PointName(AttrUInt(domElem, AttrP1Line2)), - PointName(AttrUInt(domElem, AttrP2Line2)), - PointName(tool.getId())); - return record; - case Tool::Spline: - { - const QSharedPointer spl = data->GeometricObject(tool.getId()); - SCASSERT(not spl.isNull()) - record.description = spl->NameForHistory(tr("Curve")); - return record; - } - case Tool::CubicBezier: - { - const QSharedPointer spl = data->GeometricObject(tool.getId()); - SCASSERT(not spl.isNull()) - record.description = spl->NameForHistory(tr("Cubic bezier curve")); - return record; - } - case Tool::Arc: - { - const QSharedPointer arc = data->GeometricObject(tool.getId()); - SCASSERT(not arc.isNull()) - record.description = arc->NameForHistory(tr("Arc")); - return record; - } - case Tool::ArcWithLength: - { - const QSharedPointer arc = data->GeometricObject(tool.getId()); - SCASSERT(not arc.isNull()) - record.description = tr("%1 with length %2") - .arg(arc->NameForHistory(tr("Arc"))) - .arg(arc->GetLength()); - return record; - } - case Tool::SplinePath: - { - const QSharedPointer splPath = data->GeometricObject(tool.getId()); - SCASSERT(not splPath.isNull()) - record.description = splPath->NameForHistory(tr("Spline path")); - return record; - } - case Tool::CubicBezierPath: - { - const QSharedPointer splPath = data->GeometricObject(tool.getId()); - SCASSERT(not splPath.isNull()) - record.description = splPath->NameForHistory(tr("Cubic bezier curve path")); - return record; - } - case Tool::PointOfContact: - record.description = tr("%4 - point of contact of arc with the center in point %1 and line %2_%3") - .arg(PointName(AttrUInt(domElem, AttrCenter)), - PointName(AttrUInt(domElem, AttrFirstPoint)), - PointName(AttrUInt(domElem, AttrSecondPoint)), - PointName(tool.getId())); - return record; - case Tool::Height: - record.description = tr("Point of perpendicular from point %1 to line %2_%3") - .arg(PointName(AttrUInt(domElem, AttrBasePoint)), - PointName(AttrUInt(domElem, AttrP1Line)), - PointName(AttrUInt(domElem, AttrP2Line))); - return record; - case Tool::Triangle: - record.description = tr("Triangle: axis %1_%2, points %3 and %4") - .arg(PointName(AttrUInt(domElem, AttrAxisP1)), - PointName(AttrUInt(domElem, AttrAxisP2)), - PointName(AttrUInt(domElem, AttrFirstPoint)), - PointName(AttrUInt(domElem, AttrSecondPoint))); - return record; - case Tool::PointOfIntersection: - record.description = tr("%1 - point of intersection %2 and %3") - .arg(PointName(tool.getId()), - PointName(AttrUInt(domElem, AttrFirstPoint)), - PointName(AttrUInt(domElem, AttrSecondPoint))); - return record; - case Tool::CutArc: - { - const QSharedPointer arc = data->GeometricObject(AttrUInt(domElem, AttrArc)); - SCASSERT(not arc.isNull()) - record.description = tr("%1 - cut %2") - .arg(PointName(tool.getId()), arc->NameForHistory(tr("arc"))); - return record; - } - case Tool::CutSpline: - { - const quint32 splineId = AttrUInt(domElem, VToolCutSpline::AttrSpline); - const QSharedPointer spl = data->GeometricObject(splineId); - SCASSERT(not spl.isNull()) - record.description = tr("%1 - cut %2") - .arg(PointName(tool.getId()), spl->NameForHistory(tr("curve"))); - return record; - } - case Tool::CutSplinePath: - { - const quint32 splinePathId = AttrUInt(domElem, VToolCutSplinePath::AttrSplinePath); - const QSharedPointer splPath = - data->GeometricObject(splinePathId); - SCASSERT(not splPath.isNull()) - record.description = tr("%1 - cut %2") - .arg(PointName(tool.getId()), splPath->NameForHistory(tr("curve path"))); - return record; - } - case Tool::LineIntersectAxis: - record.description = tr("%1 - point of intersection line %2_%3 and axis through point %4") - .arg(PointName(tool.getId()), - PointName(AttrUInt(domElem, AttrP1Line)), - PointName(AttrUInt(domElem, AttrP2Line)), - PointName(AttrUInt(domElem, AttrBasePoint))); - return record; - case Tool::CurveIntersectAxis: - record.description = tr("%1 - point of intersection curve and axis through point %2") - .arg(PointName(tool.getId()), PointName(AttrUInt(domElem, AttrBasePoint))); - return record; - case Tool::PointOfIntersectionArcs: - record.description = tr("%1 - point of arcs intersection").arg(PointName(tool.getId())); - return record; - case Tool::PointOfIntersectionCircles: - record.description = tr("%1 - point of circles intersection").arg(PointName(tool.getId())); - return record; - case Tool::PointOfIntersectionCurves: - record.description = tr("%1 - point of curves intersection").arg(PointName(tool.getId())); - return record; - case Tool::PointFromCircleAndTangent: - record.description = tr("%1 - point from circle and tangent").arg(PointName(tool.getId())); - return record; - case Tool::PointFromArcAndTangent: - record.description = tr("%1 - point from arc and tangent").arg(PointName(tool.getId())); - return record; - case Tool::TrueDarts: - record.description = tr("Correction the dart %1_%2_%3") - .arg(PointName(AttrUInt(domElem, AttrDartP1)), - PointName(AttrUInt(domElem, AttrDartP2)), - PointName(AttrUInt(domElem, AttrDartP2))); - return record; - case Tool::EllipticalArc: - { - const QSharedPointer elArc = data->GeometricObject(tool.getId()); - SCASSERT(not elArc.isNull()) - record.description = tr("%1 with length %2") - .arg(elArc->NameForHistory(tr("Elliptical arc"))) - .arg(elArc->GetLength()); - return record; - } - case Tool::Rotation: - record.description = tr("Rotate objects around point %1. Suffix '%2'") - .arg(PointName(AttrUInt(domElem, AttrCenter)), - doc->GetParametrString(domElem, AttrSuffix, QString())); - return record; - case Tool::FlippingByLine: - record.description = tr("Flipping by line %1_%2. Suffix '%3'") - .arg(PointName(AttrUInt(domElem, AttrP1Line)), - PointName(AttrUInt(domElem, AttrP2Line)), - doc->GetParametrString(domElem, AttrSuffix, QString())); - return record; - case Tool::FlippingByAxis: - record.description = tr("Flipping by axis through %1 point. Suffix '%2'") - .arg(PointName(AttrUInt(domElem, AttrCenter)), - doc->GetParametrString(domElem, AttrSuffix, QString())); - return record; - case Tool::Move: - record.description = tr("Move objects. Suffix '%1'") - .arg(doc->GetParametrString(domElem, AttrSuffix, QString())); - return record; - //Because "history" not only show history of pattern, but help restore current data for each pattern's - //piece, we need add record about details and nodes, but don't show them. - case Tool::Piece: - case Tool::UnionDetails: - case Tool::NodeArc: - case Tool::NodeElArc: - case Tool::NodePoint: - case Tool::NodeSpline: - case Tool::NodeSplinePath: - case Tool::Group: - case Tool::PiecePath: - case Tool::Pin: - case Tool::PlaceLabel: - case Tool::InsertNode: - case Tool::DuplicateDetail: - return record; - } + record = RecordDescription(tool, record, domElem); } catch (const VExceptionBadId &e) { @@ -487,6 +255,238 @@ HistoryRecord DialogHistory::Record(const VToolRecord &tool) const return record; } +//--------------------------------------------------------------------------------------------------------------------- +auto DialogHistory::RecordDescription(const VToolRecord &tool, HistoryRecord record, + const QDomElement &domElem) const -> HistoryRecord +{ + // This check helps to find missed tools in the switch + Q_STATIC_ASSERT_X(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 59, "Not all tools were used in history."); + + switch ( tool.getTypeTool() ) + { + case Tool::Arrow: + case Tool::SinglePoint: + case Tool::DoublePoint: + case Tool::LinePoint: + case Tool::AbstractSpline: + case Tool::Cut: + case Tool::Midpoint:// Same as Tool::AlongLine, but tool will never has such type + case Tool::ArcIntersectAxis:// Same as Tool::CurveIntersectAxis, but tool will never has such type + case Tool::BackgroundImage: + case Tool::BackgroundImageControls: + case Tool::BackgroundPixmapImage: + case Tool::BackgroundSVGImage: + case Tool::LAST_ONE_DO_NOT_USE: + Q_UNREACHABLE(); //-V501 + break; + case Tool::BasePoint: + record.description = tr("%1 - Base point").arg(PointName(tool.getId())); + return record; + case Tool::EndLine: + record.description = tr("%1_%2 - Line from point %1 to point %2") + .arg(PointName(AttrUInt(domElem, AttrBasePoint)), PointName(tool.getId())); + return record; + case Tool::Line: + record.description = tr("%1_%2 - Line from point %1 to point %2") + .arg(PointName(AttrUInt(domElem, AttrFirstPoint)), + PointName(AttrUInt(domElem, AttrSecondPoint))); + return record; + case Tool::AlongLine: + record.description = tr("%3 - Point along line %1_%2") + .arg(PointName(AttrUInt(domElem, AttrFirstPoint)), + PointName(AttrUInt(domElem, AttrSecondPoint)), PointName(tool.getId())); + return record; + case Tool::ShoulderPoint: + record.description = tr("%1 - Point of shoulder").arg(PointName(tool.getId())); + return record; + case Tool::Normal: + record.description = tr("%3 - normal to line %1_%2") + .arg(PointName(AttrUInt(domElem, AttrFirstPoint)), + PointName(AttrUInt(domElem, AttrSecondPoint)), PointName(tool.getId())); + return record; + case Tool::Bisector: + record.description = tr("%4 - bisector of angle %1_%2_%3") + .arg(PointName(AttrUInt(domElem, AttrFirstPoint)), + PointName(AttrUInt(domElem, AttrSecondPoint)), + PointName(AttrUInt(domElem, AttrThirdPoint)), PointName(tool.getId())); + return record; + case Tool::LineIntersect: + record.description = tr("%5 - intersection of lines %1_%2 and %3_%4") + .arg(PointName(AttrUInt(domElem, AttrP1Line1)), + PointName(AttrUInt(domElem, AttrP2Line1)), + PointName(AttrUInt(domElem, AttrP1Line2)), + PointName(AttrUInt(domElem, AttrP2Line2)), + PointName(tool.getId())); + return record; + case Tool::Spline: + { + const QSharedPointer spl = data->GeometricObject(tool.getId()); + record.description = spl->NameForHistory(tr("Curve")); + return record; + } + case Tool::CubicBezier: + { + const QSharedPointer spl = data->GeometricObject(tool.getId()); + record.description = spl->NameForHistory(tr("Cubic bezier curve")); + return record; + } + case Tool::Arc: + { + const QSharedPointer arc = data->GeometricObject(tool.getId()); + record.description = arc->NameForHistory(tr("Arc")); + return record; + } + case Tool::ArcWithLength: + { + const QSharedPointer arc = data->GeometricObject(tool.getId()); + record.description = tr("%1 with length %2") + .arg(arc->NameForHistory(tr("Arc"))) + .arg(arc->GetLength()); + return record; + } + case Tool::SplinePath: + { + const QSharedPointer splPath = data->GeometricObject(tool.getId()); + record.description = splPath->NameForHistory(tr("Spline path")); + return record; + } + case Tool::CubicBezierPath: + { + const QSharedPointer splPath = data->GeometricObject(tool.getId()); + record.description = splPath->NameForHistory(tr("Cubic bezier curve path")); + return record; + } + case Tool::PointOfContact: + record.description = tr("%4 - point of contact of arc with the center in point %1 and line %2_%3") + .arg(PointName(AttrUInt(domElem, AttrCenter)), + PointName(AttrUInt(domElem, AttrFirstPoint)), + PointName(AttrUInt(domElem, AttrSecondPoint)), + PointName(tool.getId())); + return record; + case Tool::Height: + record.description = tr("Point of perpendicular from point %1 to line %2_%3") + .arg(PointName(AttrUInt(domElem, AttrBasePoint)), + PointName(AttrUInt(domElem, AttrP1Line)), + PointName(AttrUInt(domElem, AttrP2Line))); + return record; + case Tool::Triangle: + record.description = tr("Triangle: axis %1_%2, points %3 and %4") + .arg(PointName(AttrUInt(domElem, AttrAxisP1)), + PointName(AttrUInt(domElem, AttrAxisP2)), + PointName(AttrUInt(domElem, AttrFirstPoint)), + PointName(AttrUInt(domElem, AttrSecondPoint))); + return record; + case Tool::PointOfIntersection: + record.description = tr("%1 - point of intersection %2 and %3") + .arg(PointName(tool.getId()), + PointName(AttrUInt(domElem, AttrFirstPoint)), + PointName(AttrUInt(domElem, AttrSecondPoint))); + return record; + case Tool::CutArc: + { + const QSharedPointer arc = data->GeometricObject(AttrUInt(domElem, AttrArc)); + record.description = tr("%1 - cut %2") + .arg(PointName(tool.getId()), arc->NameForHistory(tr("arc"))); + return record; + } + case Tool::CutSpline: + { + const quint32 splineId = AttrUInt(domElem, VToolCutSpline::AttrSpline); + const QSharedPointer spl = data->GeometricObject(splineId); + record.description = tr("%1 - cut %2") + .arg(PointName(tool.getId()), spl->NameForHistory(tr("curve"))); + return record; + } + case Tool::CutSplinePath: + { + const quint32 splinePathId = AttrUInt(domElem, VToolCutSplinePath::AttrSplinePath); + const QSharedPointer splPath = + data->GeometricObject(splinePathId); + record.description = tr("%1 - cut %2") + .arg(PointName(tool.getId()), splPath->NameForHistory(tr("curve path"))); + return record; + } + case Tool::LineIntersectAxis: + record.description = tr("%1 - point of intersection line %2_%3 and axis through point %4") + .arg(PointName(tool.getId()), + PointName(AttrUInt(domElem, AttrP1Line)), + PointName(AttrUInt(domElem, AttrP2Line)), + PointName(AttrUInt(domElem, AttrBasePoint))); + return record; + case Tool::CurveIntersectAxis: + record.description = tr("%1 - point of intersection curve and axis through point %2") + .arg(PointName(tool.getId()), PointName(AttrUInt(domElem, AttrBasePoint))); + return record; + case Tool::PointOfIntersectionArcs: + record.description = tr("%1 - point of arcs intersection").arg(PointName(tool.getId())); + return record; + case Tool::PointOfIntersectionCircles: + record.description = tr("%1 - point of circles intersection").arg(PointName(tool.getId())); + return record; + case Tool::PointOfIntersectionCurves: + record.description = tr("%1 - point of curves intersection").arg(PointName(tool.getId())); + return record; + case Tool::PointFromCircleAndTangent: + record.description = tr("%1 - point from circle and tangent").arg(PointName(tool.getId())); + return record; + case Tool::PointFromArcAndTangent: + record.description = tr("%1 - point from arc and tangent").arg(PointName(tool.getId())); + return record; + case Tool::TrueDarts: + record.description = tr("Correction the dart %1_%2_%3") + .arg(PointName(AttrUInt(domElem, AttrDartP1)), + PointName(AttrUInt(domElem, AttrDartP2)), + PointName(AttrUInt(domElem, AttrDartP2))); + return record; + case Tool::EllipticalArc: + { + const QSharedPointer elArc = data->GeometricObject(tool.getId()); + record.description = tr("%1 with length %2") + .arg(elArc->NameForHistory(tr("Elliptical arc"))) + .arg(elArc->GetLength()); + return record; + } + case Tool::Rotation: + record.description = tr("Rotate objects around point %1. Suffix '%2'") + .arg(PointName(AttrUInt(domElem, AttrCenter)), + VDomDocument::GetParametrString(domElem, AttrSuffix, QString())); + return record; + case Tool::FlippingByLine: + record.description = tr("Flipping by line %1_%2. Suffix '%3'") + .arg(PointName(AttrUInt(domElem, AttrP1Line)), + PointName(AttrUInt(domElem, AttrP2Line)), + VDomDocument::GetParametrString(domElem, AttrSuffix, QString())); + return record; + case Tool::FlippingByAxis: + record.description = tr("Flipping by axis through %1 point. Suffix '%2'") + .arg(PointName(AttrUInt(domElem, AttrCenter)), + VDomDocument::GetParametrString(domElem, AttrSuffix, QString())); + return record; + case Tool::Move: + record.description = tr("Move objects. Suffix '%1'") + .arg(VDomDocument::GetParametrString(domElem, AttrSuffix, QString())); + return record; + //Because "history" not only show history of pattern, but help restore current data for each pattern's + //piece, we need add record about details and nodes, but don't show them. + case Tool::Piece: + case Tool::UnionDetails: + case Tool::NodeArc: + case Tool::NodeElArc: + case Tool::NodePoint: + case Tool::NodeSpline: + case Tool::NodeSplinePath: + case Tool::Group: + case Tool::PiecePath: + case Tool::Pin: + case Tool::PlaceLabel: + case Tool::InsertNode: + case Tool::DuplicateDetail: + return record; + } + + return record; +} + QT_WARNING_POP //--------------------------------------------------------------------------------------------------------------------- @@ -506,14 +506,14 @@ void DialogHistory::InitialTable() */ void DialogHistory::ShowPoint() { - const QVector *history = doc->getHistory(); - if (history->size()>0) + const QVector *history = m_doc->getHistory(); + if (not history->empty()) { QTableWidgetItem *item = ui->tableWidget->item(0, 1); item->setSelected(true); - cursorToolRecordRow = 0; + m_cursorToolRecordRow = 0; item = ui->tableWidget->item(0, 0); - quint32 id = qvariant_cast(item->data(Qt::UserRole)); + auto id = qvariant_cast(item->data(Qt::UserRole)); emit ShowHistoryTool(id, true); } } @@ -526,15 +526,15 @@ void DialogHistory::ShowPoint() * @param pointId point if in data. * @return point name. */ -QString DialogHistory::PointName(quint32 pointId) const +auto DialogHistory::PointName(quint32 pointId) const -> QString { return data->GeometricObject(pointId)->name(); } //--------------------------------------------------------------------------------------------------------------------- -quint32 DialogHistory::AttrUInt(const QDomElement &domElement, const QString &name) const +auto DialogHistory::AttrUInt(const QDomElement &domElement, const QString &name) const -> quint32 { - return doc->GetParametrUInt(domElement, name, QChar('0')); + return VDomDocument::GetParametrUInt(domElement, name, QChar('0')); } //--------------------------------------------------------------------------------------------------------------------- @@ -544,8 +544,8 @@ quint32 DialogHistory::AttrUInt(const QDomElement &domElement, const QString &na */ void DialogHistory::closeEvent(QCloseEvent *event) { - QTableWidgetItem *item = ui->tableWidget->item(cursorToolRecordRow, 0); - quint32 id = qvariant_cast(item->data(Qt::UserRole)); + QTableWidgetItem *item = ui->tableWidget->item(m_cursorToolRecordRow, 0); + auto id = qvariant_cast(item->data(Qt::UserRole)); emit ShowHistoryTool(id, false); VValentinaSettings *settings = VAbstractValApplication::VApp()->ValentinaSettings(); @@ -574,29 +574,29 @@ void DialogHistory::changeEvent(QEvent *event) //--------------------------------------------------------------------------------------------------------------------- void DialogHistory::showEvent(QShowEvent *event) { - QDialog::showEvent( event ); // return default behavior + QDialog::showEvent( event ); // return default behavior NOLINT(bugprone-parent-virtual-call) } //--------------------------------------------------------------------------------------------------------------------- void DialogHistory::RetranslateUi() { - qint32 currentRow = cursorRow; + qint32 currentRow = m_cursorRow; UpdateHistory(); - QTableWidgetItem *item = ui->tableWidget->item(cursorRow, 0); + QTableWidgetItem *item = ui->tableWidget->item(m_cursorRow, 0); SCASSERT(item != nullptr) item->setIcon(QIcon(QString())); - cursorRow = currentRow; - cellClicked(cursorRow, 0); + m_cursorRow = currentRow; + cellClicked(m_cursorRow, 0); ui->lineEditFind->setPlaceholderText(m_search->SearchPlaceholder()); UpdateSearchControlsTooltips(); } //--------------------------------------------------------------------------------------------------------------------- -int DialogHistory::CursorRow() const +auto DialogHistory::CursorRow() const -> int { - const quint32 cursor = doc->getCursor(); + const quint32 cursor = m_doc->getCursor(); if (cursor == 0) { return ui->tableWidget->rowCount()-1; @@ -605,7 +605,7 @@ int DialogHistory::CursorRow() const for (int i = 0; i < ui->tableWidget->rowCount(); ++i) { QTableWidgetItem *item = ui->tableWidget->item(i, 0); - const quint32 id = qvariant_cast(item->data(Qt::UserRole)); + const auto id = qvariant_cast(item->data(Qt::UserRole)); if (cursor == id) { return i; @@ -641,14 +641,14 @@ void DialogHistory::InitSearch() SaveSearchRequest(); InitSearchHistory(); m_search->FindPrevious(); - ui->labelResults->setText(QString("%1/%2").arg(m_search->MatchIndex()+1).arg(m_search->MatchCount())); + ui->labelResults->setText(QStringLiteral("%1/%2").arg(m_search->MatchIndex()+1).arg(m_search->MatchCount())); }); connect(ui->toolButtonFindNext, &QToolButton::clicked, this, [this]() { SaveSearchRequest(); InitSearchHistory(); m_search->FindNext(); - ui->labelResults->setText(QString("%1/%2").arg(m_search->MatchIndex()+1).arg(m_search->MatchCount())); + ui->labelResults->setText(QStringLiteral("%1/%2").arg(m_search->MatchIndex()+1).arg(m_search->MatchCount())); }); connect(m_search.data(), &VTableSearch::HasResult, this, [this] (bool state) @@ -658,7 +658,8 @@ void DialogHistory::InitSearch() if (state) { - ui->labelResults->setText(QString("%1/%2").arg(m_search->MatchIndex()+1).arg(m_search->MatchCount())); + ui->labelResults->setText( + QStringLiteral("%1/%2").arg(m_search->MatchIndex()+1).arg(m_search->MatchCount())); } else { diff --git a/src/app/valentina/dialogs/dialoghistory.h b/src/app/valentina/dialogs/dialoghistory.h index d1c557312..eea2ae1b6 100644 --- a/src/app/valentina/dialogs/dialoghistory.h +++ b/src/app/valentina/dialogs/dialoghistory.h @@ -52,19 +52,19 @@ namespace Ui */ class DialogHistory : public DialogTool { - Q_OBJECT + Q_OBJECT // NOLINT public: DialogHistory(VContainer *data, VPattern *doc, QWidget *parent = nullptr); - virtual ~DialogHistory() override; + ~DialogHistory() override; public slots: - virtual void DialogAccepted() override; + void DialogAccepted() override; /** TODO ISSUE 79 : create real function * @brief DialogApply apply data and emit signal about applied dialog. */ - virtual void DialogApply() override {} - void cellClicked(int row, int column); - void ChangedCursor(quint32 id); - void UpdateHistory(); + void DialogApply() override {} + void cellClicked(int row, int column); + void ChangedCursor(quint32 id); + void UpdateHistory(); signals: /** * @brief ShowHistoryTool signal change color of selected in records tool @@ -73,36 +73,39 @@ signals: */ void ShowHistoryTool(quint32 id, bool enable); protected: - virtual void closeEvent ( QCloseEvent * event ) override; - virtual void changeEvent(QEvent* event) override; - virtual bool IsValid() const final {return true;} - virtual void showEvent( QShowEvent *event ) override; + void closeEvent ( QCloseEvent * event ) override; + void changeEvent(QEvent* event) override; + auto IsValid() const -> bool final {return true;} + void showEvent( QShowEvent *event ) override; private: - Q_DISABLE_COPY(DialogHistory) + // cppcheck-suppress unknownMacro + Q_DISABLE_COPY_MOVE(DialogHistory) // NOLINT /** @brief ui keeps information about user interface */ Ui::DialogHistory *ui; /** @brief doc dom document container */ - VPattern *doc; + VPattern *m_doc; /** @brief cursorRow save number of row where is cursor */ - qint32 cursorRow{0}; + qint32 m_cursorRow{0}; /** @brief cursorToolRecordRow save number of row selected record */ - qint32 cursorToolRecordRow{0}; + qint32 m_cursorToolRecordRow{0}; QSharedPointer m_search{}; QMenu *m_searchHistory; - void FillTable(); - HistoryRecord Record(const VToolRecord &tool) const; - void InitialTable(); - void ShowPoint(); - QString PointName(quint32 pointId) const; - quint32 AttrUInt(const QDomElement &domElement, const QString &name) const; - void RetranslateUi(); - int CursorRow() const; + void FillTable(); + auto Record(const VToolRecord &tool) const -> HistoryRecord; + auto RecordDescription(const VToolRecord &tool, HistoryRecord record, + const QDomElement &domElem) const -> HistoryRecord; + void InitialTable(); + void ShowPoint(); + auto PointName(quint32 pointId) const -> QString; + auto AttrUInt(const QDomElement &domElement, const QString &name) const -> quint32; + void RetranslateUi(); + auto CursorRow() const -> int; void InitSearch(); void InitSearchHistory(); diff --git a/src/app/valentina/dialogs/dialogincrements.cpp b/src/app/valentina/dialogs/dialogincrements.cpp index dcfb29e36..355d0aa63 100644 --- a/src/app/valentina/dialogs/dialogincrements.cpp +++ b/src/app/valentina/dialogs/dialogincrements.cpp @@ -45,7 +45,7 @@ #include #include -#define DIALOG_MAX_FORMULA_HEIGHT 64 +constexpr int DIALOG_MAX_FORMULA_HEIGHT = 64; namespace { @@ -62,8 +62,8 @@ enum class IncrUnits : qint8 {Pattern, Degrees}; DialogIncrements::DialogIncrements(VContainer *data, VPattern *doc, QWidget *parent) :DialogTool(data, NULL_ID, parent), ui(new Ui::DialogIncrements), - data(data), - doc(doc), + m_data(data), + m_doc(doc), m_completeData(doc->GetCompleteData()), m_searchHistory(new QMenu(this)), m_searchHistoryPC(new QMenu(this)) @@ -116,7 +116,7 @@ DialogIncrements::DialogIncrements(VContainer *data, VPattern *doc, QWidget *par FillRadiusesArcs(); FillAnglesCurves(); - connect(this->doc, &VPattern::FullUpdateFromFile, this, &DialogIncrements::FullUpdateFromFile); + connect(this->m_doc, &VPattern::FullUpdateFromFile, this, &DialogIncrements::FullUpdateFromFile); ui->tabWidget->setCurrentIndex(0); auto *validator = new QRegularExpressionValidator(QRegularExpression(QStringLiteral("^$|")+NameRegExp()), this); @@ -171,13 +171,13 @@ DialogIncrements::DialogIncrements(VContainer *data, VPattern *doc, QWidget *par */ void DialogIncrements::FillIncrements() { - FillIncrementsTable(ui->tableWidgetIncrement, data->DataIncrementsWithSeparators(), false); + FillIncrementsTable(ui->tableWidgetIncrement, m_data->DataIncrementsWithSeparators(), false); } //--------------------------------------------------------------------------------------------------------------------- void DialogIncrements::FillPreviewCalculations() { - FillIncrementsTable(ui->tableWidgetPC, data->DataIncrementsWithSeparators(), true); + FillIncrementsTable(ui->tableWidgetPC, m_data->DataIncrementsWithSeparators(), true); } //--------------------------------------------------------------------------------------------------------------------- @@ -331,7 +331,7 @@ auto DialogIncrements::GetCustomName() const -> QString name = CustomIncrSign + VAbstractApplication::VApp()->TrVars()->InternalVarToUser(increment_) + QString::number(num); num++; - } while (not data->IsUnique(name)); + } while (not m_data->IsUnique(name)); return name; } @@ -586,7 +586,7 @@ void DialogIncrements::EnableDetails(QTableWidget *table, bool enabled) { const QTableWidgetItem *nameField = table->item(table->currentRow(), 0); SCASSERT(nameField != nullptr) - QSharedPointer incr = data->GetVariable(nameField->text()); + QSharedPointer incr = m_data->GetVariable(nameField->text()); const bool isSeparator = incr->GetIncrementType() == IncrementType::Separator; if (table == ui->tableWidgetIncrement) @@ -617,7 +617,7 @@ void DialogIncrements::EnableDetails(QTableWidget *table, bool enabled) //--------------------------------------------------------------------------------------------------------------------- void DialogIncrements::LocalUpdateTree() { - doc->LiteParseIncrements(); + m_doc->LiteParseIncrements(); int row = ui->tableWidgetIncrement->currentRow(); @@ -642,7 +642,7 @@ void DialogIncrements::LocalUpdateTree() //--------------------------------------------------------------------------------------------------------------------- auto DialogIncrements::IncrementUsed(const QString &name) const -> bool { - const QVector expressions = doc->ListExpressions(); + const QVector expressions = m_doc->ListExpressions(); for(const auto &field : expressions) { @@ -723,7 +723,7 @@ void DialogIncrements::ShowTableIncrementDetails(QTableWidget *table) try { - incr = data->GetVariable(nameField->text()); + incr = m_data->GetVariable(nameField->text()); } catch(const VExceptionBadId &e) { @@ -811,15 +811,15 @@ void DialogIncrements::AddNewIncrement(IncrementType type) if (table->currentRow() == -1) { currentRow = table->rowCount(); - incrementMode ? doc->AddEmptyIncrement(name, type) : doc->AddEmptyPreviewCalculation(name, type); + incrementMode ? m_doc->AddEmptyIncrement(name, type) : m_doc->AddEmptyPreviewCalculation(name, type); } else { currentRow = table->currentRow()+1; const QTableWidgetItem *nameField = table->item(table->currentRow(), 0); - incrementMode ? doc->AddEmptyIncrementAfter(nameField->text(), name, type) : - doc->AddEmptyPreviewCalculationAfter(nameField->text(), name, type); + incrementMode ? m_doc->AddEmptyIncrementAfter(nameField->text(), name, type) : + m_doc->AddEmptyPreviewCalculationAfter(nameField->text(), name, type); } m_hasChanges = true; @@ -1234,7 +1234,7 @@ void DialogIncrements::FullUpdateFromFile() ui->tableWidgetLinesAngles->clearContents(); ui->tableWidgetRadiusesArcs->clearContents(); - m_completeData = doc->GetCompleteData(); + m_completeData = m_doc->GetCompleteData(); FillIncrements(); FillPreviewCalculations(); @@ -1257,17 +1257,17 @@ void DialogIncrements::RefreshPattern() { if (m_hasChanges) { - QVector expressions = doc->ListExpressions(); + QVector expressions = m_doc->ListExpressions(); for (auto &item : m_renameList) { - doc->ReplaceNameInFormula(expressions, item.first, item.second); + m_doc->ReplaceNameInFormula(expressions, item.first, item.second); } m_renameList.clear(); const int row = ui->tableWidgetIncrement->currentRow(); const int rowPC = ui->tableWidgetPC->currentRow(); - doc->LiteParseTree(Document::FullLiteParse); + m_doc->LiteParseTree(Document::FullLiteParse); ui->tableWidgetIncrement->blockSignals(true); ui->tableWidgetIncrement->selectRow(row); @@ -1395,11 +1395,11 @@ void DialogIncrements::RemoveIncrement() if (button == ui->toolButtonRemove) { - doc->RemoveIncrement(nameField->text()); + m_doc->RemoveIncrement(nameField->text()); } else if (button == ui->toolButtonRemovePC) { - doc->RemovePreviewCalculation(nameField->text()); + m_doc->RemovePreviewCalculation(nameField->text()); } m_hasChanges = true; @@ -1440,11 +1440,11 @@ void DialogIncrements::MoveUp() if (button == ui->toolButtonUp) { - doc->MoveUpIncrement(nameField->text()); + m_doc->MoveUpIncrement(nameField->text()); } else if (button == ui->toolButtonUpPC) { - doc->MoveUpPreviewCalculation(nameField->text()); + m_doc->MoveUpPreviewCalculation(nameField->text()); } m_hasChanges = true; @@ -1485,11 +1485,11 @@ void DialogIncrements::MoveDown() if (button == ui->toolButtonDown) { - doc->MoveDownIncrement(nameField->text()); + m_doc->MoveDownIncrement(nameField->text()); } else if (button == ui->toolButtonDownPC) { - doc->MoveDownPreviewCalculation(nameField->text()); + m_doc->MoveDownPreviewCalculation(nameField->text()); } m_hasChanges = true; @@ -1531,7 +1531,7 @@ void DialogIncrements::SaveIncrName(const QString &text) QString newName = text.isEmpty() ? GetCustomName() : CustomIncrSign + text; bool updateFlag = not text.isEmpty(); - if (not data->IsUnique(newName)) + if (not m_data->IsUnique(newName)) { updateFlag = false; qint32 num = 2; @@ -1540,13 +1540,13 @@ void DialogIncrements::SaveIncrName(const QString &text) { name = name + '_' + QString::number(num); num++; - } while (not data->IsUnique(name)); + } while (not m_data->IsUnique(name)); newName = name; } - doc->SetIncrementName(nameField->text(), newName); - QVector expression = doc->ListIncrementExpressions(); - doc->ReplaceNameInFormula(expression, nameField->text(), newName); + m_doc->SetIncrementName(nameField->text(), newName); + QVector expression = m_doc->ListIncrementExpressions(); + m_doc->ReplaceNameInFormula(expression, nameField->text(), newName); CacheRename(nameField->text(), newName); @@ -1558,7 +1558,7 @@ void DialogIncrements::SaveIncrName(const QString &text) else { nameField->setText(newName); - doc->LiteParseIncrements(); + m_doc->LiteParseIncrements(); } table->blockSignals(true); @@ -1596,7 +1596,7 @@ void DialogIncrements::SaveIncrUnits() const QTableWidgetItem *nameField = table->item(row, 0); const IncrUnits units = static_cast(combo->currentData().toInt()); - doc->SetIncrementSpecialUnits(nameField->text(), units == IncrUnits::Degrees); + m_doc->SetIncrementSpecialUnits(nameField->text(), units == IncrUnits::Degrees); LocalUpdateTree(); table->blockSignals(true); @@ -1636,7 +1636,7 @@ void DialogIncrements::SaveIncrDescription() const QTextCursor cursor = textEdit->textCursor(); const QTableWidgetItem *nameField = table->item(row, 0); - doc->SetIncrementDescription(nameField->text(), textEdit->toPlainText()); + m_doc->SetIncrementDescription(nameField->text(), textEdit->toPlainText()); LocalUpdateTree(); table->blockSignals(true); @@ -1678,7 +1678,7 @@ void DialogIncrements::SaveIncrFormula() const QTableWidgetItem *nameField = table->item(row, 0); QString text = textEdit->toPlainText(); - QSharedPointer incr = data->GetVariable(nameField->text()); + QSharedPointer incr = m_data->GetVariable(nameField->text()); QTableWidgetItem *formulaField = table->item(row, 2); if (formulaField->text() == text) @@ -1726,7 +1726,7 @@ void DialogIncrements::SaveIncrFormula() { const QString formula = VAbstractApplication::VApp()->TrVars() ->FormulaFromUser(text, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); - doc->SetIncrementFormula(nameField->text(), formula); + m_doc->SetIncrementFormula(nameField->text(), formula); } catch (qmu::QmuParserError &e) // Just in case something bad will happen { @@ -1837,7 +1837,7 @@ void DialogIncrements::Fx() } const QTableWidgetItem *nameField = table->item(row, 0); - QSharedPointer incr = data->GetVariable(nameField->text()); + QSharedPointer incr = m_data->GetVariable(nameField->text()); QScopedPointer dialog(new DialogEditWrongFormula(incr->GetData(), NULL_ID, this)); dialog->setWindowTitle(tr("Edit increment")); @@ -1852,7 +1852,7 @@ void DialogIncrements::Fx() { // Fix the bug #492. https://bitbucket.org/dismine/valentina/issues/492/valentina-crashes-when-add-an-increment // Because of the bug need to take QTableWidgetItem twice time. Previous update "killed" the pointer. - doc->SetIncrementFormula(table->item(row, 0)->text(), dialog->GetFormula()); + m_doc->SetIncrementFormula(table->item(row, 0)->text(), dialog->GetFormula()); m_hasChanges = true; LocalUpdateTree(); @@ -1871,7 +1871,7 @@ void DialogIncrements::closeEvent(QCloseEvent *event) ui->lineEditName->blockSignals(true); ui->plainTextEditDescription->blockSignals(true); - disconnect(this->doc, &VPattern::FullUpdateFromFile, this, &DialogIncrements::FullUpdateFromFile); + disconnect(this->m_doc, &VPattern::FullUpdateFromFile, this, &DialogIncrements::FullUpdateFromFile); VValentinaSettings *settings = VAbstractValApplication::VApp()->ValentinaSettings(); @@ -1996,7 +1996,7 @@ void DialogIncrements::RestoreAfterClose() // Because of bug on Mac OS with Qt 5.11 closing this dialog causes a crash. Instead of closing we will keep // dialog in memory and reuse it again. This function redo some moves made after close. - connect(this->doc, &VPattern::FullUpdateFromFile, this, &DialogIncrements::FullUpdateFromFile); + connect(this->m_doc, &VPattern::FullUpdateFromFile, this, &DialogIncrements::FullUpdateFromFile); ui->tabWidget->setCurrentIndex(0); diff --git a/src/app/valentina/dialogs/dialogincrements.h b/src/app/valentina/dialogs/dialogincrements.h index 47c4c4ee4..11614e91b 100644 --- a/src/app/valentina/dialogs/dialogincrements.h +++ b/src/app/valentina/dialogs/dialogincrements.h @@ -90,10 +90,10 @@ private: Ui::DialogIncrements *ui; /** @brief data container with data */ - VContainer *data; // need because we must change data //-V703 + VContainer *m_data; // need because we must change data //-V703 /** @brief doc dom document container */ - VPattern *doc; + VPattern *m_doc; /** @brief m_completeData need to show all internal variables */ VContainer m_completeData; diff --git a/src/app/valentina/dialogs/dialogknownmaterials.cpp b/src/app/valentina/dialogs/dialogknownmaterials.cpp index 0878e44be..a4292c18f 100644 --- a/src/app/valentina/dialogs/dialogknownmaterials.cpp +++ b/src/app/valentina/dialogs/dialogknownmaterials.cpp @@ -59,7 +59,7 @@ void DialogKnownMaterials::SetList(const QStringList &list) int row = -1; - for (auto &m : list) + for (const auto &m : list) { if (not m.isEmpty()) { @@ -76,7 +76,7 @@ void DialogKnownMaterials::SetList(const QStringList &list) } //--------------------------------------------------------------------------------------------------------------------- -QStringList DialogKnownMaterials::GetList() const +auto DialogKnownMaterials::GetList() const -> QStringList { QStringList list; @@ -124,10 +124,7 @@ void DialogKnownMaterials::Remove() { ui->listWidget->blockSignals(true); QListWidgetItem *curLine = ui->listWidget->takeItem(ui->listWidget->currentRow()); - if (curLine) - { - delete curLine; - } + delete curLine; ui->listWidget->blockSignals(false); ShowDetails(); } diff --git a/src/app/valentina/dialogs/dialogknownmaterials.h b/src/app/valentina/dialogs/dialogknownmaterials.h index 640427b4d..08738f4c3 100644 --- a/src/app/valentina/dialogs/dialogknownmaterials.h +++ b/src/app/valentina/dialogs/dialogknownmaterials.h @@ -31,6 +31,8 @@ #include +#include "../vmisc/defglobal.h" + namespace Ui { class DialogKnownMaterials; @@ -38,14 +40,14 @@ namespace Ui class DialogKnownMaterials : public QDialog { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit DialogKnownMaterials(QWidget *parent = nullptr); - virtual ~DialogKnownMaterials(); + ~DialogKnownMaterials() override; - void SetList(const QStringList &list); - QStringList GetList() const; + void SetList(const QStringList &list); + auto GetList() const -> QStringList; private slots: void ShowDetails(); @@ -54,7 +56,8 @@ private slots: void SaveText(const QString &text); private: - Q_DISABLE_COPY(DialogKnownMaterials) + // cppcheck-suppress unknownMacro + Q_DISABLE_COPY_MOVE(DialogKnownMaterials) // NOLINT Ui::DialogKnownMaterials *ui; void SetupControls(); diff --git a/src/app/valentina/dialogs/dialoglayoutprogress.cpp b/src/app/valentina/dialogs/dialoglayoutprogress.cpp index 1427c89aa..4350e5eab 100644 --- a/src/app/valentina/dialogs/dialoglayoutprogress.cpp +++ b/src/app/valentina/dialogs/dialoglayoutprogress.cpp @@ -28,7 +28,7 @@ #include "dialoglayoutprogress.h" #include "ui_dialoglayoutprogress.h" -#include "../core/vapplication.h" +#include "../vmisc/vabstractvalapplication.h" #include "../vmisc/vvalentinasettings.h" #include @@ -36,6 +36,10 @@ #include #include #include +#include +#include + +using namespace std::chrono_literals; //--------------------------------------------------------------------------------------------------------------------- DialogLayoutProgress::DialogLayoutProgress(QElapsedTimer timer, qint64 timeout, QWidget *parent) @@ -44,7 +48,7 @@ DialogLayoutProgress::DialogLayoutProgress(QElapsedTimer timer, qint64 timeout, m_movie(new QMovie(QStringLiteral("://icon/16x16/progress.gif"))), m_timer(timer), m_timeout(timeout), - progressTimer(new QTimer(this)) + m_progressTimer(new QTimer(this)) { ui->setupUi(this); @@ -64,7 +68,7 @@ DialogLayoutProgress::DialogLayoutProgress(QElapsedTimer timer, qint64 timeout, this->setWindowFlags(Qt::Dialog | Qt::WindowTitleHint | Qt::CustomizeWindowHint); - connect(progressTimer, &QTimer::timeout, this, [this]() + connect(m_progressTimer, &QTimer::timeout, this, [this]() { const qint64 elapsed = m_timer.elapsed(); const int timeout = static_cast(m_timeout - elapsed); @@ -76,10 +80,10 @@ DialogLayoutProgress::DialogLayoutProgress(QElapsedTimer timer, qint64 timeout, if (timeout <= 1000) { emit Timeout(); - progressTimer->stop(); + m_progressTimer->stop(); } }); - progressTimer->start(1000); + m_progressTimer->start(1s); } //--------------------------------------------------------------------------------------------------------------------- @@ -98,7 +102,7 @@ void DialogLayoutProgress::Start() //--------------------------------------------------------------------------------------------------------------------- void DialogLayoutProgress::Finished() { - progressTimer->stop(); + m_progressTimer->stop(); done(QDialog::Accepted); } @@ -117,7 +121,7 @@ void DialogLayoutProgress::showEvent(QShowEvent *event) return; } - if (isInitialized) + if (m_isInitialized) { return; } @@ -126,5 +130,5 @@ void DialogLayoutProgress::showEvent(QShowEvent *event) setMaximumSize(size()); setMinimumSize(size()); - isInitialized = true;//first show windows are held + m_isInitialized = true;//first show windows are held } diff --git a/src/app/valentina/dialogs/dialoglayoutprogress.h b/src/app/valentina/dialogs/dialoglayoutprogress.h index 1c35d7c18..da24a054b 100644 --- a/src/app/valentina/dialogs/dialoglayoutprogress.h +++ b/src/app/valentina/dialogs/dialoglayoutprogress.h @@ -33,7 +33,7 @@ #include #include -#include "../vlayout/vlayoutdef.h" +#include "../vmisc/defglobal.h" namespace Ui { @@ -42,11 +42,11 @@ namespace Ui class DialogLayoutProgress : public QDialog { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit DialogLayoutProgress(QElapsedTimer timer, qint64 timeout, QWidget *parent = nullptr); - ~DialogLayoutProgress(); + ~DialogLayoutProgress() override; signals: void Abort(); @@ -58,16 +58,17 @@ public slots: void Efficiency(qreal value); protected: - virtual void showEvent(QShowEvent *event) override; + void showEvent(QShowEvent *event) override; private: - Q_DISABLE_COPY(DialogLayoutProgress) + // cppcheck-suppress unknownMacro + Q_DISABLE_COPY_MOVE(DialogLayoutProgress) // NOLINT Ui::DialogLayoutProgress *ui; QMovie *m_movie; QElapsedTimer m_timer; qint64 m_timeout; - bool isInitialized{false}; - QTimer *progressTimer; + bool m_isInitialized{false}; + QTimer *m_progressTimer; }; #endif // DIALOGLAYOUTPROGRESS_H diff --git a/src/app/valentina/dialogs/dialoglayoutsettings.cpp b/src/app/valentina/dialogs/dialoglayoutsettings.cpp index 5431368b7..77b894a87 100644 --- a/src/app/valentina/dialogs/dialoglayoutsettings.cpp +++ b/src/app/valentina/dialogs/dialoglayoutsettings.cpp @@ -28,10 +28,8 @@ #include "dialoglayoutsettings.h" #include "ui_dialoglayoutsettings.h" -#include "../core/vapplication.h" -#include "../ifc/xml/vdomdocument.h" #include "../vmisc/vvalentinasettings.h" -#include "../vmisc/vmath.h" +#include "../vmisc/vabstractvalapplication.h" #include "../vlayout/vlayoutgenerator.h" #include @@ -41,12 +39,12 @@ //--------------------------------------------------------------------------------------------------------------------- DialogLayoutSettings::DialogLayoutSettings(VLayoutGenerator *generator, QWidget *parent, bool disableSettings) : VAbstractLayoutDialog(parent), - disableSettings(disableSettings), + m_disableSettings(disableSettings), ui(new Ui::DialogLayoutSettings), - oldPaperUnit(Unit::Mm), - oldLayoutUnit(Unit::Mm), - generator(generator), - isInitialized(false) + m_oldPaperUnit(Unit::Mm), + m_oldLayoutUnit(Unit::Mm), + m_generator(generator), + m_isInitialized(false) { ui->setupUi(this); @@ -63,7 +61,7 @@ DialogLayoutSettings::DialogLayoutSettings(VLayoutGenerator *generator, QWidget InitPrinter(); //in export console mode going to use defaults - if (disableSettings == false) + if (not disableSettings) { ReadSettings(); } @@ -116,9 +114,9 @@ DialogLayoutSettings::~DialogLayoutSettings() } //--------------------------------------------------------------------------------------------------------------------- -qreal DialogLayoutSettings::GetPaperHeight() const +auto DialogLayoutSettings::GetPaperHeight() const -> qreal { - return UnitConvertor(ui->doubleSpinBoxPaperHeight->value(), oldPaperUnit, Unit::Px); + return UnitConvertor(ui->doubleSpinBoxPaperHeight->value(), m_oldPaperUnit, Unit::Px); } //--------------------------------------------------------------------------------------------------------------------- @@ -129,9 +127,9 @@ void DialogLayoutSettings::SetPaperHeight(qreal value) } //--------------------------------------------------------------------------------------------------------------------- -qreal DialogLayoutSettings::GetPaperWidth() const +auto DialogLayoutSettings::GetPaperWidth() const -> qreal { - return UnitConvertor(ui->doubleSpinBoxPaperWidth->value(), oldPaperUnit, Unit::Px); + return UnitConvertor(ui->doubleSpinBoxPaperWidth->value(), m_oldPaperUnit, Unit::Px); } //--------------------------------------------------------------------------------------------------------------------- @@ -142,7 +140,7 @@ void DialogLayoutSettings::SetPaperWidth(qreal value) } //--------------------------------------------------------------------------------------------------------------------- -int DialogLayoutSettings::GetNestingTime() const +auto DialogLayoutSettings::GetNestingTime() const -> int { return ui->spinBoxNestingTime->value(); } @@ -154,7 +152,7 @@ void DialogLayoutSettings::SetNestingTime(int value) } //--------------------------------------------------------------------------------------------------------------------- -qreal DialogLayoutSettings::GetEfficiencyCoefficient() const +auto DialogLayoutSettings::GetEfficiencyCoefficient() const -> qreal { return ui->doubleSpinBoxEfficiency->value(); } @@ -166,9 +164,9 @@ void DialogLayoutSettings::SetEfficiencyCoefficient(qreal ration) } //--------------------------------------------------------------------------------------------------------------------- -qreal DialogLayoutSettings::GetLayoutWidth() const +auto DialogLayoutSettings::GetLayoutWidth() const -> qreal { - return UnitConvertor(ui->doubleSpinBoxLayoutWidth->value(), oldLayoutUnit, Unit::Px); + return UnitConvertor(ui->doubleSpinBoxLayoutWidth->value(), m_oldLayoutUnit, Unit::Px); } //--------------------------------------------------------------------------------------------------------------------- @@ -178,13 +176,13 @@ void DialogLayoutSettings::SetLayoutWidth(qreal value) } //--------------------------------------------------------------------------------------------------------------------- -QMarginsF DialogLayoutSettings::GetFields() const +auto DialogLayoutSettings::GetFields() const -> QMarginsF { QMarginsF fields; - fields.setLeft(UnitConvertor(ui->doubleSpinBoxLeftField->value(), oldLayoutUnit, Unit::Px)); - fields.setRight(UnitConvertor(ui->doubleSpinBoxRightField->value(), oldLayoutUnit, Unit::Px)); - fields.setTop(UnitConvertor(ui->doubleSpinBoxTopField->value(), oldLayoutUnit, Unit::Px)); - fields.setBottom(UnitConvertor(ui->doubleSpinBoxBottomField->value(), oldLayoutUnit, Unit::Px)); + fields.setLeft(UnitConvertor(ui->doubleSpinBoxLeftField->value(), m_oldLayoutUnit, Unit::Px)); + fields.setRight(UnitConvertor(ui->doubleSpinBoxRightField->value(), m_oldLayoutUnit, Unit::Px)); + fields.setTop(UnitConvertor(ui->doubleSpinBoxTopField->value(), m_oldLayoutUnit, Unit::Px)); + fields.setBottom(UnitConvertor(ui->doubleSpinBoxBottomField->value(), m_oldLayoutUnit, Unit::Px)); return fields; } @@ -198,20 +196,19 @@ void DialogLayoutSettings::SetFields(const QMarginsF &value) } //--------------------------------------------------------------------------------------------------------------------- -Cases DialogLayoutSettings::GetGroup() const +auto DialogLayoutSettings::GetGroup() const -> Cases { if (ui->radioButtonThreeGroups->isChecked()) { return Cases::CaseThreeGroup; } - else if (ui->radioButtonTwoGroups->isChecked()) + + if (ui->radioButtonTwoGroups->isChecked()) { return Cases::CaseTwoGroup; } - else - { - return Cases::CaseDesc; - } + + return Cases::CaseDesc; } //--------------------------------------------------------------------------------------------------------------------- @@ -234,7 +231,7 @@ void DialogLayoutSettings::SetGroup(const Cases &value) } //--------------------------------------------------------------------------------------------------------------------- -bool DialogLayoutSettings::GetFollowGrainline() const +auto DialogLayoutSettings::GetFollowGrainline() const -> bool { return ui->checkBoxFollowGrainline->isChecked(); } @@ -246,7 +243,7 @@ void DialogLayoutSettings::SetFollowGrainline(bool state) } //--------------------------------------------------------------------------------------------------------------------- -bool DialogLayoutSettings::GetManualPriority() const +auto DialogLayoutSettings::GetManualPriority() const -> bool { return ui->checkBoxManualPriority->isChecked(); } @@ -258,7 +255,7 @@ void DialogLayoutSettings::SetManualPriority(bool state) } //--------------------------------------------------------------------------------------------------------------------- -bool DialogLayoutSettings::GetAutoCropLength() const +auto DialogLayoutSettings::GetAutoCropLength() const -> bool { return ui->checkBoxAutoCropLength->isChecked(); } @@ -270,7 +267,7 @@ void DialogLayoutSettings::SetAutoCropLength(bool autoCropLength) } //--------------------------------------------------------------------------------------------------------------------- -bool DialogLayoutSettings::GetAutoCropWidth() const +auto DialogLayoutSettings::GetAutoCropWidth() const -> bool { return ui->checkBoxAutoCropWidth->isChecked(); } @@ -282,7 +279,7 @@ void DialogLayoutSettings::SetAutoCropWidth(bool autoCropWidth) } //--------------------------------------------------------------------------------------------------------------------- -bool DialogLayoutSettings::IsSaveLength() const +auto DialogLayoutSettings::IsSaveLength() const -> bool { return ui->checkBoxSaveLength->isChecked(); } @@ -294,7 +291,7 @@ void DialogLayoutSettings::SetSaveLength(bool save) } //--------------------------------------------------------------------------------------------------------------------- -bool DialogLayoutSettings::IsPreferOneSheetSolution() const +auto DialogLayoutSettings::IsPreferOneSheetSolution() const -> bool { return ui->checkBoxOneSheetSolution->isChecked(); } @@ -306,7 +303,7 @@ void DialogLayoutSettings::SetPreferOneSheetSolution(bool prefer) } //--------------------------------------------------------------------------------------------------------------------- -bool DialogLayoutSettings::IsUnitePages() const +auto DialogLayoutSettings::IsUnitePages() const -> bool { return ui->checkBoxUnitePages->isChecked(); } @@ -318,7 +315,7 @@ void DialogLayoutSettings::SetUnitePages(bool save) } //--------------------------------------------------------------------------------------------------------------------- -bool DialogLayoutSettings::IsStripOptimization() const +auto DialogLayoutSettings::IsStripOptimization() const -> bool { return ui->groupBoxStrips->isChecked(); } @@ -330,7 +327,7 @@ void DialogLayoutSettings::SetStripOptimization(bool save) } //--------------------------------------------------------------------------------------------------------------------- -quint8 DialogLayoutSettings::GetMultiplier() const +auto DialogLayoutSettings::GetMultiplier() const -> quint8 { return static_cast(ui->spinBoxMultiplier->value()); } @@ -342,7 +339,7 @@ void DialogLayoutSettings::SetMultiplier(const quint8 &value) } //--------------------------------------------------------------------------------------------------------------------- -bool DialogLayoutSettings::IsIgnoreAllFields() const +auto DialogLayoutSettings::IsIgnoreAllFields() const -> bool { return ui->checkBoxIgnoreFileds->isChecked(); } @@ -354,7 +351,7 @@ void DialogLayoutSettings::SetIgnoreAllFields(bool value) } //--------------------------------------------------------------------------------------------------------------------- -bool DialogLayoutSettings::IsTextAsPaths() const +auto DialogLayoutSettings::IsTextAsPaths() const -> bool { return ui->checkBoxTextAsPaths->isChecked(); } @@ -366,7 +363,7 @@ void DialogLayoutSettings::SetTextAsPaths(bool value) } //--------------------------------------------------------------------------------------------------------------------- -bool DialogLayoutSettings::IsNestQuantity() const +auto DialogLayoutSettings::IsNestQuantity() const -> bool { return ui->checkBoxNestQuantity->isChecked(); } @@ -378,7 +375,7 @@ void DialogLayoutSettings::SetNestQuantity(bool state) } //--------------------------------------------------------------------------------------------------------------------- -QString DialogLayoutSettings::SelectedPrinter() const +auto DialogLayoutSettings::SelectedPrinter() const -> QString { return ui->comboBoxPrinter->currentText(); } @@ -451,15 +448,15 @@ void DialogLayoutSettings::ConvertPaperSize() ui->doubleSpinBoxPaperWidth->blockSignals(false); ui->doubleSpinBoxPaperHeight->blockSignals(false); - const qreal newWidth = UnitConvertor(width, oldPaperUnit, paperUnit); - const qreal newHeight = UnitConvertor(height, oldPaperUnit, paperUnit); + const qreal newWidth = UnitConvertor(width, m_oldPaperUnit, paperUnit); + const qreal newHeight = UnitConvertor(height, m_oldPaperUnit, paperUnit); - const qreal newLeft = UnitConvertor(left, oldPaperUnit, paperUnit); - const qreal newRight = UnitConvertor(right, oldPaperUnit, paperUnit); - const qreal newTop = UnitConvertor(top, oldPaperUnit, paperUnit); - const qreal newBottom = UnitConvertor(bottom, oldPaperUnit, paperUnit); + const qreal newLeft = UnitConvertor(left, m_oldPaperUnit, paperUnit); + const qreal newRight = UnitConvertor(right, m_oldPaperUnit, paperUnit); + const qreal newTop = UnitConvertor(top, m_oldPaperUnit, paperUnit); + const qreal newBottom = UnitConvertor(bottom, m_oldPaperUnit, paperUnit); - oldPaperUnit = paperUnit; + m_oldPaperUnit = paperUnit; CorrectPaperDecimals(); MinimumPaperSize(); @@ -473,7 +470,7 @@ void DialogLayoutSettings::ConvertPaperSize() } //--------------------------------------------------------------------------------------------------------------------- -bool DialogLayoutSettings::SelectPaperUnit(const QString& units) +auto DialogLayoutSettings::SelectPaperUnit(const QString& units) -> bool { qint32 indexUnit = ui->comboBoxPaperSizeUnit->findData(units); if (indexUnit != -1) @@ -484,7 +481,7 @@ bool DialogLayoutSettings::SelectPaperUnit(const QString& units) } //--------------------------------------------------------------------------------------------------------------------- -bool DialogLayoutSettings::SelectLayoutUnit(const QString &units) +auto DialogLayoutSettings::SelectLayoutUnit(const QString &units) -> bool { qint32 indexUnit = ui->comboBoxLayoutUnit->findData(units); if (indexUnit != -1) @@ -495,19 +492,19 @@ bool DialogLayoutSettings::SelectLayoutUnit(const QString &units) } //--------------------------------------------------------------------------------------------------------------------- -qreal DialogLayoutSettings::LayoutToPixels(qreal value) const +auto DialogLayoutSettings::LayoutToPixels(qreal value) const -> qreal { return UnitConvertor(value, LayoutUnit(), Unit::Px); } //--------------------------------------------------------------------------------------------------------------------- -qreal DialogLayoutSettings::PageToPixels(qreal value) const +auto DialogLayoutSettings::PageToPixels(qreal value) const -> qreal { return UnitConvertor(value, PaperUnit(), Unit::Px); } //--------------------------------------------------------------------------------------------------------------------- -QString DialogLayoutSettings::MakeGroupsHelp() +auto DialogLayoutSettings::MakeGroupsHelp() -> QString { //that is REALLY dummy ... can't figure fast how to automate generation... :/ return tr("\n\tThree groups: big, middle, small = 0;\n\tTwo groups: big, small = 1;\n\tDescending area = 2"); @@ -522,7 +519,7 @@ void DialogLayoutSettings::showEvent(QShowEvent *event) return; } - if (isInitialized) + if (m_isInitialized) { return; } @@ -534,7 +531,7 @@ void DialogLayoutSettings::showEvent(QShowEvent *event) resize(sz); } - isInitialized = true;//first show windows are held + m_isInitialized = true;//first show windows are held } //--------------------------------------------------------------------------------------------------------------------- @@ -543,7 +540,7 @@ void DialogLayoutSettings::resizeEvent(QResizeEvent *event) // remember the size for the next time this dialog is opened, but only // if widget was already initialized, which rules out the resize at // dialog creating, which would - if (isInitialized) + if (m_isInitialized) { VAbstractApplication::VApp()->Settings()->SetLayoutSettingsDialogSize(size()); } @@ -558,9 +555,9 @@ void DialogLayoutSettings::ConvertLayoutSize() ui->doubleSpinBoxLayoutWidth->setMaximum(FromPixel(QIMAGE_MAX, unit)); - const qreal newLayoutWidth = UnitConvertor(layoutWidth, oldLayoutUnit, unit); + const qreal newLayoutWidth = UnitConvertor(layoutWidth, m_oldLayoutUnit, unit); - oldLayoutUnit = unit; + m_oldLayoutUnit = unit; CorrectLayoutDecimals(); MinimumLayoutSize(); @@ -585,7 +582,7 @@ void DialogLayoutSettings::PaperSizeChanged() } //--------------------------------------------------------------------------------------------------------------------- -bool DialogLayoutSettings::SelectTemplate(const PaperSizeTemplate& id) +auto DialogLayoutSettings::SelectTemplate(const PaperSizeTemplate& id) -> bool { int index = ui->comboBoxTemplates->findData(static_cast(id)); if (index > -1) @@ -617,35 +614,35 @@ void DialogLayoutSettings::Swap(bool checked) //--------------------------------------------------------------------------------------------------------------------- void DialogLayoutSettings::DialogAccepted() { - SCASSERT(generator != nullptr) - generator->SetLayoutWidth(GetLayoutWidth()); - generator->SetCaseType(GetGroup()); - generator->SetPaperHeight(GetPaperHeight()); - generator->SetPaperWidth(GetPaperWidth()); - generator->SetNestingTime(GetNestingTime()); - generator->SetEfficiencyCoefficient(GetEfficiencyCoefficient()); - generator->SetFollowGrainline(GetFollowGrainline()); - generator->SetManualPriority(GetManualPriority()); - generator->SetAutoCropLength(GetAutoCropLength()); - generator->SetAutoCropWidth(GetAutoCropWidth()); - generator->SetSaveLength(IsSaveLength()); - generator->SetPreferOneSheetSolution(IsPreferOneSheetSolution()); - generator->SetUnitePages(IsUnitePages()); - generator->SetStripOptimization(IsStripOptimization()); - generator->SetMultiplier(GetMultiplier()); - generator->SetTextAsPaths(IsTextAsPaths()); - generator->SetNestQuantity(IsNestQuantity()); + SCASSERT(m_generator != nullptr) + m_generator->SetLayoutWidth(GetLayoutWidth()); + m_generator->SetCaseType(GetGroup()); + m_generator->SetPaperHeight(GetPaperHeight()); + m_generator->SetPaperWidth(GetPaperWidth()); + m_generator->SetNestingTime(GetNestingTime()); + m_generator->SetEfficiencyCoefficient(GetEfficiencyCoefficient()); + m_generator->SetFollowGrainline(GetFollowGrainline()); + m_generator->SetManualPriority(GetManualPriority()); + m_generator->SetAutoCropLength(GetAutoCropLength()); + m_generator->SetAutoCropWidth(GetAutoCropWidth()); + m_generator->SetSaveLength(IsSaveLength()); + m_generator->SetPreferOneSheetSolution(IsPreferOneSheetSolution()); + m_generator->SetUnitePages(IsUnitePages()); + m_generator->SetStripOptimization(IsStripOptimization()); + m_generator->SetMultiplier(GetMultiplier()); + m_generator->SetTextAsPaths(IsTextAsPaths()); + m_generator->SetNestQuantity(IsNestQuantity()); if (IsIgnoreAllFields()) { - generator->SetPrinterFields(false, QMarginsF()); + m_generator->SetPrinterFields(false, QMarginsF()); } else { QPrinterInfo printer = QPrinterInfo::printerInfo(ui->comboBoxPrinter->currentText()); if (printer.isNull()) { - generator->SetPrinterFields(true, GetFields()); + m_generator->SetPrinterFields(true, GetFields()); } else { @@ -660,43 +657,23 @@ void DialogLayoutSettings::DialogAccepted() QMessageBox::Yes|QMessageBox::No, QMessageBox::No); if (answer == QMessageBox::No) { - if (fields.left() < minFields.left()) - { - ui->doubleSpinBoxLeftField->setValue(UnitConvertor(minFields.left(), Unit::Px, LayoutUnit())); - } - - if (fields.right() < minFields.right()) - { - ui->doubleSpinBoxRightField->setValue(UnitConvertor(minFields.right(), Unit::Px, LayoutUnit())); - } - - if (fields.top() < minFields.top()) - { - ui->doubleSpinBoxTopField->setValue(UnitConvertor(minFields.top(), Unit::Px, LayoutUnit())); - } - - if (fields.bottom() < minFields.bottom()) - { - ui->doubleSpinBoxBottomField->setValue(UnitConvertor(minFields.bottom(), Unit::Px, - LayoutUnit())); - } - - generator->SetPrinterFields(true, GetFields()); + SetMinMargins(fields, minFields); + m_generator->SetPrinterFields(true, GetFields()); } else { - generator->SetPrinterFields(false, GetFields()); + m_generator->SetPrinterFields(false, GetFields()); } } else { - generator->SetPrinterFields(true, GetFields()); + m_generator->SetPrinterFields(true, GetFields()); } } } //don't want to break visual settings when cmd used - if (disableSettings == false) + if (not m_disableSettings) { WriteSettings(); } @@ -781,7 +758,7 @@ void DialogLayoutSettings::InitPaperUnits() ui->comboBoxPaperSizeUnit->addItem(tr("Pixels"), QVariant(UnitsToStr(Unit::Px))); // set default unit - oldPaperUnit = StrToUnits(VAbstractValApplication::VApp()->ValentinaSettings()->GetUnit()); + m_oldPaperUnit = StrToUnits(VAbstractValApplication::VApp()->ValentinaSettings()->GetUnit()); const qint32 indexUnit = ui->comboBoxPaperSizeUnit->findData( VAbstractValApplication::VApp()->ValentinaSettings()->GetUnit()); if (indexUnit != -1) @@ -798,7 +775,7 @@ void DialogLayoutSettings::InitLayoutUnits() ui->comboBoxLayoutUnit->addItem(tr("Inches"), QVariant(UnitsToStr(Unit::Inch))); // set default unit - oldLayoutUnit = StrToUnits(VAbstractValApplication::VApp()->ValentinaSettings()->GetUnit()); + m_oldLayoutUnit = StrToUnits(VAbstractValApplication::VApp()->ValentinaSettings()->GetUnit()); const qint32 indexUnit = ui->comboBoxLayoutUnit->findData( VAbstractValApplication::VApp()->ValentinaSettings()->GetUnit()); if (indexUnit != -1) @@ -829,9 +806,9 @@ void DialogLayoutSettings::InitPrinter() } //--------------------------------------------------------------------------------------------------------------------- -QString DialogLayoutSettings::MakeHelpTemplateList() +auto DialogLayoutSettings::MakeHelpTemplateList() -> QString { - QString out = "\n"; + QString out = QChar('\n'); auto cntr = static_cast(PaperSizeTemplate::A0); for (int i = 0; i < VAbstractLayoutDialog::pageFormatNames.size(); ++i) @@ -842,11 +819,11 @@ QString DialogLayoutSettings::MakeHelpTemplateList() if (i < VAbstractLayoutDialog::pageFormatNames.size() - 2) { - out += ",\n"; + out += QLatin1String(",\n"); } else { - out += ".\n"; + out += QLatin1String(".\n"); } } } @@ -854,9 +831,9 @@ QString DialogLayoutSettings::MakeHelpTemplateList() } //--------------------------------------------------------------------------------------------------------------------- -QString DialogLayoutSettings::MakeHelpTiledPdfTemplateList() +auto DialogLayoutSettings::MakeHelpTiledPdfTemplateList() -> QString { - QString out = "\n"; + QString out = QChar('\n'); for (int i = 0; i <= static_cast(PaperSizeTemplate::Tabloid); ++i) { @@ -864,18 +841,18 @@ QString DialogLayoutSettings::MakeHelpTiledPdfTemplateList() if (i < static_cast(PaperSizeTemplate::Tabloid)) { - out += ",\n"; + out += QLatin1String(",\n"); } else { - out += ".\n"; + out += QLatin1String(".\n"); } } return out; } //--------------------------------------------------------------------------------------------------------------------- -QSizeF DialogLayoutSettings::Template() +auto DialogLayoutSettings::Template() -> QSizeF { const PaperSizeTemplate temp = static_cast(ui->comboBoxTemplates->currentData().toInt()); @@ -908,11 +885,11 @@ QSizeF DialogLayoutSettings::Template() default: break; } - return QSizeF(); + return {}; } //--------------------------------------------------------------------------------------------------------------------- -QSizeF DialogLayoutSettings::GetTemplateSize(const PaperSizeTemplate &tmpl, const Unit &unit) const +auto DialogLayoutSettings::GetTemplateSize(const PaperSizeTemplate &tmpl, const Unit &unit) const -> QSizeF { qreal width = 0; qreal height = 0; @@ -929,42 +906,37 @@ QSizeF DialogLayoutSettings::GetTemplateSize(const PaperSizeTemplate &tmpl, cons } //--------------------------------------------------------------------------------------------------------------------- -QMarginsF DialogLayoutSettings::MinPrinterFields() const +auto DialogLayoutSettings::MinPrinterFields() const -> QMarginsF { QPrinterInfo printer = QPrinterInfo::printerInfo(ui->comboBoxPrinter->currentText()); if (not printer.isNull()) { - QSharedPointer pr = QSharedPointer(new QPrinter(printer)); - return GetMinPrinterFields(pr); - } - else - { - return QMarginsF(); + return GetMinPrinterFields(QSharedPointer(new QPrinter(printer))); } + + return {}; } //--------------------------------------------------------------------------------------------------------------------- -QMarginsF DialogLayoutSettings::GetDefPrinterFields() const +auto DialogLayoutSettings::GetDefPrinterFields() const -> QMarginsF { QPrinterInfo printer = QPrinterInfo::printerInfo(ui->comboBoxPrinter->currentText()); if (not printer.isNull()) { return GetPrinterFields(QSharedPointer(new QPrinter(printer))); } - else - { - return QMarginsF(); - } + + return {}; } //--------------------------------------------------------------------------------------------------------------------- -Unit DialogLayoutSettings::PaperUnit() const +auto DialogLayoutSettings::PaperUnit() const -> Unit { return StrToUnits(ui->comboBoxPaperSizeUnit->currentData().toString()); } //--------------------------------------------------------------------------------------------------------------------- -Unit DialogLayoutSettings::LayoutUnit() const +auto DialogLayoutSettings::LayoutUnit() const -> Unit { return StrToUnits(ui->comboBoxLayoutUnit->currentData().toString()); } @@ -972,7 +944,7 @@ Unit DialogLayoutSettings::LayoutUnit() const //--------------------------------------------------------------------------------------------------------------------- void DialogLayoutSettings::CorrectPaperDecimals() { - switch (oldPaperUnit) + switch (m_oldPaperUnit) { case Unit::Cm: case Unit::Mm: @@ -1002,7 +974,7 @@ void DialogLayoutSettings::CorrectPaperDecimals() //--------------------------------------------------------------------------------------------------------------------- void DialogLayoutSettings::CorrectLayoutDecimals() { - switch (oldLayoutUnit) + switch (m_oldLayoutUnit) { case Unit::Cm: case Unit::Mm: @@ -1020,7 +992,7 @@ void DialogLayoutSettings::CorrectLayoutDecimals() //--------------------------------------------------------------------------------------------------------------------- void DialogLayoutSettings::MinimumPaperSize() { - const qreal value = UnitConvertor(1, Unit::Px, oldPaperUnit); + const qreal value = UnitConvertor(1, Unit::Px, m_oldPaperUnit); ui->doubleSpinBoxPaperWidth->setMinimum(value); ui->doubleSpinBoxPaperHeight->setMinimum(value); } @@ -1028,7 +1000,7 @@ void DialogLayoutSettings::MinimumPaperSize() //--------------------------------------------------------------------------------------------------------------------- void DialogLayoutSettings::MinimumLayoutSize() { - const qreal value = UnitConvertor(1, Unit::Px, oldLayoutUnit); + const qreal value = UnitConvertor(1, Unit::Px, m_oldLayoutUnit); ui->doubleSpinBoxLayoutWidth->setMinimum(value); } @@ -1092,9 +1064,9 @@ void DialogLayoutSettings::WriteSettings() const //--------------------------------------------------------------------------------------------------------------------- void DialogLayoutSettings::SheetSize(const QSizeF &size) { - oldPaperUnit = PaperUnit(); - ui->doubleSpinBoxPaperWidth->setMaximum(FromPixel(QIMAGE_MAX, oldPaperUnit)); - ui->doubleSpinBoxPaperHeight->setMaximum(FromPixel(QIMAGE_MAX, oldPaperUnit)); + m_oldPaperUnit = PaperUnit(); + ui->doubleSpinBoxPaperWidth->setMaximum(FromPixel(QIMAGE_MAX, m_oldPaperUnit)); + ui->doubleSpinBoxPaperHeight->setMaximum(FromPixel(QIMAGE_MAX, m_oldPaperUnit)); ui->doubleSpinBoxPaperWidth->setValue(size.width()); ui->doubleSpinBoxPaperHeight->setValue(size.height()); @@ -1112,3 +1084,28 @@ void DialogLayoutSettings::SetAdditionalOptions(bool value) SetUnitePages(value); SetStripOptimization(value); } + +//--------------------------------------------------------------------------------------------------------------------- +void DialogLayoutSettings::SetMinMargins(const QMarginsF &fields, const QMarginsF &minFields) +{ + if (fields.left() < minFields.left()) + { + ui->doubleSpinBoxLeftField->setValue(UnitConvertor(minFields.left(), Unit::Px, LayoutUnit())); + } + + if (fields.right() < minFields.right()) + { + ui->doubleSpinBoxRightField->setValue(UnitConvertor(minFields.right(), Unit::Px, LayoutUnit())); + } + + if (fields.top() < minFields.top()) + { + ui->doubleSpinBoxTopField->setValue(UnitConvertor(minFields.top(), Unit::Px, LayoutUnit())); + } + + if (fields.bottom() < minFields.bottom()) + { + ui->doubleSpinBoxBottomField->setValue(UnitConvertor(minFields.bottom(), Unit::Px, + LayoutUnit())); + } +} diff --git a/src/app/valentina/dialogs/dialoglayoutsettings.h b/src/app/valentina/dialogs/dialoglayoutsettings.h index ede8a90fd..7bdd6f243 100644 --- a/src/app/valentina/dialogs/dialoglayoutsettings.h +++ b/src/app/valentina/dialogs/dialoglayoutsettings.h @@ -33,7 +33,7 @@ #include #include "../vlayout/dialogs/vabstractlayoutdialog.h" -#include "../vlayout/vbank.h" +#include "../vlayout/vlayoutdef.h" namespace Ui { @@ -44,85 +44,85 @@ class VLayoutGenerator; class DialogLayoutSettings : public VAbstractLayoutDialog { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit DialogLayoutSettings(VLayoutGenerator *generator, QWidget *parent = nullptr, bool disableSettings = false); - virtual ~DialogLayoutSettings(); + ~DialogLayoutSettings() override; - qreal GetPaperHeight() const; + auto GetPaperHeight() const -> qreal; void SetPaperHeight(qreal value); - qreal GetPaperWidth() const; + auto GetPaperWidth() const -> qreal; void SetPaperWidth(qreal value); - int GetNestingTime() const; + auto GetNestingTime() const -> int; void SetNestingTime(int value); - qreal GetEfficiencyCoefficient() const; - void SetEfficiencyCoefficient(qreal ration); + auto GetEfficiencyCoefficient() const -> qreal; + void SetEfficiencyCoefficient(qreal ration); - qreal GetLayoutWidth() const; + auto GetLayoutWidth() const -> qreal; void SetLayoutWidth(qreal value); - QMarginsF GetFields() const; + auto GetFields() const -> QMarginsF; void SetFields(const QMarginsF &value); - Cases GetGroup() const; + auto GetGroup() const -> Cases; void SetGroup(const Cases &value); - bool GetFollowGrainline() const; + auto GetFollowGrainline() const -> bool; void SetFollowGrainline(bool state); - bool GetManualPriority() const; + auto GetManualPriority() const -> bool; void SetManualPriority(bool state); - bool GetAutoCropLength() const; + auto GetAutoCropLength() const -> bool; void SetAutoCropLength(bool autoCropLength); - bool GetAutoCropWidth() const; + auto GetAutoCropWidth() const -> bool; void SetAutoCropWidth(bool autoCropWidth); - bool IsSaveLength() const; + auto IsSaveLength() const -> bool; void SetSaveLength(bool save); - bool IsPreferOneSheetSolution() const; + auto IsPreferOneSheetSolution() const -> bool; void SetPreferOneSheetSolution(bool prefer); - bool IsUnitePages() const; + auto IsUnitePages() const -> bool; void SetUnitePages(bool save); - bool IsStripOptimization() const; + auto IsStripOptimization() const -> bool; void SetStripOptimization(bool save); - quint8 GetMultiplier() const; - void SetMultiplier(const quint8 &value); + auto GetMultiplier() const -> quint8; + void SetMultiplier(const quint8 &value); - bool IsIgnoreAllFields() const; + auto IsIgnoreAllFields() const -> bool; void SetIgnoreAllFields(bool value); - bool IsTextAsPaths() const; + auto IsTextAsPaths() const -> bool; void SetTextAsPaths(bool value); - bool IsNestQuantity() const; + auto IsNestQuantity() const -> bool; void SetNestQuantity(bool state); - QString SelectedPrinter() const; + auto SelectedPrinter() const -> QString; void EnableLandscapeOrientation(); //support functions for the command line parser which uses invisible dialog to properly build layout generator - bool SelectTemplate(const PaperSizeTemplate& id); - static QString MakeHelpTemplateList(); - static QString MakeHelpTiledPdfTemplateList(); - bool SelectPaperUnit(const QString& units); - bool SelectLayoutUnit(const QString& units); - qreal LayoutToPixels(qreal value) const; - qreal PageToPixels(qreal value) const; - static QString MakeGroupsHelp(); + auto SelectTemplate(const PaperSizeTemplate& id) -> bool; + static auto MakeHelpTemplateList() -> QString; + static auto MakeHelpTiledPdfTemplateList() -> QString; + auto SelectPaperUnit(const QString& units) -> bool; + auto SelectLayoutUnit(const QString& units) -> bool; + auto LayoutToPixels(qreal value) const -> qreal; + auto PageToPixels(qreal value) const -> qreal; + static auto MakeGroupsHelp() -> QString; protected: void showEvent(QShowEvent *event) override; void resizeEvent(QResizeEvent *event) override; - QSizeF GetTemplateSize(const PaperSizeTemplate &tmpl, const Unit &unit) const; + auto GetTemplateSize(const PaperSizeTemplate &tmpl, const Unit &unit) const -> QSizeF; public slots: void DialogAccepted(); @@ -139,26 +139,27 @@ private slots: void CorrectMaxFileds(); void IgnoreAllFields(int state); private: - Q_DISABLE_COPY(DialogLayoutSettings) + // cppcheck-suppress unknownMacro + Q_DISABLE_COPY_MOVE(DialogLayoutSettings) // NOLINT - bool disableSettings; + bool m_disableSettings; Ui::DialogLayoutSettings *ui; - Unit oldPaperUnit; - Unit oldLayoutUnit; - VLayoutGenerator *generator; - bool isInitialized; + Unit m_oldPaperUnit; + Unit m_oldLayoutUnit; + VLayoutGenerator *m_generator; + bool m_isInitialized; void InitPaperUnits(); void InitLayoutUnits(); void InitPrinter(); - QSizeF Template(); + auto Template() -> QSizeF; - QMarginsF MinPrinterFields() const; - QMarginsF GetDefPrinterFields() const; + auto MinPrinterFields() const -> QMarginsF; + auto GetDefPrinterFields() const -> QMarginsF; - Unit PaperUnit() const; - Unit LayoutUnit() const; + auto PaperUnit() const -> Unit; + auto LayoutUnit() const -> Unit; void CorrectPaperDecimals(); void CorrectLayoutDecimals(); @@ -171,6 +172,8 @@ private: void SheetSize(const QSizeF &size); void SetAdditionalOptions(bool value); + + void SetMinMargins(const QMarginsF &fields, const QMarginsF &minFields); }; #endif // DIALOGLAYOUTSETTINGS_H diff --git a/src/app/valentina/dialogs/dialognewpattern.cpp b/src/app/valentina/dialogs/dialognewpattern.cpp index 7a1f076b7..6368479bb 100644 --- a/src/app/valentina/dialogs/dialognewpattern.cpp +++ b/src/app/valentina/dialogs/dialognewpattern.cpp @@ -28,8 +28,8 @@ #include "dialognewpattern.h" #include "ui_dialognewpattern.h" -#include "../core/vapplication.h" #include "../vmisc/vvalentinasettings.h" +#include "../vmisc/vabstractvalapplication.h" #include "../vpatterndb/vcontainer.h" #include @@ -37,10 +37,11 @@ #include #include #include +#include //--------------------------------------------------------------------------------------------------------------------- DialogNewPattern::DialogNewPattern(VContainer *data, const QString &patternPieceName, QWidget *parent) - :QDialog(parent), ui(new Ui::DialogNewPattern), data(data), isInitialized(false) + :QDialog(parent), ui(new Ui::DialogNewPattern), m_data(data) { ui->setupUi(this); @@ -67,7 +68,7 @@ DialogNewPattern::~DialogNewPattern() } //--------------------------------------------------------------------------------------------------------------------- -Unit DialogNewPattern::PatternUnit() const +auto DialogNewPattern::PatternUnit() const -> Unit { const qint32 index = ui->comboBoxUnits->currentIndex(); return StrToUnits(ui->comboBoxUnits->itemData(index).toString()); @@ -77,7 +78,7 @@ Unit DialogNewPattern::PatternUnit() const void DialogNewPattern::CheckState() { bool flagName = false; - if (ui->lineEditName->text().isEmpty() == false) + if (not ui->lineEditName->text().isEmpty()) { flagName = true; } @@ -96,7 +97,7 @@ void DialogNewPattern::showEvent(QShowEvent *event) return; } - if (isInitialized) + if (m_isInitialized) { return; } @@ -105,7 +106,7 @@ void DialogNewPattern::showEvent(QShowEvent *event) setMaximumSize(size()); setMinimumSize(size()); - isInitialized = true;//first show windows are held + m_isInitialized = true;//first show windows are held } //--------------------------------------------------------------------------------------------------------------------- @@ -125,7 +126,7 @@ void DialogNewPattern::InitUnits() } //--------------------------------------------------------------------------------------------------------------------- -QString DialogNewPattern::name() const +auto DialogNewPattern::name() const -> QString { return ui->lineEditName->text(); } diff --git a/src/app/valentina/dialogs/dialognewpattern.h b/src/app/valentina/dialogs/dialognewpattern.h index 8de042391..34c67e737 100644 --- a/src/app/valentina/dialogs/dialognewpattern.h +++ b/src/app/valentina/dialogs/dialognewpattern.h @@ -42,21 +42,22 @@ namespace Ui class DialogNewPattern : public QDialog { - Q_OBJECT + Q_OBJECT // NOLINT public: DialogNewPattern(VContainer *data, const QString &patternPieceName, QWidget *parent = nullptr); - virtual ~DialogNewPattern(); - QString name() const; - Unit PatternUnit() const; + ~DialogNewPattern() override; + auto name() const -> QString; + auto PatternUnit() const -> Unit; protected: - virtual void showEvent(QShowEvent *event) override; + void showEvent(QShowEvent *event) override; private slots: void CheckState(); private: - Q_DISABLE_COPY(DialogNewPattern) + // cppcheck-suppress unknownMacro + Q_DISABLE_COPY_MOVE(DialogNewPattern) // NOLINT Ui::DialogNewPattern *ui; - VContainer *data; - bool isInitialized; + VContainer *m_data; + bool m_isInitialized{false}; void InitUnits(); }; diff --git a/src/app/valentina/dialogs/dialogpatternproperties.cpp b/src/app/valentina/dialogs/dialogpatternproperties.cpp index 3973c8f18..3beb4d0cb 100644 --- a/src/app/valentina/dialogs/dialogpatternproperties.cpp +++ b/src/app/valentina/dialogs/dialogpatternproperties.cpp @@ -45,8 +45,6 @@ #include "../xml/vpattern.h" #include "../vpatterndb/vcontainer.h" #include "../core/vapplication.h" -#include "../vtools/dialogs/support/dialogeditlabel.h" -#include "dialogknownmaterials.h" #include "../vmisc/vvalentinasettings.h" #include "../qmuparser/qmudef.h" #include "../ifc/xml/vpatternimage.h" @@ -56,8 +54,8 @@ DialogPatternProperties::DialogPatternProperties(VPattern *doc, VContainer *pattern, QWidget *parent) : QDialog(parent), ui(new Ui::DialogPatternProperties), - doc(doc), - pattern(pattern) + m_doc(doc), + m_pattern(pattern) { ui->setupUi(this); @@ -130,7 +128,7 @@ DialogPatternProperties::DialogPatternProperties(VPattern *doc, VContainer *pat ui->checkBoxPatternReadOnly->setChecked(readOnly); if (not readOnly) { - connect(ui->checkBoxPatternReadOnly, &QRadioButton::toggled, this, [this](){securityChanged = true;}); + connect(ui->checkBoxPatternReadOnly, &QRadioButton::toggled, this, [this](){m_securityChanged = true;}); } else { @@ -163,8 +161,8 @@ DialogPatternProperties::DialogPatternProperties(VPattern *doc, VContainer *pat ValidatePassmarkLength(); //Initialization change value. Set to default value after initialization - defaultChanged = false; - securityChanged = false; + m_defaultChanged = false; + m_securityChanged = false; } //--------------------------------------------------------------------------------------------------------------------- @@ -180,7 +178,7 @@ auto DialogPatternProperties::eventFilter(QObject *object, QEvent *event) -> boo { if (event->type() == QEvent::KeyPress) { - auto *keyEvent = static_cast(event); + auto *keyEvent = static_cast(event); // NOLINT(cppcoreguidelines-pro-type-static-cast-downcast) if ((keyEvent->key() == Qt::Key_Space) && ((keyEvent->modifiers() & Qt::ControlModifier) != 0U)) { m_completer->complete(); @@ -188,7 +186,7 @@ auto DialogPatternProperties::eventFilter(QObject *object, QEvent *event) -> boo } } - return false; + return false;// clazy:exclude=base-class-event } return QDialog::eventFilter(object, event); @@ -222,18 +220,18 @@ void DialogPatternProperties::Ok() //--------------------------------------------------------------------------------------------------------------------- void DialogPatternProperties::DescEdited() { - descriptionChanged = true; + m_descriptionChanged = true; } //--------------------------------------------------------------------------------------------------------------------- void DialogPatternProperties::SaveDescription() { - if (descriptionChanged) + if (m_descriptionChanged) { - doc->SetNotes(ui->plainTextEditTechNotes->document()->toPlainText()); - doc->SetDescription(ui->plainTextEditDescription->document()->toPlainText()); - doc->SetLabelPrefix(qvariant_cast(ui->comboBoxLabelLanguage->currentData())); - doc->SetPassmarkLengthVariable(ui->lineEditPassmarkLength->text()); + m_doc->SetNotes(ui->plainTextEditTechNotes->document()->toPlainText()); + m_doc->SetDescription(ui->plainTextEditDescription->document()->toPlainText()); + m_doc->SetLabelPrefix(qvariant_cast(ui->comboBoxLabelLanguage->currentData())); + m_doc->SetPassmarkLengthVariable(ui->lineEditPassmarkLength->text()); if (m_oldPassmarkLength != ui->lineEditPassmarkLength->text()) { @@ -241,19 +239,19 @@ void DialogPatternProperties::SaveDescription() m_oldPassmarkLength = ui->lineEditPassmarkLength->text(); } - descriptionChanged = false; - emit doc->patternChanged(false); + m_descriptionChanged = false; + emit m_doc->patternChanged(false); } } //--------------------------------------------------------------------------------------------------------------------- void DialogPatternProperties::SaveReadOnlyState() { - if (securityChanged) + if (m_securityChanged) { - doc->SetReadOnly(ui->checkBoxPatternReadOnly->isChecked()); - securityChanged = false; - emit doc->patternChanged(false); + m_doc->SetReadOnly(ui->checkBoxPatternReadOnly->isChecked()); + m_securityChanged = false; + emit m_doc->patternChanged(false); } } @@ -286,42 +284,42 @@ void DialogPatternProperties::InitImage() connect(ui->imageLabel, &QWidget::customContextMenuRequested, this, [this]() { QMenu menu(this); - menu.addAction(deleteAction); - menu.addAction(changeImageAction); - menu.addAction(saveImageAction); - menu.addAction(showImageAction); + menu.addAction(m_deleteAction); + menu.addAction(m_changeImageAction); + menu.addAction(m_saveImageAction); + menu.addAction(m_showImageAction); menu.exec(QCursor::pos()); menu.show(); }); - deleteAction = new QAction(tr("Delete image"), this); - changeImageAction = new QAction(tr("Change image"), this); - saveImageAction = new QAction(tr("Save image to file"), this); - showImageAction = new QAction(tr("Show image"), this); + m_deleteAction = new QAction(tr("Delete image"), this); + m_changeImageAction = new QAction(tr("Change image"), this); + m_saveImageAction = new QAction(tr("Save image to file"), this); + m_showImageAction = new QAction(tr("Show image"), this); - connect(deleteAction, &QAction::triggered, this, [this]() + connect(m_deleteAction, &QAction::triggered, this, [this]() { - doc->DeleteImage(); + m_doc->DeleteImage(); ui->imageLabel->setText(tr("Change image")); - deleteAction->setEnabled(false); - saveImageAction->setEnabled(false); - showImageAction->setEnabled(false); + m_deleteAction->setEnabled(false); + m_saveImageAction->setEnabled(false); + m_showImageAction->setEnabled(false); }); - connect(changeImageAction, &QAction::triggered, this, &DialogPatternProperties::ChangeImage); - connect(saveImageAction, &QAction::triggered, this, &DialogPatternProperties::SaveImage); - connect(showImageAction, &QAction::triggered, this, &DialogPatternProperties::ShowImage); + connect(m_changeImageAction, &QAction::triggered, this, &DialogPatternProperties::ChangeImage); + connect(m_saveImageAction, &QAction::triggered, this, &DialogPatternProperties::SaveImage); + connect(m_showImageAction, &QAction::triggered, this, &DialogPatternProperties::ShowImage); - const VPatternImage image = doc->GetImage(); + const VPatternImage image = m_doc->GetImage(); if (image.IsValid()) { ui->imageLabel->setPixmap(image.GetPixmap(ui->imageLabel->width(), ui->imageLabel->height())); } else { - deleteAction->setEnabled(false); - saveImageAction->setEnabled(false); - showImageAction->setEnabled(false); + m_deleteAction->setEnabled(false); + m_saveImageAction->setEnabled(false); + m_showImageAction->setEnabled(false); } } @@ -341,19 +339,19 @@ void DialogPatternProperties::ChangeImage() return; } - doc->SetImage(image); + m_doc->SetImage(image); ui->imageLabel->setPixmap(image.GetPixmap(ui->imageLabel->width(), ui->imageLabel->height())); - deleteAction->setEnabled(true); - saveImageAction->setEnabled(true); - showImageAction->setEnabled(true); + m_deleteAction->setEnabled(true); + m_saveImageAction->setEnabled(true); + m_showImageAction->setEnabled(true); } } //--------------------------------------------------------------------------------------------------------------------- void DialogPatternProperties::SaveImage() { - const VPatternImage image = doc->GetImage(); + const VPatternImage image = m_doc->GetImage(); if (not image.IsValid()) { @@ -390,7 +388,7 @@ void DialogPatternProperties::SaveImage() //--------------------------------------------------------------------------------------------------------------------- void DialogPatternProperties::ShowImage() { - const VPatternImage image = doc->GetImage(); + const VPatternImage image = m_doc->GetImage(); if (not image.IsValid()) { diff --git a/src/app/valentina/dialogs/dialogpatternproperties.h b/src/app/valentina/dialogs/dialogpatternproperties.h index aafc3f26b..eda47a5db 100644 --- a/src/app/valentina/dialogs/dialogpatternproperties.h +++ b/src/app/valentina/dialogs/dialogpatternproperties.h @@ -33,8 +33,7 @@ #include #include -#include "../vmisc/def.h" -#include "../ifc/ifcdef.h" +#include "../vmisc/defglobal.h" class VPattern; class VContainer; @@ -49,14 +48,14 @@ namespace Ui class DialogPatternProperties : public QDialog { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit DialogPatternProperties(VPattern *doc, VContainer *pattern, QWidget *parent = nullptr); - virtual ~DialogPatternProperties() override; + ~DialogPatternProperties() override; signals: void UpddatePieces(); protected: - virtual bool eventFilter(QObject *object, QEvent *event) override; + auto eventFilter(QObject *object, QEvent *event) -> bool override; private slots: void Apply(); void Ok(); @@ -65,27 +64,28 @@ private slots: void SaveImage(); void ShowImage(); private: - Q_DISABLE_COPY(DialogPatternProperties) + // cppcheck-suppress unknownMacro + Q_DISABLE_COPY_MOVE(DialogPatternProperties) // NOLINT Ui::DialogPatternProperties *ui; - VPattern *doc; - VContainer *pattern; - QMap data{}; - bool descriptionChanged{false}; - bool defaultChanged{false}; - bool securityChanged{false}; - QAction *deleteAction{nullptr}; - QAction *changeImageAction{nullptr}; - QAction *saveImageAction{nullptr}; - QAction *showImageAction{nullptr}; - QCompleter *m_completer{nullptr}; - QStringList m_variables{}; - QString m_oldPassmarkLength{}; + VPattern *m_doc; + VContainer *m_pattern; + QMap m_data{}; + bool m_descriptionChanged{false}; + bool m_defaultChanged{false}; + bool m_securityChanged{false}; + QAction *m_deleteAction{nullptr}; + QAction *m_changeImageAction{nullptr}; + QAction *m_saveImageAction{nullptr}; + QAction *m_showImageAction{nullptr}; + QCompleter *m_completer{nullptr}; + QStringList m_variables{}; + QString m_oldPassmarkLength{}; QPointer m_tmpImage{}; - void SaveDescription(); - void SaveReadOnlyState(); + void SaveDescription(); + void SaveReadOnlyState(); - void InitImage(); + void InitImage(); void ValidatePassmarkLength() const; }; diff --git a/src/app/valentina/dialogs/dialogpreferences.cpp b/src/app/valentina/dialogs/dialogpreferences.cpp index cbd2106d5..ad5640120 100644 --- a/src/app/valentina/dialogs/dialogpreferences.cpp +++ b/src/app/valentina/dialogs/dialogpreferences.cpp @@ -28,20 +28,20 @@ #include "dialogpreferences.h" #include "ui_dialogpreferences.h" -#include "../core/vapplication.h" #include "configpages/preferencesconfigurationpage.h" #include "configpages/preferencespatternpage.h" #include "configpages/preferencespathpage.h" #include "../vmisc/vvalentinasettings.h" +#include "../vmisc/vabstractvalapplication.h" #include #include +#include //--------------------------------------------------------------------------------------------------------------------- DialogPreferences::DialogPreferences(QWidget *parent) : QDialog(parent), ui(new Ui::DialogPreferences), - m_isInitialized(false), m_configurePage(new PreferencesConfigurationPage), m_patternPage(new PreferencesPatternPage), m_pathPage(new PreferencesPathPage) @@ -92,7 +92,7 @@ void DialogPreferences::showEvent(QShowEvent *event) // do your init stuff here QSize sz = VAbstractApplication::VApp()->Settings()->GetPreferenceDialogSize(); - if (sz.isEmpty() == false) + if (not sz.isEmpty()) { resize(sz); } diff --git a/src/app/valentina/dialogs/dialogpreferences.h b/src/app/valentina/dialogs/dialogpreferences.h index 74426624e..be8d546b6 100644 --- a/src/app/valentina/dialogs/dialogpreferences.h +++ b/src/app/valentina/dialogs/dialogpreferences.h @@ -31,6 +31,8 @@ #include +#include "../vmisc/defglobal.h" + namespace Ui { class DialogPreferences; @@ -44,23 +46,24 @@ class VPattern; class DialogPreferences : public QDialog { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit DialogPreferences(QWidget *parent = nullptr); - virtual ~DialogPreferences(); + ~DialogPreferences() override; signals: void UpdateProperties(); protected: - virtual void showEvent(QShowEvent *event) override; - virtual void resizeEvent(QResizeEvent *event) override; - virtual void changeEvent(QEvent* event) override; + void showEvent(QShowEvent *event) override; + void resizeEvent(QResizeEvent *event) override; + void changeEvent(QEvent* event) override; private slots: void PageChanged(QListWidgetItem *current, QListWidgetItem *previous); private: - Q_DISABLE_COPY(DialogPreferences) + // cppcheck-suppress unknownMacro + Q_DISABLE_COPY_MOVE(DialogPreferences) // NOLINT Ui::DialogPreferences *ui; - bool m_isInitialized; + bool m_isInitialized{false}; PreferencesConfigurationPage *m_configurePage; PreferencesPatternPage *m_patternPage; PreferencesPathPage *m_pathPage; diff --git a/src/app/valentina/dialogs/dialogsavelayout.cpp b/src/app/valentina/dialogs/dialogsavelayout.cpp index 980ebcf9f..feb67ebda 100644 --- a/src/app/valentina/dialogs/dialogsavelayout.cpp +++ b/src/app/valentina/dialogs/dialogsavelayout.cpp @@ -43,22 +43,20 @@ #include #ifndef Q_OS_WIN - Q_GLOBAL_STATIC_WITH_ARGS(const QString, baseFilenameRegExp, (QLatin1String("^[^\\/]+$"))) + Q_GLOBAL_STATIC_WITH_ARGS(const QString, baseFilenameRegExp, (QLatin1String("^[^\\/]+$"))) // NOLINT #else - Q_GLOBAL_STATIC_WITH_ARGS(const QString, baseFilenameRegExp, (QLatin1String("^[^\\:?\"*|\\/<>]+$"))) + Q_GLOBAL_STATIC_WITH_ARGS(const QString, baseFilenameRegExp, (QLatin1String("^[^\\:?\"*|\\/<>]+$"))) // NOLINT #endif -bool DialogSaveLayout::havePdf = false; -bool DialogSaveLayout::tested = false; +bool DialogSaveLayout::havePdf = false; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables) +bool DialogSaveLayout::tested = false; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables) //--------------------------------------------------------------------------------------------------------------------- DialogSaveLayout::DialogSaveLayout(int count, Draw mode, const QString &fileName, QWidget *parent) : VAbstractLayoutDialog(parent), ui(new Ui::DialogSaveLAyout), - count(count), - isInitialized(false), - m_mode(mode), - m_tiledExportMode(false) + m_count(count), + m_mode(mode) { ui->setupUi(this); @@ -90,8 +88,7 @@ DialogSaveLayout::DialogSaveLayout(int count, Draw mode, const QString &fileName } else { - VException e(tr("The base filename does not match a regular expression.")); - throw e; + throw VException(tr("The base filename does not match a regular expression.")); } } @@ -230,7 +227,7 @@ void DialogSaveLayout::SetBinaryDXFFormat(bool binary) } //--------------------------------------------------------------------------------------------------------------------- -bool DialogSaveLayout::IsBinaryDXFFormat() const +auto DialogSaveLayout::IsBinaryDXFFormat() const -> bool { switch(Format()) { @@ -278,7 +275,7 @@ bool DialogSaveLayout::IsBinaryDXFFormat() const } //--------------------------------------------------------------------------------------------------------------------- -QString DialogSaveLayout::MakeHelpFormatList() +auto DialogSaveLayout::MakeHelpFormatList() -> QString { QString out(QStringLiteral("\n")); const auto formats = InitFormats(); @@ -316,8 +313,7 @@ void DialogSaveLayout::SetDestinationPath(const QString &cmdDestinationPath) QDir dir; if (not dir.cd(cmdDestinationPath)) { - VException e(tr("The destination directory doesn't exists or is not readable.")); - throw e; + throw VException(tr("The destination directory doesn't exists or is not readable.")); } path = dir.absolutePath(); } @@ -327,7 +323,7 @@ void DialogSaveLayout::SetDestinationPath(const QString &cmdDestinationPath) } //--------------------------------------------------------------------------------------------------------------------- -Draw DialogSaveLayout::Mode() const +auto DialogSaveLayout::Mode() const -> Draw { return m_mode; } @@ -339,19 +335,19 @@ DialogSaveLayout::~DialogSaveLayout() } //--------------------------------------------------------------------------------------------------------------------- -QString DialogSaveLayout::Path() const +auto DialogSaveLayout::Path() const -> QString { return ui->lineEditPath->text(); } //--------------------------------------------------------------------------------------------------------------------- -QString DialogSaveLayout::FileName() const +auto DialogSaveLayout::FileName() const -> QString { return ui->lineEditFileName->text(); } //--------------------------------------------------------------------------------------------------------------------- -LayoutExportFormats DialogSaveLayout::Format() const +auto DialogSaveLayout::Format() const -> LayoutExportFormats { return static_cast(ui->comboBoxFormat->currentData().toInt()); } @@ -361,7 +357,7 @@ void DialogSaveLayout::Save() { WriteSettings(); - for (int i=0; i < count; ++i) + for (int i=0; i < m_count; ++i) { const QString name = Path()+'/'+FileName()+QString::number(i+1)+VLayoutExporter::ExportFormatSuffix(Format()); if (QFile::exists(name)) @@ -374,10 +370,8 @@ void DialogSaveLayout::Save() reject(); return; } - else - { - break; - } + + break; } } accept(); @@ -503,7 +497,7 @@ void DialogSaveLayout::VerticalScaleChanged(double d) } //--------------------------------------------------------------------------------------------------------------------- -bool DialogSaveLayout::IsTextAsPaths() const +auto DialogSaveLayout::IsTextAsPaths() const -> bool { return ui->checkBoxTextAsPaths->isChecked(); } @@ -540,7 +534,7 @@ void DialogSaveLayout::SetTiledMargins(QMarginsF margins) } //--------------------------------------------------------------------------------------------------------------------- -QMarginsF DialogSaveLayout::GetTiledMargins() const +auto DialogSaveLayout::GetTiledMargins() const -> QMarginsF { QMarginsF margins = QMarginsF( ui->doubleSpinBoxLeftField->value(), @@ -563,7 +557,7 @@ void DialogSaveLayout::SetTiledPageFormat(PaperSizeTemplate format) } //--------------------------------------------------------------------------------------------------------------------- -VAbstractLayoutDialog::PaperSizeTemplate DialogSaveLayout::GetTiledPageFormat() const +auto DialogSaveLayout::GetTiledPageFormat() const -> VAbstractLayoutDialog::PaperSizeTemplate { if (ui->comboBoxTemplates->currentIndex() != -1) { @@ -586,16 +580,14 @@ void DialogSaveLayout::SetTiledPageOrientation(PageOrientation orientation) } //--------------------------------------------------------------------------------------------------------------------- -PageOrientation DialogSaveLayout::GetTiledPageOrientation() const +auto DialogSaveLayout::GetTiledPageOrientation() const -> PageOrientation { if(ui->toolButtonPortrait->isChecked()) { return PageOrientation::Portrait; } - else - { - return PageOrientation::Landscape; - } + + return PageOrientation::Landscape; } //--------------------------------------------------------------------------------------------------------------------- @@ -605,7 +597,7 @@ void DialogSaveLayout::SetXScale(qreal scale) } //--------------------------------------------------------------------------------------------------------------------- -qreal DialogSaveLayout::GetXScale() const +auto DialogSaveLayout::GetXScale() const -> qreal { return ui->doubleSpinBoxHorizontalScale->value() / 100.; } @@ -617,7 +609,7 @@ void DialogSaveLayout::SetYScale(qreal scale) } //--------------------------------------------------------------------------------------------------------------------- -qreal DialogSaveLayout::GetYScale() const +auto DialogSaveLayout::GetYScale() const -> qreal { return ui->doubleSpinBoxVerticalScale->value() / 100.; } @@ -631,7 +623,7 @@ void DialogSaveLayout::showEvent(QShowEvent *event) return; } - if (isInitialized) + if (m_isInitialized) { return; } @@ -639,11 +631,11 @@ void DialogSaveLayout::showEvent(QShowEvent *event) setFixedHeight(size().height()); - isInitialized = true;//first show windows are held + m_isInitialized = true;//first show windows are held } //--------------------------------------------------------------------------------------------------------------------- -bool DialogSaveLayout::SupportPSTest() +auto DialogSaveLayout::SupportPSTest() -> bool { if (!tested) { @@ -654,7 +646,7 @@ bool DialogSaveLayout::SupportPSTest() } //--------------------------------------------------------------------------------------------------------------------- -QVector > DialogSaveLayout::InitFormats() +auto DialogSaveLayout::InitFormats() -> QVector > { QVector> list; diff --git a/src/app/valentina/dialogs/dialogsavelayout.h b/src/app/valentina/dialogs/dialogsavelayout.h index 3daee718f..ee196f8bb 100644 --- a/src/app/valentina/dialogs/dialogsavelayout.h +++ b/src/app/valentina/dialogs/dialogsavelayout.h @@ -29,9 +29,9 @@ #ifndef DIALOGSAVELAYOUT_H #define DIALOGSAVELAYOUT_H -#include "../vgeometry/vgeometrydef.h" #include "../vlayout/dialogs/vabstractlayoutdialog.h" #include "../vlayout/vlayoutdef.h" +#include "../vmisc/def.h" namespace Ui { @@ -40,49 +40,49 @@ namespace Ui class DialogSaveLayout : public VAbstractLayoutDialog { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit DialogSaveLayout(int count, Draw mode = Draw::Layout, const QString &fileName = QString(), QWidget *parent = nullptr); - virtual ~DialogSaveLayout(); + ~DialogSaveLayout() override; - QString Path() const; - QString FileName() const; + auto Path() const -> QString; + auto FileName() const -> QString; - LayoutExportFormats Format() const; - void SelectFormat(LayoutExportFormats format); + auto Format() const -> LayoutExportFormats; + void SelectFormat(LayoutExportFormats format); void SetBinaryDXFFormat(bool binary); - bool IsBinaryDXFFormat() const; + auto IsBinaryDXFFormat() const -> bool; - static QString MakeHelpFormatList(); - void SetDestinationPath(const QString& cmdDestinationPath); + static auto MakeHelpFormatList() -> QString; + void SetDestinationPath(const QString& cmdDestinationPath); - Draw Mode() const; + auto Mode() const -> Draw; - bool IsTextAsPaths() const; + auto IsTextAsPaths() const -> bool; void SetTextAsPaths(bool textAsPaths); void SetTiledExportMode(bool tiledExportMode); - void SetTiledMargins(QMarginsF margins); - QMarginsF GetTiledMargins() const; + void SetTiledMargins(QMarginsF margins); + auto GetTiledMargins() const -> QMarginsF; - void SetTiledPageFormat(PaperSizeTemplate format); - PaperSizeTemplate GetTiledPageFormat() const; + void SetTiledPageFormat(PaperSizeTemplate format); + auto GetTiledPageFormat() const -> PaperSizeTemplate; - void SetTiledPageOrientation(PageOrientation orientation); - PageOrientation GetTiledPageOrientation() const; + void SetTiledPageOrientation(PageOrientation orientation); + auto GetTiledPageOrientation() const -> PageOrientation; - void SetXScale(qreal scale); - qreal GetXScale() const; + void SetXScale(qreal scale); + auto GetXScale() const -> qreal; - void SetYScale(qreal scale); - qreal GetYScale() const; + void SetYScale(qreal scale); + auto GetYScale() const -> qreal; protected: - virtual void showEvent(QShowEvent *event) override; + void showEvent(QShowEvent *event) override; private slots: void Save(); @@ -92,18 +92,19 @@ private slots: void HorizontalScaleChanged(double d); void VerticalScaleChanged(double d); private: - Q_DISABLE_COPY(DialogSaveLayout) + // cppcheck-suppress unknownMacro + Q_DISABLE_COPY_MOVE(DialogSaveLayout) // NOLINT Ui::DialogSaveLAyout *ui; - int count; - bool isInitialized; + int m_count; + bool m_isInitialized{false}; Draw m_mode; - bool m_tiledExportMode; + bool m_tiledExportMode{false}; bool m_scaleConnected{true}; - static bool havePdf; - static bool tested; - static bool SupportPSTest(); - static QVector > InitFormats(); + static bool havePdf; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables) + static bool tested; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables) + static auto SupportPSTest() -> bool; + static auto InitFormats() -> QVector >; void RemoveFormatFromList(LayoutExportFormats format); diff --git a/src/app/valentina/dialogs/vwidgetbackgroundimages.h b/src/app/valentina/dialogs/vwidgetbackgroundimages.h index baac11960..8954c355a 100644 --- a/src/app/valentina/dialogs/vwidgetbackgroundimages.h +++ b/src/app/valentina/dialogs/vwidgetbackgroundimages.h @@ -48,7 +48,7 @@ enum class ScaleUnit {Percent, Mm, Cm, Inch, Px}; class VWidgetBackgroundImages : public QWidget { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit VWidgetBackgroundImages(VAbstractPattern *doc, QWidget *parent = nullptr); @@ -83,7 +83,7 @@ private slots: private: // cppcheck-suppress unknownMacro - Q_DISABLE_COPY_MOVE(VWidgetBackgroundImages) + Q_DISABLE_COPY_MOVE(VWidgetBackgroundImages) // NOLINT Ui::VWidgetBackgroundImages *ui; VAbstractPattern *m_doc; diff --git a/src/app/valentina/dialogs/vwidgetdetails.cpp b/src/app/valentina/dialogs/vwidgetdetails.cpp index d4edbada5..2f7f5bc63 100644 --- a/src/app/valentina/dialogs/vwidgetdetails.cpp +++ b/src/app/valentina/dialogs/vwidgetdetails.cpp @@ -37,18 +37,21 @@ #include #include #include +#include + +using namespace std::chrono_literals; namespace { - enum PieceColumn - { - InLayout = 0, - PieceName = 1 - }; +enum PieceColumn +{ + InLayout = 0, + PieceName = 1 +}; - Q_GLOBAL_STATIC_WITH_ARGS(const QString, allowDetailIcon, (QLatin1String("://icon/16x16/allow_detail.png"))) - Q_GLOBAL_STATIC_WITH_ARGS(const QString, forbidDetailIcon, (QLatin1String("://icon/16x16/forbid_detail.png"))) -} +Q_GLOBAL_STATIC_WITH_ARGS(const QString, allowDetailIcon, (QLatin1String("://icon/16x16/allow_detail.png"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, forbidDetailIcon, (QLatin1String("://icon/16x16/forbid_detail.png"))) // NOLINT +} // namespace //--------------------------------------------------------------------------------------------------------------------- VWidgetDetails::VWidgetDetails(VContainer *data, VAbstractPattern *doc, QWidget *parent) @@ -88,7 +91,7 @@ void VWidgetDetails::UpdateList() // The filling table is a very expensive operation. This optimization will postpone it. // Each time a new request happen we will wait 800 ms before calling it. If at this time a new request will arrive // we will wait 800 ms more. And so on, until nothing happens within 800ms. - m_updateListTimer->start(800); + m_updateListTimer->start(800ms); } //--------------------------------------------------------------------------------------------------------------------- @@ -149,7 +152,7 @@ void VWidgetDetails::InLayoutStateChanged(int row, int column) const QHash *allDetails = m_data->DataPieces(); const bool inLayout = not allDetails->value(id).IsInLayout(); - TogglePieceInLayout *togglePrint = new TogglePieceInLayout(id, inLayout, m_data, m_doc); + auto *togglePrint = new TogglePieceInLayout(id, inLayout, m_data, m_doc); connect(togglePrint, &TogglePieceInLayout::Toggled, this, &VWidgetDetails::ToggledPiece); VAbstractApplication::VApp()->getUndoStack()->push(togglePrint); } @@ -198,7 +201,7 @@ void VWidgetDetails::ToggleSectionDetails(bool select) { if (not (select == allDetails->value(id).IsInLayout())) { - TogglePieceInLayout *togglePrint = new TogglePieceInLayout(id, select, m_data, m_doc); + auto *togglePrint = new TogglePieceInLayout(id, select, m_data, m_doc); connect(togglePrint, &TogglePieceInLayout::Toggled, this, &VWidgetDetails::ToggledPiece); VAbstractApplication::VApp()->getUndoStack()->push(togglePrint); } @@ -234,9 +237,9 @@ void VWidgetDetails::ToggledPieceItem(QTableWidgetItem *item) } //--------------------------------------------------------------------------------------------------------------------- -QTableWidgetItem *VWidgetDetails::PrepareInLayoutColumnCell(const VPiece &det, quint32 id) const +auto VWidgetDetails::PrepareInLayoutColumnCell(const VPiece &det, quint32 id) -> QTableWidgetItem * { - QTableWidgetItem *item = new QTableWidgetItem(); + auto *item = new QTableWidgetItem(); item->setTextAlignment(Qt::AlignHCenter); item->setIcon(det.IsInLayout() ? QIcon(*allowDetailIcon) : QIcon(*forbidDetailIcon)); item->setData(Qt::UserRole, id); @@ -249,7 +252,7 @@ QTableWidgetItem *VWidgetDetails::PrepareInLayoutColumnCell(const VPiece &det, q } //--------------------------------------------------------------------------------------------------------------------- -QTableWidgetItem *VWidgetDetails::PreparePieceNameColumnCell(const VPiece &det) const +auto VWidgetDetails::PreparePieceNameColumnCell(const VPiece &det) -> QTableWidgetItem * { QString name = det.GetName(); if (name.isEmpty()) @@ -257,7 +260,7 @@ QTableWidgetItem *VWidgetDetails::PreparePieceNameColumnCell(const VPiece &det) name = tr("Unnamed"); } - QTableWidgetItem *item = new QTableWidgetItem(name); + auto *item = new QTableWidgetItem(name); item->setTextAlignment(Qt::AlignLeft | Qt::AlignVCenter); // set the item non-editable (view only), and non-selectable @@ -368,7 +371,7 @@ void VWidgetDetails::ShowContextMenu(const QPoint &pos) { select = not allDetails->value(id).IsInLayout(); - TogglePieceInLayout *togglePrint = new TogglePieceInLayout(id, select, m_data, m_doc); + auto *togglePrint = new TogglePieceInLayout(id, select, m_data, m_doc); connect(togglePrint, &TogglePieceInLayout::Toggled, this, &VWidgetDetails::ToggledPiece); VAbstractApplication::VApp()->getUndoStack()->push(togglePrint); } diff --git a/src/app/valentina/dialogs/vwidgetdetails.h b/src/app/valentina/dialogs/vwidgetdetails.h index 06f898a04..72804bcfe 100644 --- a/src/app/valentina/dialogs/vwidgetdetails.h +++ b/src/app/valentina/dialogs/vwidgetdetails.h @@ -31,6 +31,8 @@ #include +#include "../vmisc/defglobal.h" + class VAbstractPattern; class VContainer; class VPiece; @@ -43,11 +45,11 @@ namespace Ui class VWidgetDetails : public QWidget { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit VWidgetDetails(VContainer *data, VAbstractPattern *doc, QWidget *parent = nullptr); - virtual ~VWidgetDetails(); + ~VWidgetDetails() override; signals: void Highlight(quint32 id); @@ -58,7 +60,7 @@ public slots: void ToggledPiece(quint32 id); protected: - virtual void changeEvent ( QEvent * event) override; + void changeEvent ( QEvent * event) override; private slots: void InLayoutStateChanged(int row, int column); @@ -67,7 +69,8 @@ private slots: void on_checkBoxHideNotInLayout_stateChanged(); private: - Q_DISABLE_COPY(VWidgetDetails) + // cppcheck-suppress unknownMacro + Q_DISABLE_COPY_MOVE(VWidgetDetails) // NOLINT Ui::VWidgetDetails *ui; VAbstractPattern *m_doc; VContainer *m_data; @@ -77,8 +80,8 @@ private: void ToggleSectionDetails(bool select); void ToggledPieceItem(QTableWidgetItem *item); - Q_REQUIRED_RESULT QTableWidgetItem *PrepareInLayoutColumnCell(const VPiece &det, quint32 id) const; - Q_REQUIRED_RESULT QTableWidgetItem *PreparePieceNameColumnCell(const VPiece &det) const; + static Q_REQUIRED_RESULT auto PrepareInLayoutColumnCell(const VPiece &det, quint32 id) -> QTableWidgetItem *; + static Q_REQUIRED_RESULT auto PreparePieceNameColumnCell(const VPiece &det) -> QTableWidgetItem *; }; #endif // VWIDGETDETAILS_H diff --git a/src/app/valentina/dialogs/vwidgetgroups.cpp b/src/app/valentina/dialogs/vwidgetgroups.cpp index 0c6017168..6354eb2ce 100644 --- a/src/app/valentina/dialogs/vwidgetgroups.cpp +++ b/src/app/valentina/dialogs/vwidgetgroups.cpp @@ -41,7 +41,7 @@ VWidgetGroups::VWidgetGroups(VAbstractPattern *doc, QWidget *parent) : QWidget(parent), ui(new Ui::VWidgetGroups), - doc(doc) + m_doc(doc) { ui->setupUi(this); @@ -65,7 +65,7 @@ VWidgetGroups::~VWidgetGroups() //---------------------------------------------------------------------------------------------------------------------- void VWidgetGroups::SetGroupVisibility(vidtype id, bool visible) const { - ChangeGroupVisibility *changeGroup = new ChangeGroupVisibility(doc, id, visible); + auto *changeGroup = new ChangeGroupVisibility(m_doc, id, visible); connect(changeGroup, &ChangeGroupVisibility::UpdateGroup, this, [this](vidtype id, bool visible) { int row = GroupRow(id); @@ -87,7 +87,7 @@ void VWidgetGroups::SetGroupVisibility(vidtype id, bool visible) const //--------------------------------------------------------------------------------------------------------------------- void VWidgetGroups::SetMultipleGroupsVisibility(const QVector &groups, bool visible) const { - auto *changeGroups = new ChangeMultipleGroupsVisibility(doc, groups, visible); + auto *changeGroups = new ChangeMultipleGroupsVisibility(m_doc, groups, visible); connect(changeGroups, &ChangeMultipleGroupsVisibility::UpdateMultipleGroups, this, [this](const QMap &groups) { @@ -115,7 +115,7 @@ void VWidgetGroups::SetMultipleGroupsVisibility(const QVector &groups, } //--------------------------------------------------------------------------------------------------------------------- -QMap VWidgetGroups::FilterGroups(const QMap &groups) +auto VWidgetGroups::FilterGroups(const QMap &groups) -> QMap { QMap filtered; QSet filterCategories = ConvertToSet(VAbstractPattern::FilterGroupTags(ui->lineEditTags->text())); @@ -141,7 +141,7 @@ QMap VWidgetGroups::FilterGroups(const QMap int { for (int r = 0; r < ui->tableWidget->rowCount(); ++r) { @@ -157,6 +157,78 @@ int VWidgetGroups::GroupRow(vidtype id) const return -1; } +//--------------------------------------------------------------------------------------------------------------------- +void VWidgetGroups::ActionPreferences(quint32 id) +{ + QScopedPointer fackeContainer(new VContainer(VAbstractApplication::VApp()->TrVars(), + VAbstractValApplication::VApp()->patternUnitsP(), + VContainer::UniqueNamespace())); + QScopedPointer dialog(new DialogGroup(fackeContainer.data(), NULL_ID, this)); + dialog->SetName(m_doc->GetGroupName(id)); + dialog->SetTags(m_doc->GetGroupTags(id)); + dialog->SetGroupCategories(m_doc->GetGroupCategories()); + const int result = dialog->exec(); + + if (result == QDialog::Accepted) + { + auto *changeGroupOptions = new ChangeGroupOptions(m_doc, id, dialog->GetName(), dialog->GetTags()); + connect(changeGroupOptions, &ChangeGroupOptions::UpdateGroups, this, &VWidgetGroups::UpdateGroups); + VAbstractApplication::VApp()->getUndoStack()->push(changeGroupOptions); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void VWidgetGroups::ActionHideAll() +{ + if (ui->tableWidget->rowCount() < 1) + { + return; + } + + QVector groups; + groups.reserve(ui->tableWidget->rowCount()); + for (int r = 0; r < ui->tableWidget->rowCount(); ++r) + { + QTableWidgetItem *rowItem = ui->tableWidget->item(r, 0); + quint32 i = rowItem->data(Qt::UserRole).toUInt(); + if (m_doc->GetGroupVisibility(i)) + { + groups.append(i); + } + } + + if (not groups.isEmpty()) + { + SetMultipleGroupsVisibility(groups, false); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void VWidgetGroups::ActionShowAll() +{ + if (ui->tableWidget->rowCount() < 1) + { + return; + } + + QVector groups; + groups.reserve(ui->tableWidget->rowCount()); + for (int r = 0; r < ui->tableWidget->rowCount(); ++r) + { + QTableWidgetItem *rowItem = ui->tableWidget->item(r, 0); + quint32 i = rowItem->data(Qt::UserRole).toUInt(); + if (not m_doc->GetGroupVisibility(i)) + { + groups.append(i); + } + } + + if (not groups.isEmpty()) + { + SetMultipleGroupsVisibility(groups, true); + } +} + //--------------------------------------------------------------------------------------------------------------------- void VWidgetGroups::GroupVisibilityChanged(int row, int column) { @@ -166,7 +238,7 @@ void VWidgetGroups::GroupVisibilityChanged(int row, int column) } QTableWidgetItem *item = ui->tableWidget->item(row, column); const quint32 id = item->data(Qt::UserRole).toUInt(); - SetGroupVisibility(id, not doc->GetGroupVisibility(id)); + SetGroupVisibility(id, not m_doc->GetGroupVisibility(id)); } //--------------------------------------------------------------------------------------------------------------------- @@ -178,7 +250,7 @@ void VWidgetGroups::RenameGroup(int row, int column) } const quint32 id = ui->tableWidget->item(row, 0)->data(Qt::UserRole).toUInt(); - ::RenameGroup *renameGroup = new ::RenameGroup(doc, id, ui->tableWidget->item(row, column)->text()); + auto *renameGroup = new ::RenameGroup(m_doc, id, ui->tableWidget->item(row, column)->text()); connect(renameGroup, &RenameGroup::UpdateGroups, this, &VWidgetGroups::UpdateGroups); VAbstractApplication::VApp()->getUndoStack()->push(renameGroup); } @@ -201,7 +273,7 @@ void VWidgetGroups::CtxMenu(const QPoint &pos) for (int r = 0; r < ui->tableWidget->rowCount(); ++r) { QTableWidgetItem *rowItem = ui->tableWidget->item(r, 0); - if (rowItem and visibility != doc->GetGroupVisibility(rowItem->data(Qt::UserRole).toUInt())) + if (rowItem and visibility != m_doc->GetGroupVisibility(rowItem->data(Qt::UserRole).toUInt())) { return true; } @@ -211,7 +283,7 @@ void VWidgetGroups::CtxMenu(const QPoint &pos) }; QScopedPointer menu(new QMenu()); - QAction *triggerVisibilityMenu = doc->GetGroupVisibility(id) ? + QAction *triggerVisibilityMenu = m_doc->GetGroupVisibility(id) ? menu->addAction(QIcon(QStringLiteral("://icon/16x16/closed_eye.png")), tr("Hide")) : menu->addAction(QIcon(QStringLiteral("://icon/16x16/open_eye.png")), tr("Show")); @@ -227,93 +299,38 @@ void VWidgetGroups::CtxMenu(const QPoint &pos) if (selectedAction == triggerVisibilityMenu) { - SetGroupVisibility(id, not doc->GetGroupVisibility(id)); + SetGroupVisibility(id, not m_doc->GetGroupVisibility(id)); } else if (selectedAction == actionPreferences) { - QScopedPointer fackeContainer(new VContainer(VAbstractApplication::VApp()->TrVars(), - VAbstractValApplication::VApp()->patternUnitsP(), - VContainer::UniqueNamespace())); - QScopedPointer dialog(new DialogGroup(fackeContainer.data(), NULL_ID, this)); - dialog->SetName(doc->GetGroupName(id)); - dialog->SetTags(doc->GetGroupTags(id)); - dialog->SetGroupCategories(doc->GetGroupCategories()); - const int result = dialog->exec(); - - if (result == QDialog::Accepted) - { - ChangeGroupOptions *changeGroupOptions = new ChangeGroupOptions(doc, id, dialog->GetName(), - dialog->GetTags()); - connect(changeGroupOptions, &ChangeGroupOptions::UpdateGroups, this, &VWidgetGroups::UpdateGroups); - VAbstractApplication::VApp()->getUndoStack()->push(changeGroupOptions); - } + ActionPreferences(id); } else if (selectedAction == actionDelete) { - DelGroup *delGroup = new DelGroup(doc, id); + auto *delGroup = new DelGroup(m_doc, id); connect(delGroup, &DelGroup::UpdateGroups, this, &VWidgetGroups::UpdateGroups); VAbstractApplication::VApp()->getUndoStack()->push(delGroup); } else if (selectedAction == actionHideAll) {//all groups in "group" make unvisible - if (ui->tableWidget->rowCount() < 1) - { - return; - } - - QVector groups; - groups.reserve(ui->tableWidget->rowCount()); - for (int r = 0; r < ui->tableWidget->rowCount(); ++r) - { - QTableWidgetItem *rowItem = ui->tableWidget->item(r, 0); - quint32 i = rowItem->data(Qt::UserRole).toUInt(); - if (doc->GetGroupVisibility(i)) - { - groups.append(i); - } - } - - if (not groups.isEmpty()) - { - SetMultipleGroupsVisibility(groups, false); - } + ActionHideAll(); } else if (selectedAction == actionShowAll) {//all groups in "group" make visible - if (ui->tableWidget->rowCount() < 1) - { - return; - } - - QVector groups; - groups.reserve(ui->tableWidget->rowCount()); - for (int r = 0; r < ui->tableWidget->rowCount(); ++r) - { - QTableWidgetItem *rowItem = ui->tableWidget->item(r, 0); - quint32 i = rowItem->data(Qt::UserRole).toUInt(); - if (not doc->GetGroupVisibility(i)) - { - groups.append(i); - } - } - - if (not groups.isEmpty()) - { - SetMultipleGroupsVisibility(groups, true); - } + ActionShowAll(); } } //--------------------------------------------------------------------------------------------------------------------- void VWidgetGroups::UpdateGroups() { - FillTable(doc->GetGroups()); + FillTable(m_doc->GetGroups()); } //--------------------------------------------------------------------------------------------------------------------- void VWidgetGroups::FillTable(QMap groups) { - ui->lineEditTags->SetCompletion(doc->GetGroupCategories()); + ui->lineEditTags->SetCompletion(m_doc->GetGroupCategories()); groups = FilterGroups(groups); @@ -347,7 +364,7 @@ void VWidgetGroups::FillTable(QMap groups) item->setTextAlignment(Qt::AlignLeft | Qt::AlignVCenter); if (not data.tags.isEmpty()) { - item->setToolTip(tr("Categories: %1.").arg(data.tags.join(", "))); + item->setToolTip(tr("Categories: %1.").arg(data.tags.join(QStringLiteral(", ")))); } if(data.items.isEmpty()) diff --git a/src/app/valentina/dialogs/vwidgetgroups.h b/src/app/valentina/dialogs/vwidgetgroups.h index ba4e0f17c..75a96cc55 100644 --- a/src/app/valentina/dialogs/vwidgetgroups.h +++ b/src/app/valentina/dialogs/vwidgetgroups.h @@ -31,6 +31,7 @@ #include #include "../vmisc/typedef.h" +#include "../vmisc/defglobal.h" class QTableWidgetItem; class VAbstractPattern; @@ -43,11 +44,11 @@ namespace Ui class VWidgetGroups : public QWidget { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit VWidgetGroups(VAbstractPattern *doc, QWidget *parent = nullptr); - virtual ~VWidgetGroups(); + ~VWidgetGroups() override; public slots: void UpdateGroups(); @@ -58,17 +59,22 @@ private slots: void CtxMenu(const QPoint &pos); private: - Q_DISABLE_COPY(VWidgetGroups) + // cppcheck-suppress unknownMacro + Q_DISABLE_COPY_MOVE(VWidgetGroups) // NOLINT Ui::VWidgetGroups *ui; - VAbstractPattern *doc; + VAbstractPattern *m_doc; void FillTable(QMap groups); void SetGroupVisibility(vidtype id, bool visible) const; void SetMultipleGroupsVisibility(const QVector &groups, bool visible) const; - QMap FilterGroups(const QMap &groups); + auto FilterGroups(const QMap &groups) -> QMap; - int GroupRow(vidtype id) const; + auto GroupRow(vidtype id) const -> int; + + void ActionPreferences(quint32 id); + void ActionHideAll(); + void ActionShowAll(); }; #endif // VWIDGETGROUPS_H diff --git a/src/app/valentina/main.cpp b/src/app/valentina/main.cpp index 323d220b7..be34e752f 100644 --- a/src/app/valentina/main.cpp +++ b/src/app/valentina/main.cpp @@ -45,7 +45,7 @@ //--------------------------------------------------------------------------------------------------------------------- -int main(int argc, char *argv[]) +auto main(int argc, char *argv[]) -> int { #if defined(APPIMAGE) && defined(Q_OS_LINUX) /* Fix path to ICU_DATA when run AppImage.*/ @@ -53,16 +53,16 @@ int main(int argc, char *argv[]) auto FreeMemory = qScopeGuard([exe_dir] {free(exe_dir);}); #endif // defined(APPIMAGE) && defined(Q_OS_LINUX) - Q_INIT_RESOURCE(cursor); - Q_INIT_RESOURCE(icon); - Q_INIT_RESOURCE(schema); - Q_INIT_RESOURCE(theme); - Q_INIT_RESOURCE(flags); - Q_INIT_RESOURCE(icons); - Q_INIT_RESOURCE(toolicon); - Q_INIT_RESOURCE(style); + Q_INIT_RESOURCE(cursor); // NOLINT + Q_INIT_RESOURCE(icon); // NOLINT + Q_INIT_RESOURCE(schema); // NOLINT + Q_INIT_RESOURCE(theme); // NOLINT + Q_INIT_RESOURCE(flags); // NOLINT + Q_INIT_RESOURCE(icons); // NOLINT + Q_INIT_RESOURCE(toolicon); // NOLINT + Q_INIT_RESOURCE(style); // NOLINT - QT_REQUIRE_VERSION(argc, argv, "5.4.0")// clazy:exclude=qstring-arg,qstring-allocations + QT_REQUIRE_VERSION(argc, argv, "5.4.0")// clazy:exclude=qstring-arg,qstring-allocations NOLINT #if defined(Q_OS_WIN) VAbstractApplication::WinAttachConsole(); @@ -112,5 +112,5 @@ int main(int argc, char *argv[]) } #endif // defined(APPIMAGE) && defined(Q_OS_LINUX) - return app.exec(); + return VApplication::exec(); } diff --git a/src/app/valentina/mainwindow.cpp b/src/app/valentina/mainwindow.cpp index 624adb3e8..3dcd10f52 100644 --- a/src/app/valentina/mainwindow.cpp +++ b/src/app/valentina/mainwindow.cpp @@ -28,20 +28,19 @@ #include "mainwindow.h" #include "ui_mainwindow.h" -#include "../vgeometry/vspline.h" #include "../ifc/exception/vexceptionobjecterror.h" #include "../ifc/exception/vexceptionconversionerror.h" #include "../ifc/exception/vexceptionemptyparameter.h" #include "../ifc/exception/vexceptionwrongid.h" #include "../ifc/exception/vexceptionundo.h" #include "../ifc/exception/vexceptioninvalidhistory.h" -#include "version.h" #include "core/vapplication.h" #include "../vmisc/customevents.h" #include "../vmisc/vvalentinasettings.h" #include "../vmisc/def.h" #include "../vmisc/qxtcsvmodel.h" #include "../vmisc/vmodifierkey.h" +#include "../vmisc/vsysexits.h" #include "undocommands/renamepp.h" #include "core/vtooloptionspropertybrowser.h" #include "../ifc/xml/vpatternconverter.h" @@ -50,37 +49,124 @@ #include "../ifc/xml/vvitconverter.h" #include "../vwidgets/vwidgetpopup.h" #include "../vwidgets/vmaingraphicsscene.h" -#include "tools/drawTools/drawtools.h" -#include "../vtools/dialogs/tooldialogs.h" -#include "tools/vtoolseamallowance.h" -#include "tools/nodeDetails/vtoolpiecepath.h" -#include "tools/nodeDetails/vtoolpin.h" -#include "tools/nodeDetails/vtoolplacelabel.h" -#include "tools/vtooluniondetails.h" -#include "dialogs/dialogs.h" -#include "dialogs/vwidgetgroups.h" + #include "../vtools/undocommands/undogroup.h" -#include "dialogs/vwidgetdetails.h" -#include "dialogs/dialogaddbackgroundimage.h" -#include "../vpatterndb/vpiecepath.h" -#include "../qmuparser/qmuparsererror.h" -#include "../vtools/dialogs/support/dialogeditlabel.h" #include "../vformat/vpatternrecipe.h" #include "../vlayout/dialogs/watermarkwindow.h" +#if QT_VERSION < QT_VERSION_CHECK(5, 7, 0) #include "../vmisc/backport/qoverload.h" +#endif // QT_VERSION < QT_VERSION_CHECK(5, 7, 0) #include "../vlayout/vlayoutexporter.h" #include "../vwidgets/vgraphicssimpletextitem.h" #include "../vlayout/dialogs/dialoglayoutscale.h" #include "../vmisc/dialogs/dialogselectlanguage.h" + +#include "../vtools/undocommands/image/addbackgroundimage.h" +#include "../vtools/undocommands/image/deletebackgroundimage.h" +#include "../ifc/xml/utils.h" +#include "../ifc/xml/vbackgroundpatternimage.h" + +#include "dialogs/vwidgetbackgroundimages.h" +#include "dialogs/vwidgetgroups.h" +#include "dialogs/vwidgetdetails.h" +#include "dialogs/dialogaddbackgroundimage.h" +#include "dialogs/dialoghistory.h" +#include "dialogs/dialogincrements.h" +#include "dialogs/dialogpatternproperties.h" +#include "dialogs/dialognewpattern.h" +#include "dialogs/dialogaboutapp.h" +#include "dialogs/dialogpreferences.h" +#include "dialogs/dialogfinalmeasurements.h" + +#include "../vtools/dialogs/support/dialogeditlabel.h" + +#include "../vtools/dialogs/tools/dialogalongline.h" +#include "../vtools/dialogs/tools/dialogarc.h" +#include "../vtools/dialogs/tools/dialogarcwithlength.h" +#include "../vtools/dialogs/tools/dialogbisector.h" +#include "../vtools/dialogs/tools/piece/dialogseamallowance.h" +#include "../vtools/dialogs/tools/dialogendline.h" +#include "../vtools/dialogs/tools/dialogline.h" +#include "../vtools/dialogs/tools/dialoglineintersect.h" +#include "../vtools/dialogs/tools/dialognormal.h" +#include "../vtools/dialogs/tools/dialogpointofcontact.h" +#include "../vtools/dialogs/tools/dialogshoulderpoint.h" +#include "../vtools/dialogs/tools/dialogspline.h" +#include "../vtools/dialogs/tools/dialogcubicbezier.h" +#include "../vtools/dialogs/tools/dialogsplinepath.h" +#include "../vtools/dialogs/tools/dialogcubicbezierpath.h" +#include "../vtools/dialogs/tools/dialogheight.h" +#include "../vtools/dialogs/tools/dialogcutarc.h" +#include "../vtools/dialogs/tools/dialogcutspline.h" +#include "../vtools/dialogs/tools/dialogcutsplinepath.h" +#include "../vtools/dialogs/tools/dialoguniondetails.h" +#include "../vtools/dialogs/tools/dialogtriangle.h" +#include "../vtools/dialogs/tools/dialogpointofintersection.h" +#include "../vtools/dialogs/tools/dialoglineintersectaxis.h" +#include "../vtools/dialogs/tools/dialogcurveintersectaxis.h" +#include "../vtools/dialogs/tools/dialogpointofintersectionarcs.h" +#include "../vtools/dialogs/tools/dialogpointofintersectioncircles.h" +#include "../vtools/dialogs/tools/dialogpointofintersectioncurves.h" +#include "../vtools/dialogs/tools/dialogpointfromcircleandtangent.h" +#include "../vtools/dialogs/tools/dialogpointfromarcandtangent.h" +#include "../vtools/dialogs/tools/dialogtruedarts.h" +#include "../vtools/dialogs/tools/dialoggroup.h" +#include "../vtools/dialogs/tools/dialogrotation.h" +#include "../vtools/dialogs/tools/dialogflippingbyline.h" +#include "../vtools/dialogs/tools/dialogflippingbyaxis.h" +#include "../vtools/dialogs/tools/dialogmove.h" +#include "../vtools/dialogs/tools/dialogellipticalarc.h" +#include "../vtools/dialogs/tools/piece/dialogpiecepath.h" +#include "../vtools/dialogs/tools/piece/dialogpin.h" +#include "../vtools/dialogs/tools/piece/dialoginsertnode.h" +#include "../vtools/dialogs/tools/piece/dialogplacelabel.h" +#include "../vtools/dialogs/tools/piece/dialogduplicatedetail.h" + #include "../vtools/tools/backgroundimage/vbackgroundimageitem.h" #include "../vtools/tools/backgroundimage/vbackgroundpixmapitem.h" #include "../vtools/tools/backgroundimage/vbackgroundsvgitem.h" #include "../vtools/tools/backgroundimage/vbackgroundimagecontrols.h" -#include "../vtools/undocommands/image/addbackgroundimage.h" -#include "../vtools/undocommands/image/deletebackgroundimage.h" -#include "../ifc/xml/utils.h" -#include "dialogs/vwidgetbackgroundimages.h" -#include "../ifc/xml/vbackgroundpatternimage.h" + +#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolalongline.h" +#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolbisector.h" +#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolendline.h" +#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolnormal.h" +#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolshoulderpoint.h" +#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolheight.h" +#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoollineintersectaxis.h" +#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolcurveintersectaxis.h" +#include "../vtools/tools/drawTools/toolcurve/vtoolarc.h" +#include "../vtools/tools/drawTools/toolcurve/vtoolellipticalarc.h" +#include "../vtools/tools/drawTools/toolcurve/vtoolarcwithlength.h" +#include "../vtools/tools/drawTools/toolcurve/vtoolspline.h" +#include "../vtools/tools/drawTools/toolcurve/vtoolcubicbezier.h" +#include "../vtools/tools/drawTools/toolcurve/vtoolsplinepath.h" +#include "../vtools/tools/drawTools/toolcurve/vtoolcubicbezierpath.h" +#include "../vtools/tools/drawTools/vtoolline.h" +#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutspline.h" +#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutsplinepath.h" +#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutarc.h" +#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoollineintersect.h" +#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofcontact.h" +#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolbasepoint.h" +#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/vtooltriangle.h" +#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersection.h" +#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectionarcs.h" +#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncircles.h" +#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncurves.h" +#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromcircleandtangent.h" +#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromarcandtangent.h" +#include "../vtools/tools/drawTools/toolpoint/tooldoublepoint/vtooltruedarts.h" +#include "../vtools/tools/drawTools/operation/vtoolrotation.h" +#include "../vtools/tools/drawTools/operation/flipping/vtoolflippingbyline.h" +#include "../vtools/tools/drawTools/operation/flipping/vtoolflippingbyaxis.h" +#include "../vtools/tools/drawTools/operation/vtoolmove.h" +#include "../vtools/tools/vtoolseamallowance.h" +#include "../vtools/tools/vtooluniondetails.h" + +#include "../vtools/tools/nodeDetails/vtoolpiecepath.h" +#include "../vtools/tools/nodeDetails/vtoolpin.h" +#include "../vtools/tools/nodeDetails/vtoolplacelabel.h" #if QT_VERSION < QT_VERSION_CHECK(5, 12, 0) #include "../vmisc/backport/qscopeguard.h" @@ -116,6 +202,7 @@ #include #include #include +#include #if defined(Q_OS_WIN32) && QT_VERSION >= QT_VERSION_CHECK(5, 7, 0) #include @@ -127,21 +214,23 @@ #include #endif //defined(Q_OS_MAC) +using namespace std::chrono_literals; + QT_WARNING_PUSH QT_WARNING_DISABLE_CLANG("-Wmissing-prototypes") QT_WARNING_DISABLE_INTEL(1418) -Q_LOGGING_CATEGORY(vMainWindow, "v.mainwindow") +Q_LOGGING_CATEGORY(vMainWindow, "v.mainwindow") // NOLINT QT_WARNING_POP namespace { -Q_GLOBAL_STATIC_WITH_ARGS(const QString, autosavePrefix, (QLatin1String(".autosave"))) +Q_GLOBAL_STATIC_WITH_ARGS(const QString, autosavePrefix, (QLatin1String(".autosave"))) // NOLINT //--------------------------------------------------------------------------------------------------------------------- -QVector SortDetailsForLayout(const QHash *allDetails, - const QString &nameRegex = QString()) +auto SortDetailsForLayout(const QHash *allDetails, + const QString &nameRegex = QString()) -> QVector { QVector details; QHash::const_iterator i = allDetails->constBegin(); @@ -207,37 +296,23 @@ void WarningNotUniquePieceName(const QHash *allDetails) * @param parent parent widget. */ MainWindow::MainWindow(QWidget *parent) - :MainWindowsNoGUI(parent), ui(new Ui::MainWindow), watcher(new QFileSystemWatcher(this)), currentTool(Tool::Arrow), - lastUsedTool(Tool::Arrow), sceneDraw(nullptr), sceneDetails(nullptr), - isInitialized(false), mChanges(false), mChangesAsked(true), - patternReadOnly(false), - dialogTable(nullptr), - dialogTool(), - dialogHistory(nullptr), - dialogFMeasurements(nullptr), - comboBoxDraws(nullptr), patternPieceLabel(nullptr), - currentDrawIndex(0), currentToolBoxIndex(0), - drawMode(true), - leftGoToStage(nullptr), - rightGoToStage(nullptr), - autoSaveTimer(nullptr), - measurementsSyncTimer(new QTimer(this)), - guiEnabled(true), - toolOptions(nullptr), - groupsWidget(nullptr), - detailsWidget(nullptr), - lock(nullptr), - toolButtonPointerList(), - m_progressBar(new QProgressBar(this)), - m_statusLabel(new QLabel(this)), - m_gradation(new QTimer(this)) + : MainWindowsNoGUI(parent), + ui(new Ui::MainWindow), + m_watcher(new QFileSystemWatcher(this)), + m_dialogTable(nullptr), + m_dialogHistory(nullptr), + m_dialogFMeasurements(nullptr), + m_measurementsSyncTimer(new QTimer(this)), + m_progressBar(new QProgressBar(this)), + m_statusLabel(new QLabel(this)), + m_gradation(new QTimer(this)) { CreateActions(); InitScenes(); connect(m_gradation, &QTimer::timeout, this, &MainWindow::GradationChanged); - doc = new VPattern(pattern, sceneDraw, sceneDetails); + doc = new VPattern(pattern, m_sceneDraw, m_sceneDetails); connect(doc, &VPattern::ClearMainWindow, this, &MainWindow::Clear); connect(doc, &VPattern::patternChanged, this, &MainWindow::PatternChangesWereSaved); connect(doc, &VPattern::UndoCommand, this, &MainWindow::FullParseFile); @@ -289,19 +364,19 @@ MainWindow::MainWindow(QWidget *parent) connect(ui->listWidget, &QListWidget::currentRowChanged, this, &MainWindow::ShowPaper); ui->dockWidgetLayoutPages->setVisible(false); - connect(watcher, &QFileSystemWatcher::fileChanged, this, &MainWindow::MeasurementsChanged); + connect(m_watcher, &QFileSystemWatcher::fileChanged, this, &MainWindow::MeasurementsChanged); - measurementsSyncTimer->setTimerType(Qt::VeryCoarseTimer); - connect(measurementsSyncTimer, &QTimer::timeout, this, [this]() + m_measurementsSyncTimer->setTimerType(Qt::VeryCoarseTimer); + connect(m_measurementsSyncTimer, &QTimer::timeout, this, [this]() { if (isActiveWindow()) { static bool asking = false; - if (not asking && mChanges && not mChangesAsked) + if (not asking && m_mChanges && not m_mChangesAsked) { asking = true; - mChangesAsked = true; - measurementsSyncTimer->stop(); + m_mChangesAsked = true; + m_measurementsSyncTimer->stop(); const auto answer = QMessageBox::question(this, tr("Measurements"), tr("Measurements were changed. Do you want to sync measurements now?"), @@ -350,7 +425,7 @@ MainWindow::MainWindow(QWidget *parent) { VValentinaSettings *settings = VAbstractValApplication::VApp()->ValentinaSettings(); QFont f = ui->plainTextEditPatternMessages->font(); - if (f.pointSize() < settings->GetDefMaxPatternMessageFontSize()) + if (f.pointSize() < VValentinaSettings::GetDefMaxPatternMessageFontSize()) { f.setPointSize(f.pointSize()+1); ui->plainTextEditPatternMessages->setFont(f); @@ -362,7 +437,7 @@ MainWindow::MainWindow(QWidget *parent) { VValentinaSettings *settings = VAbstractValApplication::VApp()->ValentinaSettings(); QFont f = ui->plainTextEditPatternMessages->font(); - if (f.pointSize() > settings->GetDefMinPatternMessageFontSize()) + if (f.pointSize() > VValentinaSettings::GetDefMinPatternMessageFontSize()) { f.setPointSize(f.pointSize()-1); ui->plainTextEditPatternMessages->setFont(f); @@ -392,9 +467,9 @@ MainWindow::MainWindow(QWidget *parent) } }); - if (VApplication::VApp()->IsGUIMode()) + if (VApplication::IsGUIMode()) { - QTimer::singleShot(1000, this, &MainWindow::SetDefaultGUILanguage); + QTimer::singleShot(1s, this, &MainWindow::SetDefaultGUILanguage); } } @@ -407,14 +482,14 @@ void MainWindow::AddPP(const QString &PPName) return; } - if (comboBoxDraws->count() == 0) + if (m_comboBoxDraws->count() == 0) { - sceneDraw->InitOrigins(); - sceneDetails->InitOrigins(); + m_sceneDraw->InitOrigins(); + m_sceneDetails->InitOrigins(); } - comboBoxDraws->blockSignals(true); - comboBoxDraws->addItem(PPName); + m_comboBoxDraws->blockSignals(true); + m_comboBoxDraws->addItem(PPName); pattern->ClearCalculationGObjects(); //Create single point @@ -423,7 +498,7 @@ void MainWindow::AddPP(const QString &PPName) const QPointF startPosition = StartPositionNewPP(); VToolBasePointInitData initData; - initData.scene = sceneDraw; + initData.scene = m_sceneDraw; initData.doc = doc; initData.data = pattern; initData.parse = Document::FullParse; @@ -439,16 +514,16 @@ void MainWindow::AddPP(const QString &PPName) SetEnableTool(true); SetEnableWidgets(true); - const qint32 index = comboBoxDraws->findText(PPName); + const qint32 index = m_comboBoxDraws->findText(PPName); if ( index != -1 ) { // -1 for not found - comboBoxDraws->setCurrentIndex(index); + m_comboBoxDraws->setCurrentIndex(index); } else { - comboBoxDraws->setCurrentIndex(0); + m_comboBoxDraws->setCurrentIndex(0); } - comboBoxDraws->blockSignals(false); + m_comboBoxDraws->blockSignals(false); // Show best for new PP VMainGraphicsView::NewSceneRect(ui->view->scene(), ui->view, spoint); @@ -460,74 +535,70 @@ void MainWindow::AddPP(const QString &PPName) } //--------------------------------------------------------------------------------------------------------------------- -QPointF MainWindow::StartPositionNewPP() const +auto MainWindow::StartPositionNewPP() const -> QPointF { const qreal originX = 30.0; const qreal originY = 40.0; const qreal margin = 40.0; - if (comboBoxDraws->count() > 1) + if (m_comboBoxDraws->count() > 1) { - const QRectF rect = sceneDraw->VisibleItemsBoundingRect(); + const QRectF rect = m_sceneDraw->VisibleItemsBoundingRect(); if (rect.width() <= rect.height()) { - return QPointF(rect.width()+margin, originY); - } - else - { - return QPointF(originX, rect.height()+margin); + return {rect.width()+margin, originY}; } + + return {originX, rect.height()+margin}; } - else - { - return QPointF(originX, originY); - } + + return {originX, originY}; } //--------------------------------------------------------------------------------------------------------------------- void MainWindow::InitScenes() { - sceneDraw = new VMainGraphicsScene(this); - currentScene = sceneDraw; + m_sceneDraw = new VMainGraphicsScene(this); + currentScene = m_sceneDraw; VAbstractValApplication::VApp()->setCurrentScene(¤tScene); - connect(this, &MainWindow::EnableItemMove, sceneDraw, &VMainGraphicsScene::EnableItemMove); - connect(this, &MainWindow::ItemsSelection, sceneDraw, &VMainGraphicsScene::ItemsSelection); + connect(this, &MainWindow::EnableItemMove, m_sceneDraw, &VMainGraphicsScene::EnableItemMove); + connect(this, &MainWindow::ItemsSelection, m_sceneDraw, &VMainGraphicsScene::ItemsSelection); - connect(this, &MainWindow::EnableLabelSelection, sceneDraw, &VMainGraphicsScene::ToggleLabelSelection); - connect(this, &MainWindow::EnablePointSelection, sceneDraw, &VMainGraphicsScene::TogglePointSelection); - connect(this, &MainWindow::EnableLineSelection, sceneDraw, &VMainGraphicsScene::ToggleLineSelection); - connect(this, &MainWindow::EnableArcSelection, sceneDraw, &VMainGraphicsScene::ToggleArcSelection); - connect(this, &MainWindow::EnableElArcSelection, sceneDraw, &VMainGraphicsScene::ToggleElArcSelection); - connect(this, &MainWindow::EnableSplineSelection, sceneDraw, &VMainGraphicsScene::ToggleSplineSelection); - connect(this, &MainWindow::EnableSplinePathSelection, sceneDraw, &VMainGraphicsScene::ToggleSplinePathSelection); + connect(this, &MainWindow::EnableLabelSelection, m_sceneDraw, &VMainGraphicsScene::ToggleLabelSelection); + connect(this, &MainWindow::EnablePointSelection, m_sceneDraw, &VMainGraphicsScene::TogglePointSelection); + connect(this, &MainWindow::EnableLineSelection, m_sceneDraw, &VMainGraphicsScene::ToggleLineSelection); + connect(this, &MainWindow::EnableArcSelection, m_sceneDraw, &VMainGraphicsScene::ToggleArcSelection); + connect(this, &MainWindow::EnableElArcSelection, m_sceneDraw, &VMainGraphicsScene::ToggleElArcSelection); + connect(this, &MainWindow::EnableSplineSelection, m_sceneDraw, &VMainGraphicsScene::ToggleSplineSelection); + connect(this, &MainWindow::EnableSplinePathSelection, m_sceneDraw, &VMainGraphicsScene::ToggleSplinePathSelection); - connect(this, &MainWindow::EnableLabelHover, sceneDraw, &VMainGraphicsScene::ToggleLabelHover); - connect(this, &MainWindow::EnablePointHover, sceneDraw, &VMainGraphicsScene::TogglePointHover); - connect(this, &MainWindow::EnableLineHover, sceneDraw, &VMainGraphicsScene::ToggleLineHover); - connect(this, &MainWindow::EnableArcHover, sceneDraw, &VMainGraphicsScene::ToggleArcHover); - connect(this, &MainWindow::EnableElArcHover, sceneDraw, &VMainGraphicsScene::ToggleElArcHover); - connect(this, &MainWindow::EnableSplineHover, sceneDraw, &VMainGraphicsScene::ToggleSplineHover); - connect(this, &MainWindow::EnableSplinePathHover, sceneDraw, &VMainGraphicsScene::ToggleSplinePathHover); + connect(this, &MainWindow::EnableLabelHover, m_sceneDraw, &VMainGraphicsScene::ToggleLabelHover); + connect(this, &MainWindow::EnablePointHover, m_sceneDraw, &VMainGraphicsScene::TogglePointHover); + connect(this, &MainWindow::EnableLineHover, m_sceneDraw, &VMainGraphicsScene::ToggleLineHover); + connect(this, &MainWindow::EnableArcHover, m_sceneDraw, &VMainGraphicsScene::ToggleArcHover); + connect(this, &MainWindow::EnableElArcHover, m_sceneDraw, &VMainGraphicsScene::ToggleElArcHover); + connect(this, &MainWindow::EnableSplineHover, m_sceneDraw, &VMainGraphicsScene::ToggleSplineHover); + connect(this, &MainWindow::EnableSplinePathHover, m_sceneDraw, &VMainGraphicsScene::ToggleSplinePathHover); - connect(sceneDraw, &VMainGraphicsScene::mouseMove, this, &MainWindow::MouseMove); - connect(sceneDraw, &VMainGraphicsScene::AddBackgroundImage, this, &MainWindow::PlaceBackgroundImage); + connect(m_sceneDraw, &VMainGraphicsScene::mouseMove, this, &MainWindow::MouseMove); + connect(m_sceneDraw, &VMainGraphicsScene::AddBackgroundImage, this, &MainWindow::PlaceBackgroundImage); - sceneDetails = new VMainGraphicsScene(this); - connect(this, &MainWindow::EnableItemMove, sceneDetails, &VMainGraphicsScene::EnableItemMove); + m_sceneDetails = new VMainGraphicsScene(this); + connect(this, &MainWindow::EnableItemMove, m_sceneDetails, &VMainGraphicsScene::EnableItemMove); - connect(this, &MainWindow::EnableNodeLabelSelection, sceneDetails, &VMainGraphicsScene::ToggleNodeLabelSelection); - connect(this, &MainWindow::EnableNodePointSelection, sceneDetails, &VMainGraphicsScene::ToggleNodePointSelection); - connect(this, &MainWindow::EnableDetailSelection, sceneDetails, &VMainGraphicsScene::ToggleDetailSelection); + connect(this, &MainWindow::EnableNodeLabelSelection, m_sceneDetails, &VMainGraphicsScene::ToggleNodeLabelSelection); + connect(this, &MainWindow::EnableNodePointSelection, m_sceneDetails, &VMainGraphicsScene::ToggleNodePointSelection); + connect(this, &MainWindow::EnableDetailSelection, m_sceneDetails, &VMainGraphicsScene::ToggleDetailSelection); - connect(this, &MainWindow::EnableNodeLabelHover, sceneDetails, &VMainGraphicsScene::ToggleNodeLabelHover); - connect(this, &MainWindow::EnableNodePointHover, sceneDetails, &VMainGraphicsScene::ToggleNodePointHover); - connect(this, &MainWindow::EnableDetailHover, sceneDetails, &VMainGraphicsScene::ToggleDetailHover); + connect(this, &MainWindow::EnableNodeLabelHover, m_sceneDetails, &VMainGraphicsScene::ToggleNodeLabelHover); + connect(this, &MainWindow::EnableNodePointHover, m_sceneDetails, &VMainGraphicsScene::ToggleNodePointHover); + connect(this, &MainWindow::EnableDetailHover, m_sceneDetails, &VMainGraphicsScene::ToggleDetailHover); - connect(sceneDetails, &VMainGraphicsScene::mouseMove, this, &MainWindow::MouseMove); + connect(m_sceneDetails, &VMainGraphicsScene::mouseMove, this, &MainWindow::MouseMove); ui->view->setScene(currentScene); - sceneDraw->setTransform(ui->view->transform()); - sceneDetails->setTransform(ui->view->transform()); + m_sceneDraw->setTransform(ui->view->transform()); + m_sceneDetails->setTransform(ui->view->transform()); connect(ui->view, &VMainGraphicsView::MouseRelease, this, [this](){EndVisualization(true);}); connect(ui->view, &VMainGraphicsView::ScaleChanged, this, &MainWindow::ScaleChanged); @@ -539,40 +610,40 @@ void MainWindow::InitScenes() } //--------------------------------------------------------------------------------------------------------------------- -bool MainWindow::LoadMeasurements(const QString &path) +auto MainWindow::LoadMeasurements(const QString &path) -> bool { - m = OpenMeasurementFile(path); + m_m = OpenMeasurementFile(path); - if (m->isNull()) + if (m_m->isNull()) { return false; } try { - VAbstractValApplication::VApp()->SetMeasurementsType(m->Type()); - if (m->Type() == MeasurementsType::Individual) + VAbstractValApplication::VApp()->SetMeasurementsType(m_m->Type()); + if (m_m->Type() == MeasurementsType::Individual) { - VAbstractValApplication::VApp()->SetCustomerName(m->Customer()); - VAbstractValApplication::VApp()->SetCustomerBirthDate(m->BirthDate()); - VAbstractValApplication::VApp()->SetCustomerEmail(m->Email()); + VAbstractValApplication::VApp()->SetCustomerName(m_m->Customer()); + VAbstractValApplication::VApp()->SetCustomerBirthDate(m_m->BirthDate()); + VAbstractValApplication::VApp()->SetCustomerEmail(m_m->Email()); } - else if (m->Type() == MeasurementsType::Multisize) + else if (m_m->Type() == MeasurementsType::Multisize) { auto DimensionBase = [](qreal current, qreal tableBase) { return not VFuzzyComparePossibleNulls(current, -1) ? current : tableBase; }; - m_currentDimensionA = DimensionBase(doc->GetDimensionAValue(), m->DimensionABase()); - m_currentDimensionB = DimensionBase(doc->GetDimensionBValue(), m->DimensionBBase()); - m_currentDimensionC = DimensionBase(doc->GetDimensionCValue(), m->DimensionCBase()); + m_currentDimensionA = DimensionBase(doc->GetDimensionAValue(), m_m->DimensionABase()); + m_currentDimensionB = DimensionBase(doc->GetDimensionBValue(), m_m->DimensionBBase()); + m_currentDimensionC = DimensionBase(doc->GetDimensionCValue(), m_m->DimensionCBase()); } ToolBarOption(); SetDimensionBases(); pattern->ClearVariables({VarType::Measurement, VarType::MeasurementSeparator}); - m->StoreNames(false); - m->ReadMeasurements(m_currentDimensionA, m_currentDimensionB, m_currentDimensionC); + m_m->StoreNames(false); + m_m->ReadMeasurements(m_currentDimensionA, m_currentDimensionB, m_currentDimensionC); } catch (VExceptionEmptyParameter &e) { @@ -591,7 +662,7 @@ bool MainWindow::LoadMeasurements(const QString &path) } //--------------------------------------------------------------------------------------------------------------------- -bool MainWindow::UpdateMeasurements(const QString &path, qreal baseA, qreal baseB, qreal baseC) +auto MainWindow::UpdateMeasurements(const QString &path, qreal baseA, qreal baseB, qreal baseC) -> bool { return UpdateMeasurements(OpenMeasurementFile(path), baseA, baseB, baseC); } @@ -600,14 +671,14 @@ bool MainWindow::UpdateMeasurements(const QString &path, qreal baseA, qreal base auto MainWindow::UpdateMeasurements(const QSharedPointer &mFile, qreal baseA, qreal baseB, qreal baseC) -> bool { - m = mFile; + m_m = mFile; - if (m->isNull()) + if (m_m->isNull()) { return false; } - if (VAbstractValApplication::VApp()->GetMeasurementsType() != m->Type()) + if (VAbstractValApplication::VApp()->GetMeasurementsType() != m_m->Type()) { qCCritical(vMainWindow, "%s", qUtf8Printable(tr("Measurement files types have not match."))); if (not VApplication::IsGUIMode()) @@ -619,64 +690,7 @@ auto MainWindow::UpdateMeasurements(const QSharedPointer &mFile, try { - pattern->ClearVariables({VarType::Measurement, VarType::MeasurementSeparator}); - - if (not m->Dimensions().isEmpty()) - { - const QList dimensions = m->Dimensions().values(); - - auto InitDimensionLabel = [this, dimensions](const MeasurementDimension_p& dimension, - QPointer &name, QPointer &control) - { - if (dimension.isNull()) - { - return; - } - - if (name == nullptr) - { - name = new QLabel(dimension->Name()+QChar(':')); - } - else - { - name->setText(dimension->Name()+QChar(':')); - } - name->setToolTip(VAbstartMeasurementDimension::DimensionToolTip(dimension, m->IsFullCircumference())); - - if (control == nullptr) - { - control = new QComboBox; - control->setSizeAdjustPolicy(QComboBox::AdjustToContents); - } - }; - - MeasurementDimension_p dimension = dimensions.at(0); - InitDimensionLabel(dimension, dimensionALabel, dimensionA); - InitDimensionGradation(0, dimension, dimensionA); - - if (dimensions.size() > 1) - { - dimension = dimensions.at(1); - InitDimensionLabel(dimension, dimensionBLabel, dimensionB); - InitDimensionGradation(1, dimension, dimensionB); - - if (dimensions.size() > 2) - { - dimension = dimensions.at(2); - InitDimensionLabel(dimension, dimensionCLabel, dimensionC); - InitDimensionGradation(2, dimension, dimensionC); - } - } - } - - m->StoreNames(false); - m->ReadMeasurements(baseA, baseB, baseC); - if (m->Type() == MeasurementsType::Individual) - { - VAbstractValApplication::VApp()->SetCustomerName(m->Customer()); - VAbstractValApplication::VApp()->SetCustomerBirthDate(m->BirthDate()); - VAbstractValApplication::VApp()->SetCustomerEmail(m->Email()); - } + ReadMeasurements(baseA, baseB, baseC); } catch (VExceptionEmptyParameter &e) { @@ -692,6 +706,69 @@ auto MainWindow::UpdateMeasurements(const QSharedPointer &mFile, return true; } +//--------------------------------------------------------------------------------------------------------------------- +void MainWindow::ReadMeasurements(qreal baseA, qreal baseB, qreal baseC) +{ + pattern->ClearVariables({VarType::Measurement, VarType::MeasurementSeparator}); + + if (not m_m->Dimensions().isEmpty()) + { + const QList dimensions = m_m->Dimensions().values(); + + auto InitDimensionLabel = [this, dimensions](const MeasurementDimension_p& dimension, + QPointer &name, QPointer &control) + { + if (dimension.isNull()) + { + return; + } + + if (name == nullptr) + { + name = new QLabel(dimension->Name()+QChar(':')); + } + else + { + name->setText(dimension->Name()+QChar(':')); + } + name->setToolTip(VAbstartMeasurementDimension::DimensionToolTip(dimension, m_m->IsFullCircumference())); + + if (control == nullptr) + { + control = new QComboBox; + control->setSizeAdjustPolicy(QComboBox::AdjustToContents); + } + }; + + MeasurementDimension_p dimension = dimensions.at(0); + InitDimensionLabel(dimension, m_dimensionALabel, m_dimensionA); + InitDimensionGradation(0, dimension, m_dimensionA); + + if (dimensions.size() > 1) + { + dimension = dimensions.at(1); + InitDimensionLabel(dimension, m_dimensionBLabel, m_dimensionB); + InitDimensionGradation(1, dimension, m_dimensionB); + + if (dimensions.size() > 2) + { + dimension = dimensions.at(2); + InitDimensionLabel(dimension, m_dimensionCLabel, m_dimensionC); + InitDimensionGradation(2, dimension, m_dimensionC); + } + } + } + + m_m->StoreNames(false); + m_m->ReadMeasurements(baseA, baseB, baseC); + if (m_m->Type() == MeasurementsType::Individual) + { + VAbstractValApplication::VApp()->SetCustomerName(m_m->Customer()); + VAbstractValApplication::VApp()->SetCustomerBirthDate(m_m->BirthDate()); + VAbstractValApplication::VApp()->SetCustomerEmail(m_m->Email()); + } +} + //--------------------------------------------------------------------------------------------------------------------- /** * @brief SetToolButton set tool and show dialog. @@ -709,9 +786,9 @@ void MainWindow::SetToolButton(bool checked, Tool t, const QString &cursor, cons { CancelTool(); emit EnableItemMove(false); - currentTool = lastUsedTool = t; + m_currentTool = m_lastUsedTool = t; auto cursorResource = cursor; - if (qApp->devicePixelRatio() >= 2) + if (qApp->devicePixelRatio() >= 2) // NOLINT(cppcoreguidelines-pro-type-static-cast-downcast) { // Try to load HiDPI versions of the cursors if availible auto cursorHidpiResource = QString(cursor).replace(QLatin1String(".png"), QLatin1String("@2x.png")); @@ -726,7 +803,7 @@ void MainWindow::SetToolButton(bool checked, Tool t, const QString &cursor, cons ui->view->setCurrentCursorShape(); // Hack to fix problem with a cursor m_statusLabel->setText(toolTip); ui->view->setShowToolOptions(false); - dialogTool = new Dialog(pattern, 0, this); + m_dialogTool = new Dialog(pattern, 0, this); // This check helps to find missed tools in the switch Q_STATIC_ASSERT_X(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 59, "Check if need to extend."); @@ -734,40 +811,40 @@ void MainWindow::SetToolButton(bool checked, Tool t, const QString &cursor, cons switch(t) { case Tool::Midpoint: - dialogTool->Build(t); + m_dialogTool->Build(t); break; case Tool::PiecePath: case Tool::Pin: case Tool::InsertNode: case Tool::PlaceLabel: - dialogTool->SetPiecesList(doc->GetActivePPPieces()); + m_dialogTool->SetPiecesList(doc->GetActivePPPieces()); break; case Tool::Rotation: case Tool::Move: case Tool::FlippingByAxis: case Tool::FlippingByLine: case Tool::Group: - dialogTool->SetGroupCategories(doc->GetGroupCategories()); + m_dialogTool->SetGroupCategories(doc->GetGroupCategories()); break; case Tool::Piece: - dialogTool->SetPatternDoc(doc); + m_dialogTool->SetPatternDoc(doc); break; default: break; } - VMainGraphicsScene *scene = qobject_cast(currentScene); + auto *scene = qobject_cast(currentScene); SCASSERT(scene != nullptr) - connect(scene, &VMainGraphicsScene::ChoosedObject, dialogTool.data(), &DialogTool::ChosenObject); - connect(scene, &VMainGraphicsScene::SelectedObject, dialogTool.data(), &DialogTool::SelectedObject); - connect(dialogTool.data(), &DialogTool::DialogClosed, this, closeDialogSlot); - connect(dialogTool.data(), &DialogTool::ToolTip, this, &MainWindow::ShowToolTip); + connect(scene, &VMainGraphicsScene::ChoosedObject, m_dialogTool.data(), &DialogTool::ChosenObject); + connect(scene, &VMainGraphicsScene::SelectedObject, m_dialogTool.data(), &DialogTool::SelectedObject); + connect(m_dialogTool.data(), &DialogTool::DialogClosed, this, closeDialogSlot); + connect(m_dialogTool.data(), &DialogTool::ToolTip, this, &MainWindow::ShowToolTip); emit ui->view->itemClicked(nullptr); } else { - if (QToolButton *tButton = qobject_cast< QToolButton * >(this->sender())) + if (auto *tButton = qobject_cast< QToolButton * >(this->sender())) { tButton->setChecked(true); } @@ -792,11 +869,11 @@ void MainWindow::SetToolButtonWithApply(bool checked, Tool t, const QString &cur { SetToolButton(checked, t, cursor, toolTip, closeDialogSlot); - connect(dialogTool.data(), &DialogTool::DialogApplied, this, applyDialogSlot); + connect(m_dialogTool.data(), &DialogTool::DialogApplied, this, applyDialogSlot); } else { - if (QToolButton *tButton = qobject_cast< QToolButton * >(this->sender())) + if (auto *tButton = qobject_cast< QToolButton * >(this->sender())) { tButton->setChecked(true); } @@ -810,13 +887,13 @@ void MainWindow::SetToolButtonWithApply(bool checked, Tool t, const QString &cur template void MainWindow::ClosedDialog(int result) { - SCASSERT(not dialogTool.isNull()) + SCASSERT(not m_dialogTool.isNull()) if (result == QDialog::Accepted) { - VMainGraphicsScene *scene = qobject_cast(currentScene); + auto *scene = qobject_cast(currentScene); SCASSERT(scene != nullptr) - QGraphicsItem *tool = dynamic_cast(DrawTool::Create(dialogTool, scene, doc, pattern)); + auto *tool = dynamic_cast(DrawTool::Create(m_dialogTool, scene, doc, pattern)); // Do not check for nullptr! See issue #719. emit ui->view->itemClicked(tool); } @@ -831,14 +908,14 @@ void MainWindow::ClosedDialog(int result) template void MainWindow::ClosedDialogWithApply(int result, VMainGraphicsScene *scene) { - SCASSERT(not dialogTool.isNull()) + SCASSERT(not m_dialogTool.isNull()) if (result == QDialog::Accepted) { ApplyDialog(scene); } // If before Cancel was used Apply we have an item - DrawTool *vtool = qobject_cast(dialogTool->GetAssociatedTool());// Don't check for nullptr here - if (dialogTool->GetAssociatedTool() != nullptr) + auto *vtool = qobject_cast(m_dialogTool->GetAssociatedTool());// Don't check for nullptr here + if (m_dialogTool->GetAssociatedTool() != nullptr) { SCASSERT(vtool != nullptr) vtool->DialogLinkDestroy(); @@ -854,9 +931,9 @@ void MainWindow::ClosedDialogWithApply(int result, VMainGraphicsScene *scene) if (doc->getCursor() > 0) { doc->LiteParseTree(Document::LiteParse); - if (dialogHistory) + if (m_dialogHistory) { - dialogHistory->UpdateHistory(); + m_dialogHistory->UpdateHistory(); } } } @@ -868,18 +945,18 @@ void MainWindow::ClosedDialogWithApply(int result, VMainGraphicsScene *scene) template void MainWindow::ApplyDialog(VMainGraphicsScene *scene) { - SCASSERT(not dialogTool.isNull()) + SCASSERT(not m_dialogTool.isNull()) // Only create tool if not already created with apply - if (dialogTool->GetAssociatedTool() == nullptr) + if (m_dialogTool->GetAssociatedTool() == nullptr) { SCASSERT(scene != nullptr) - dialogTool->SetAssociatedTool(DrawTool::Create(dialogTool, scene, doc, pattern)); + m_dialogTool->SetAssociatedTool(DrawTool::Create(m_dialogTool, scene, doc, pattern)); } else { // Or update associated tool with data - DrawTool * vtool = qobject_cast(dialogTool->GetAssociatedTool()); + auto * vtool = qobject_cast(m_dialogTool->GetAssociatedTool()); SCASSERT(vtool != nullptr) vtool->FullUpdateFromGuiApply(); } @@ -889,28 +966,28 @@ void MainWindow::ApplyDialog(VMainGraphicsScene *scene) template void MainWindow::ClosedDrawDialogWithApply(int result) { - ClosedDialogWithApply(result, sceneDraw); + ClosedDialogWithApply(result, m_sceneDraw); } //--------------------------------------------------------------------------------------------------------------------- template void MainWindow::ApplyDrawDialog() { - ApplyDialog(sceneDraw); + ApplyDialog(m_sceneDraw); } //--------------------------------------------------------------------------------------------------------------------- template void MainWindow::ClosedDetailsDialogWithApply(int result) { - ClosedDialogWithApply(result, sceneDetails); + ClosedDialogWithApply(result, m_sceneDetails); } //--------------------------------------------------------------------------------------------------------------------- template void MainWindow::ApplyDetailsDialog() { - ApplyDialog(sceneDetails); + ApplyDialog(m_sceneDetails); } //--------------------------------------------------------------------------------------------------------------------- @@ -1265,13 +1342,13 @@ void MainWindow::ToolDuplicateDetail(bool checked) //--------------------------------------------------------------------------------------------------------------------- void MainWindow::ClosedDialogDuplicateDetail(int result) { - SCASSERT(not dialogTool.isNull()) + SCASSERT(not m_dialogTool.isNull()) if (result == QDialog::Accepted) { - VMainGraphicsScene *scene = qobject_cast(currentScene); + auto *scene = qobject_cast(currentScene); SCASSERT(scene != nullptr) - QGraphicsItem *tool = dynamic_cast(VToolSeamAllowance::Duplicate(dialogTool, scene, doc)); + auto *tool = dynamic_cast(VToolSeamAllowance::Duplicate(m_dialogTool, scene, doc)); // Do not check for nullptr! See issue #719. emit ui->view->itemClicked(tool); } @@ -1308,7 +1385,8 @@ void MainWindow::ToolFlippingByLine(bool checked) const QString tooltip = tr("Select one or more objects, hold %1 - for multiple selection, " "%2 - confirm selection") .arg(VModifierKey::Control(), VModifierKey::EnterKey()); - SetToolButtonWithApply(checked, Tool::FlippingByLine, ":/cursor/flipping_line_cursor.png", + SetToolButtonWithApply(checked, Tool::FlippingByLine, + QStringLiteral(":/cursor/flipping_line_cursor.png"), tooltip, &MainWindow::ClosedDrawDialogWithApply, &MainWindow::ApplyDrawDialog); } @@ -1320,7 +1398,8 @@ void MainWindow::ToolFlippingByAxis(bool checked) const QString tooltip = tr("Select one or more objects, hold %1 - for multiple selection, " "%2 - confirm selection") .arg(VModifierKey::Control(), VModifierKey::EnterKey()); - SetToolButtonWithApply(checked, Tool::FlippingByAxis, ":/cursor/flipping_axis_cursor.png", + SetToolButtonWithApply(checked, Tool::FlippingByAxis, + QStringLiteral(":/cursor/flipping_axis_cursor.png"), tooltip, &MainWindow::ClosedDrawDialogWithApply, &MainWindow::ApplyDrawDialog); } @@ -1332,7 +1411,7 @@ void MainWindow::ToolMove(bool checked) const QString tooltip = tr("Select one or more objects, hold %1 - for multiple selection, " "%2 - confirm selection") .arg(VModifierKey::Control(), VModifierKey::EnterKey()); - SetToolButtonWithApply(checked, Tool::Move, ":/cursor/move_cursor.png", tooltip, + SetToolButtonWithApply(checked, Tool::Move, QStringLiteral(":/cursor/move_cursor.png"), tooltip, &MainWindow::ClosedDrawDialogWithApply, &MainWindow::ApplyDrawDialog); } @@ -1340,17 +1419,17 @@ void MainWindow::ToolMove(bool checked) //--------------------------------------------------------------------------------------------------------------------- void MainWindow::ClosedDialogGroup(int result) { - SCASSERT(dialogTool != nullptr) + SCASSERT(m_dialogTool != nullptr) if (result == QDialog::Accepted) { - const QPointer dialog = qobject_cast(dialogTool); + const QPointer dialog = qobject_cast(m_dialogTool); SCASSERT(not dialog.isNull()) const QDomElement group = doc->CreateGroup(pattern->getNextId(), dialog->GetName(), dialog->GetTags(), dialog->GetGroup()); if (not group.isNull()) { - AddGroup *addGroup = new AddGroup(group, doc); - connect(addGroup, &AddGroup::UpdateGroups, groupsWidget, &VWidgetGroups::UpdateGroups); + auto *addGroup = new AddGroup(group, doc); + connect(addGroup, &AddGroup::UpdateGroups, m_groupsWidget, &VWidgetGroups::UpdateGroups); VAbstractApplication::VApp()->getUndoStack()->push(addGroup); } } @@ -1360,10 +1439,10 @@ void MainWindow::ClosedDialogGroup(int result) //--------------------------------------------------------------------------------------------------------------------- void MainWindow::ClosedDialogPiecePath(int result) { - SCASSERT(dialogTool != nullptr); + SCASSERT(m_dialogTool != nullptr); if (result == QDialog::Accepted) { - VToolPiecePath::Create(dialogTool, sceneDetails, doc, pattern); + VToolPiecePath::Create(m_dialogTool, m_sceneDetails, doc, pattern); } ArrowTool(true); doc->LiteParseTree(Document::LiteParse); @@ -1372,10 +1451,10 @@ void MainWindow::ClosedDialogPiecePath(int result) //--------------------------------------------------------------------------------------------------------------------- void MainWindow::ClosedDialogPin(int result) { - SCASSERT(dialogTool != nullptr); + SCASSERT(m_dialogTool != nullptr); if (result == QDialog::Accepted) { - VToolPin::Create(dialogTool, doc, pattern); + VToolPin::Create(m_dialogTool, doc, pattern); } ArrowTool(true); doc->LiteParseTree(Document::LiteParse); @@ -1384,10 +1463,10 @@ void MainWindow::ClosedDialogPin(int result) //--------------------------------------------------------------------------------------------------------------------- void MainWindow::ClosedDialogPlaceLabel(int result) { - SCASSERT(dialogTool != nullptr); + SCASSERT(m_dialogTool != nullptr); if (result == QDialog::Accepted) { - VToolPlaceLabel::Create(dialogTool, doc, pattern); + VToolPlaceLabel::Create(m_dialogTool, doc, pattern); } ArrowTool(true); doc->LiteParseTree(Document::LiteParse); @@ -1396,12 +1475,12 @@ void MainWindow::ClosedDialogPlaceLabel(int result) //--------------------------------------------------------------------------------------------------------------------- void MainWindow::ClosedDialogInsertNode(int result) { - SCASSERT(dialogTool != nullptr); + SCASSERT(m_dialogTool != nullptr); if (result == QDialog::Accepted) { - const QPointer dTool = qobject_cast(dialogTool); + const QPointer dTool = qobject_cast(m_dialogTool); SCASSERT(not dTool.isNull()) - VToolSeamAllowance::InsertNodes(dTool->GetNodes(), dTool->GetPieceId(), sceneDetails, pattern, doc); + VToolSeamAllowance::InsertNodes(dTool->GetNodes(), dTool->GetPieceId(), m_sceneDetails, pattern, doc); } ArrowTool(true); doc->LiteParseTree(Document::LiteParse); @@ -1410,7 +1489,7 @@ void MainWindow::ClosedDialogInsertNode(int result) //--------------------------------------------------------------------------------------------------------------------- void MainWindow::ZoomFitBestCurrent() { - if(drawMode) + if(m_drawMode) { const QRectF rect = doc->ActiveDrawBoundingRect(); if (rect.isEmpty()) @@ -1486,7 +1565,7 @@ void MainWindow::RemoveBackgroundImage(const QUuid &id) void MainWindow::ToolCutArc(bool checked) { ToolSelectArc(); - SetToolButtonWithApply(checked, Tool::CutArc, ":/cursor/arc_cut_cursor.png", + SetToolButtonWithApply(checked, Tool::CutArc, QStringLiteral(":/cursor/arc_cut_cursor.png"), tr("Select arc"), &MainWindow::ClosedDrawDialogWithApply, &MainWindow::ApplyDrawDialog); } @@ -1496,7 +1575,7 @@ void MainWindow::ToolLineIntersectAxis(bool checked) { ToolSelectPointByRelease(); SetToolButtonWithApply(checked, Tool::LineIntersectAxis, - ":/cursor/line_intersect_axis_cursor.png", + QStringLiteral(":/cursor/line_intersect_axis_cursor.png"), tr("Select first point of line"), &MainWindow::ClosedDrawDialogWithApply, &MainWindow::ApplyDrawDialog); @@ -1507,7 +1586,7 @@ void MainWindow::ToolCurveIntersectAxis(bool checked) { ToolSelectAllDrawObjects(); SetToolButtonWithApply(checked, Tool::CurveIntersectAxis, - ":/cursor/curve_intersect_axis_cursor.png", + QStringLiteral(":/cursor/curve_intersect_axis_cursor.png"), tr("Select curve"), &MainWindow::ClosedDrawDialogWithApply, &MainWindow::ApplyDrawDialog); @@ -1519,7 +1598,7 @@ void MainWindow::ToolArcIntersectAxis(bool checked) ToolSelectAllDrawObjects(); // Reuse ToolCurveIntersectAxis but with different cursor and tool tip SetToolButtonWithApply(checked, Tool::ArcIntersectAxis, - ":/cursor/arc_intersect_axis_cursor.png", + QStringLiteral(":/cursor/arc_intersect_axis_cursor.png"), tr("Select arc"), &MainWindow::ClosedDrawDialogWithApply, &MainWindow::ApplyDrawDialog); @@ -1530,7 +1609,7 @@ void MainWindow::ToolPointOfIntersectionArcs(bool checked) { ToolSelectArc(); SetToolButtonWithApply(checked, Tool::PointOfIntersectionArcs, - "://cursor/point_of_intersection_arcs.png", + QStringLiteral("://cursor/point_of_intersection_arcs.png"), tr("Select first an arc"), &MainWindow::ClosedDrawDialogWithApply, &MainWindow::ApplyDrawDialog); @@ -1540,44 +1619,40 @@ void MainWindow::ToolPointOfIntersectionArcs(bool checked) void MainWindow::ToolPointOfIntersectionCircles(bool checked) { ToolSelectPointByRelease(); - SetToolButtonWithApply(checked, Tool::PointOfIntersectionCircles, - "://cursor/point_of_intersection_circles.png", - tr("Select first circle center"), - &MainWindow::ClosedDrawDialogWithApply, - &MainWindow::ApplyDrawDialog); + SetToolButtonWithApply( + checked, Tool::PointOfIntersectionCircles, QStringLiteral("://cursor/point_of_intersection_circles.png"), + tr("Select first circle center"), &MainWindow::ClosedDrawDialogWithApply, + &MainWindow::ApplyDrawDialog); } //--------------------------------------------------------------------------------------------------------------------- void MainWindow::ToolPointOfIntersectionCurves(bool checked) { ToolSelectCurve(); - SetToolButtonWithApply(checked, Tool::PointOfIntersectionCurves, - "://cursor/intersection_curves_cursor.png", - tr("Select first curve"), - &MainWindow::ClosedDrawDialogWithApply, - &MainWindow::ApplyDrawDialog); + SetToolButtonWithApply( + checked, Tool::PointOfIntersectionCurves, QStringLiteral("://cursor/intersection_curves_cursor.png"), + tr("Select first curve"), &MainWindow::ClosedDrawDialogWithApply, + &MainWindow::ApplyDrawDialog); } //--------------------------------------------------------------------------------------------------------------------- void MainWindow::ToolPointFromCircleAndTangent(bool checked) { ToolSelectPointByRelease(); - SetToolButtonWithApply(checked, Tool::PointFromCircleAndTangent, - "://cursor/point_from_circle_and_tangent_cursor.png", - tr("Select point on tangent"), - &MainWindow::ClosedDrawDialogWithApply, - &MainWindow::ApplyDrawDialog); + SetToolButtonWithApply( + checked, Tool::PointFromCircleAndTangent, QStringLiteral("://cursor/point_from_circle_and_tangent_cursor.png"), + tr("Select point on tangent"), &MainWindow::ClosedDrawDialogWithApply, + &MainWindow::ApplyDrawDialog); } //--------------------------------------------------------------------------------------------------------------------- void MainWindow::ToolPointFromArcAndTangent(bool checked) { ToolSelectPointArc(); - SetToolButtonWithApply(checked, Tool::PointFromArcAndTangent, - "://cursor/point_from_arc_and_tangent_cursor.png", - tr("Select point on tangent"), - &MainWindow::ClosedDrawDialogWithApply, - &MainWindow::ApplyDrawDialog); + SetToolButtonWithApply( + checked, Tool::PointFromArcAndTangent, QStringLiteral("://cursor/point_from_arc_and_tangent_cursor.png"), + tr("Select point on tangent"), &MainWindow::ClosedDrawDialogWithApply, + &MainWindow::ApplyDrawDialog); } //--------------------------------------------------------------------------------------------------------------------- @@ -1585,7 +1660,7 @@ void MainWindow::ToolArcWithLength(bool checked) { ToolSelectPointByRelease(); SetToolButtonWithApply(checked, Tool::ArcWithLength, - "://cursor/arc_with_length_cursor.png", + QStringLiteral("://cursor/arc_with_length_cursor.png"), tr("Select point of the center of the arc"), &MainWindow::ClosedDrawDialogWithApply, &MainWindow::ApplyDrawDialog); @@ -1595,10 +1670,9 @@ void MainWindow::ToolArcWithLength(bool checked) void MainWindow::ToolTrueDarts(bool checked) { ToolSelectPointByRelease(); - SetToolButtonWithApply(checked, Tool::TrueDarts, - "://cursor/true_darts_cursor.png", - tr("Select the first base line point"), - &MainWindow::ClosedDrawDialogWithApply, + SetToolButtonWithApply(checked, Tool::TrueDarts, QStringLiteral("://cursor/true_darts_cursor.png"), + tr("Select the first base line point"), + &MainWindow::ClosedDrawDialogWithApply, &MainWindow::ApplyDrawDialog); } @@ -1609,7 +1683,7 @@ void MainWindow::ToolInsertNode(bool checked) const QString tooltip = tr("Select one or more objects, hold %1 - for multiple selection, " "%2 - finish creation") .arg(VModifierKey::Control(), VModifierKey::EnterKey()); - SetToolButton(checked, Tool::InsertNode, "://cursor/insert_node_cursor.png", + SetToolButton(checked, Tool::InsertNode, QStringLiteral("://cursor/insert_node_cursor.png"), tooltip, &MainWindow::ClosedDialogInsertNode); } @@ -1630,7 +1704,7 @@ void MainWindow::ShowToolTip(const QString &toolTip) */ void MainWindow::UpdateVisibilityGroups() { - groupsWidget->UpdateGroups(); + m_groupsWidget->UpdateGroups(); } //--------------------------------------------------------------------------------------------------------------------- @@ -1639,7 +1713,7 @@ void MainWindow::UpdateVisibilityGroups() */ void MainWindow::UpdateDetailsList() { - detailsWidget->UpdateList(); + m_detailsWidget->UpdateList(); } //--------------------------------------------------------------------------------------------------------------------- @@ -1659,7 +1733,7 @@ void MainWindow::showEvent( QShowEvent *event ) m_taskbarButton->setWindow(windowHandle()); #endif - if (isInitialized) + if (m_isInitialized) { return; } @@ -1667,7 +1741,7 @@ void MainWindow::showEvent( QShowEvent *event ) MinimumScrollBar(); - isInitialized = true;//first show windows are held + m_isInitialized = true;//first show windows are held } //--------------------------------------------------------------------------------------------------------------------- @@ -1680,7 +1754,7 @@ void MainWindow::changeEvent(QEvent *event) undoAction->setText(tr("&Undo")); redoAction->setText(tr("&Redo")); statusBar()->showMessage(tr("Changes applied."), 5000); - patternPieceLabel->setText(tr("Pattern Piece:")); + m_patternPieceLabel->setText(tr("Pattern Piece:")); if (VApplication::VApp()->GetDrawMode() == Draw::Calculation) { @@ -1696,7 +1770,7 @@ void MainWindow::changeEvent(QEvent *event) ToolBarOption(); UpdateWindowTitle(); - emit sceneDetails->LanguageChanged(); + emit m_sceneDetails->LanguageChanged(); } // remember to call base class implementation QMainWindow::changeEvent(event); @@ -1765,8 +1839,7 @@ void MainWindow::PrepareSceneList(PreviewQuatilty quality) ui->listWidget->clear(); for (int i=1; i<=m_layoutSettings->LayoutScenes().size(); ++i) { - QListWidgetItem *item = new QListWidgetItem(ScenePreview(i-1, ui->listWidget->iconSize(), quality), - QString::number(i)); + auto *item = new QListWidgetItem(ScenePreview(i-1, ui->listWidget->iconSize(), quality), QString::number(i)); ui->listWidget->addItem(item); } @@ -1804,7 +1877,7 @@ void MainWindow::ExportToCSVData(const QString &fileName, bool withHeader, int m //Sorting QHash by id for (i = increments.constBegin(); i != increments.constEnd(); ++i) { - const QSharedPointer incr = i.value(); + const QSharedPointer &incr = i.value(); if (incr->IsPreviewCalculation() == save) { map.insert(incr->GetIndex(), i.key()); @@ -1855,22 +1928,22 @@ void MainWindow::ToolBarStyle(QToolBar *bar) const //--------------------------------------------------------------------------------------------------------------------- void MainWindow::ScaleChanged(qreal scale) { - if (not doubleSpinBoxScale.isNull()) + if (not m_doubleSpinBoxScale.isNull()) { - doubleSpinBoxScale->blockSignals(true); - doubleSpinBoxScale->setMaximum(qFloor(VMainGraphicsView::MaxScale()*1000)/10.0); - doubleSpinBoxScale->setMinimum(qFloor(VMainGraphicsView::MinScale()*1000)/10.0); - doubleSpinBoxScale->setValue(qFloor(scale*1000)/10.0); - doubleSpinBoxScale->setSingleStep(1); - doubleSpinBoxScale->blockSignals(false); + m_doubleSpinBoxScale->blockSignals(true); + m_doubleSpinBoxScale->setMaximum(qFloor(VMainGraphicsView::MaxScale()*1000)/10.0); + m_doubleSpinBoxScale->setMinimum(qFloor(VMainGraphicsView::MinScale()*1000)/10.0); + m_doubleSpinBoxScale->setValue(qFloor(scale*1000)/10.0); + m_doubleSpinBoxScale->setSingleStep(1); + m_doubleSpinBoxScale->blockSignals(false); } } //--------------------------------------------------------------------------------------------------------------------- void MainWindow::LoadIndividual() { - const QString filter = tr("Individual measurements") + QLatin1String(" (*.vit);;") + tr("Multisize measurements") + - QLatin1String(" (*.vst)"); + const QString filter = tr("Individual measurements") + QStringLiteral(" (*.vit);;") + tr("Multisize measurements") + + QStringLiteral(" (*.vst)"); //Use standard path to individual measurements const QString path = VAbstractValApplication::VApp()->ValentinaSettings()->GetPathIndividualMeasurements(); @@ -1890,11 +1963,11 @@ void MainWindow::LoadIndividual() { if (not doc->MPath().isEmpty()) { - watcher->removePath(AbsoluteMPath(VAbstractValApplication::VApp()->GetPatternPath(), doc->MPath())); + m_watcher->removePath(AbsoluteMPath(VAbstractValApplication::VApp()->GetPatternPath(), doc->MPath())); } ui->actionUnloadMeasurements->setEnabled(true); doc->SetMPath(RelativeMPath(VAbstractValApplication::VApp()->GetPatternPath(), mPath)); - watcher->addPath(mPath); + m_watcher->addPath(mPath); PatternChangesWereSaved(false); ui->actionEditCurrent->setEnabled(true); statusBar()->showMessage(tr("Measurements loaded"), 5000); @@ -1914,8 +1987,8 @@ void MainWindow::LoadIndividual() //--------------------------------------------------------------------------------------------------------------------- void MainWindow::LoadMultisize() { - const QString filter = tr("Multisize measurements") + QLatin1String(" (*.vst);;") + tr("Individual measurements") + - QLatin1String("(*.vit)"); + const QString filter = tr("Multisize measurements") + QStringLiteral(" (*.vst);;") + tr("Individual measurements") + + QStringLiteral("(*.vit)"); //Use standard path to multisize measurements QString path = VAbstractValApplication::VApp()->ValentinaSettings()->GetPathMultisizeMeasurements(); path = VCommonSettings::PrepareMultisizeTables(path); @@ -1928,11 +2001,11 @@ void MainWindow::LoadMultisize() { if (not doc->MPath().isEmpty()) { - watcher->removePath(AbsoluteMPath(VAbstractValApplication::VApp()->GetPatternPath(), doc->MPath())); + m_watcher->removePath(AbsoluteMPath(VAbstractValApplication::VApp()->GetPatternPath(), doc->MPath())); } ui->actionUnloadMeasurements->setEnabled(true); doc->SetMPath(RelativeMPath(VAbstractValApplication::VApp()->GetPatternPath(), mPath)); - watcher->addPath(mPath); + m_watcher->addPath(mPath); PatternChangesWereSaved(false); ui->actionEditCurrent->setEnabled(true); statusBar()->showMessage(tr("Measurements loaded"), 5000); @@ -1954,12 +2027,12 @@ void MainWindow::UnloadMeasurements() if (doc->ListMeasurements().isEmpty()) { - watcher->removePath(AbsoluteMPath(VAbstractValApplication::VApp()->GetPatternPath(), doc->MPath())); + m_watcher->removePath(AbsoluteMPath(VAbstractValApplication::VApp()->GetPatternPath(), doc->MPath())); const MeasurementsType oldType = VAbstractValApplication::VApp()->GetMeasurementsType(); VAbstractValApplication::VApp()->SetMeasurementsType(MeasurementsType::Unknown); - m.clear(); + m_m.clear(); VAbstractValApplication::VApp()->SetDimensionHeight(0); VAbstractValApplication::VApp()->SetDimensionSize(0); @@ -2013,36 +2086,36 @@ void MainWindow::ShowMeasurements() QStringList arguments; arguments.append(absoluteMPath); - arguments.append("-u"); + arguments.append(QStringLiteral("-u")); arguments.append(UnitsToStr(VAbstractValApplication::VApp()->patternUnits())); if (VAbstractValApplication::VApp()->GetMeasurementsType() == MeasurementsType::Multisize) { if (m_currentDimensionA > 0) { - arguments.append("-a"); + arguments.append(QStringLiteral("-a")); arguments.append(QString::number(m_currentDimensionA)); } if (m_currentDimensionB > 0) { - arguments.append("-b"); + arguments.append(QStringLiteral("-b")); arguments.append(QString::number(m_currentDimensionB)); } if (m_currentDimensionC > 0) { - arguments.append("-c"); + arguments.append(QStringLiteral("-c")); arguments.append(QString::number(m_currentDimensionC)); } } if (isNoScaling) { - arguments.append(QLatin1String("--") + LONG_OPTION_NO_HDPI_SCALING); + arguments.append(QStringLiteral("--") + LONG_OPTION_NO_HDPI_SCALING); } - const QString tape = VApplication::VApp()->TapeFilePath(); + const QString tape = VApplication::TapeFilePath(); const QString workingDirectory = QFileInfo(tape).absoluteDir().absolutePath(); QProcess::startDetached(tape, arguments, workingDirectory); } @@ -2055,13 +2128,13 @@ void MainWindow::ShowMeasurements() //--------------------------------------------------------------------------------------------------------------------- void MainWindow::MeasurementsChanged(const QString &path) { - mChanges = false; + m_mChanges = false; QFileInfo checkFile(path); if (checkFile.exists()) { - mChanges = true; - mChangesAsked = false; - measurementsSyncTimer->start(1500); + m_mChanges = true; + m_mChangesAsked = false; + m_measurementsSyncTimer->start(1500ms); } else { @@ -2069,31 +2142,29 @@ void MainWindow::MeasurementsChanged(const QString &path) { if (checkFile.exists()) { - mChanges = true; - mChangesAsked = false; - measurementsSyncTimer->start(1500); + m_mChanges = true; + m_mChangesAsked = false; + m_measurementsSyncTimer->start(1500ms); break; } - else - { - std::this_thread::sleep_for(std::chrono::milliseconds(10)); - } + + std::this_thread::sleep_for(std::chrono::milliseconds(10)); } } UpdateWindowTitle(); - ui->actionSyncMeasurements->setEnabled(mChanges); + ui->actionSyncMeasurements->setEnabled(m_mChanges); } //--------------------------------------------------------------------------------------------------------------------- void MainWindow::SyncMeasurements() { - if (mChanges) + if (m_mChanges) { const QString path = AbsoluteMPath(VAbstractValApplication::VApp()->GetPatternPath(), doc->MPath()); // Temporarily remove the path to prevent infinite synchronization after a format conversion. - watcher->removePath(path); + m_watcher->removePath(path); if(UpdateMeasurements(path, m_currentDimensionA, m_currentDimensionB, m_currentDimensionC)) { @@ -2103,20 +2174,20 @@ void MainWindow::SyncMeasurements() VWidgetPopup::PopupMessage(this, msg); doc->LiteParseTree(Document::FullLiteParse); StoreDimensions(); - mChanges = false; - mChangesAsked = true; - measurementsSyncTimer->stop(); + m_mChanges = false; + m_mChangesAsked = true; + m_measurementsSyncTimer->stop(); UpdateWindowTitle(); - ui->actionSyncMeasurements->setEnabled(mChanges); + ui->actionSyncMeasurements->setEnabled(m_mChanges); } else { qCWarning(vMainWindow, "%s", qUtf8Printable(tr("Couldn't sync measurements."))); } - if (not watcher->files().contains(path)) + if (not m_watcher->files().contains(path)) { - watcher->addPath(path); + m_watcher->addPath(path); } } } @@ -2143,7 +2214,7 @@ void MainWindow::EditCurrentWatermark() //--------------------------------------------------------------------------------------------------------------------- void MainWindow::LoadWatermark() { - const QString filter(tr("Watermark files") + QLatin1String(" (*.vwm)")); + const QString filter(tr("Watermark files") + QStringLiteral(" (*.vwm)")); QString dir = QDir::homePath(); qDebug("Run QFileDialog::getOpenFileName: dir = %s.", qUtf8Printable(dir)); const QString filePath = QFileDialog::getOpenFileName(this, tr("Open file"), dir, filter, nullptr, @@ -2188,84 +2259,37 @@ void MainWindow::CleanWaterkmarkEditors() //--------------------------------------------------------------------------------------------------------------------- void MainWindow::StoreMultisizeMDimensions() { - VAbstractValApplication::VApp()->SetMeasurementsUnits(m->Units()); + VAbstractValApplication::VApp()->SetMeasurementsUnits(m_m->Units()); - QList dimensions = m->Dimensions().values(); + QList dimensions = m_m->Dimensions().values(); if (not dimensions.isEmpty()) { - if (not dimensionALabel.isNull()) + if (not m_dimensionALabel.isNull()) { - dimensionALabel->setText(dimensions.at(0)->Name()+QChar(':')); + m_dimensionALabel->setText(dimensions.at(0)->Name()+QChar(':')); } } if (dimensions.size() > 1) { - if (not dimensionBLabel.isNull()) + if (not m_dimensionBLabel.isNull()) { - dimensionBLabel->setText(dimensions.at(1)->Name()+QChar(':')); + m_dimensionBLabel->setText(dimensions.at(1)->Name()+QChar(':')); } } if (dimensions.size() > 2) { - if (not dimensionCLabel.isNull()) + if (not m_dimensionCLabel.isNull()) { - dimensionCLabel->setText(dimensions.at(2)->Name()+QChar(':')); + m_dimensionCLabel->setText(dimensions.at(2)->Name()+QChar(':')); } } - auto StoreDimension = [this, dimensions](int index, qreal currentBase) - { - if (dimensions.size() > index) - { - const MeasurementDimension_p& dimension = dimensions.at(index); - const DimesionLabels labels = dimension->Labels(); - - switch(dimension->Type()) - { - case MeasurementDimension::X: - VAbstractValApplication::VApp()->SetDimensionHeight(currentBase); - VAbstractValApplication::VApp()->SetDimensionHeightLabel( - labels.value(currentBase, QString::number(currentBase))); - break; - case MeasurementDimension::Y: - { - const bool fc = m->IsFullCircumference(); - VAbstractValApplication::VApp()->SetDimensionSize(fc ? currentBase*2 : currentBase); - VAbstractValApplication::VApp()->SetDimensionSizeLabel( - labels.value(currentBase, QString::number(fc ? currentBase*2 : currentBase))); - const bool measurement = dimension->IsBodyMeasurement(); - VAbstractValApplication::VApp() - ->SetDimensionSizeUnits(measurement ? m->Units() : Unit::LAST_UNIT_DO_NOT_USE); - break; - } - case MeasurementDimension::W: - { - const bool fc = m->IsFullCircumference(); - VAbstractValApplication::VApp()->SetDimensionWaist(fc ? currentBase*2 : currentBase); - VAbstractValApplication::VApp()->SetDimensionWaistLabel( - labels.value(currentBase, QString::number(fc ? currentBase*2 : currentBase))); - break; - } - case MeasurementDimension::Z: - { - const bool fc = m->IsFullCircumference(); - VAbstractValApplication::VApp()->SetDimensionHip(fc ? currentBase*2 : currentBase); - VAbstractValApplication::VApp()->SetDimensionHipLabel( - labels.value(currentBase, QString::number(fc ? currentBase*2 : currentBase))); - break; - } - default: - break; - } - } - }; - - StoreDimension(0, m_currentDimensionA); - StoreDimension(1, m_currentDimensionB); - StoreDimension(2, m_currentDimensionC); + StoreMultisizeMDimension(dimensions, 0, m_currentDimensionA); + StoreMultisizeMDimension(dimensions, 1, m_currentDimensionB); + StoreMultisizeMDimension(dimensions, 2, m_currentDimensionC); } //--------------------------------------------------------------------------------------------------------------------- @@ -2273,56 +2297,105 @@ void MainWindow::StoreIndividualMDimensions() { QMap > measurements = pattern->DataMeasurements(); - auto StoreDimension = [this, measurements](IMD type) - { - const QString name = VAbstractApplication::VApp()->TrVars()->VarToUser(m->MeasurementForDimension(type)); - const bool valid = not name.isEmpty() && measurements.contains(name); - const qreal value = valid ? *measurements.value(name)->GetValue() : 0; - switch(type) - { - case IMD::X: - VAbstractValApplication::VApp()->SetDimensionHeight(value); - VAbstractValApplication::VApp()->SetDimensionHeightLabel(QString::number(value)); - break; - case IMD::Y: - VAbstractValApplication::VApp()->SetDimensionSize(value); - VAbstractValApplication::VApp()->SetDimensionSizeLabel(QString::number(value)); - break; - case IMD::W: - VAbstractValApplication::VApp()->SetDimensionWaist(value); - VAbstractValApplication::VApp()->SetDimensionWaistLabel(QString::number(value)); - break; - case IMD::Z: - VAbstractValApplication::VApp()->SetDimensionHip(value); - VAbstractValApplication::VApp()->SetDimensionHipLabel(QString::number(value)); - break; - case IMD::N: - default: - break; - } - }; - - StoreDimension(IMD::X); - StoreDimension(IMD::Y); - StoreDimension(IMD::W); - StoreDimension(IMD::Z); + StoreIndividualMDimension(measurements, IMD::X); + StoreIndividualMDimension(measurements, IMD::Y); + StoreIndividualMDimension(measurements, IMD::W); + StoreIndividualMDimension(measurements, IMD::Z); } //--------------------------------------------------------------------------------------------------------------------- -QVector MainWindow::DimensionRestrictedValues(int index, const MeasurementDimension_p &dimension) +void MainWindow::StoreMultisizeMDimension(const QList &dimensions, int index, qreal currentBase) +{ + if (dimensions.size() > index) + { + const MeasurementDimension_p& dimension = dimensions.at(index); + const DimesionLabels labels = dimension->Labels(); + + switch(dimension->Type()) + { + case MeasurementDimension::X: + VAbstractValApplication::VApp()->SetDimensionHeight(currentBase); + VAbstractValApplication::VApp()->SetDimensionHeightLabel( + labels.value(currentBase, QString::number(currentBase))); + break; + case MeasurementDimension::Y: + { + const bool fc = m_m->IsFullCircumference(); + VAbstractValApplication::VApp()->SetDimensionSize(fc ? currentBase*2 : currentBase); + VAbstractValApplication::VApp()->SetDimensionSizeLabel( + labels.value(currentBase, QString::number(fc ? currentBase*2 : currentBase))); + const bool measurement = dimension->IsBodyMeasurement(); + VAbstractValApplication::VApp() + ->SetDimensionSizeUnits(measurement ? m_m->Units() : Unit::LAST_UNIT_DO_NOT_USE); + break; + } + case MeasurementDimension::W: + { + const bool fc = m_m->IsFullCircumference(); + VAbstractValApplication::VApp()->SetDimensionWaist(fc ? currentBase*2 : currentBase); + VAbstractValApplication::VApp()->SetDimensionWaistLabel( + labels.value(currentBase, QString::number(fc ? currentBase*2 : currentBase))); + break; + } + case MeasurementDimension::Z: + { + const bool fc = m_m->IsFullCircumference(); + VAbstractValApplication::VApp()->SetDimensionHip(fc ? currentBase*2 : currentBase); + VAbstractValApplication::VApp()->SetDimensionHipLabel( + labels.value(currentBase, QString::number(fc ? currentBase*2 : currentBase))); + break; + } + default: + break; + } + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void MainWindow::StoreIndividualMDimension(const QMap > &measurements, IMD type) +{ + const QString name = VAbstractApplication::VApp()->TrVars()->VarToUser(m_m->MeasurementForDimension(type)); + const bool valid = not name.isEmpty() && measurements.contains(name); + const qreal value = valid ? *measurements.value(name)->GetValue() : 0; + switch(type) + { + case IMD::X: + VAbstractValApplication::VApp()->SetDimensionHeight(value); + VAbstractValApplication::VApp()->SetDimensionHeightLabel(QString::number(value)); + break; + case IMD::Y: + VAbstractValApplication::VApp()->SetDimensionSize(value); + VAbstractValApplication::VApp()->SetDimensionSizeLabel(QString::number(value)); + break; + case IMD::W: + VAbstractValApplication::VApp()->SetDimensionWaist(value); + VAbstractValApplication::VApp()->SetDimensionWaistLabel(QString::number(value)); + break; + case IMD::Z: + VAbstractValApplication::VApp()->SetDimensionHip(value); + VAbstractValApplication::VApp()->SetDimensionHipLabel(QString::number(value)); + break; + case IMD::N: + default: + break; + } +} + +//--------------------------------------------------------------------------------------------------------------------- +auto MainWindow::DimensionRestrictedValues(int index, const MeasurementDimension_p &dimension) -> QVector { VDimensionRestriction restriction; if (index == 0) { - restriction = m->Restriction(0); + restriction = m_m->Restriction(0); } else if (index == 1) { - restriction = m->Restriction(m_currentDimensionA); + restriction = m_m->Restriction(m_currentDimensionA); } else { - restriction = m->Restriction(m_currentDimensionA, m_currentDimensionB); + restriction = m_m->Restriction(m_currentDimensionA, m_currentDimensionB); } const QVector bases = dimension->ValidBases(); @@ -2342,7 +2415,7 @@ QVector MainWindow::DimensionRestrictedValues(int index, const Measuremen //--------------------------------------------------------------------------------------------------------------------- void MainWindow::SetDimensionBases() { - const QList dimensions = m->Dimensions().values(); + const QList dimensions = m_m->Dimensions().values(); auto SetBase = [dimensions](int index, const QPointer& control, double &value) { @@ -2366,22 +2439,22 @@ void MainWindow::SetDimensionBases() } }; - SetBase(0, dimensionA, m_currentDimensionA); - SetBase(1, dimensionB, m_currentDimensionB); - SetBase(2, dimensionC, m_currentDimensionC); + SetBase(0, m_dimensionA, m_currentDimensionA); + SetBase(1, m_dimensionB, m_currentDimensionB); + SetBase(2, m_dimensionC, m_currentDimensionC); } //--------------------------------------------------------------------------------------------------------------------- void MainWindow::StoreDimensions() { - if (m->Type() == MeasurementsType::Multisize) + if (m_m->Type() == MeasurementsType::Multisize) { StoreMultisizeMDimensions(); doc->SetPatternWasChanged(true); emit doc->UpdatePatternLabel(); } - else if (m->Type() == MeasurementsType::Individual) + else if (m_m->Type() == MeasurementsType::Individual) { StoreIndividualMDimensions(); @@ -2411,7 +2484,7 @@ void MainWindow::ExportDraw(const QString &fileName) ui->view->ZoomOriginal(); // Set to original scale // Enable all items on scene - const QList qItems = sceneDraw->items(); + const QList qItems = m_sceneDraw->items(); for (auto *item : qItems) { item->setEnabled(true); @@ -2424,16 +2497,16 @@ void MainWindow::ExportDraw(const QString &fileName) ui->view->repaint(); - sceneDraw->SetOriginsVisible(false); + m_sceneDraw->SetOriginsVisible(false); - const QRectF rect = sceneDraw->VisibleItemsBoundingRect(); - sceneDraw->update(rect); + const QRectF rect = m_sceneDraw->VisibleItemsBoundingRect(); + m_sceneDraw->update(rect); exporter.SetImageRect(rect); exporter.SetOffset(rect.topLeft()); // Correct positions to fit SVG view rect - exporter.ExportToSVG(sceneDraw); + exporter.ExportToSVG(m_sceneDraw); - sceneDraw->SetOriginsVisible(true); + m_sceneDraw->SetOriginsVisible(true); // Restore scale, scrollbars and current active pattern piece ui->view->setTransform(viewTransform); @@ -2452,9 +2525,9 @@ void MainWindow::NewBackgroundImageItem(const VBackgroundPatternImage &image) if (m_backgroudcontrols == nullptr) { m_backgroudcontrols = new VBackgroundImageControls(doc); - connect(sceneDraw, &VMainGraphicsScene::ItemByMouseRelease, m_backgroudcontrols, + connect(m_sceneDraw, &VMainGraphicsScene::ItemByMouseRelease, m_backgroudcontrols, &VBackgroundImageControls::DeactivateControls); - sceneDraw->addItem(m_backgroudcontrols); + m_sceneDraw->addItem(m_backgroudcontrols); } if (m_backgroundImages.contains(image.Id())) @@ -2472,11 +2545,11 @@ void MainWindow::NewBackgroundImageItem(const VBackgroundPatternImage &image) if (item != nullptr) { m_backgroundImages.insert(image.Id(), item); - sceneDraw->addItem(item); + m_sceneDraw->addItem(item); } } - VMainGraphicsView::NewSceneRect(sceneDraw, ui->view); + VMainGraphicsView::NewSceneRect(m_sceneDraw, ui->view); } //--------------------------------------------------------------------------------------------------------------------- @@ -2502,15 +2575,196 @@ auto MainWindow::InitBackgroundImageItem(const VBackgroundPatternImage &image) - connect(this, &MainWindow::EnableBackgroundImageSelection, item, &VBackgroundImageItem::EnableSelection); connect(item, &VBackgroundImageItem::ShowImageInExplorer, this, &MainWindow::ShowBackgroundImageInExplorer); connect(item, &VBackgroundImageItem::SaveImage, this, &MainWindow::SaveBackgroundImage); - connect(m_backgroudcontrols, &VBackgroundImageControls::ActiveImageChanged, backgroundImagesWidget, + connect(m_backgroudcontrols, &VBackgroundImageControls::ActiveImageChanged, m_backgroundImagesWidget, &VWidgetBackgroundImages::ImageSelected); - connect(backgroundImagesWidget, &VWidgetBackgroundImages::SelectImage, m_backgroudcontrols, + connect(m_backgroundImagesWidget, &VWidgetBackgroundImages::SelectImage, m_backgroudcontrols, &VBackgroundImageControls::ActivateControls); } return item; } +//--------------------------------------------------------------------------------------------------------------------- +auto MainWindow::SavePatternAs(const QString &fileName) -> bool +{ + // Need for restoring previous state in case of failure + const bool wasModified = doc->IsModified(); // Need because SetReadOnly() will change internal state + const bool readOnly = doc->IsReadOnly(); + + doc->SetReadOnly(false);// Save as... disable read only state + QString error; + const bool result = SavePattern(fileName, error); + if (not result) + { + QMessageBox messageBox(this); + messageBox.setIcon(QMessageBox::Warning); + messageBox.setInformativeText(tr("Could not save file")); + messageBox.setDefaultButton(QMessageBox::Ok); + messageBox.setDetailedText(error); + messageBox.setStandardButtons(QMessageBox::Ok); + messageBox.exec(); + + // Restoring previous state + doc->SetReadOnly(readOnly); + doc->SetModified(wasModified); + + return result; + } + + const QString oldFilePath = VAbstractValApplication::VApp()->GetPatternPath(); + if (not oldFilePath.isEmpty()) + { + qCDebug(vMainWindow, "Updating restore file list."); + QStringList restoreFiles = VAbstractValApplication::VApp()->ValentinaSettings()->GetRestoreFileList(); + restoreFiles.removeAll(oldFilePath); + VAbstractValApplication::VApp()->ValentinaSettings()->SetRestoreFileList(restoreFiles); + QFile::remove(oldFilePath + *autosavePrefix); + } + + m_curFileFormatVersion = VPatternConverter::PatternMaxVer; + m_curFileFormatVersionStr = VPatternConverter::PatternMaxVerStr; + m_patternReadOnly = false; + + qCDebug(vMainWindow, "Locking file"); + if (VAbstractValApplication::VApp()->GetPatternPath() == fileName && not m_lock.isNull()) + { + m_lock->Unlock(); + } + VlpCreateLock(m_lock, fileName); + + if (m_lock->IsLocked()) + { + qCDebug(vMainWindow, "Pattern file %s was locked.", qUtf8Printable(fileName)); + } + else + { + qCDebug(vMainWindow, "Failed to lock %s", qUtf8Printable(fileName)); + qCDebug(vMainWindow, "Error type: %d", m_lock->GetLockError()); + qCCritical(vMainWindow, "%s", + qUtf8Printable(tr("Failed to lock. This file already opened in another window. Expect " + "collissions when run 2 copies of the program."))); + } + + return result; +} + +//--------------------------------------------------------------------------------------------------------------------- +auto MainWindow::FullParsePattern() -> bool +{ + QFuture futureTestUniqueId; + + auto WaitForFutureFinish = [](QFuture &futureTestUniqueId) + { + try + { + futureTestUniqueId.waitForFinished(); + } + catch (...) + { + // ignore + } + }; + + auto HandleError = [this, WaitForFutureFinish](QFuture &futureTestUniqueId) + { + SetEnabledGUI(false); + if (VAbstractValApplication::VApp()->getOpeningPattern()) + { + WaitForFutureFinish(futureTestUniqueId); + } + + if (not VApplication::IsGUIMode()) + { + QCoreApplication::exit(V_EX_DATAERR); + } + }; + + try + { + if (VAbstractValApplication::VApp()->getOpeningPattern()) + { + futureTestUniqueId = QtConcurrent::run(static_cast(doc), &VDomDocument::TestUniqueId); // clazy:exclude=unneeded-cast + } + + SetEnabledGUI(true); + doc->Parse(Document::FullParse); + ParseBackgroundImages(); + + if (VAbstractValApplication::VApp()->getOpeningPattern()) + { + futureTestUniqueId.waitForFinished(); + } + } + catch (const VExceptionUndo &) + { + /* If user want undo last operation before undo we need finish broken redo operation. For those we post event + * myself. Later in method customEvent call undo.*/ + if (VAbstractValApplication::VApp()->getOpeningPattern()) + { + try + { + futureTestUniqueId.waitForFinished(); + } + catch (const VExceptionWrongId &e) + { + qCCritical(vMainWindow, "%s\n\n%s\n\n%s", qUtf8Printable(tr("Error wrong id.")), + qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation())); + SetEnabledGUI(false); + if (not VApplication::IsGUIMode()) + { + QCoreApplication::exit(V_EX_DATAERR); + } + return false; + } + } + QApplication::postEvent(this, new UndoEvent()); + return false; + } + catch (const VExceptionObjectError &e) + { + qCCritical(vMainWindow, "%s\n\n%s\n\n%s", qUtf8Printable(tr("Error parsing file.")), //-V807 + qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation())); + HandleError(futureTestUniqueId); + return false; + } + catch (const VExceptionConversionError &e) + { + qCCritical(vMainWindow, "%s\n\n%s\n\n%s", qUtf8Printable(tr("Error can't convert value.")), + qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation())); + HandleError(futureTestUniqueId); + return false; + } + catch (const VExceptionEmptyParameter &e) + { + qCCritical(vMainWindow, "%s\n\n%s\n\n%s", qUtf8Printable(tr("Error empty parameter.")), + qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation())); + HandleError(futureTestUniqueId); + return false; + } + catch (const VExceptionWrongId &e) + { + qCCritical(vMainWindow, "%s\n\n%s\n\n%s", qUtf8Printable(tr("Error wrong id.")), + qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation())); + HandleError(futureTestUniqueId); + return false; + } + catch (VException &e) + { + qCCritical(vMainWindow, "%s\n\n%s\n\n%s", qUtf8Printable(tr("Error parsing file.")), + qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation())); + HandleError(futureTestUniqueId); + return false; + } + catch (const std::bad_alloc &) + { + qCCritical(vMainWindow, "%s", qUtf8Printable(tr("Error parsing file (std::bad_alloc)."))); + HandleError(futureTestUniqueId); + return false; + } + + return true; +} + //--------------------------------------------------------------------------------------------------------------------- #if defined(Q_OS_MAC) void MainWindow::OpenAt(QAction *where) @@ -2535,13 +2789,13 @@ void MainWindow::ToolBarOption() { ui->toolBarOption->clear(); - if (not zoomScale.isNull()) + if (not m_zoomScale.isNull()) { - delete zoomScale; + delete m_zoomScale; } - if (not doubleSpinBoxScale.isNull()) + if (not m_doubleSpinBoxScale.isNull()) { - delete doubleSpinBoxScale; + delete m_doubleSpinBoxScale; } if (not m_mouseCoordinate.isNull()) @@ -2556,20 +2810,20 @@ void MainWindow::ToolBarOption() InitDimensionControls(); - zoomScale = new QLabel(tr("Scale:"), this); - ui->toolBarOption->addWidget(zoomScale); + m_zoomScale = new QLabel(tr("Scale:"), this); + ui->toolBarOption->addWidget(m_zoomScale); - doubleSpinBoxScale = new QDoubleSpinBox(this); - doubleSpinBoxScale->setDecimals(1); - doubleSpinBoxScale->setSuffix("%"); + m_doubleSpinBoxScale = new QDoubleSpinBox(this); + m_doubleSpinBoxScale->setDecimals(1); + m_doubleSpinBoxScale->setSuffix(QChar('%')); ScaleChanged(ui->view->transform().m11()); - connect(doubleSpinBoxScale.data(), QOverload::of(&QDoubleSpinBox::valueChanged), + connect(m_doubleSpinBoxScale.data(), QOverload::of(&QDoubleSpinBox::valueChanged), this, [this](double d){ui->view->Zoom(d/100.0);}); - ui->toolBarOption->addWidget(doubleSpinBoxScale); + ui->toolBarOption->addWidget(m_doubleSpinBoxScale); ui->toolBarOption->addSeparator(); - m_mouseCoordinate = new QLabel(QString("0, 0 (%1)") + m_mouseCoordinate = new QLabel(QStringLiteral("0, 0 (%1)") .arg(UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true))); ui->toolBarOption->addWidget(m_mouseCoordinate); @@ -2581,13 +2835,13 @@ void MainWindow::ToolBarOption() //--------------------------------------------------------------------------------------------------------------------- void MainWindow::ToolBarStages() { - leftGoToStage = new QLabel(this); - leftGoToStage->setPixmap(QPixmap("://icon/24x24/fast_forward_left_to_right_arrow.png")); - ui->toolBarStages->insertWidget(ui->actionDetails, leftGoToStage); + m_leftGoToStage = new QLabel(this); + m_leftGoToStage->setPixmap(QPixmap(QStringLiteral("://icon/24x24/fast_forward_left_to_right_arrow.png"))); + ui->toolBarStages->insertWidget(ui->actionDetails, m_leftGoToStage); - rightGoToStage = new QLabel(this); - rightGoToStage->setPixmap(QPixmap("://icon/24x24/left_to_right_arrow.png")); - ui->toolBarStages->insertWidget(ui->actionLayout, rightGoToStage); + m_rightGoToStage = new QLabel(this); + m_rightGoToStage->setPixmap(QPixmap(QStringLiteral("://icon/24x24/left_to_right_arrow.png"))); + ui->toolBarStages->insertWidget(ui->actionLayout, m_rightGoToStage); } //--------------------------------------------------------------------------------------------------------------------- @@ -2596,15 +2850,15 @@ void MainWindow::ToolBarStages() */ void MainWindow::ToolBarDraws() { - patternPieceLabel = new QLabel(tr("Pattern Piece:")); - ui->toolBarDraws->addWidget(patternPieceLabel); + m_patternPieceLabel = new QLabel(tr("Pattern Piece:")); + ui->toolBarDraws->addWidget(m_patternPieceLabel); // By using Qt UI Designer we can't add QComboBox to toolbar - comboBoxDraws = new QComboBox; - ui->toolBarDraws->addWidget(comboBoxDraws); - comboBoxDraws->setSizeAdjustPolicy(QComboBox::AdjustToContents); - comboBoxDraws->setEnabled(false); - connect(comboBoxDraws, QOverload::of(&QComboBox::currentIndexChanged), + m_comboBoxDraws = new QComboBox; + ui->toolBarDraws->addWidget(m_comboBoxDraws); + m_comboBoxDraws->setSizeAdjustPolicy(QComboBox::AdjustToContents); + m_comboBoxDraws->setEnabled(false); + connect(m_comboBoxDraws, QOverload::of(&QComboBox::currentIndexChanged), this, [this](int index){ChangePP(index);}); connect(ui->actionOptionDraw, &QAction::triggered, this, [this]() @@ -2615,7 +2869,7 @@ void MainWindow::ToolBarDraws() { return; } - VAbstractApplication::VApp()->getUndoStack()->push(new RenamePP(doc, draw, comboBoxDraws)); + VAbstractApplication::VApp()->getUndoStack()->push(new RenamePP(doc, draw, m_comboBoxDraws)); }); } @@ -2666,14 +2920,14 @@ void MainWindow::ToolBarTools() { VValentinaSettings *settings = VAbstractValApplication::VApp()->ValentinaSettings(); settings->SetLabelFontSize(settings->GetLabelFontSize() + 1); - if (sceneDraw) + if (m_sceneDraw) { - sceneDraw->update(); + m_sceneDraw->update(); } - if (sceneDetails) + if (m_sceneDetails) { - sceneDetails->update(); + m_sceneDetails->update(); } }); @@ -2682,14 +2936,14 @@ void MainWindow::ToolBarTools() { VValentinaSettings *settings = VAbstractValApplication::VApp()->ValentinaSettings(); settings->SetLabelFontSize(settings->GetLabelFontSize() - 1); - if (sceneDraw) + if (m_sceneDraw) { - sceneDraw->update(); + m_sceneDraw->update(); } - if (sceneDetails) + if (m_sceneDetails) { - sceneDetails->update(); + m_sceneDetails->update(); } }); @@ -2697,15 +2951,15 @@ void MainWindow::ToolBarTools() connect(ui->actionOriginalLabelFont, &QAction::triggered, this, [this]() { VValentinaSettings *settings = VAbstractValApplication::VApp()->ValentinaSettings(); - settings->SetLabelFontSize(settings->GetDefLabelFontSize()); - if (sceneDraw) + settings->SetLabelFontSize(VCommonSettings::GetDefLabelFontSize()); + if (m_sceneDraw) { - sceneDraw->update(); + m_sceneDraw->update(); } - if (sceneDetails) + if (m_sceneDetails) { - sceneDetails->update(); + m_sceneDetails->update(); } }); @@ -2713,14 +2967,14 @@ void MainWindow::ToolBarTools() connect(ui->actionHideLabels, &QAction::triggered, this, [this](bool checked) { VAbstractValApplication::VApp()->ValentinaSettings()->SetHideLabels(checked); - if (sceneDraw) + if (m_sceneDraw) { - sceneDraw->update(); + m_sceneDraw->update(); } - if (sceneDetails) + if (m_sceneDetails) { - sceneDetails->update(); + m_sceneDetails->update(); } }); @@ -2730,15 +2984,15 @@ void MainWindow::ToolBarTools() //--------------------------------------------------------------------------------------------------------------------- void MainWindow::InitToolButtons() { - toolButtonPointerList.append(ui->toolButtonPointerPoint); - toolButtonPointerList.append(ui->toolButtonPointerLine); - toolButtonPointerList.append(ui->toolButtonPointerCurve); - toolButtonPointerList.append(ui->toolButtonPointerArc); - toolButtonPointerList.append(ui->toolButtonPointerDetail); - toolButtonPointerList.append(ui->toolButtonPointerOperations); - toolButtonPointerList.append(ui->toolButtonPointerEllipticalArc); + m_toolButtonPointerList.append(ui->toolButtonPointerPoint); + m_toolButtonPointerList.append(ui->toolButtonPointerLine); + m_toolButtonPointerList.append(ui->toolButtonPointerCurve); + m_toolButtonPointerList.append(ui->toolButtonPointerArc); + m_toolButtonPointerList.append(ui->toolButtonPointerDetail); + m_toolButtonPointerList.append(ui->toolButtonPointerOperations); + m_toolButtonPointerList.append(ui->toolButtonPointerEllipticalArc); - for (auto pointer : qAsConst(toolButtonPointerList)) + for (auto *pointer : qAsConst(m_toolButtonPointerList)) { connect(pointer, &QToolButton::clicked, this, &MainWindow::ArrowTool); } @@ -2826,10 +3080,10 @@ void MainWindow::CancelTool() Q_STATIC_ASSERT_X(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 59, "Not all tools were handled."); qCDebug(vMainWindow, "Canceling tool."); - if(not dialogTool.isNull()) + if(not m_dialogTool.isNull()) { - dialogTool->hide(); - dialogTool->deleteLater(); + m_dialogTool->hide(); + m_dialogTool->deleteLater(); } qCDebug(vMainWindow, "Dialog closed."); @@ -2837,10 +3091,10 @@ void MainWindow::CancelTool() currentScene->clearSelection(); emit ui->view->itemClicked(nullptr); // Hide visualization to avoid a crash - switch ( currentTool ) + switch ( m_currentTool ) { case Tool::Arrow: - for (auto pointer : qAsConst(toolButtonPointerList)) + for (auto *pointer : qAsConst(m_toolButtonPointerList)) { pointer->setChecked(false); } @@ -3018,15 +3272,15 @@ QT_WARNING_POP */ void MainWindow::ArrowTool(bool checked) { - if (checked && currentTool != Tool::Arrow) + if (checked && m_currentTool != Tool::Arrow) { qCDebug(vMainWindow, "Arrow tool."); CancelTool(); - for (auto pointer : qAsConst(toolButtonPointerList)) + for (auto *pointer : qAsConst(m_toolButtonPointerList)) { pointer->setChecked(true); } - currentTool = Tool::Arrow; + m_currentTool = Tool::Arrow; emit EnableItemMove(true); emit ItemsSelection(SelectionType::ByMouseRelease); VAbstractTool::m_suppressContextMenu = false; @@ -3067,7 +3321,7 @@ void MainWindow::ArrowTool(bool checked) } else { - for (auto pointer : qAsConst(toolButtonPointerList)) + for (auto *pointer : qAsConst(m_toolButtonPointerList)) { pointer->setChecked(true); } @@ -3105,7 +3359,7 @@ void MainWindow::SaveCurrentScene() if (VAbstractValApplication::VApp()->GetDrawMode() == Draw::Calculation || VAbstractValApplication::VApp()->GetDrawMode() == Draw::Modeling) { - VMainGraphicsScene *scene = qobject_cast(currentScene); + auto *scene = qobject_cast(currentScene); SCASSERT(scene != nullptr) /*Save transform*/ @@ -3124,7 +3378,7 @@ void MainWindow::SaveCurrentScene() */ void MainWindow::RestoreCurrentScene() { - VMainGraphicsScene *scene = qobject_cast(currentScene); + auto *scene = qobject_cast(currentScene); SCASSERT(scene != nullptr) /*Set transform for current scene*/ @@ -3148,25 +3402,25 @@ void MainWindow::ActionDraw(bool checked) qCDebug(vMainWindow, "Show draw scene"); ArrowTool(true); - leftGoToStage->setPixmap(QPixmap("://icon/24x24/fast_forward_left_to_right_arrow.png")); - rightGoToStage->setPixmap(QPixmap("://icon/24x24/left_to_right_arrow.png")); + m_leftGoToStage->setPixmap(QPixmap(QStringLiteral("://icon/24x24/fast_forward_left_to_right_arrow.png"))); + m_rightGoToStage->setPixmap(QPixmap(QStringLiteral("://icon/24x24/left_to_right_arrow.png"))); ui->actionDraw->setChecked(true); ui->actionDetails->setChecked(false); ui->actionLayout->setChecked(false); SaveCurrentScene(); - currentScene = sceneDraw; + currentScene = m_sceneDraw; ui->view->setScene(currentScene); RestoreCurrentScene(); VAbstractValApplication::VApp()->SetDrawMode(Draw::Calculation); - comboBoxDraws->setCurrentIndex(currentDrawIndex);//restore current pattern peace - drawMode = true; + m_comboBoxDraws->setCurrentIndex(m_currentDrawIndex);//restore current pattern peace + m_drawMode = true; SetEnableTool(true); SetEnableWidgets(true); - ui->toolBox->setCurrentIndex(currentToolBoxIndex); + ui->toolBox->setCurrentIndex(m_currentToolBoxIndex); if (VAbstractValApplication::VApp()->GetMeasurementsType() == MeasurementsType::Multisize) { @@ -3176,7 +3430,7 @@ void MainWindow::ActionDraw(bool checked) ui->dockWidgetLayoutPages->setVisible(false); ui->dockWidgetToolOptions->setVisible(m_toolOptionsActive); - ui->dockWidgetGroups->setWidget(groupsWidget); + ui->dockWidgetGroups->setWidget(m_groupsWidget); ui->dockWidgetGroups->setWindowTitle(tr("Groups of visibility")); ui->dockWidgetGroups->setVisible(m_groupsActive); ui->dockWidgetGroups->setToolTip(tr("Contains all visibility groups")); @@ -3200,15 +3454,15 @@ void MainWindow::ActionDetails(bool checked) { ArrowTool(true); - if(drawMode) + if(m_drawMode) { - currentDrawIndex = comboBoxDraws->currentIndex();//save current pattern piece - drawMode = false; + m_currentDrawIndex = m_comboBoxDraws->currentIndex();//save current pattern piece + m_drawMode = false; } - comboBoxDraws->setCurrentIndex(comboBoxDraws->count()-1);// Need to get data about all details + m_comboBoxDraws->setCurrentIndex(m_comboBoxDraws->count()-1);// Need to get data about all details - leftGoToStage->setPixmap(QPixmap("://icon/24x24/right_to_left_arrow.png")); - rightGoToStage->setPixmap(QPixmap("://icon/24x24/left_to_right_arrow.png")); + m_leftGoToStage->setPixmap(QPixmap(QStringLiteral("://icon/24x24/right_to_left_arrow.png"))); + m_rightGoToStage->setPixmap(QPixmap(QStringLiteral("://icon/24x24/left_to_right_arrow.png"))); ui->actionDraw->setChecked(false); ui->actionDetails->setChecked(true); @@ -3226,19 +3480,19 @@ void MainWindow::ActionDetails(bool checked) } } - detailsWidget->UpdateList(); + m_detailsWidget->UpdateList(); qCDebug(vMainWindow, "Show details scene"); SaveCurrentScene(); - currentScene = sceneDetails; + currentScene = m_sceneDetails; emit ui->view->itemClicked(nullptr); ui->view->setScene(currentScene); RestoreCurrentScene(); if (VAbstractValApplication::VApp()->GetDrawMode() == Draw::Calculation) { - currentToolBoxIndex = ui->toolBox->currentIndex(); + m_currentToolBoxIndex = ui->toolBox->currentIndex(); } VAbstractValApplication::VApp()->SetDrawMode(Draw::Modeling); SetEnableTool(true); @@ -3252,7 +3506,7 @@ void MainWindow::ActionDetails(bool checked) ui->dockWidgetLayoutPages->setVisible(false); - ui->dockWidgetGroups->setWidget(detailsWidget); + ui->dockWidgetGroups->setWidget(m_detailsWidget); ui->dockWidgetGroups->setWindowTitle(tr("Details")); ui->dockWidgetGroups->setVisible(m_groupsActive); ui->dockWidgetGroups->setToolTip(tr("Show which details will go in layout")); @@ -3277,115 +3531,113 @@ void MainWindow::ActionDetails(bool checked) */ void MainWindow::ActionLayout(bool checked) { - if (checked) + if (not checked) { - ArrowTool(true); - - if(drawMode) - { - currentDrawIndex = comboBoxDraws->currentIndex();//save current pattern piece - drawMode = false; - } - comboBoxDraws->setCurrentIndex(comboBoxDraws->count()-1);// Need to get data about all details - - leftGoToStage->setPixmap(QPixmap("://icon/24x24/right_to_left_arrow.png")); - rightGoToStage->setPixmap(QPixmap("://icon/24x24/fast_forward_right_to_left_arrow.png")); - - ui->actionDraw->setChecked(false); - ui->actionDetails->setChecked(false); ui->actionLayout->setChecked(true); + return; + } - QVector details; - if(not VAbstractValApplication::VApp()->getOpeningPattern()) + ArrowTool(true); + + if(m_drawMode) + { + m_currentDrawIndex = m_comboBoxDraws->currentIndex();//save current pattern piece + m_drawMode = false; + } + m_comboBoxDraws->setCurrentIndex(m_comboBoxDraws->count()-1);// Need to get data about all details + + m_leftGoToStage->setPixmap(QPixmap(QStringLiteral("://icon/24x24/right_to_left_arrow.png"))); + m_rightGoToStage->setPixmap(QPixmap(QStringLiteral("://icon/24x24/fast_forward_right_to_left_arrow.png"))); + + ui->actionDraw->setChecked(false); + ui->actionDetails->setChecked(false); + ui->actionLayout->setChecked(true); + + QVector details; + if(not VAbstractValApplication::VApp()->getOpeningPattern()) + { + const QHash *allDetails = pattern->DataPieces(); + if (allDetails->count() == 0) { - const QHash *allDetails = pattern->DataPieces(); - if (allDetails->count() == 0) - { - QMessageBox::information(this, tr("Layout mode"), tr("You can't use Layout mode yet. " - "Please, create at least one workpiece."), - QMessageBox::Ok, QMessageBox::Ok); - ActionDraw(true); - return; - } - else - { - WarningNotUniquePieceName(allDetails); - details = SortDetailsForLayout(allDetails); - - if (details.count() == 0) - { - QMessageBox::information(this, tr("Layout mode"), tr("You can't use Layout mode yet. Please, " - "include at least one detail in layout."), - QMessageBox::Ok, QMessageBox::Ok); - VAbstractValApplication::VApp()->GetDrawMode() == Draw::Calculation ? ActionDraw(true) - : ActionDetails(true); - return; - } - } + QMessageBox::information(this, tr("Layout mode"), tr("You can't use Layout mode yet. " + "Please, create at least one workpiece."), + QMessageBox::Ok, QMessageBox::Ok); + ActionDraw(true); + return; } - comboBoxDraws->setCurrentIndex(-1);// Hide pattern pieces + WarningNotUniquePieceName(allDetails); + details = SortDetailsForLayout(allDetails); - qCDebug(vMainWindow, "Show layout scene"); - - SaveCurrentScene(); - - try + if (details.count() == 0) { - listDetails = PrepareDetailsForLayout(details); - } - catch (VException &e) - { - listDetails.clear(); - QMessageBox::warning(this, tr("Layout mode"), - tr("You can't use Layout mode yet.") + QLatin1String(" \n") + e.ErrorMessage(), - QMessageBox::Ok, QMessageBox::Ok); + QMessageBox::information(this, tr("Layout mode"), tr("You can't use Layout mode yet. Please, " + "include at least one detail in layout."), + QMessageBox::Ok, QMessageBox::Ok); VAbstractValApplication::VApp()->GetDrawMode() == Draw::Calculation ? ActionDraw(true) : ActionDetails(true); return; } - currentScene = tempSceneLayout; - emit ui->view->itemClicked(nullptr); - ui->view->setScene(currentScene); - - if (VAbstractValApplication::VApp()->GetDrawMode() == Draw::Calculation) - { - currentToolBoxIndex = ui->toolBox->currentIndex(); - } - VAbstractValApplication::VApp()->SetDrawMode(Draw::Layout); - SetEnableTool(true); - SetEnableWidgets(true); - ui->toolBox->setCurrentIndex(ui->toolBox->indexOf(ui->layoutPage)); - - if (not m_mouseCoordinate.isNull()) - { - m_mouseCoordinate->setText(QString()); - } - - if (VAbstractValApplication::VApp()->GetMeasurementsType() == MeasurementsType::Multisize) - { - ui->toolBarOption->setVisible(false); - } - - ui->dockWidgetLayoutPages->setVisible(true); - ui->dockWidgetToolOptions->setVisible(false); - ui->dockWidgetGroups->setVisible(false); - ui->dockWidgetBackgroundImages->setVisible(false); - - ShowPaper(ui->listWidget->currentRow()); - - if (m_layoutSettings->LayoutScenes().isEmpty() || m_layoutSettings->IsLayoutStale()) - { - ui->toolButtonLayoutSettings->click(); - } - - m_statusLabel->setText(QString()); } - else + + m_comboBoxDraws->setCurrentIndex(-1);// Hide pattern pieces + + qCDebug(vMainWindow, "Show layout scene"); + + SaveCurrentScene(); + + try { - ui->actionLayout->setChecked(true); + listDetails = PrepareDetailsForLayout(details); } + catch (VException &e) + { + listDetails.clear(); + QMessageBox::warning(this, tr("Layout mode"), + tr("You can't use Layout mode yet.") + QStringLiteral(" \n") + e.ErrorMessage(), + QMessageBox::Ok, QMessageBox::Ok); + VAbstractValApplication::VApp()->GetDrawMode() == Draw::Calculation ? ActionDraw(true) + : ActionDetails(true); + return; + } + + currentScene = tempSceneLayout; + emit ui->view->itemClicked(nullptr); + ui->view->setScene(currentScene); + + if (VAbstractValApplication::VApp()->GetDrawMode() == Draw::Calculation) + { + m_currentToolBoxIndex = ui->toolBox->currentIndex(); + } + VAbstractValApplication::VApp()->SetDrawMode(Draw::Layout); + SetEnableTool(true); + SetEnableWidgets(true); + ui->toolBox->setCurrentIndex(ui->toolBox->indexOf(ui->layoutPage)); + + if (not m_mouseCoordinate.isNull()) + { + m_mouseCoordinate->setText(QString()); + } + + if (VAbstractValApplication::VApp()->GetMeasurementsType() == MeasurementsType::Multisize) + { + ui->toolBarOption->setVisible(false); + } + + ui->dockWidgetLayoutPages->setVisible(true); + ui->dockWidgetToolOptions->setVisible(false); + ui->dockWidgetGroups->setVisible(false); + ui->dockWidgetBackgroundImages->setVisible(false); + + ShowPaper(ui->listWidget->currentRow()); + + if (m_layoutSettings->LayoutScenes().isEmpty() || m_layoutSettings->IsLayoutStale()) + { + ui->toolButtonLayoutSettings->click(); + } + + m_statusLabel->setText(QString()); } //--------------------------------------------------------------------------------------------------------------------- @@ -3393,10 +3645,8 @@ void MainWindow::ActionLayout(bool checked) * @brief on_actionSaveAs_triggered save as pattern file. * @return true for successes saving. */ -bool MainWindow::on_actionSaveAs_triggered() +auto MainWindow::on_actionSaveAs_triggered() -> bool { - const QString oldFilePath = VAbstractValApplication::VApp()->GetPatternPath(); - QString filters(tr("Pattern files") + QLatin1String("(*.val)")); QString dir; if (VAbstractValApplication::VApp()->GetPatternPath().isEmpty()) { @@ -3414,15 +3664,15 @@ bool MainWindow::on_actionSaveAs_triggered() usedNotExistedDir = directory.mkpath(QChar('.')); } - QString newFileName = tr("pattern") + QLatin1String(".val"); - + QString newFileName = tr("pattern") + QStringLiteral(".val"); if(not VAbstractValApplication::VApp()->GetPatternPath().isEmpty()) { newFileName = StrippedName(VAbstractValApplication::VApp()->GetPatternPath()); } + QString filters(tr("Pattern files") + QStringLiteral("(*.val)")); QString fileName = QFileDialog::getSaveFileName(this, tr("Save as"), - dir + QLatin1String("/") + newFileName, + dir + QChar('/') + newFileName, filters, nullptr, VAbstractApplication::VApp()->NativeFileDialog()); auto RemoveTempDir = qScopeGuard([usedNotExistedDir, dir]() @@ -3458,63 +3708,7 @@ bool MainWindow::on_actionSaveAs_triggered() } } - // Need for restoring previous state in case of failure - const bool wasModified = doc->IsModified(); // Need because SetReadOnly() will change internal state - const bool readOnly = doc->IsReadOnly(); - - doc->SetReadOnly(false);// Save as... disable read only state - QString error; - const bool result = SavePattern(fileName, error); - if (result == false) - { - QMessageBox messageBox(this); - messageBox.setIcon(QMessageBox::Warning); - messageBox.setInformativeText(tr("Could not save file")); - messageBox.setDefaultButton(QMessageBox::Ok); - messageBox.setDetailedText(error); - messageBox.setStandardButtons(QMessageBox::Ok); - messageBox.exec(); - - // Restoring previous state - doc->SetReadOnly(readOnly); - doc->SetModified(wasModified); - - return result; - } - else if (not oldFilePath.isEmpty()) - { - qCDebug(vMainWindow, "Updating restore file list."); - QStringList restoreFiles = VAbstractValApplication::VApp()->ValentinaSettings()->GetRestoreFileList(); - restoreFiles.removeAll(oldFilePath); - VAbstractValApplication::VApp()->ValentinaSettings()->SetRestoreFileList(restoreFiles); - QFile::remove(oldFilePath + *autosavePrefix); - } - - m_curFileFormatVersion = VPatternConverter::PatternMaxVer; - m_curFileFormatVersionStr = VPatternConverter::PatternMaxVerStr; - patternReadOnly = false; - - qCDebug(vMainWindow, "Locking file"); - if (VAbstractValApplication::VApp()->GetPatternPath() == fileName && not lock.isNull()) - { - lock->Unlock(); - } - VlpCreateLock(lock, fileName); - - if (lock->IsLocked()) - { - qCDebug(vMainWindow, "Pattern file %s was locked.", qUtf8Printable(fileName)); - } - else - { - qCDebug(vMainWindow, "Failed to lock %s", qUtf8Printable(fileName)); - qCDebug(vMainWindow, "Error type: %d", lock->GetLockError()); - qCCritical(vMainWindow, "%s", - qUtf8Printable(tr("Failed to lock. This file already opened in another window. Expect " - "collissions when run 2 copies of the program."))); - } - - return result; + return SavePatternAs(fileName); } //--------------------------------------------------------------------------------------------------------------------- @@ -3522,45 +3716,43 @@ bool MainWindow::on_actionSaveAs_triggered() * @brief on_actionSave_triggered save pattern file. * @return true for successes saving. */ -bool MainWindow::on_actionSave_triggered() +auto MainWindow::on_actionSave_triggered() -> bool { - if (VAbstractValApplication::VApp()->GetPatternPath().isEmpty() || patternReadOnly) + if (VAbstractValApplication::VApp()->GetPatternPath().isEmpty() || m_patternReadOnly) { return on_actionSaveAs_triggered(); } + + if (m_curFileFormatVersion < VPatternConverter::PatternMaxVer + && not ContinueFormatRewrite(m_curFileFormatVersionStr, VPatternConverter::PatternMaxVerStr)) + { + return false; + } + + if (not CheckFilePermissions(VAbstractValApplication::VApp()->GetPatternPath(), this)) + { + return false; + } + + QString error; + bool result = SavePattern(VAbstractValApplication::VApp()->GetPatternPath(), error); + if (result) + { + QFile::remove(VAbstractValApplication::VApp()->GetPatternPath() + *autosavePrefix); + m_curFileFormatVersion = VPatternConverter::PatternMaxVer; + m_curFileFormatVersionStr = VPatternConverter::PatternMaxVerStr; + } else { - if (m_curFileFormatVersion < VPatternConverter::PatternMaxVer - && not ContinueFormatRewrite(m_curFileFormatVersionStr, VPatternConverter::PatternMaxVerStr)) - { - return false; - } - - if (not CheckFilePermissions(VAbstractValApplication::VApp()->GetPatternPath(), this)) - { - return false; - } - - QString error; - bool result = SavePattern(VAbstractValApplication::VApp()->GetPatternPath(), error); - if (result) - { - QFile::remove(VAbstractValApplication::VApp()->GetPatternPath() + *autosavePrefix); - m_curFileFormatVersion = VPatternConverter::PatternMaxVer; - m_curFileFormatVersionStr = VPatternConverter::PatternMaxVerStr; - } - else - { - QMessageBox messageBox(this); - messageBox.setIcon(QMessageBox::Warning); - messageBox.setText(tr("Could not save the file")); - messageBox.setDefaultButton(QMessageBox::Ok); - messageBox.setDetailedText(error); - messageBox.setStandardButtons(QMessageBox::Ok); - messageBox.exec(); - } - return result; + QMessageBox messageBox(this); + messageBox.setIcon(QMessageBox::Warning); + messageBox.setText(tr("Could not save the file")); + messageBox.setDefaultButton(QMessageBox::Ok); + messageBox.setDetailedText(error); + messageBox.setStandardButtons(QMessageBox::Ok); + messageBox.exec(); } + return result; } //--------------------------------------------------------------------------------------------------------------------- @@ -3570,7 +3762,7 @@ bool MainWindow::on_actionSave_triggered() void MainWindow::on_actionOpen_triggered() { qCDebug(vMainWindow, "Openning new file."); - const QString filter(tr("Pattern files") + QLatin1String(" (*.val)")); + const QString filter(tr("Pattern files") + QStringLiteral(" (*.val)")); //Get list last open files const QStringList files = VAbstractValApplication::VApp()->ValentinaSettings()->GetRecentFileList(); QString dir; @@ -3596,13 +3788,13 @@ void MainWindow::on_actionOpen_triggered() //--------------------------------------------------------------------------------------------------------------------- void MainWindow::on_actionOpenPuzzle_triggered() { - const QString puzzle = VApplication::VApp()->PuzzleFilePath(); + const QString puzzle = VApplication::PuzzleFilePath(); const QString workingDirectory = QFileInfo(puzzle).absoluteDir().absolutePath(); QStringList arguments; if (isNoScaling) { - arguments.append(QLatin1String("--") + LONG_OPTION_NO_HDPI_SCALING); + arguments.append(QStringLiteral("--") + LONG_OPTION_NO_HDPI_SCALING); } QProcess::startDetached(puzzle, arguments, workingDirectory); @@ -3632,7 +3824,7 @@ void MainWindow::on_actionCreateManualLayout_triggered() catch (VException &e) { QMessageBox::warning(this, tr("Export details"), - tr("Can't export details.") + QLatin1String(" \n") + e.ErrorMessage(), + tr("Can't export details.") + QStringLiteral(" \n") + e.ErrorMessage(), QMessageBox::Ok, QMessageBox::Ok); return; } @@ -3651,12 +3843,12 @@ void MainWindow::on_actionCreateManualLayout_triggered() QStringList arguments {"-r", rldFile.fileName()}; if (isNoScaling) { - arguments.append(QLatin1String("--") + LONG_OPTION_NO_HDPI_SCALING); + arguments.append(QStringLiteral("--") + LONG_OPTION_NO_HDPI_SCALING); } rldFile.setAutoRemove(false); - const QString puzzle = VApplication::VApp()->PuzzleFilePath(); + const QString puzzle = VApplication::PuzzleFilePath(); const QString workingDirectory = QFileInfo(puzzle).absoluteDir().absolutePath(); QProcess::startDetached(puzzle, arguments, workingDirectory); } @@ -3669,7 +3861,7 @@ void MainWindow::on_actionCreateManualLayout_triggered() //--------------------------------------------------------------------------------------------------------------------- void MainWindow::on_actionUpdateManualLayout_triggered() { - const QString filter(tr("Manual layout files") + QLatin1String(" (*.vlt)")); + const QString filter(tr("Manual layout files") + QStringLiteral(" (*.vlt)")); //Use standard path to manual layouts const QString path = VAbstractValApplication::VApp()->ValentinaSettings()->GetPathManualLayouts(); @@ -3719,7 +3911,7 @@ void MainWindow::on_actionUpdateManualLayout_triggered() catch (VException &e) { QMessageBox::warning(this, tr("Export details"), - tr("Can't export details.") + QLatin1String(" \n") + e.ErrorMessage(), + tr("Can't export details.") + QStringLiteral(" \n") + e.ErrorMessage(), QMessageBox::Ok, QMessageBox::Ok); return; } @@ -3738,12 +3930,12 @@ void MainWindow::on_actionUpdateManualLayout_triggered() QStringList arguments {filePath, "-r", rldFile.fileName()}; if (isNoScaling) { - arguments.append(QLatin1String("--") + LONG_OPTION_NO_HDPI_SCALING); + arguments.append(QStringLiteral("--") + LONG_OPTION_NO_HDPI_SCALING); } rldFile.setAutoRemove(false); - const QString puzzle = VApplication::VApp()->PuzzleFilePath(); + const QString puzzle = VApplication::PuzzleFilePath(); const QString workingDirectory = QFileInfo(puzzle).absoluteDir().absolutePath(); QProcess::startDetached(puzzle, arguments, workingDirectory); } @@ -3773,7 +3965,7 @@ void MainWindow::ActionAddBackgroundImage() void MainWindow::Clear() { qCDebug(vMainWindow, "Reseting main window."); - lock.reset(); + m_lock.reset(); qCDebug(vMainWindow, "Unlocked pattern file."); ActionDraw(true); qCDebug(vMainWindow, "Returned to Draw mode."); @@ -3782,19 +3974,19 @@ void MainWindow::Clear() qCDebug(vMainWindow, "Clearing pattern."); if (not VAbstractValApplication::VApp()->GetPatternPath().isEmpty() && not doc->MPath().isEmpty()) { - watcher->removePath(AbsoluteMPath(VAbstractValApplication::VApp()->GetPatternPath(), doc->MPath())); + m_watcher->removePath(AbsoluteMPath(VAbstractValApplication::VApp()->GetPatternPath(), doc->MPath())); } doc->Clear(); UpdateWindowTitle(); UpdateVisibilityGroups(); - detailsWidget->UpdateList(); - backgroundImagesWidget->UpdateImages(); + m_detailsWidget->UpdateList(); + m_backgroundImagesWidget->UpdateImages(); qCDebug(vMainWindow, "Clearing scenes."); - sceneDraw->clear(); - sceneDraw->SetAcceptDrop(false); - sceneDetails->clear(); + m_sceneDraw->clear(); + m_sceneDraw->SetAcceptDrop(false); + m_sceneDetails->clear(); ArrowTool(true); - comboBoxDraws->clear(); + m_comboBoxDraws->clear(); ui->actionDraw->setEnabled(false); ui->actionDetails->setEnabled(false); ui->actionLayout->setEnabled(false); @@ -3834,8 +4026,8 @@ void MainWindow::Clear() CleanLayout(); listDetails.clear(); // don't move to CleanLayout() VAbstractApplication::VApp()->getUndoStack()->clear(); - toolOptions->ClearPropertyBrowser(); - toolOptions->itemClicked(nullptr); + m_toolOptions->ClearPropertyBrowser(); + m_toolOptions->itemClicked(nullptr); m_progressBar->setVisible(false); #if defined(Q_OS_WIN32) && QT_VERSION >= QT_VERSION_CHECK(5, 7, 0) m_taskbarProgress->setVisible(false); @@ -3876,200 +4068,61 @@ void MainWindow::FullParseFile() { qCDebug(vMainWindow, "Full parsing file"); - toolOptions->ClearPropertyBrowser(); - QFuture futureTestUniqueId; + m_toolOptions->ClearPropertyBrowser(); - auto WaitForFutureFinish = [](QFuture &futureTestUniqueId) + if (not FullParsePattern()) { - try - { - futureTestUniqueId.waitForFinished(); - } - catch (...) - { - // ignore - } - }; - - try - { - if (VAbstractValApplication::VApp()->getOpeningPattern()) - { - futureTestUniqueId = QtConcurrent::run(static_cast(doc), &VDomDocument::TestUniqueId); - } - - SetEnabledGUI(true); - doc->Parse(Document::FullParse); - ParseBackgroundImages(); - - if (VAbstractValApplication::VApp()->getOpeningPattern()) - { - futureTestUniqueId.waitForFinished(); - } - } - catch (const VExceptionUndo &) - { - /* If user want undo last operation before undo we need finish broken redo operation. For those we post event - * myself. Later in method customEvent call undo.*/ - if (VAbstractValApplication::VApp()->getOpeningPattern()) - { - try - { - futureTestUniqueId.waitForFinished(); - } - catch (const VExceptionWrongId &e) - { - qCCritical(vMainWindow, "%s\n\n%s\n\n%s", qUtf8Printable(tr("Error wrong id.")), - qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation())); - SetEnabledGUI(false); - if (not VApplication::IsGUIMode()) - { - qApp->exit(V_EX_DATAERR); - } - return; - } - } - QApplication::postEvent(this, new UndoEvent()); - return; - } - catch (const VExceptionObjectError &e) - { - qCCritical(vMainWindow, "%s\n\n%s\n\n%s", qUtf8Printable(tr("Error parsing file.")), //-V807 - qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation())); - SetEnabledGUI(false); - if (VAbstractValApplication::VApp()->getOpeningPattern()) - { - WaitForFutureFinish(futureTestUniqueId); - } - if (not VApplication::IsGUIMode()) - { - qApp->exit(V_EX_DATAERR); - } - return; - } - catch (const VExceptionConversionError &e) - { - qCCritical(vMainWindow, "%s\n\n%s\n\n%s", qUtf8Printable(tr("Error can't convert value.")), - qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation())); - SetEnabledGUI(false); - if (VAbstractValApplication::VApp()->getOpeningPattern()) - { - WaitForFutureFinish(futureTestUniqueId); - } - if (not VApplication::IsGUIMode()) - { - qApp->exit(V_EX_DATAERR); - } - return; - } - catch (const VExceptionEmptyParameter &e) - { - qCCritical(vMainWindow, "%s\n\n%s\n\n%s", qUtf8Printable(tr("Error empty parameter.")), - qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation())); - SetEnabledGUI(false); - if (VAbstractValApplication::VApp()->getOpeningPattern()) - { - WaitForFutureFinish(futureTestUniqueId); - } - if (not VApplication::IsGUIMode()) - { - qApp->exit(V_EX_DATAERR); - } - return; - } - catch (const VExceptionWrongId &e) - { - qCCritical(vMainWindow, "%s\n\n%s\n\n%s", qUtf8Printable(tr("Error wrong id.")), - qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation())); - SetEnabledGUI(false); - if (VAbstractValApplication::VApp()->getOpeningPattern()) - { - WaitForFutureFinish(futureTestUniqueId); - } - if (not VApplication::IsGUIMode()) - { - qApp->exit(V_EX_DATAERR); - } - return; - } - catch (VException &e) - { - qCCritical(vMainWindow, "%s\n\n%s\n\n%s", qUtf8Printable(tr("Error parsing file.")), - qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation())); - SetEnabledGUI(false); - if (VAbstractValApplication::VApp()->getOpeningPattern()) - { - WaitForFutureFinish(futureTestUniqueId); - } - if (not VApplication::IsGUIMode()) - { - qApp->exit(V_EX_DATAERR); - } - return; - } - catch (const std::bad_alloc &) - { - qCCritical(vMainWindow, "%s", qUtf8Printable(tr("Error parsing file (std::bad_alloc)."))); - SetEnabledGUI(false); - if (VAbstractValApplication::VApp()->getOpeningPattern()) - { - WaitForFutureFinish(futureTestUniqueId); - } - if (not VApplication::IsGUIMode()) - { - qApp->exit(V_EX_DATAERR); - } return; } QString patternPiece; - if (comboBoxDraws->currentIndex() != -1) + if (m_comboBoxDraws->currentIndex() != -1) { - patternPiece = comboBoxDraws->itemText(comboBoxDraws->currentIndex()); + patternPiece = m_comboBoxDraws->itemText(m_comboBoxDraws->currentIndex()); } - comboBoxDraws->blockSignals(true); - comboBoxDraws->clear(); + m_comboBoxDraws->blockSignals(true); + m_comboBoxDraws->clear(); QStringList patternPieceNames = doc->getPatternPieces(); patternPieceNames.sort(); - comboBoxDraws->addItems(patternPieceNames); + m_comboBoxDraws->addItems(patternPieceNames); - if (not drawMode) + if (not m_drawMode) { - comboBoxDraws->setCurrentIndex(comboBoxDraws->count()-1); + m_comboBoxDraws->setCurrentIndex(m_comboBoxDraws->count()-1); } else { - const qint32 index = comboBoxDraws->findText(patternPiece); + const qint32 index = m_comboBoxDraws->findText(patternPiece); if ( index != -1 ) { - comboBoxDraws->setCurrentIndex(index); + m_comboBoxDraws->setCurrentIndex(index); } } - comboBoxDraws->blockSignals(false); + m_comboBoxDraws->blockSignals(false); ui->actionPattern_properties->setEnabled(true); GlobalChangePP(patternPiece); - SetEnableTool(comboBoxDraws->count() > 0); - detailsWidget->UpdateList(); + SetEnableTool(m_comboBoxDraws->count() > 0); + m_detailsWidget->UpdateList(); - VMainGraphicsView::NewSceneRect(sceneDraw, VAbstractValApplication::VApp()->getSceneView()); - VMainGraphicsView::NewSceneRect(sceneDetails, VAbstractValApplication::VApp()->getSceneView()); + VMainGraphicsView::NewSceneRect(m_sceneDraw, VAbstractValApplication::VApp()->getSceneView()); + VMainGraphicsView::NewSceneRect(m_sceneDetails, VAbstractValApplication::VApp()->getSceneView()); } //--------------------------------------------------------------------------------------------------------------------- void MainWindow::GlobalChangePP(const QString &patternPiece) { - const qint32 index = comboBoxDraws->findText(patternPiece); + const qint32 index = m_comboBoxDraws->findText(patternPiece); try { if ( index != -1 ) { // -1 for not found ChangePP(index, false); - comboBoxDraws->blockSignals(true); - comboBoxDraws->setCurrentIndex(index); - comboBoxDraws->blockSignals(false); + m_comboBoxDraws->blockSignals(true); + m_comboBoxDraws->setCurrentIndex(index); + m_comboBoxDraws->blockSignals(false); } else { @@ -4083,7 +4136,7 @@ void MainWindow::GlobalChangePP(const QString &patternPiece) SetEnabledGUI(false); if (not VApplication::IsGUIMode()) { - qApp->exit(V_EX_NOINPUT); + QCoreApplication::exit(V_EX_NOINPUT); } return; } @@ -4094,7 +4147,7 @@ void MainWindow::GlobalChangePP(const QString &patternPiece) SetEnabledGUI(false); if (not VApplication::IsGUIMode()) { - qApp->exit(V_EX_NOINPUT); + QCoreApplication::exit(V_EX_NOINPUT); } return; } @@ -4103,36 +4156,36 @@ void MainWindow::GlobalChangePP(const QString &patternPiece) //--------------------------------------------------------------------------------------------------------------------- void MainWindow::PreviousPatternPiece() { - int index = comboBoxDraws->currentIndex(); + int index = m_comboBoxDraws->currentIndex(); - if (index == -1 || comboBoxDraws->count() <= 1) + if (index == -1 || m_comboBoxDraws->count() <= 1) { return; } if (index == 0) { - index = comboBoxDraws->count() - 1; + index = m_comboBoxDraws->count() - 1; } else { --index; } - comboBoxDraws->setCurrentIndex(index); + m_comboBoxDraws->setCurrentIndex(index); } //--------------------------------------------------------------------------------------------------------------------- void MainWindow::NextPatternPiece() { - int index = comboBoxDraws->currentIndex(); + int index = m_comboBoxDraws->currentIndex(); - if (index == -1 || comboBoxDraws->count() <= 1) + if (index == -1 || m_comboBoxDraws->count() <= 1) { return; } - if (index == comboBoxDraws->count()-1) + if (index == m_comboBoxDraws->count()-1) { index = 0; } @@ -4141,22 +4194,22 @@ void MainWindow::NextPatternPiece() ++index; } - comboBoxDraws->setCurrentIndex(index); + m_comboBoxDraws->setCurrentIndex(index); } //--------------------------------------------------------------------------------------------------------------------- void MainWindow::SetEnabledGUI(bool enabled) { - if (guiEnabled != enabled) + if (m_guiEnabled != enabled) { - if (enabled == false) + if (not enabled) { ArrowTool(true); VAbstractApplication::VApp()->getUndoStack()->clear(); } SetEnableWidgets(enabled); - guiEnabled = enabled; + m_guiEnabled = enabled; SetEnableTool(enabled); ui->toolBarOption->setEnabled(enabled); @@ -4179,55 +4232,60 @@ void MainWindow::SetEnableWidgets(bool enable) const bool designStage = (drawStage || detailsStage); const bool piecesStage = (detailsStage || layoutStage); - comboBoxDraws->setEnabled(enable && drawStage); - ui->actionOptionDraw->setEnabled(enable && drawStage); - ui->actionSave->setEnabled(isWindowModified() && enable && not patternReadOnly); + const bool enableOnDrawStage = (enable && drawStage); + const bool enableOnDesignStage = (enable && designStage); + const bool enableOnDetailsStage = (enable && detailsStage); + const bool enableOnPiecesStage = (enable && piecesStage); + + m_comboBoxDraws->setEnabled(enableOnDrawStage); + ui->actionOptionDraw->setEnabled(enableOnDrawStage); + ui->actionSave->setEnabled(isWindowModified() && enable && not m_patternReadOnly); ui->actionSaveAs->setEnabled(enable); - ui->actionPattern_properties->setEnabled(enable && designStage); + ui->actionPattern_properties->setEnabled(enableOnDesignStage); ui->actionZoomIn->setEnabled(enable); ui->actionZoomOut->setEnabled(enable); - ui->actionArrowTool->setEnabled(enable && designStage); - ui->actionHistory->setEnabled(enable && drawStage); - ui->actionExportRecipe->setEnabled(enable && drawStage); - ui->actionNewDraw->setEnabled(enable && drawStage); + ui->actionArrowTool->setEnabled(enableOnDesignStage); + ui->actionHistory->setEnabled(enableOnDrawStage); + ui->actionExportRecipe->setEnabled(enableOnDrawStage); + ui->actionNewDraw->setEnabled(enableOnDrawStage); ui->actionDraw->setEnabled(enable); ui->actionDetails->setEnabled(enable); ui->actionLayout->setEnabled(enable); - ui->actionTable->setEnabled(enable && designStage); + ui->actionTable->setEnabled(enableOnDesignStage); ui->actionExportIncrementsToCSV->setEnabled(enable); ui->actionExportFinalMeasurementsToCSV->setEnabled(enable); ui->actionFinalMeasurements->setEnabled(enable); ui->actionZoomFitBest->setEnabled(enable); - ui->actionZoomFitBestCurrent->setEnabled(enable && drawStage); + ui->actionZoomFitBestCurrent->setEnabled(enableOnDrawStage); ui->actionZoomOriginal->setEnabled(enable); - ui->actionShowCurveDetails->setEnabled(enable && drawStage); - ui->actionShowMainPath->setEnabled(enable && detailsStage); - ui->actionLoadIndividual->setEnabled(enable && designStage); - ui->actionLoadMultisize->setEnabled(enable && designStage); - ui->actionUnloadMeasurements->setEnabled(enable && designStage); - ui->actionPreviousPatternPiece->setEnabled(enable && drawStage); - ui->actionNextPatternPiece->setEnabled(enable && drawStage); - ui->actionAddBackgroundImage->setEnabled(enable && drawStage); + ui->actionShowCurveDetails->setEnabled(enableOnDrawStage); + ui->actionShowMainPath->setEnabled(enableOnDetailsStage); + ui->actionLoadIndividual->setEnabled(enableOnDesignStage); + ui->actionLoadMultisize->setEnabled(enableOnDesignStage); + ui->actionUnloadMeasurements->setEnabled(enableOnDesignStage); + ui->actionPreviousPatternPiece->setEnabled(enableOnDrawStage); + ui->actionNextPatternPiece->setEnabled(enableOnDrawStage); + ui->actionAddBackgroundImage->setEnabled(enableOnDrawStage); ui->actionIncreaseLabelFont->setEnabled(enable); ui->actionDecreaseLabelFont->setEnabled(enable); ui->actionOriginalLabelFont->setEnabled(enable); ui->actionHideLabels->setEnabled(enable); - ui->actionCreateManualLayout->setEnabled(enable && piecesStage); - ui->actionUpdateManualLayout->setEnabled(enable && piecesStage); + ui->actionCreateManualLayout->setEnabled(enableOnPiecesStage); + ui->actionUpdateManualLayout->setEnabled(enableOnPiecesStage); ui->actionLoadWatermark->setEnabled(enable); ui->actionRemoveWatermark->setEnabled(enable && not doc->GetWatermarkPath().isEmpty()); ui->actionEditCurrentWatermark->setEnabled(enable && not doc->GetWatermarkPath().isEmpty()); - actionDockWidgetToolOptions->setEnabled(enable && designStage); - actionDockWidgetGroups->setEnabled(enable && designStage); - actionDockWidgetBackgroundImages->setEnabled(enable && drawStage); + actionDockWidgetToolOptions->setEnabled(enableOnDesignStage); + actionDockWidgetGroups->setEnabled(enableOnDesignStage); + actionDockWidgetBackgroundImages->setEnabled(enableOnDrawStage); - undoAction->setEnabled(enable && designStage && VAbstractApplication::VApp()->getUndoStack()->canUndo()); - redoAction->setEnabled(enable && designStage && VAbstractApplication::VApp()->getUndoStack()->canRedo()); + undoAction->setEnabled(enableOnDesignStage && VAbstractApplication::VApp()->getUndoStack()->canUndo()); + redoAction->setEnabled(enableOnDesignStage && VAbstractApplication::VApp()->getUndoStack()->canRedo()); //Now we don't want allow user call context menu - sceneDraw->SetDisableTools(!enable, doc->GetNameActivPP()); + m_sceneDraw->SetDisableTools(!enable, doc->GetNameActivPP()); ui->view->setEnabled(enable); } @@ -4237,10 +4295,10 @@ void MainWindow::SetEnableWidgets(bool enable) */ void MainWindow::on_actionNew_triggered() { - if (comboBoxDraws->count() == 0) + if (m_comboBoxDraws->count() == 0) { qCDebug(vMainWindow, "New PP."); - QString patternPieceName = tr("Pattern piece %1").arg(comboBoxDraws->count()+1); + QString patternPieceName = tr("Pattern piece %1").arg(m_comboBoxDraws->count()+1); qCDebug(vMainWindow, "Generated PP name: %s", qUtf8Printable(patternPieceName)); qCDebug(vMainWindow, "First PP"); @@ -4258,12 +4316,12 @@ void MainWindow::on_actionNew_triggered() } //Set scene size to size scene view - VMainGraphicsView::NewSceneRect(sceneDraw, ui->view); - VMainGraphicsView::NewSceneRect(sceneDetails, ui->view); + VMainGraphicsView::NewSceneRect(m_sceneDraw, ui->view); + VMainGraphicsView::NewSceneRect(m_sceneDetails, ui->view); AddPP(patternPieceName); - m_mouseCoordinate = new QLabel(QString("0, 0 (%1)") + m_mouseCoordinate = new QLabel(QStringLiteral("0, 0 (%1)") .arg(UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true))); ui->toolBarOption->addWidget(m_mouseCoordinate); @@ -4284,11 +4342,11 @@ void MainWindow::on_actionNew_triggered() */ void MainWindow::PatternChangesWereSaved(bool saved) { - if (guiEnabled) + if (m_guiEnabled) { const bool state = doc->IsModified() || !saved; setWindowModified(state); - not patternReadOnly ? ui->actionSave->setEnabled(state): ui->actionSave->setEnabled(false); + not m_patternReadOnly ? ui->actionSave->setEnabled(state): ui->actionSave->setEnabled(false); m_layoutSettings->SetLayoutStale(true); isNeedAutosave = not saved; } @@ -4298,21 +4356,21 @@ void MainWindow::PatternChangesWereSaved(bool saved) void MainWindow::DimensionABaseChanged() { const qreal oldValue = m_currentDimensionA; - m_currentDimensionA = dimensionA->currentData().toDouble(); + m_currentDimensionA = m_dimensionA->currentData().toDouble(); doc->SetDimensionAValue(m_currentDimensionA); if (not VFuzzyComparePossibleNulls(oldValue, m_currentDimensionA)) { - const QList dimensions = m->Dimensions().values(); + const QList dimensions = m_m->Dimensions().values(); if (dimensions.size() > 1) { MeasurementDimension_p dimension = dimensions.at(1); - InitDimensionGradation(1, dimension, dimensionB); + InitDimensionGradation(1, dimension, m_dimensionB); if (dimensions.size() > 2) { dimension = dimensions.at(2); - InitDimensionGradation(2, dimension, dimensionC); + InitDimensionGradation(2, dimension, m_dimensionC); } } @@ -4324,17 +4382,17 @@ void MainWindow::DimensionABaseChanged() void MainWindow::DimensionBBaseChanged() { const qreal oldValue = m_currentDimensionB; - m_currentDimensionB = dimensionB->currentData().toDouble(); + m_currentDimensionB = m_dimensionB->currentData().toDouble(); doc->SetDimensionBValue(m_currentDimensionB); if (not VFuzzyComparePossibleNulls(oldValue, m_currentDimensionB)) { - const QList dimensions = m->Dimensions().values(); + const QList dimensions = m_m->Dimensions().values(); if (dimensions.size() > 2) { const MeasurementDimension_p& dimension = dimensions.at(2); - InitDimensionGradation(2, dimension, dimensionC); + InitDimensionGradation(2, dimension, m_dimensionC); } m_gradation->start(); @@ -4345,7 +4403,7 @@ void MainWindow::DimensionBBaseChanged() void MainWindow::DimensionCBaseChanged() { const qreal oldValue = m_currentDimensionC; - m_currentDimensionC = dimensionC->currentData().toDouble(); + m_currentDimensionC = m_dimensionC->currentData().toDouble(); doc->SetDimensionCValue(m_currentDimensionC); if (not VFuzzyComparePossibleNulls(oldValue, m_currentDimensionC)) @@ -4359,16 +4417,16 @@ void MainWindow::GradationChanged() { m_gradation->stop(); - if (m->isNull()) + if (m_m->isNull()) { - m = OpenMeasurementFile(AbsoluteMPath(VAbstractValApplication::VApp()->GetPatternPath(), doc->MPath())); + m_m = OpenMeasurementFile(AbsoluteMPath(VAbstractValApplication::VApp()->GetPatternPath(), doc->MPath())); } - if (UpdateMeasurements(m, m_currentDimensionA, m_currentDimensionB, m_currentDimensionC)) + if (UpdateMeasurements(m_m, m_currentDimensionA, m_currentDimensionB, m_currentDimensionC)) { doc->LiteParseTree(Document::FullLiteParse); StoreDimensions(); - emit sceneDetails->DimensionsChanged(); + emit m_sceneDetails->DimensionsChanged(); } else { @@ -4386,7 +4444,7 @@ void MainWindow::ShowProgress() #if defined(Q_OS_WIN32) && QT_VERSION >= QT_VERSION_CHECK(5, 7, 0) m_taskbarProgress->setValue(newValue); #endif - qApp->processEvents(); + QCoreApplication::processEvents(); } } @@ -4403,7 +4461,7 @@ void MainWindow::ClearPatternMessages() //--------------------------------------------------------------------------------------------------------------------- void MainWindow::SetDefaultGUILanguage() { - if (VApplication::VApp()->IsGUIMode()) + if (VApplication::IsGUIMode()) { VValentinaSettings *settings = VAbstractValApplication::VApp()->ValentinaSettings(); if (not settings->IsLocaleSelected()) @@ -4426,9 +4484,9 @@ void MainWindow::AddBackgroundImageItem(const QUuid &id) { NewBackgroundImageItem(doc->GetBackgroundImage(id)); - if (backgroundImagesWidget != nullptr) + if (m_backgroundImagesWidget != nullptr) { - backgroundImagesWidget->UpdateImages(); + m_backgroundImagesWidget->UpdateImages(); } } @@ -4445,9 +4503,9 @@ void MainWindow::DeleteBackgroundImageItem(const QUuid &id) m_backgroudcontrols->ActivateControls(QUuid()); } - if (backgroundImagesWidget != nullptr) + if (m_backgroundImagesWidget != nullptr) { - backgroundImagesWidget->UpdateImages(); + m_backgroundImagesWidget->UpdateImages(); } } } @@ -4523,42 +4581,193 @@ void MainWindow::ParseBackgroundImages() { NewBackgroundImageItem(image); } - backgroundImagesWidget->UpdateImages(); + m_backgroundImagesWidget->UpdateImages(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void MainWindow::ActionHistory_triggered(bool checked) +{ + if (checked) + { + m_dialogHistory = new DialogHistory(pattern, doc, this); + m_dialogHistory->setWindowFlags(Qt::Window); + connect(this, &MainWindow::RefreshHistory, m_dialogHistory.data(), &DialogHistory::UpdateHistory); + connect(m_dialogHistory.data(), &DialogHistory::DialogClosed, this, [this]() + { + ui->actionHistory->setChecked(false); + delete m_dialogHistory; + }); + // Fix issue #526. Dialog Detail is not on top after selection second object on Mac. + m_dialogHistory->setWindowFlags(m_dialogHistory->windowFlags() | Qt::WindowStaysOnTopHint); + m_dialogHistory->show(); + } + else + { + ui->actionHistory->setChecked(true); + m_dialogHistory->activateWindow(); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void MainWindow::ActionExportRecipe_triggered() +{ + QString filters(tr("Recipe files") + QStringLiteral("(*.vpr)")); + QString fileName = + QFileDialog::getSaveFileName(this, tr("Export recipe"), + QDir::homePath() + '/' + tr("recipe") + QStringLiteral(".vpr"), + filters, nullptr, VAbstractApplication::VApp()->NativeFileDialog()); + if (fileName.isEmpty()) + { + return; + } + + try + { + VPatternRecipe recipe(doc); + QString error; + if (not recipe.SaveDocument(fileName, error)) + { + qCWarning(vMainWindow, "%s", qUtf8Printable(tr("Could not save recipe. %1").arg(error))); + } + } + catch (const VExceptionInvalidHistory &e) + { + qCCritical(vMainWindow, "%s", qUtf8Printable(tr("Could not create recipe file. %1").arg(e.ErrorMessage()))); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void MainWindow::ActionNewDraw_triggered() +{ + qCDebug(vMainWindow, "New PP."); + QString patternPieceName = tr("Pattern piece %1").arg(m_comboBoxDraws->count()+1); + qCDebug(vMainWindow, "Generated PP name: %s", qUtf8Printable(patternPieceName)); + + qCDebug(vMainWindow, "PP count %d", m_comboBoxDraws->count()); + bool ok = PatternPieceName(patternPieceName); + qCDebug(vMainWindow, "PP name: %s", qUtf8Printable(patternPieceName)); + if (not ok) + { + return; + } + + AddPP(patternPieceName); +} + +//--------------------------------------------------------------------------------------------------------------------- +void MainWindow::ActionTable_triggered() +{ + // Because of bug on Mac with Qt 5.11 closing this dialog causes a crash. Instead of closing we will keep + // dialog in memory. + if (m_dialogTable.isNull()) + { + m_dialogTable = new DialogIncrements(pattern, doc, this); + connect(m_dialogTable.data(), &DialogIncrements::UpdateProperties, m_toolOptions, + &VToolOptionsPropertyBrowser::RefreshOptions); + m_dialogTable->show(); + } + else + { + m_dialogTable->FullUpdateFromFile(); + m_dialogTable->RestoreAfterClose(); // Redo some moves after close + m_dialogTable->isVisible() ? m_dialogTable->activateWindow() : m_dialogTable->show(); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void MainWindow::ActionFinalMeasurements_triggered() +{ + if (m_dialogFMeasurements.isNull()) + { + m_dialogFMeasurements = new DialogFinalMeasurements(doc, this); + m_dialogFMeasurements->setAttribute(Qt::WA_DeleteOnClose); + connect(m_dialogFMeasurements.data(), &DialogFinalMeasurements::finished, this, [this](int result) + { + if (result == QDialog::Accepted) + { + doc->SetFinalMeasurements(m_dialogFMeasurements->FinalMeasurements()); + emit doc->UpdatePatternLabel(); + } + m_dialogFMeasurements->close(); + }); + m_dialogFMeasurements->show(); + } + else + { + m_dialogFMeasurements->activateWindow(); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void MainWindow::ActionShowMainPath_triggered(bool checked) +{ + VAbstractValApplication::VApp()->ValentinaSettings()->SetPieceShowMainPath(checked); + const QList ids = pattern->DataPieces()->keys(); + const bool updateChildren = false; + QGuiApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); + for(const auto &id : ids) + { + try + { + if (auto *tool = qobject_cast(VAbstractPattern::getTool(id))) + { + tool->RefreshGeometry(updateChildren); + } + } + catch(VExceptionBadId &) + {} + } + QGuiApplication::restoreOverrideCursor(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void MainWindow::ActionOpenTape_triggered() +{ + const QString tape = VApplication::TapeFilePath(); + const QString workingDirectory = QFileInfo(tape).absoluteDir().absolutePath(); + + QStringList arguments; + if (isNoScaling) + { + arguments.append(QStringLiteral("--") + LONG_OPTION_NO_HDPI_SCALING); + } + + QProcess::startDetached(tape, arguments, workingDirectory); } //--------------------------------------------------------------------------------------------------------------------- void MainWindow::InitDimensionControls() { - if (not dimensionA.isNull()) + if (not m_dimensionA.isNull()) { - delete dimensionA; + delete m_dimensionA; } - if (not dimensionALabel.isNull()) + if (not m_dimensionALabel.isNull()) { - delete dimensionALabel; + delete m_dimensionALabel; } - if (not dimensionB.isNull()) + if (not m_dimensionB.isNull()) { - delete dimensionB; + delete m_dimensionB; } - if (not dimensionBLabel.isNull()) + if (not m_dimensionBLabel.isNull()) { - delete dimensionBLabel; + delete m_dimensionBLabel; } - if (not dimensionC.isNull()) + if (not m_dimensionC.isNull()) { - delete dimensionC; + delete m_dimensionC; } - if (not dimensionCLabel.isNull()) + if (not m_dimensionCLabel.isNull()) { - delete dimensionCLabel; + delete m_dimensionCLabel; } if (VAbstractValApplication::VApp()->GetMeasurementsType() == MeasurementsType::Multisize) { - const QList dimensions = m->Dimensions().values(); + const QList dimensions = m_m->Dimensions().values(); const QString unit = UnitsToStr(VAbstractValApplication::VApp()->MeasurementsUnits(), true); auto InitControl = [this, dimensions, unit](int index, QPointer &name, QPointer &control) @@ -4575,7 +4784,7 @@ void MainWindow::InitDimensionControls() { name->setText(dimension->Name()+QChar(':')); } - name->setToolTip(VAbstartMeasurementDimension::DimensionToolTip(dimension, m->IsFullCircumference())); + name->setToolTip(VAbstartMeasurementDimension::DimensionToolTip(dimension, m_m->IsFullCircumference())); if (control.isNull()) { @@ -4590,25 +4799,25 @@ void MainWindow::InitDimensionControls() } }; - InitControl(0, dimensionALabel, dimensionA); - InitControl(1, dimensionBLabel, dimensionB); - InitControl(2, dimensionCLabel, dimensionC); + InitControl(0, m_dimensionALabel, m_dimensionA); + InitControl(1, m_dimensionBLabel, m_dimensionB); + InitControl(2, m_dimensionCLabel, m_dimensionC); - if (not dimensionA.isNull()) + if (not m_dimensionA.isNull()) { - connect(dimensionA.data(), QOverload::of(&QComboBox::currentIndexChanged), + connect(m_dimensionA.data(), QOverload::of(&QComboBox::currentIndexChanged), this, &MainWindow::DimensionABaseChanged); } - if (not dimensionB.isNull()) + if (not m_dimensionB.isNull()) { - connect(dimensionB.data(), QOverload::of(&QComboBox::currentIndexChanged), + connect(m_dimensionB.data(), QOverload::of(&QComboBox::currentIndexChanged), this, &MainWindow::DimensionBBaseChanged); } - if (not dimensionC.isNull()) + if (not m_dimensionC.isNull()) { - connect(dimensionC.data(), QOverload::of(&QComboBox::currentIndexChanged), + connect(m_dimensionC.data(), QOverload::of(&QComboBox::currentIndexChanged), this, &MainWindow::DimensionCBaseChanged); } @@ -4622,9 +4831,6 @@ void MainWindow::InitDimensionGradation(int index, const MeasurementDimension_p { SCASSERT(control != nullptr) - const bool fc = m->IsFullCircumference(); - const QString unit = UnitsToStr(VAbstractValApplication::VApp()->MeasurementsUnits(), true); - qreal current = -1; if (control->currentIndex() != -1) { @@ -4639,39 +4845,12 @@ void MainWindow::InitDimensionGradation(int index, const MeasurementDimension_p if (dimension->Type() == MeasurementDimension::X) { - for(auto base : bases) - { - if (labels.contains(base) && not labels.value(base).isEmpty()) - { - control->addItem(labels.value(base), base); - } - else - { - control->addItem(QStringLiteral("%1 %2").arg(base).arg(unit), base); - } - } + InitDimensionXGradation(bases, labels, control); } else if (dimension->Type() == MeasurementDimension::Y || dimension->Type() == MeasurementDimension::W || dimension->Type() == MeasurementDimension::Z) { - for(auto base : bases) - { - if (labels.contains(base) && not labels.value(base).isEmpty()) - { - control->addItem(labels.value(base), base); - } - else - { - if (dimension->IsBodyMeasurement()) - { - control->addItem(QStringLiteral("%1 %2").arg(fc ? base*2 : base).arg(unit), base); - } - else - { - control->addItem(QString::number(base), base); - } - } - } + InitDimensionYWZGradation(bases, labels, control, dimension->IsBodyMeasurement()); } // after initialization the current index is 0. The signal for changing the index will not be triggered if not make @@ -4691,6 +4870,52 @@ void MainWindow::InitDimensionGradation(int index, const MeasurementDimension_p } } +//--------------------------------------------------------------------------------------------------------------------- +void MainWindow::InitDimensionXGradation(const QVector &bases, const DimesionLabels &labels, + const QPointer &control) +{ + const QString unit = UnitsToStr(VAbstractValApplication::VApp()->MeasurementsUnits(), true); + + for(auto base : bases) + { + if (labels.contains(base) && not labels.value(base).isEmpty()) + { + control->addItem(labels.value(base), base); + } + else + { + control->addItem(QStringLiteral("%1 %2").arg(base).arg(unit), base); + } + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void MainWindow::InitDimensionYWZGradation(const QVector &bases, const DimesionLabels &labels, + const QPointer &control, bool bodyMeasurement) +{ + const bool fc = m_m->IsFullCircumference(); + const QString unit = UnitsToStr(VAbstractValApplication::VApp()->MeasurementsUnits(), true); + + for(auto base : bases) + { + if (labels.contains(base) && not labels.value(base).isEmpty()) + { + control->addItem(labels.value(base), base); + } + else + { + if (bodyMeasurement) + { + control->addItem(QStringLiteral("%1 %2").arg(fc ? base*2 : base).arg(unit), base); + } + else + { + control->addItem(QString::number(base), base); + } + } + } +} + //--------------------------------------------------------------------------------------------------------------------- /** * @brief SetEnableTool enable button. @@ -4767,7 +4992,7 @@ QT_WARNING_POP ui->actionLast_tool->setEnabled(drawTools); - for (auto pointer : qAsConst(toolButtonPointerList)) + for (auto *pointer : qAsConst(m_toolButtonPointerList)) { pointer->setEnabled(drawTools || modelingTools); pointer->setChecked(drawTools || modelingTools); @@ -4813,7 +5038,7 @@ void MainWindow::MinimumScrollBar() * @param fileName pattern file name. * @return true if all is good. */ -bool MainWindow::SavePattern(const QString &fileName, QString &error) +auto MainWindow::SavePattern(const QString &fileName, QString &error) -> bool { qCDebug(vMainWindow, "Saving pattern file %s.", qUtf8Printable(fileName)); QFileInfo tempInfo(fileName); @@ -4850,7 +5075,7 @@ bool MainWindow::SavePattern(const QString &fileName, QString &error) */ void MainWindow::AutoSavePattern() { - if (VApplication::VApp()->IsGUIMode() && not VAbstractValApplication::VApp()->GetPatternPath().isEmpty() + if (VApplication::IsGUIMode() && not VAbstractValApplication::VApp()->GetPatternPath().isEmpty() && isWindowModified() && isNeedAutosave) { qCDebug(vMainWindow, "Autosaving pattern."); @@ -4978,9 +5203,9 @@ void MainWindow::WriteSettings() * @brief MaybeSave The function is called to save pending changes. * @return returns true in all cases, except when the user clicks Cancel. */ -bool MainWindow::MaybeSave() +auto MainWindow::MaybeSave() -> bool { - if (this->isWindowModified() && guiEnabled) + if (this->isWindowModified() && m_guiEnabled) { QScopedPointer messageBox(new QMessageBox(tr("Unsaved changes"), tr("The pattern has been modified.\n" @@ -4993,7 +5218,7 @@ bool MainWindow::MaybeSave() messageBox->setButtonText(QMessageBox::Yes, VAbstractValApplication::VApp() - ->GetPatternPath().isEmpty() || patternReadOnly ? tr("Save…") : tr("Save")); + ->GetPatternPath().isEmpty() || m_patternReadOnly ? tr("Save…") : tr("Save")); messageBox->setButtonText(QMessageBox::No, tr("Don't Save")); messageBox->setWindowModality(Qt::ApplicationModal); @@ -5002,7 +5227,7 @@ bool MainWindow::MaybeSave() switch (ret) { case QMessageBox::Yes: - if (patternReadOnly) + if (m_patternReadOnly) { return on_actionSaveAs_triggered(); } @@ -5035,16 +5260,16 @@ void MainWindow::CreateMenus() //Add Undo/Redo actions. undoAction = VAbstractApplication::VApp()->getUndoStack()->createUndoAction(this, tr("&Undo")); - connect(undoAction, &QAction::triggered, toolOptions, &VToolOptionsPropertyBrowser::RefreshOptions); + connect(undoAction, &QAction::triggered, m_toolOptions, &VToolOptionsPropertyBrowser::RefreshOptions); undoAction->setShortcuts(QKeySequence::Undo); - undoAction->setIcon(QIcon::fromTheme("edit-undo")); + undoAction->setIcon(QIcon::fromTheme(QStringLiteral("edit-undo"))); ui->menuPatternPiece->insertAction(ui->actionLast_tool, undoAction); ui->toolBarTools->addAction(undoAction); redoAction = VAbstractApplication::VApp()->getUndoStack()->createRedoAction(this, tr("&Redo")); - connect(redoAction, &QAction::triggered, toolOptions, &VToolOptionsPropertyBrowser::RefreshOptions); + connect(redoAction, &QAction::triggered, m_toolOptions, &VToolOptionsPropertyBrowser::RefreshOptions); redoAction->setShortcuts(QKeySequence::Redo); - redoAction->setIcon(QIcon::fromTheme("edit-redo")); + redoAction->setIcon(QIcon::fromTheme(QStringLiteral("edit-redo"))); ui->menuPatternPiece->insertAction(ui->actionLast_tool, redoAction); ui->toolBarTools->addAction(redoAction); @@ -5063,15 +5288,15 @@ void MainWindow::LastUsedTool() // This check helps to find missed tools in the switch Q_STATIC_ASSERT_X(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 59, "Not all tools were handled."); - if (currentTool == lastUsedTool) + if (m_currentTool == m_lastUsedTool) { return; } - switch ( lastUsedTool ) + switch ( m_lastUsedTool ) { case Tool::Arrow: - for (auto pointer : qAsConst(toolButtonPointerList)) + for (auto *pointer : qAsConst(m_toolButtonPointerList)) { pointer->setChecked(true); } @@ -5312,32 +5537,32 @@ void MainWindow::AddDocks() void MainWindow::InitDocksContain() { qCDebug(vMainWindow, "Initialization property browser."); - toolOptions = new VToolOptionsPropertyBrowser(ui->dockWidgetToolOptions); + m_toolOptions = new VToolOptionsPropertyBrowser(ui->dockWidgetToolOptions); - connect(ui->view, &VMainGraphicsView::itemClicked, toolOptions, &VToolOptionsPropertyBrowser::itemClicked); - connect(doc, &VPattern::FullUpdateFromFile, toolOptions, &VToolOptionsPropertyBrowser::UpdateOptions); + connect(ui->view, &VMainGraphicsView::itemClicked, m_toolOptions, &VToolOptionsPropertyBrowser::itemClicked); + connect(doc, &VPattern::FullUpdateFromFile, m_toolOptions, &VToolOptionsPropertyBrowser::UpdateOptions); qCDebug(vMainWindow, "Initialization groups dock."); - groupsWidget = new VWidgetGroups(doc, this); - ui->dockWidgetGroups->setWidget(groupsWidget); + m_groupsWidget = new VWidgetGroups(doc, this); + ui->dockWidgetGroups->setWidget(m_groupsWidget); connect(doc, &VAbstractPattern::UpdateGroups, this, &MainWindow::UpdateVisibilityGroups); - detailsWidget = new VWidgetDetails(pattern, doc, this); - connect(doc, &VPattern::FullUpdateFromFile, detailsWidget, &VWidgetDetails::UpdateList); - connect(doc, &VPattern::UpdateInLayoutList, detailsWidget, &VWidgetDetails::UpdateList); - connect(doc, &VPattern::ShowDetail, detailsWidget, &VWidgetDetails::SelectDetail); - connect(detailsWidget, &VWidgetDetails::Highlight, sceneDetails, &VMainGraphicsScene::HighlightItem); - detailsWidget->setVisible(false); + m_detailsWidget = new VWidgetDetails(pattern, doc, this); + connect(doc, &VPattern::FullUpdateFromFile, m_detailsWidget, &VWidgetDetails::UpdateList); + connect(doc, &VPattern::UpdateInLayoutList, m_detailsWidget, &VWidgetDetails::UpdateList); + connect(doc, &VPattern::ShowDetail, m_detailsWidget, &VWidgetDetails::SelectDetail); + connect(m_detailsWidget, &VWidgetDetails::Highlight, m_sceneDetails, &VMainGraphicsScene::HighlightItem); + m_detailsWidget->setVisible(false); - backgroundImagesWidget = new VWidgetBackgroundImages(doc, this); - ui->dockWidgetBackgroundImages->setWidget(backgroundImagesWidget); - connect(backgroundImagesWidget, &VWidgetBackgroundImages::DeleteImage, this, &MainWindow::RemoveBackgroundImage); + m_backgroundImagesWidget = new VWidgetBackgroundImages(doc, this); + ui->dockWidgetBackgroundImages->setWidget(m_backgroundImagesWidget); + connect(m_backgroundImagesWidget, &VWidgetBackgroundImages::DeleteImage, this, &MainWindow::RemoveBackgroundImage); } //--------------------------------------------------------------------------------------------------------------------- -bool MainWindow::OpenNewValentina(const QString &fileName) const +auto MainWindow::OpenNewValentina(const QString &fileName) const -> bool { - if (this->isWindowModified() || VAbstractValApplication::VApp()->GetPatternPath().isEmpty() == false) + if (this->isWindowModified() || not VAbstractValApplication::VApp()->GetPatternPath().isEmpty()) { VApplication::NewValentina(fileName); return true; @@ -5354,118 +5579,13 @@ void MainWindow::CreateActions() connect(ui->actionDraw, &QAction::triggered, this, &MainWindow::ActionDraw); connect(ui->actionDetails, &QAction::triggered, this, &MainWindow::ActionDetails); connect(ui->actionLayout, &QAction::triggered, this, &MainWindow::ActionLayout); - - connect(ui->actionHistory, &QAction::triggered, this, [this](bool checked) - { - if (checked) - { - dialogHistory = new DialogHistory(pattern, doc, this); - dialogHistory->setWindowFlags(Qt::Window); - connect(this, &MainWindow::RefreshHistory, dialogHistory.data(), &DialogHistory::UpdateHistory); - connect(dialogHistory.data(), &DialogHistory::DialogClosed, this, [this]() - { - ui->actionHistory->setChecked(false); - delete dialogHistory; - }); - // Fix issue #526. Dialog Detail is not on top after selection second object on Mac. - dialogHistory->setWindowFlags(dialogHistory->windowFlags() | Qt::WindowStaysOnTopHint); - dialogHistory->show(); - } - else - { - ui->actionHistory->setChecked(true); - dialogHistory->activateWindow(); - } - }); - - connect(ui->actionExportRecipe, &QAction::triggered, this, [this]() - { - QString filters(tr("Recipe files") + QStringLiteral("(*.vpr)")); - QString fileName = - QFileDialog::getSaveFileName(this, tr("Export recipe"), - QDir::homePath() + '/' + tr("recipe") + QStringLiteral(".vpr"), - filters, nullptr, VAbstractApplication::VApp()->NativeFileDialog()); - if (fileName.isEmpty()) - { - return; - } - - try - { - VPatternRecipe recipe(doc); - QString error; - if (not recipe.SaveDocument(fileName, error)) - { - qCWarning(vMainWindow, "%s", qUtf8Printable(tr("Could not save recipe. %1").arg(error))); - } - } - catch (const VExceptionInvalidHistory &e) - { - qCCritical(vMainWindow, "%s", qUtf8Printable(tr("Could not create recipe file. %1").arg(e.ErrorMessage()))); - } - }); - - connect(ui->actionNewDraw, &QAction::triggered, this, [this]() - { - qCDebug(vMainWindow, "New PP."); - QString patternPieceName = tr("Pattern piece %1").arg(comboBoxDraws->count()+1); - qCDebug(vMainWindow, "Generated PP name: %s", qUtf8Printable(patternPieceName)); - - qCDebug(vMainWindow, "PP count %d", comboBoxDraws->count()); - bool ok = PatternPieceName(patternPieceName); - qCDebug(vMainWindow, "PP name: %s", qUtf8Printable(patternPieceName)); - if (not ok) - { - return; - } - - AddPP(patternPieceName); - }); - + connect(ui->actionHistory, &QAction::triggered, this, &MainWindow::ActionHistory_triggered); + connect(ui->actionExportRecipe, &QAction::triggered, this, &MainWindow::ActionExportRecipe_triggered); + connect(ui->actionNewDraw, &QAction::triggered, this, &MainWindow::ActionNewDraw_triggered); connect(ui->actionExportIncrementsToCSV, &QAction::triggered, this, &MainWindow::ExportDataToCSV); connect(ui->actionExportFinalMeasurementsToCSV, &QAction::triggered, this, &MainWindow::ExportFMeasurementsToCSV); - - connect(ui->actionTable, &QAction::triggered, this, [this]() - { - // Because of bug on Mac with Qt 5.11 closing this dialog causes a crash. Instead of closing we will keep - // dialog in memory. - if (dialogTable.isNull()) - { - dialogTable = new DialogIncrements(pattern, doc, this); - connect(dialogTable.data(), &DialogIncrements::UpdateProperties, toolOptions, - &VToolOptionsPropertyBrowser::RefreshOptions); - dialogTable->show(); - } - else - { - dialogTable->FullUpdateFromFile(); - dialogTable->RestoreAfterClose(); // Redo some moves after close - dialogTable->isVisible() ? dialogTable->activateWindow() : dialogTable->show(); - } - }); - - connect(ui->actionFinalMeasurements, &QAction::triggered, this, [this]() - { - if (dialogFMeasurements.isNull()) - { - dialogFMeasurements = new DialogFinalMeasurements(doc, this); - dialogFMeasurements->setAttribute(Qt::WA_DeleteOnClose); - connect(dialogFMeasurements.data(), &DialogFinalMeasurements::finished, this, [this](int result) - { - if (result == QDialog::Accepted) - { - doc->SetFinalMeasurements(dialogFMeasurements->FinalMeasurements()); - emit doc->UpdatePatternLabel(); - } - dialogFMeasurements->close(); - }); - dialogFMeasurements->show(); - } - else - { - dialogFMeasurements->activateWindow(); - } - }); + connect(ui->actionTable, &QAction::triggered, this, &MainWindow::ActionTable_triggered); + connect(ui->actionFinalMeasurements, &QAction::triggered, this, &MainWindow::ActionFinalMeasurements_triggered); connect(ui->actionAbout_Qt, &QAction::triggered, this, [this]() { @@ -5474,7 +5594,7 @@ void MainWindow::CreateActions() connect(ui->actionAbout_Valentina, &QAction::triggered, this, [this]() { - DialogAboutApp *aboutDialog = new DialogAboutApp(this); + auto *aboutDialog = new DialogAboutApp(this); aboutDialog->setAttribute(Qt::WA_DeleteOnClose, true); aboutDialog->show(); }); @@ -5498,7 +5618,7 @@ void MainWindow::CreateActions() connect(ui->actionPattern_properties, &QAction::triggered, this, [this]() { DialogPatternProperties proper(doc, pattern, this); - connect(&proper, &DialogPatternProperties::UpddatePieces, sceneDetails, + connect(&proper, &DialogPatternProperties::UpddatePieces, m_sceneDetails, &VMainGraphicsScene::UpdatePiecePassmarks); proper.exec(); }); @@ -5517,49 +5637,16 @@ void MainWindow::CreateActions() connect(ui->actionShowCurveDetails, &QAction::triggered, this, [this](bool checked) { emit ui->view->itemClicked(nullptr); - sceneDraw->EnableDetailsMode(checked); + m_sceneDraw->EnableDetailsMode(checked); VAbstractValApplication::VApp()->ValentinaSettings()->SetShowCurveDetails(checked); }); ui->actionShowMainPath->setChecked(VAbstractValApplication::VApp()->ValentinaSettings()->IsPieceShowMainPath()); - connect(ui->actionShowMainPath, &QAction::triggered, this, [this](bool checked) - { - VAbstractValApplication::VApp()->ValentinaSettings()->SetPieceShowMainPath(checked); - const QList ids = pattern->DataPieces()->keys(); - const bool updateChildren = false; - QGuiApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); - for(auto &id : ids) - { - try - { - if (VToolSeamAllowance *tool = qobject_cast(VAbstractPattern::getTool(id))) - { - tool->RefreshGeometry(updateChildren); - } - } - catch(VExceptionBadId &) - {} - } - QGuiApplication::restoreOverrideCursor(); - }); + connect(ui->actionShowMainPath, &QAction::triggered, this, &MainWindow::ActionShowMainPath_triggered); connect(ui->actionLoadIndividual, &QAction::triggered, this, &MainWindow::LoadIndividual); connect(ui->actionLoadMultisize, &QAction::triggered, this, &MainWindow::LoadMultisize); - - connect(ui->actionOpenTape, &QAction::triggered, this, [this]() - { - const QString tape = VApplication::VApp()->TapeFilePath(); - const QString workingDirectory = QFileInfo(tape).absoluteDir().absolutePath(); - - QStringList arguments; - if (isNoScaling) - { - arguments.append(QLatin1String("--") + LONG_OPTION_NO_HDPI_SCALING); - } - - QProcess::startDetached(tape, arguments, workingDirectory); - }); - + connect(ui->actionOpenTape, &QAction::triggered, this, &MainWindow::ActionOpenTape_triggered); connect(ui->actionEditCurrent, &QAction::triggered, this, &MainWindow::ShowMeasurements); connect(ui->actionExportAs, &QAction::triggered, this, &MainWindow::ExportLayoutAs); connect(ui->actionPrintPreview, &QAction::triggered, this, &MainWindow::PrintPreviewOrigin); @@ -5570,12 +5657,12 @@ void MainWindow::CreateActions() //Actions for recent files loaded by a main window application. for (int i = 0; i < MaxRecentFiles; ++i) { - QAction *action = new QAction(this); + auto *action = new QAction(this); action->setVisible(false); m_recentFileActs[i] = action; connect(m_recentFileActs[i], &QAction::triggered, this, [this]() { - if (QAction *action = qobject_cast(sender())) + if (auto *action = qobject_cast(sender())) { const QString filePath = action->data().toString(); if (not filePath.isEmpty()) @@ -5605,25 +5692,25 @@ void MainWindow::CreateActions() void MainWindow::InitAutoSave() { //Autosaving file each 1 minutes - delete autoSaveTimer; - autoSaveTimer = nullptr; + delete m_autoSaveTimer; + m_autoSaveTimer = nullptr; - autoSaveTimer = new QTimer(this); - autoSaveTimer->setTimerType(Qt::VeryCoarseTimer); - connect(autoSaveTimer, &QTimer::timeout, this, &MainWindow::AutoSavePattern); - autoSaveTimer->stop(); + m_autoSaveTimer = new QTimer(this); + m_autoSaveTimer->setTimerType(Qt::VeryCoarseTimer); + connect(m_autoSaveTimer, &QTimer::timeout, this, &MainWindow::AutoSavePattern); + m_autoSaveTimer->stop(); if (VAbstractValApplication::VApp()->ValentinaSettings()->GetAutosaveState()) { const qint32 autoTime = VAbstractValApplication::VApp()->ValentinaSettings()->GetAutosaveTime(); - autoSaveTimer->start(autoTime*60000); + m_autoSaveTimer->start(autoTime*60000); qCDebug(vMainWindow, "Autosaving each %d minutes.", autoTime); } - VApplication::VApp()->setAutoSaveTimer(autoSaveTimer); + VApplication::VApp()->setAutoSaveTimer(m_autoSaveTimer); } //--------------------------------------------------------------------------------------------------------------------- -bool MainWindow::PatternPieceName(QString &name) +auto MainWindow::PatternPieceName(QString &name) -> bool { QScopedPointer dlg(new QInputDialog(this)); dlg->setInputMode( QInputDialog::TextInput ); @@ -5633,7 +5720,7 @@ bool MainWindow::PatternPieceName(QString &name) dlg->resize(300, 100); dlg->setTextValue(name); QString nameDraw; - while (1) + while (true) { const bool bOk = dlg->exec(); nameDraw = dlg->textValue(); @@ -5647,7 +5734,7 @@ bool MainWindow::PatternPieceName(QString &name) continue; } - if (comboBoxDraws->findText(nameDraw) == -1) + if (m_comboBoxDraws->findText(nameDraw) == -1) { name = nameDraw; break;// unique name @@ -5670,7 +5757,7 @@ MainWindow::~MainWindow() * @brief LoadPattern open pattern file. * @param fileName name of file. */ -bool MainWindow::LoadPattern(QString fileName, const QString& customMeasureFile) +auto MainWindow::LoadPattern(QString fileName, const QString& customMeasureFile) -> bool { qCDebug(vMainWindow, "Loading new file %s.", qUtf8Printable(fileName)); @@ -5701,7 +5788,7 @@ bool MainWindow::LoadPattern(QString fileName, const QString& customMeasureFile) return false; } - if (fileName.endsWith(".vit") || fileName.endsWith(".vst")) + if (fileName.endsWith(QStringLiteral(".vit")) || fileName.endsWith(QStringLiteral(".vst"))) { try { @@ -5712,17 +5799,17 @@ bool MainWindow::LoadPattern(QString fileName, const QString& customMeasureFile) if (m.Type() == MeasurementsType::Multisize || m.Type() == MeasurementsType::Individual) { - const QString tape = VApplication::VApp()->TapeFilePath(); + const QString tape = VApplication::TapeFilePath(); const QString workingDirectory = QFileInfo(tape).absoluteDir().absolutePath(); QStringList arguments = QStringList() << fileName; if (isNoScaling) { - arguments.append(QLatin1String("--") + LONG_OPTION_NO_HDPI_SCALING); + arguments.append(QStringLiteral("--") + LONG_OPTION_NO_HDPI_SCALING); } QProcess::startDetached(tape, arguments, workingDirectory); - qApp->exit(V_EX_OK); + QCoreApplication::exit(V_EX_OK); return false; // stop continue processing } } @@ -5733,55 +5820,55 @@ bool MainWindow::LoadPattern(QString fileName, const QString& customMeasureFile) Clear(); if (not VApplication::IsGUIMode()) { - qApp->exit(V_EX_NOINPUT); + QCoreApplication::exit(V_EX_NOINPUT); } return false; } } - if (fileName.endsWith(".vlt")) + if (fileName.endsWith(QStringLiteral(".vlt"))) { // Here comes undocumented Valentina's feature. // Because app bundle in Mac OS X doesn't allow setup assosiation for Puzzle we must do this through Valentina - const QString puzzle = VApplication::VApp()->PuzzleFilePath(); + const QString puzzle = VApplication::PuzzleFilePath(); const QString workingDirectory = QFileInfo(puzzle).absoluteDir().absolutePath(); QStringList arguments = QStringList() << fileName; if (isNoScaling) { - arguments.append(QLatin1String("--") + LONG_OPTION_NO_HDPI_SCALING); + arguments.append(QStringLiteral("--") + LONG_OPTION_NO_HDPI_SCALING); } QProcess::startDetached(puzzle, arguments, workingDirectory); - qApp->exit(V_EX_OK); + QCoreApplication::exit(V_EX_OK); return false; // stop continue processing } qCDebug(vMainWindow, "Loking file"); - VlpCreateLock(lock, fileName); + VlpCreateLock(m_lock, fileName); - if (lock->IsLocked()) + if (m_lock->IsLocked()) { qCDebug(vMainWindow, "Pattern file %s was locked.", qUtf8Printable(fileName)); } else { - if (not IgnoreLocking(lock->GetLockError(), fileName, VApplication::IsGUIMode())) + if (not IgnoreLocking(m_lock->GetLockError(), fileName, VApplication::IsGUIMode())) { return false; } } // On this stage scene empty. Fit scene size to view size - VMainGraphicsView::NewSceneRect(sceneDraw, ui->view); - VMainGraphicsView::NewSceneRect(sceneDetails, ui->view); + VMainGraphicsView::NewSceneRect(m_sceneDraw, ui->view); + VMainGraphicsView::NewSceneRect(m_sceneDetails, ui->view); VAbstractValApplication::VApp()->setOpeningPattern();//Begin opening file try { // Quick reading measurements doc->setXMLContent(fileName); - const unsigned currentFormatVersion = doc->GetFormatVersion(doc->GetFormatVersionStr()); + const unsigned currentFormatVersion = VDomDocument::GetFormatVersion(doc->GetFormatVersionStr()); if (currentFormatVersion != VPatternConverter::PatternMaxVer) { // Because we rely on the fact that we know where is path to measurements optimization available only for // the latest format version @@ -5814,14 +5901,12 @@ bool MainWindow::LoadPattern(QString fileName, const QString& customMeasureFile) .arg(fakeName))); if (not VApplication::IsGUIMode()) { - qApp->exit(V_EX_NOINPUT); + QCoreApplication::exit(V_EX_NOINPUT); } return false; } - else - { - path = AbsoluteMPath(fileName, doc->MPath()); - } + + path = AbsoluteMPath(fileName, doc->MPath()); } if (not path.isEmpty()) @@ -5836,7 +5921,7 @@ bool MainWindow::LoadPattern(QString fileName, const QString& customMeasureFile) .arg(path))); if (not VApplication::IsGUIMode()) { - qApp->exit(V_EX_NOINPUT); + QCoreApplication::exit(V_EX_NOINPUT); } return false; } @@ -5850,16 +5935,14 @@ bool MainWindow::LoadPattern(QString fileName, const QString& customMeasureFile) Clear(); if (not VApplication::IsGUIMode()) { - qApp->exit(V_EX_NOINPUT); + QCoreApplication::exit(V_EX_NOINPUT); } return false; } - else - { - ui->actionUnloadMeasurements->setEnabled(true); - watcher->addPath(fixedMPath); - ui->actionEditCurrent->setEnabled(true); - } + + ui->actionUnloadMeasurements->setEnabled(true); + m_watcher->addPath(fixedMPath); + ui->actionEditCurrent->setEnabled(true); } if (VAbstractValApplication::VApp()->GetMeasurementsType() == MeasurementsType::Unknown) @@ -5893,7 +5976,7 @@ bool MainWindow::LoadPattern(QString fileName, const QString& customMeasureFile) Clear(); if (not VApplication::IsGUIMode()) { - qApp->exit(V_EX_NOINPUT); + QCoreApplication::exit(V_EX_NOINPUT); } return false; } @@ -5916,17 +5999,17 @@ bool MainWindow::LoadPattern(QString fileName, const QString& customMeasureFile) #endif m_statusLabel->setVisible(true); - if (guiEnabled) + if (m_guiEnabled) { // No errors occurred - if (VApplication::VApp()->IsGUIMode()) + if (VApplication::IsGUIMode()) { /* Collect garbage only after successfully parse. This way wrongly accused items have one more time to restore * a reference. */ QTimer::singleShot(100, Qt::CoarseTimer, this, [this](){doc->GarbageCollector(true);}); } - patternReadOnly = doc->IsReadOnly(); - sceneDraw->SetAcceptDrop(true); + m_patternReadOnly = doc->IsReadOnly(); + m_sceneDraw->SetAcceptDrop(true); SetEnableWidgets(true); setCurrentFile(fileName); qCDebug(vMainWindow, "File loaded."); @@ -5940,21 +6023,20 @@ bool MainWindow::LoadPattern(QString fileName, const QString& customMeasureFile) m_statusLabel->setText(QString()); return true; } - else - { - VAbstractValApplication::VApp()->setOpeningPattern();// End opening file - return false; - } + + VAbstractValApplication::VApp()->setOpeningPattern();// End opening file + return false; } //--------------------------------------------------------------------------------------------------------------------- -QStringList MainWindow::GetUnlokedRestoreFileList() const +auto MainWindow::GetUnlokedRestoreFileList() -> QStringList { QStringList restoreFiles; //Take all files that need to be restored QStringList files = VAbstractValApplication::VApp()->ValentinaSettings()->GetRestoreFileList(); - if (files.size() > 0) + if (not files.empty()) { + restoreFiles.reserve(files.size()); for (auto &file : files) { // Seeking file that realy need reopen @@ -5989,11 +6071,11 @@ QStringList MainWindow::GetUnlokedRestoreFileList() const //--------------------------------------------------------------------------------------------------------------------- void MainWindow::ToolBarStyles() { - ToolBarStyle(ui->toolBarDraws); - ToolBarStyle(ui->toolBarOption); - ToolBarStyle(ui->toolBarStages); - ToolBarStyle(ui->toolBarTools); - ToolBarStyle(ui->mainToolBar); + MainWindow::ToolBarStyle(ui->toolBarDraws); + MainWindow::ToolBarStyle(ui->toolBarOption); + MainWindow::ToolBarStyle(ui->toolBarStages); + MainWindow::ToolBarStyle(ui->toolBarTools); + MainWindow::ToolBarStyle(ui->mainToolBar); } //--------------------------------------------------------------------------------------------------------------------- @@ -6027,12 +6109,12 @@ void MainWindow::Preferences() if (guard.isNull()) { QGuiApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); - DialogPreferences *preferences = new DialogPreferences(this); + auto *preferences = new DialogPreferences(this); // QScopedPointer needs to be sure any exception will never block guard QScopedPointer dlg(preferences); guard = preferences; connect(dlg.data(), &DialogPreferences::UpdateProperties, this, &MainWindow::WindowsLocale); // Must be first - connect(dlg.data(), &DialogPreferences::UpdateProperties, toolOptions, + connect(dlg.data(), &DialogPreferences::UpdateProperties, m_toolOptions, &VToolOptionsPropertyBrowser::RefreshOptions); connect(dlg.data(), &DialogPreferences::UpdateProperties, this, &MainWindow::ToolBarStyles); connect(dlg.data(), &DialogPreferences::UpdateProperties, this, &MainWindow::ToolBoxSizePolicy); @@ -6070,8 +6152,8 @@ void MainWindow::ExportDrawAs() { auto Uncheck = qScopeGuard([this] {ui->toolButtonExportDraw->setChecked(false);}); - QString filters(tr("Scalable Vector Graphics files") + QLatin1String("(*.svg)")); - QString dir = QDir::homePath() + QLatin1String("/") + FileName() + QLatin1String(".svg"); + QString filters(tr("Scalable Vector Graphics files") + QStringLiteral("(*.svg)")); + QString dir = QDir::homePath() + QChar('/') + FileName() + QStringLiteral(".svg"); QString fileName = QFileDialog::getSaveFileName(this, tr("Save draw"), dir, filters, nullptr, VAbstractApplication::VApp()->NativeFileDialog()); @@ -6148,7 +6230,7 @@ void MainWindow::ExportDetailsAs() catch (VException &e) { QMessageBox::warning(this, tr("Export details"), - tr("Can't export details.") + QLatin1String(" \n") + e.ErrorMessage(), + tr("Can't export details.") + QStringLiteral(" \n") + e.ErrorMessage(), QMessageBox::Ok, QMessageBox::Ok); return; } @@ -6180,11 +6262,12 @@ void MainWindow::ExportDetailsAs() void MainWindow::ReopenFilesAfterCrash(QStringList &args) { const QStringList files = GetUnlokedRestoreFileList(); - if (files.size() > 0) + if (not files.empty()) { qCDebug(vMainWindow, "Reopen files after crash."); QStringList restoreFiles; + restoreFiles.reserve(files.size()); for (int i = 0; i < files.size(); ++i) { QFile file(files.at(i) + *autosavePrefix); @@ -6194,7 +6277,7 @@ void MainWindow::ReopenFilesAfterCrash(QStringList &args) } } - if (restoreFiles.size() > 0) + if (not restoreFiles.empty()) { QMessageBox::StandardButton reply; const QString mes = tr("Valentina didn't shut down correctly. Do you want reopen files (%1) you had open?") @@ -6228,7 +6311,7 @@ void MainWindow::ReopenFilesAfterCrash(QStringList &args) } //--------------------------------------------------------------------------------------------------------------------- -QString MainWindow::CheckPathToMeasurements(const QString &patternPath, const QString &path) +auto MainWindow::CheckPathToMeasurements(const QString &patternPath, const QString &path) -> QString { if (path.isEmpty()) { @@ -6267,124 +6350,116 @@ QString MainWindow::CheckPathToMeasurements(const QString &patternPath, const QS }; QFileInfo table(path); - if (table.exists() == false) + if (not table.exists()) { - if (!VApplication::IsGUIMode()) + if (not VApplication::IsGUIMode()) { - return QString();// console mode doesn't support fixing path to a measurement file + return {};// console mode doesn't support fixing path to a measurement file + } + + const QString text = tr("The measurements file

%1

could not be found. Do you " + "want to update the file location?").arg(path); + QMessageBox::StandardButton res = QMessageBox::question(this, tr("Loading measurements file"), text, + QMessageBox::Yes | QMessageBox::No, + QMessageBox::Yes); + if (res == QMessageBox::No) + { + return {}; + } + + MeasurementsType patternType; + if (table.suffix() == QLatin1String("vst")) + { + patternType = MeasurementsType::Multisize; } else { - const QString text = tr("The measurements file

%1

could not be found. Do you " - "want to update the file location?").arg(path); - QMessageBox::StandardButton res = QMessageBox::question(this, tr("Loading measurements file"), text, - QMessageBox::Yes | QMessageBox::No, - QMessageBox::Yes); - if (res == QMessageBox::No) + patternType = MeasurementsType::Individual; // or Unknown + } + + auto DirPath = [patternPath, table](const QString &defPath, QString &selectedName) + { + QString dirPath; + const QDir patternDir = QFileInfo(patternPath).absoluteDir(); + QString measurements = table.fileName(); + if (patternDir.exists(measurements)) { - return QString(); + selectedName = measurements; + dirPath = patternDir.absolutePath(); + } + else if (patternDir.exists(measurements.replace(' ', '_'))) + { + selectedName = measurements.replace(' ', '_'); + dirPath = patternDir.absolutePath(); } else { - MeasurementsType patternType; - if (table.suffix() == QLatin1String("vst")) - { - patternType = MeasurementsType::Multisize; - } - else - { - patternType = MeasurementsType::Individual; // or Unknown - } - - auto DirPath = [patternPath, table](const QString &defPath, QString &selectedName) - { - QString dirPath; - const QDir patternDir = QFileInfo(patternPath).absoluteDir(); - QString measurements = table.fileName(); - if (patternDir.exists(measurements)) - { - selectedName = measurements; - dirPath = patternDir.absolutePath(); - } - else if (patternDir.exists(measurements.replace(' ', '_'))) - { - selectedName = measurements.replace(' ', '_'); - dirPath = patternDir.absolutePath(); - } - else - { - dirPath = defPath; - } - return dirPath; - }; - - - QString mPath; - if (patternType == MeasurementsType::Multisize) - { - const QString filter = tr("Multisize measurements") + QLatin1String(" (*.vst);;") + - tr("Individual measurements") + QLatin1String(" (*.vit)"); - //Use standard path to multisize measurements - QString selectedName; - const QString dirPath = DirPath(VAbstractValApplication::VApp() - ->ValentinaSettings()->GetPathMultisizeMeasurements(), - selectedName); - mPath = FindLocation(filter, dirPath, selectedName); - } - else - { - const QString filter = tr("Individual measurements") + QLatin1String(" (*.vit);;") + - tr("Multisize measurements") + QLatin1String(" (*.vst)"); - //Use standard path to individual measurements - QString selectedName; - const QString dirPath = DirPath(VAbstractValApplication::VApp() - ->ValentinaSettings()->GetPathIndividualMeasurements(), - selectedName); - mPath = FindLocation(filter, dirPath, selectedName); - } - - if (mPath.isEmpty()) - { - return mPath; - } - else - { - QScopedPointer m(new VMeasurements(pattern)); - m->setXMLContent(mPath); - - patternType = m->Type(); - - if (patternType == MeasurementsType::Unknown) - { - VException e(tr("Measurement file has unknown format.")); - throw e; - } - - if (patternType == MeasurementsType::Multisize) - { - VVSTConverter converter(mPath); - m->setXMLContent(converter.Convert());// Read again after conversion - } - else - { - VVITConverter converter(mPath); - m->setXMLContent(converter.Convert());// Read again after conversion - } - - if (not m->IsDefinedKnownNamesValid()) - { - VException e(tr("Measurement file contains invalid known measurement(s).")); - throw e; - } - - CheckRequiredMeasurements(m.data()); - - VAbstractValApplication::VApp()->SetMeasurementsType(patternType); - doc->SetMPath(RelativeMPath(patternPath, mPath)); - return mPath; - } + dirPath = defPath; } + return dirPath; + }; + + + QString mPath; + if (patternType == MeasurementsType::Multisize) + { + const QString filter = tr("Multisize measurements") + QStringLiteral(" (*.vst);;") + + tr("Individual measurements") + QStringLiteral(" (*.vit)"); + //Use standard path to multisize measurements + QString selectedName; + const QString dirPath = DirPath(VAbstractValApplication::VApp() + ->ValentinaSettings()->GetPathMultisizeMeasurements(), + selectedName); + mPath = FindLocation(filter, dirPath, selectedName); } + else + { + const QString filter = tr("Individual measurements") + QStringLiteral(" (*.vit);;") + + tr("Multisize measurements") + QStringLiteral(" (*.vst)"); + //Use standard path to individual measurements + QString selectedName; + const QString dirPath = DirPath(VAbstractValApplication::VApp() + ->ValentinaSettings()->GetPathIndividualMeasurements(), + selectedName); + mPath = FindLocation(filter, dirPath, selectedName); + } + + if (mPath.isEmpty()) + { + return mPath; + } + + QScopedPointer m(new VMeasurements(pattern)); + m->setXMLContent(mPath); + + patternType = m->Type(); + + if (patternType == MeasurementsType::Unknown) + { + throw VException(tr("Measurement file has unknown format.")); + } + + if (patternType == MeasurementsType::Multisize) + { + VVSTConverter converter(mPath); + m->setXMLContent(converter.Convert());// Read again after conversion + } + else + { + VVITConverter converter(mPath); + m->setXMLContent(converter.Convert());// Read again after conversion + } + + if (not m->IsDefinedKnownNamesValid()) + { + throw VException(tr("Measurement file contains invalid known measurement(s).")); + } + + CheckRequiredMeasurements(m.data()); + + VAbstractValApplication::VApp()->SetMeasurementsType(patternType); + doc->SetMPath(RelativeMPath(patternPath, mPath)); + return mPath; } return path; } @@ -6394,10 +6469,10 @@ void MainWindow::ChangePP(int index, bool zoomBestFit) { if (index != -1) { - doc->ChangeActivPP(comboBoxDraws->itemText(index)); + doc->ChangeActivPP(m_comboBoxDraws->itemText(index)); doc->setCurrentData(); emit RefreshHistory(); - if (drawMode) + if (m_drawMode) { ArrowTool(true); if (zoomBestFit) @@ -6405,17 +6480,17 @@ void MainWindow::ChangePP(int index, bool zoomBestFit) ZoomFitBestCurrent(); } } - toolOptions->itemClicked(nullptr);//hide options for tool in previous pattern piece - groupsWidget->UpdateGroups(); + m_toolOptions->itemClicked(nullptr);//hide options for tool in previous pattern piece + m_groupsWidget->UpdateGroups(); } } //--------------------------------------------------------------------------------------------------------------------- void MainWindow::EndVisualization(bool click) { - if (not dialogTool.isNull()) + if (not m_dialogTool.isNull()) { - dialogTool->ShowDialog(click); + m_dialogTool->ShowDialog(click); } } @@ -6429,7 +6504,7 @@ void MainWindow::ZoomFirstShow() * pattern will be moved. Looks very ugly. It is best solution that i have now. */ - if (pattern->DataPieces()->size() > 0) + if (not pattern->DataPieces()->empty()) { ActionDetails(true); ui->view->ZoomFitBest(); @@ -6441,10 +6516,10 @@ void MainWindow::ZoomFirstShow() } ZoomFitBestCurrent(); - VMainGraphicsView::NewSceneRect(sceneDraw, ui->view); - VMainGraphicsView::NewSceneRect(sceneDetails, ui->view); + VMainGraphicsView::NewSceneRect(m_sceneDraw, ui->view); + VMainGraphicsView::NewSceneRect(m_sceneDetails, ui->view); - if (pattern->DataPieces()->size() > 0) + if (not pattern->DataPieces()->empty()) { ActionDetails(true); ui->view->ZoomFitBest(); @@ -6457,7 +6532,7 @@ void MainWindow::ZoomFirstShow() } //--------------------------------------------------------------------------------------------------------------------- -bool MainWindow::DoExport(const VCommandLinePtr &expParams) +auto MainWindow::DoExport(const VCommandLinePtr &expParams) -> bool { QVector details; if(not VAbstractValApplication::VApp()->getOpeningPattern()) @@ -6466,20 +6541,18 @@ bool MainWindow::DoExport(const VCommandLinePtr &expParams) if (allDetails->count() == 0) { qCCritical(vMainWindow, "%s", qUtf8Printable(tr("You can't export empty scene."))); - qApp->exit(V_EX_DATAERR); + QCoreApplication::exit(V_EX_DATAERR); return false; } - else - { - details = SortDetailsForLayout(allDetails, expParams->OptExportSuchDetails()); - if (details.count() == 0) - { - qCCritical(vMainWindow, "%s", qUtf8Printable(tr("You can't export empty scene. Please, " - "include at least one detail in layout."))); - qApp->exit(V_EX_DATAERR); - return false; - } + details = SortDetailsForLayout(allDetails, expParams->OptExportSuchDetails()); + + if (details.count() == 0) + { + qCCritical(vMainWindow, "%s", qUtf8Printable(tr("You can't export empty scene. Please, " + "include at least one detail in layout."))); + QCoreApplication::exit(V_EX_DATAERR); + return false; } } listDetails = PrepareDetailsForLayout(details); @@ -6513,7 +6586,7 @@ bool MainWindow::DoExport(const VCommandLinePtr &expParams) { m_dialogSaveLayout.clear(); qCCritical(vMainWindow, "%s\n\n%s", qUtf8Printable(tr("Export error.")), qUtf8Printable(e.ErrorMessage())); - qApp->exit(V_EX_DATAERR); + QCoreApplication::exit(V_EX_DATAERR); return false; } } @@ -6551,13 +6624,13 @@ bool MainWindow::DoExport(const VCommandLinePtr &expParams) m_dialogSaveLayout.clear(); qCCritical(vMainWindow, "%s\n\n%s", qUtf8Printable(tr("Export error.")), qUtf8Printable(e.ErrorMessage())); - qApp->exit(V_EX_DATAERR); + QCoreApplication::exit(V_EX_DATAERR); return false; } } else { - qApp->exit(V_EX_DATAERR); + QCoreApplication::exit(V_EX_DATAERR); return false; } } @@ -6571,7 +6644,7 @@ bool MainWindow::DoExport(const VCommandLinePtr &expParams) * @param expParams command line options * @return true if succesfull */ -bool MainWindow::DoFMExport(const VCommandLinePtr &expParams) +auto MainWindow::DoFMExport(const VCommandLinePtr &expParams) -> bool { QString filePath = expParams->OptExportFMTo(); @@ -6579,7 +6652,7 @@ bool MainWindow::DoFMExport(const VCommandLinePtr &expParams) { qCCritical(vMainWindow, "%s\n\n%s", qUtf8Printable(tr("Export final measurements error.")), qUtf8Printable(tr("Destination path is empty."))); - qApp->exit(V_EX_DATAERR); + QCoreApplication::exit(V_EX_DATAERR); return false; } @@ -6610,7 +6683,7 @@ bool MainWindow::DoFMExport(const VCommandLinePtr &expParams) } //--------------------------------------------------------------------------------------------------------------------- -bool MainWindow::SetDimensionA(int value) +auto MainWindow::SetDimensionA(int value) -> bool { if (not VApplication::IsGUIMode()) { @@ -6618,10 +6691,10 @@ bool MainWindow::SetDimensionA(int value) { if (VAbstractValApplication::VApp()->GetMeasurementsType() == MeasurementsType::Multisize) { - const qint32 index = dimensionA->findData(value); + const qint32 index = m_dimensionA->findData(value); if (index != -1) { - dimensionA->setCurrentIndex(index); + m_dimensionA->setCurrentIndex(index); } else { @@ -6653,7 +6726,7 @@ bool MainWindow::SetDimensionA(int value) } //--------------------------------------------------------------------------------------------------------------------- -bool MainWindow::SetDimensionB(int value) +auto MainWindow::SetDimensionB(int value) -> bool { if (not VApplication::IsGUIMode()) { @@ -6661,10 +6734,10 @@ bool MainWindow::SetDimensionB(int value) { if (VAbstractValApplication::VApp()->GetMeasurementsType() == MeasurementsType::Multisize) { - const qint32 index = dimensionB->findData(value); + const qint32 index = m_dimensionB->findData(value); if (index != -1) { - dimensionB->setCurrentIndex(index); + m_dimensionB->setCurrentIndex(index); } else { @@ -6696,7 +6769,7 @@ bool MainWindow::SetDimensionB(int value) } //--------------------------------------------------------------------------------------------------------------------- -bool MainWindow::SetDimensionC(int value) +auto MainWindow::SetDimensionC(int value) -> bool { if (not VApplication::IsGUIMode()) { @@ -6704,10 +6777,10 @@ bool MainWindow::SetDimensionC(int value) { if (VAbstractValApplication::VApp()->GetMeasurementsType() == MeasurementsType::Multisize) { - const qint32 index = dimensionC->findData(value); + const qint32 index = m_dimensionC->findData(value); if (index != -1) { - dimensionC->setCurrentIndex(index); + m_dimensionC->setCurrentIndex(index); } else { @@ -6741,7 +6814,7 @@ bool MainWindow::SetDimensionC(int value) //--------------------------------------------------------------------------------------------------------------------- void MainWindow::ProcessCMD() { - const VCommandLinePtr cmd = VApplication::VApp()->CommandLine(); + const VCommandLinePtr cmd = VApplication::CommandLine(); auto args = cmd->OptInputFileNames(); isNoScaling = cmd->IsNoScalingEnabled(); @@ -6760,7 +6833,7 @@ void MainWindow::ProcessCMD() if (args.size() != 1) { qCritical() << tr("Please, provide one input file."); - qApp->exit(V_EX_NOINPUT); + QCoreApplication::exit(V_EX_NOINPUT); return; } @@ -6793,7 +6866,7 @@ void MainWindow::ProcessCMD() if (not (aSetted && bSetted && cSetted)) { - qApp->exit(V_EX_DATAERR); + QCoreApplication::exit(V_EX_DATAERR); return; } @@ -6810,12 +6883,12 @@ void MainWindow::ProcessCMD() } } - qApp->exit(V_EX_OK);// close program after processing in console mode + QCoreApplication::exit(V_EX_OK);// close program after processing in console mode } } //--------------------------------------------------------------------------------------------------------------------- -QString MainWindow::GetPatternFileName() +auto MainWindow::GetPatternFileName() -> QString { QString shownName = tr("untitled.val"); if(not VAbstractValApplication::VApp()->GetPatternPath().isEmpty()) @@ -6827,25 +6900,23 @@ QString MainWindow::GetPatternFileName() } //--------------------------------------------------------------------------------------------------------------------- -QString MainWindow::GetMeasurementFileName() +auto MainWindow::GetMeasurementFileName() -> QString { if(doc->MPath().isEmpty()) { - return QString(); + return {}; } - else + + QString shownName = QStringLiteral(" ["); + shownName += StrippedName(AbsoluteMPath(VAbstractValApplication::VApp()->GetPatternPath(), doc->MPath())); + + if(m_mChanges) { - QString shownName(" ["); - shownName += StrippedName(AbsoluteMPath(VAbstractValApplication::VApp()->GetPatternPath(), doc->MPath())); - - if(mChanges) - { - shownName += QLatin1String("*"); - } - - shownName += QLatin1String("]"); - return shownName; + shownName += QChar('*'); } + + shownName += QChar(']'); + return shownName; } //--------------------------------------------------------------------------------------------------------------------- @@ -6863,14 +6934,14 @@ void MainWindow::UpdateWindowTitle() //#endif /*Q_OS_WIN32*/ } - if (not patternReadOnly && isFileWritable) + if (not m_patternReadOnly && isFileWritable) { setWindowTitle(GetPatternFileName()+GetMeasurementFileName()); } else { - setWindowTitle(GetPatternFileName()+GetMeasurementFileName() + QLatin1String(" (") + tr("read only") + - QLatin1String(")")); + setWindowTitle(GetPatternFileName()+GetMeasurementFileName() + QStringLiteral(" (") + tr("read only") + + QChar(')')); } setWindowFilePath(VAbstractValApplication::VApp()->GetPatternPath()); @@ -7168,7 +7239,7 @@ void MainWindow::ToolSelectDetail() void MainWindow::PrintPatternMessage(QEvent *event) { SCASSERT(event != nullptr) - auto *patternMessage = static_cast(event); + auto *patternMessage = static_cast(event); // NOLINT(cppcoreguidelines-pro-type-static-cast-downcast) QString severity; @@ -7207,8 +7278,7 @@ void MainWindow::PrintPatternMessage(QEvent *event) //--------------------------------------------------------------------------------------------------------------------- void MainWindow::OpenWatermark(const QString &path) { - QList>::const_iterator i; - for (i = m_watermarkEditors.cbegin(); i != m_watermarkEditors.cend(); ++i) + for (auto i = m_watermarkEditors.cbegin(); i != m_watermarkEditors.cend(); ++i) { if (not (*i).isNull() && not (*i)->CurrentFile().isEmpty() && (*i)->CurrentFile() == AbsoluteMPath(VAbstractValApplication::VApp()->GetPatternPath(), path)) diff --git a/src/app/valentina/mainwindow.h b/src/app/valentina/mainwindow.h index 8f2a6af37..8f927b447 100644 --- a/src/app/valentina/mainwindow.h +++ b/src/app/valentina/mainwindow.h @@ -65,19 +65,19 @@ class VWidgetBackgroundImages; */ class MainWindow : public MainWindowsNoGUI { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit MainWindow(QWidget *parent = nullptr); - virtual ~MainWindow() override; + ~MainWindow() override; - bool LoadPattern(QString fileName, const QString &customMeasureFile = QString()); + auto LoadPattern(QString fileName, const QString &customMeasureFile = QString()) -> bool; public slots: void ProcessCMD(); - virtual void ShowToolTip(const QString &toolTip) override; - virtual void UpdateVisibilityGroups() override; - virtual void UpdateDetailsList() override; - virtual void ZoomFitBestCurrent() override; + void ShowToolTip(const QString &toolTip) override; + void UpdateVisibilityGroups() override; + void UpdateDetailsList() override; + void ZoomFitBestCurrent() override; void PlaceBackgroundImage(const QPointF &pos, const QString &fileName); void RemoveBackgroundImage(const QUuid &id); @@ -110,16 +110,15 @@ signals: void EnableDetailHover(bool enable); void EnableImageBackgroundHover(bool enable); protected: - virtual void keyPressEvent(QKeyEvent *event) override; - virtual void showEvent(QShowEvent *event) override; - virtual void changeEvent(QEvent* event) override; - virtual void closeEvent(QCloseEvent *event) override; - virtual void customEvent(QEvent * event) override; - virtual void CleanLayout() override; - virtual void PrepareSceneList(PreviewQuatilty quality) override; - virtual void ExportToCSVData(const QString &fileName, bool withHeader, int mib, - const QChar &separator) final; - virtual void ToolBarStyle(QToolBar *bar) const override; + void keyPressEvent(QKeyEvent *event) override; + void showEvent(QShowEvent *event) override; + void changeEvent(QEvent* event) override; + void closeEvent(QCloseEvent *event) override; + void customEvent(QEvent * event) override; + void CleanLayout() override; + void PrepareSceneList(PreviewQuatilty quality) override; + void ExportToCSVData(const QString &fileName, bool withHeader, int mib, const QChar &separator) final; + void ToolBarStyle(QToolBar *bar) const override; private slots: void ScaleChanged(qreal scale); void MouseMove(const QPointF &scenePos); @@ -192,8 +191,8 @@ private slots: void ActionLayout(bool checked); void on_actionNew_triggered(); - bool on_actionSaveAs_triggered(); - bool on_actionSave_triggered(); + bool on_actionSaveAs_triggered(); // NOLINT(modernize-use-trailing-return-type) + bool on_actionSave_triggered(); // NOLINT(modernize-use-trailing-return-type) void on_actionOpen_triggered(); void on_actionOpenPuzzle_triggered(); @@ -243,72 +242,81 @@ private slots: void ParseBackgroundImages(); -private: - Q_DISABLE_COPY(MainWindow) - /** @brief ui keeps information about user interface */ - Ui::MainWindow *ui; + void ActionHistory_triggered(bool checked); + void ActionExportRecipe_triggered(); + void ActionNewDraw_triggered(); + void ActionTable_triggered(); + void ActionFinalMeasurements_triggered(); + void ActionShowMainPath_triggered(bool checked); + void ActionOpenTape_triggered(); - QFileSystemWatcher *watcher; +private: + // cppcheck-suppress unknownMacro + Q_DISABLE_COPY_MOVE(MainWindow) // NOLINT + /** @brief ui keeps information about user interface */ + Ui::MainWindow *ui; + + QFileSystemWatcher *m_watcher; /** @brief tool current tool */ - Tool currentTool; + Tool m_currentTool{Tool::Arrow}; /** @brief tool last used tool */ - Tool lastUsedTool; + Tool m_lastUsedTool{Tool::Arrow}; /** @brief sceneDraw draw scene. */ - VMainGraphicsScene *sceneDraw; + VMainGraphicsScene *m_sceneDraw{nullptr}; /** @brief sceneDetails details scene. */ - VMainGraphicsScene *sceneDetails; + VMainGraphicsScene *m_sceneDetails{nullptr}; /** @brief isInitialized true after first show window. */ - bool isInitialized; + bool m_isInitialized{false}; /** @brief mChanges true if measurement file was changed. */ - bool mChanges; - bool mChangesAsked; + bool m_mChanges{false}; + bool m_mChangesAsked{true}; - bool patternReadOnly; + bool m_patternReadOnly{false}; - QPointer dialogTable; - QPointer dialogTool; - QPointer dialogHistory; - QPointer dialogFMeasurements; + QPointer m_dialogTable; + QPointer m_dialogTool{}; + QPointer m_dialogHistory; + QPointer m_dialogFMeasurements; /** @brief comboBoxDraws comboc who show name of pattern peaces. */ - QComboBox *comboBoxDraws; - QLabel *patternPieceLabel; + QComboBox *m_comboBoxDraws{nullptr}; + QLabel *m_patternPieceLabel{nullptr}; /** @brief currentDrawIndex save current selected pattern peace. */ - qint32 currentDrawIndex; + qint32 m_currentDrawIndex{0}; /** @brief currentToolBoxIndex save current set of tools. */ - qint32 currentToolBoxIndex; + qint32 m_currentToolBoxIndex{0}; /** @brief drawMode true if we current draw scene. */ - bool drawMode; + bool m_drawMode{true}; - QLabel *leftGoToStage; - QLabel *rightGoToStage; - QTimer *autoSaveTimer; - QTimer *measurementsSyncTimer; - bool guiEnabled; - QPointer dimensionA{nullptr}; - QPointer dimensionB{nullptr}; - QPointer dimensionC{nullptr}; - QPointer dimensionALabel{nullptr}; - QPointer dimensionBLabel{nullptr}; - QPointer dimensionCLabel{nullptr}; - QPointer zoomScale{nullptr}; - QPointer doubleSpinBoxScale{nullptr}; - VToolOptionsPropertyBrowser *toolOptions; - VWidgetGroups *groupsWidget; - VWidgetDetails *detailsWidget; - VWidgetBackgroundImages *backgroundImagesWidget{nullptr}; - QSharedPointer> lock; + QLabel *m_leftGoToStage{nullptr}; + QLabel *m_rightGoToStage{nullptr}; + QTimer *m_autoSaveTimer{nullptr}; + QTimer *m_measurementsSyncTimer; + bool m_guiEnabled{true}; + QPointer m_dimensionA{nullptr}; + QPointer m_dimensionB{nullptr}; + QPointer m_dimensionC{nullptr}; + QPointer m_dimensionALabel{nullptr}; + QPointer m_dimensionBLabel{nullptr}; + QPointer m_dimensionCLabel{nullptr}; + QPointer m_zoomScale{nullptr}; + QPointer m_doubleSpinBoxScale{nullptr}; + VToolOptionsPropertyBrowser *m_toolOptions{nullptr}; + VWidgetGroups *m_groupsWidget{nullptr}; + VWidgetDetails *m_detailsWidget{nullptr}; + VWidgetBackgroundImages *m_backgroundImagesWidget{nullptr}; + QSharedPointer> m_lock{nullptr}; - QList toolButtonPointerList; + QList m_toolButtonPointerList{}; QProgressBar *m_progressBar; QLabel *m_statusLabel; @@ -319,7 +327,7 @@ private: qreal m_currentDimensionB{0}; qreal m_currentDimensionC{0}; - QSharedPointer m{}; + QSharedPointer m_m{}; QTimer *m_gradation; @@ -333,30 +341,33 @@ private: void InitDimensionControls(); void InitDimensionGradation(int index, const MeasurementDimension_p &dimension, const QPointer &control); + static void InitDimensionXGradation(const QVector &bases, const DimesionLabels &labels, + const QPointer &control); + void InitDimensionYWZGradation(const QVector &bases, const DimesionLabels &labels, + const QPointer &control, bool bodyMeasurement); - void ToolBarOption(); - void ToolBarStages(); - void ToolBarDraws(); - void ToolBarTools(); - void InitToolButtons(); - void CancelTool(); + void ToolBarOption(); + void ToolBarStages(); + void ToolBarDraws(); + void ToolBarTools(); + void InitToolButtons(); + void CancelTool(); - void SetEnableWidgets(bool enable); - void SetEnableTool(bool enable); - void SetLayoutModeActions(); + void SetEnableWidgets(bool enable); + void SetEnableTool(bool enable); + void SetLayoutModeActions(); - void SaveCurrentScene(); - void RestoreCurrentScene(); - void MinimumScrollBar(); + void SaveCurrentScene(); + void RestoreCurrentScene(); + void MinimumScrollBar(); template - void SetToolButton(bool checked, Tool t, const QString &cursor, const QString &toolTip, - Func closeDialogSlot); + void SetToolButton(bool checked, Tool t, const QString &cursor, const QString &toolTip, Func closeDialogSlot); template - void SetToolButtonWithApply(bool checked, Tool t, const QString &cursor, const QString &toolTip, - Func closeDialogSlot, Func2 applyDialogSlot); + void SetToolButtonWithApply(bool checked, Tool t, const QString &cursor, const QString &toolTip, + Func closeDialogSlot, Func2 applyDialogSlot); template - void ClosedDialog(int result); + void ClosedDialog(int result); template void ClosedDialogWithApply(int result, VMainGraphicsScene *scene); @@ -371,54 +382,55 @@ private: template void ApplyDetailsDialog(); - bool SavePattern(const QString &fileName, QString &error); - void AutoSavePattern(); - void setCurrentFile(const QString &fileName); + auto SavePattern(const QString &fileName, QString &error) -> bool; + void AutoSavePattern(); + void setCurrentFile(const QString &fileName); - void ReadSettings(); - void WriteSettings(); + void ReadSettings(); + void WriteSettings(); - bool MaybeSave(); - void CreateMenus(); - void CreateActions(); - void InitAutoSave(); - bool PatternPieceName(QString &name); - QString CheckPathToMeasurements(const QString &patternPath, const QString &path); - void ChangePP(int index, bool zoomBestFit = true); + auto MaybeSave() -> bool; + void CreateMenus(); + void CreateActions(); + void InitAutoSave(); + auto PatternPieceName(QString &name) -> bool; + auto CheckPathToMeasurements(const QString &patternPath, const QString &path) -> QString; + void ChangePP(int index, bool zoomBestFit = true); /** * @brief EndVisualization try show dialog after and working with tool visualization. */ - void EndVisualization(bool click = false); - void ZoomFirstShow(); + void EndVisualization(bool click = false); + void ZoomFirstShow(); - void AddDocks(); - void InitDocksContain(); - bool OpenNewValentina(const QString &fileName = QString())const; - void FileClosedCorrect(); - QStringList GetUnlokedRestoreFileList()const; + void AddDocks(); + void InitDocksContain(); + auto OpenNewValentina(const QString &fileName = QString())const -> bool; + void FileClosedCorrect(); + static auto GetUnlokedRestoreFileList() -> QStringList; - void AddPP(const QString &PPName); - QPointF StartPositionNewPP() const; + void AddPP(const QString &PPName); + auto StartPositionNewPP() const -> QPointF; - void InitScenes(); + void InitScenes(); - bool LoadMeasurements(const QString &path); - bool UpdateMeasurements(const QString &path, qreal baseA, qreal baseB, qreal baseC); - bool UpdateMeasurements(const QSharedPointer &mFile, qreal baseA, qreal baseB, - qreal baseC); + auto LoadMeasurements(const QString &path) -> bool; + auto UpdateMeasurements(const QString &path, qreal baseA, qreal baseB, qreal baseC) -> bool; + auto UpdateMeasurements(const QSharedPointer &mFile, qreal baseA, qreal baseB, qreal baseC) -> bool; - void ReopenFilesAfterCrash(QStringList &args); - bool DoExport(const VCommandLinePtr& expParams); - bool DoFMExport(const VCommandLinePtr& expParams); + void ReadMeasurements(qreal baseA, qreal baseB, qreal baseC); - bool SetDimensionA(int value); - bool SetDimensionB(int value); - bool SetDimensionC(int value); + void ReopenFilesAfterCrash(QStringList &args); + auto DoExport(const VCommandLinePtr& expParams) -> bool; + auto DoFMExport(const VCommandLinePtr& expParams) -> bool; - QString GetPatternFileName(); - QString GetMeasurementFileName(); + auto SetDimensionA(int value) -> bool; + auto SetDimensionB(int value) -> bool; + auto SetDimensionC(int value) -> bool; - void UpdateWindowTitle(); + static auto GetPatternFileName() -> QString; + auto GetMeasurementFileName() -> QString; + + void UpdateWindowTitle(); void ToolSelectPoint(); void ToolSelectPointByPress(); @@ -441,7 +453,10 @@ private: void StoreMultisizeMDimensions(); void StoreIndividualMDimensions(); - QVector DimensionRestrictedValues(int index, const MeasurementDimension_p &dimension); + void StoreMultisizeMDimension(const QList &dimensions, int index, qreal currentBase); + void StoreIndividualMDimension(const QMap > &measurements, IMD type); + + auto DimensionRestrictedValues(int index, const MeasurementDimension_p &dimension) -> QVector; void SetDimensionBases(); void StoreDimensions(); @@ -450,6 +465,10 @@ private: void NewBackgroundImageItem(const VBackgroundPatternImage &image); auto InitBackgroundImageItem(const VBackgroundPatternImage &image) -> VBackgroundImageItem *; + + auto SavePatternAs(const QString &fileName) -> bool; + + auto FullParsePattern() -> bool; }; #endif // MAINWINDOW_H diff --git a/src/app/valentina/mainwindowsnogui.cpp b/src/app/valentina/mainwindowsnogui.cpp index ba8a8217d..2f9491df1 100644 --- a/src/app/valentina/mainwindowsnogui.cpp +++ b/src/app/valentina/mainwindowsnogui.cpp @@ -29,33 +29,24 @@ #include "mainwindowsnogui.h" #include "core/vapplication.h" #include "../vpatterndb/vcontainer.h" -#include "../vobj/vobjpaintdevice.h" -#include "../vdxf/vdxfpaintdevice.h" #include "dialogs/dialoglayoutsettings.h" #include "../vwidgets/vmaingraphicsscene.h" #include "../vmisc/dialogs/dialogexporttocsv.h" #include "../vmisc/qxtcsvmodel.h" #include "../vmisc/compatibility.h" +#include "../vmisc/vsysexits.h" #include "../vformat/vmeasurements.h" -#include "../vformat/vwatermark.h" #include "../vlayout/vlayoutgenerator.h" #include "dialogs/dialoglayoutprogress.h" #include "dialogs/dialogsavelayout.h" -#include "dialogs/dialoglayoutscale.h" #include "../vlayout/vposter.h" #include "../vlayout/vlayoutexporter.h" -#include "../vpatterndb/floatItemData/vpiecelabeldata.h" -#include "../vpatterndb/floatItemData/vpatternlabeldata.h" -#include "../vpatterndb/floatItemData/vgrainlinedata.h" -#include "../vpatterndb/measurements.h" #include "../vpatterndb/calculator.h" #include "../vtools/tools/vabstracttool.h" -#include "../vtools/tools/vtoolseamallowance.h" #include "../ifc/xml/vvstconverter.h" #include "../ifc/xml/vvitconverter.h" -#include "../ifc/xml/vwatermarkconverter.h" -#include "../vlayout/vrawlayout.h" #include "../vmisc/vvalentinasettings.h" +#include "../vdxf/libdxfrw/drw_base.h" #include #include @@ -81,7 +72,7 @@ QT_WARNING_PUSH QT_WARNING_DISABLE_CLANG("-Wmissing-prototypes") QT_WARNING_DISABLE_INTEL(1418) -Q_LOGGING_CATEGORY(vMainNoGUIWindow, "v.mainnoguiwindow") +Q_LOGGING_CATEGORY(vMainNoGUIWindow, "v.mainnoguiwindow") // NOLINT QT_WARNING_POP @@ -427,7 +418,7 @@ bool MainWindowsNoGUI::GenerateLayout(VLayoutGenerator& lGenerator) ShowLayoutError(nestingState); if (not VApplication::IsGUIMode()) { - qApp->exit(V_EX_DATAERR); + QCoreApplication::exit(V_EX_DATAERR); } return false; } @@ -1294,7 +1285,7 @@ bool MainWindowsNoGUI::ExportFMeasurementsToCSVData(const QString &fileName, boo .arg(i+1))); if (not VApplication::IsGUIMode()) { - qApp->exit(V_EX_DATAERR); + QCoreApplication::exit(V_EX_DATAERR); } return false; } @@ -1305,7 +1296,7 @@ bool MainWindowsNoGUI::ExportFMeasurementsToCSVData(const QString &fileName, boo qUtf8Printable(tr("Parser error at line %1: %2.").arg(i+1).arg(e.GetMsg()))); if (not VApplication::IsGUIMode()) { - qApp->exit(V_EX_DATAERR); + QCoreApplication::exit(V_EX_DATAERR); } return false; } @@ -1323,7 +1314,7 @@ bool MainWindowsNoGUI::ExportFMeasurementsToCSVData(const QString &fileName, boo qUtf8Printable(tr("File error %1.").arg(error))); if (not VApplication::IsGUIMode()) { - qApp->exit(V_EX_CANTCREAT); + QCoreApplication::exit(V_EX_CANTCREAT); } } @@ -1380,7 +1371,7 @@ QSharedPointer MainWindowsNoGUI::OpenMeasurementFile(const QStrin if (not VApplication::IsGUIMode()) { - qApp->exit(V_EX_NOINPUT); + QCoreApplication::exit(V_EX_NOINPUT); } return m; } diff --git a/src/app/valentina/mainwindowsnogui.h b/src/app/valentina/mainwindowsnogui.h index c793df64d..0197649ec 100644 --- a/src/app/valentina/mainwindowsnogui.h +++ b/src/app/valentina/mainwindowsnogui.h @@ -72,7 +72,7 @@ enum class PreviewQuatilty : bool {Fast = true, Slow = false}; class MainWindowsNoGUI : public VAbstractMainWindow { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit MainWindowsNoGUI(QWidget *parent = nullptr); virtual ~MainWindowsNoGUI() override; @@ -144,7 +144,7 @@ protected: void CheckRequiredMeasurements(const VMeasurements *m) const; private: - Q_DISABLE_COPY(MainWindowsNoGUI) + Q_DISABLE_COPY_MOVE(MainWindowsNoGUI) // NOLINT static QList CreateShadows(const QList &papers); static QList CreateScenes(const QList &papers, diff --git a/src/app/valentina/xml/vpattern.cpp b/src/app/valentina/xml/vpattern.cpp index d6f5f9915..c32d701f2 100644 --- a/src/app/valentina/xml/vpattern.cpp +++ b/src/app/valentina/xml/vpattern.cpp @@ -31,8 +31,6 @@ #include "../vtools/tools/vdatatool.h" #include "../vtools/tools/vtoolseamallowance.h" #include "../vtools/tools/vtooluniondetails.h" -#include "../vtools/tools/drawTools/drawtools.h" -#include "../vtools/tools/nodeDetails/nodedetails.h" #include "../ifc/exception/vexceptionobjecterror.h" #include "../ifc/exception/vexceptionwrongid.h" #include "../ifc/exception/vexceptionconversionerror.h" @@ -41,9 +39,9 @@ #include "../ifc/xml/vpatternconverter.h" #include "../vmisc/customevents.h" #include "../vmisc/vvalentinasettings.h" -#include "../vmisc/vmath.h" #include "../vmisc/projectversion.h" #include "../vmisc/compatibility.h" +#include "../vmisc/vsysexits.h" #include "../qmuparser/qmuparsererror.h" #include "../qmuparser/qmutokenparser.h" #include "../vgeometry/varc.h" @@ -60,6 +58,50 @@ #include "../vpatterndb/vpiecepath.h" #include "../vpatterndb/vnodedetail.h" +#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolalongline.h" +#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolbisector.h" +#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolendline.h" +#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolnormal.h" +#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolshoulderpoint.h" +#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolheight.h" +#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoollineintersectaxis.h" +#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolcurveintersectaxis.h" +#include "../vtools/tools/drawTools/toolcurve/vtoolarc.h" +#include "../vtools/tools/drawTools/toolcurve/vtoolellipticalarc.h" +#include "../vtools/tools/drawTools/toolcurve/vtoolarcwithlength.h" +#include "../vtools/tools/drawTools/toolcurve/vtoolspline.h" +#include "../vtools/tools/drawTools/toolcurve/vtoolcubicbezier.h" +#include "../vtools/tools/drawTools/toolcurve/vtoolsplinepath.h" +#include "../vtools/tools/drawTools/toolcurve/vtoolcubicbezierpath.h" +#include "../vtools/tools/drawTools/vtoolline.h" +#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutspline.h" +#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutsplinepath.h" +#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutarc.h" +#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoollineintersect.h" +#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofcontact.h" +#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolbasepoint.h" +#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/vtooltriangle.h" +#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersection.h" +#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectionarcs.h" +#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncircles.h" +#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncurves.h" +#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromcircleandtangent.h" +#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromarcandtangent.h" +#include "../vtools/tools/drawTools/toolpoint/tooldoublepoint/vtooltruedarts.h" +#include "../vtools/tools/drawTools/operation/vtoolrotation.h" +#include "../vtools/tools/drawTools/operation/flipping/vtoolflippingbyline.h" +#include "../vtools/tools/drawTools/operation/flipping/vtoolflippingbyaxis.h" +#include "../vtools/tools/drawTools/operation/vtoolmove.h" + +#include "../vtools/tools/nodeDetails/vnodearc.h" +#include "../vtools/tools/nodeDetails/vnodeellipticalarc.h" +#include "../vtools/tools/nodeDetails/vnodepoint.h" +#include "../vtools/tools/nodeDetails/vnodespline.h" +#include "../vtools/tools/nodeDetails/vnodesplinepath.h" +#include "../vtools/tools/nodeDetails/vtoolpiecepath.h" +#include "../vtools/tools/nodeDetails/vtoolpin.h" +#include "../vtools/tools/nodeDetails/vtoolplacelabel.h" + #if QT_VERSION < QT_VERSION_CHECK(5, 12, 0) #include "../vmisc/backport/qscopeguard.h" #else @@ -608,7 +650,7 @@ void VPattern::LiteParseTree(const Document &parse) emit SetEnabledGUI(false); if (not VApplication::IsGUIMode()) { - qApp->exit(V_EX_NOINPUT); + QCoreApplication::exit(V_EX_NOINPUT); } return; } @@ -619,7 +661,7 @@ void VPattern::LiteParseTree(const Document &parse) emit SetEnabledGUI(false); if (not VApplication::IsGUIMode()) { - qApp->exit(V_EX_NOINPUT); + QCoreApplication::exit(V_EX_NOINPUT); } return; } @@ -630,7 +672,7 @@ void VPattern::LiteParseTree(const Document &parse) emit SetEnabledGUI(false); if (not VApplication::IsGUIMode()) { - qApp->exit(V_EX_NOINPUT); + QCoreApplication::exit(V_EX_NOINPUT); } return; } @@ -641,7 +683,7 @@ void VPattern::LiteParseTree(const Document &parse) emit SetEnabledGUI(false); if (not VApplication::IsGUIMode()) { - qApp->exit(V_EX_NOINPUT); + QCoreApplication::exit(V_EX_NOINPUT); } return; } @@ -652,7 +694,7 @@ void VPattern::LiteParseTree(const Document &parse) emit SetEnabledGUI(false); if (not VApplication::IsGUIMode()) { - qApp->exit(V_EX_NOINPUT); + QCoreApplication::exit(V_EX_NOINPUT); } return; } @@ -662,7 +704,7 @@ void VPattern::LiteParseTree(const Document &parse) emit SetEnabledGUI(false); if (not VApplication::IsGUIMode()) { - qApp->exit(V_EX_NOINPUT); + QCoreApplication::exit(V_EX_NOINPUT); } return; } diff --git a/src/app/valentina/xml/vpattern.h b/src/app/valentina/xml/vpattern.h index f51617030..cd1e637c7 100644 --- a/src/app/valentina/xml/vpattern.h +++ b/src/app/valentina/xml/vpattern.h @@ -45,7 +45,7 @@ class VToolSeamAllowance; */ class VPattern : public VAbstractPattern { - Q_OBJECT + Q_OBJECT // NOLINT public: VPattern(VContainer *data, VMainGraphicsScene *sceneDraw, VMainGraphicsScene *sceneDetail, QObject *parent = nullptr); @@ -126,7 +126,8 @@ protected: virtual void customEvent(QEvent * event) override; private: - Q_DISABLE_COPY(VPattern) + // cppcheck-suppress unknownMacro + Q_DISABLE_COPY_MOVE(VPattern) // NOLINT /** @brief data container with data. */ VContainer *data; diff --git a/src/libs/fervor/fvavailableupdate.h b/src/libs/fervor/fvavailableupdate.h index 943bc6003..a26993076 100644 --- a/src/libs/fervor/fvavailableupdate.h +++ b/src/libs/fervor/fvavailableupdate.h @@ -28,9 +28,11 @@ #include #include +#include "../vmisc/defglobal.h" + class FvAvailableUpdate final : public QObject { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit FvAvailableUpdate(QObject *parent = nullptr); @@ -45,7 +47,8 @@ public: void SetEnclosurePlatform(const QString &enclosurePlatform); private: - Q_DISABLE_COPY(FvAvailableUpdate) + // cppcheck-suppress unknownMacro + Q_DISABLE_COPY_MOVE(FvAvailableUpdate) // NOLINT QUrl m_enclosureUrl; QString m_enclosureVersion; diff --git a/src/libs/fervor/fvupdater.cpp b/src/libs/fervor/fvupdater.cpp index 1771db164..a7cc2b64c 100644 --- a/src/libs/fervor/fvupdater.cpp +++ b/src/libs/fervor/fvupdater.cpp @@ -55,9 +55,9 @@ namespace { -Q_GLOBAL_STATIC_WITH_ARGS(const QString, defaultFeedURL, +Q_GLOBAL_STATIC_WITH_ARGS(const QString, defaultFeedURL, // NOLINT (QLatin1String("https://valentinaproject.bitbucket.io/Appcast.xml"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, testFeedURL, +Q_GLOBAL_STATIC_WITH_ARGS(const QString, testFeedURL, // NOLINT (QLatin1String("https://valentinaproject.bitbucket.io/Appcast_testing.xml"))) } diff --git a/src/libs/fervor/fvupdater.h b/src/libs/fervor/fvupdater.h index 340bd0658..cc682c6a0 100644 --- a/src/libs/fervor/fvupdater.h +++ b/src/libs/fervor/fvupdater.h @@ -35,9 +35,11 @@ #include "fvavailableupdate.h" #include "fvupdatewindow.h" +#include "../vmisc/defglobal.h" + class FvUpdater final : public QObject { - Q_OBJECT + Q_OBJECT // NOLINT public: // Singleton @@ -82,7 +84,7 @@ private: // // Singleton business // - Q_DISABLE_COPY(FvUpdater) + Q_DISABLE_COPY_MOVE(FvUpdater) // NOLINT FvUpdater(); // Hide main constructor virtual ~FvUpdater(); // Hide main destructor diff --git a/src/libs/fervor/fvupdatewindow.h b/src/libs/fervor/fvupdatewindow.h index 50fe5f31f..a494008ce 100644 --- a/src/libs/fervor/fvupdatewindow.h +++ b/src/libs/fervor/fvupdatewindow.h @@ -28,6 +28,8 @@ #include #include +#include "../vmisc/defglobal.h" + class QGraphicsScene; namespace Ui @@ -37,7 +39,7 @@ namespace Ui class FvUpdateWindow : public QDialog { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit FvUpdateWindow(QWidget *parent = nullptr); @@ -47,7 +49,8 @@ public: bool UpdateWindowWithCurrentProposedUpdate(); private: - Q_DISABLE_COPY(FvUpdateWindow) + // cppcheck-suppress unknownMacro + Q_DISABLE_COPY_MOVE(FvUpdateWindow) // NOLINT Ui::FvUpdateWindow* m_ui; }; diff --git a/src/libs/ifc/exception/vexception.cpp b/src/libs/ifc/exception/vexception.cpp index e7c4364d3..6f07cb8cf 100644 --- a/src/libs/ifc/exception/vexception.cpp +++ b/src/libs/ifc/exception/vexception.cpp @@ -33,7 +33,13 @@ #include "../ifcdef.h" -//Q_LOGGING_CATEGORY(vExcep, "v.excep") //Commented because don't use now +QT_WARNING_PUSH +QT_WARNING_DISABLE_CLANG("-Wmissing-prototypes") +QT_WARNING_DISABLE_INTEL(1418) + +//Q_LOGGING_CATEGORY(vExcep, "v.excep") // NOLINT //Commented because don't use now + +QT_WARNING_POP //--------------------------------------------------------------------------------------------------------------------- /** diff --git a/src/libs/ifc/exception/vexception.h b/src/libs/ifc/exception/vexception.h index ef1ac9613..a562be33e 100644 --- a/src/libs/ifc/exception/vexception.h +++ b/src/libs/ifc/exception/vexception.h @@ -45,7 +45,7 @@ QT_WARNING_DISABLE_GCC("-Wsuggest-final-methods") */ class VException : public QException { - Q_DECLARE_TR_FUNCTIONS(VException) + Q_DECLARE_TR_FUNCTIONS(VException) // NOLINT public: explicit VException(const QString &error) V_NOEXCEPT_EXPR (true); VException(const VException &e) V_NOEXCEPT_EXPR (true); @@ -98,7 +98,7 @@ inline QString VException::MoreInformation() const // Want have special exception for catching unhadled deleting a tool class VExceptionToolWasDeleted : public VException { - Q_DECLARE_TR_FUNCTIONS(VExceptionToolDeleted) + Q_DECLARE_TR_FUNCTIONS(VExceptionToolDeleted) // NOLINT public: explicit VExceptionToolWasDeleted(const QString &error) V_NOEXCEPT_EXPR (true); VExceptionToolWasDeleted(const VExceptionToolWasDeleted &e) V_NOEXCEPT_EXPR (true); diff --git a/src/libs/ifc/xml/vabstractconverter.h b/src/libs/ifc/xml/vabstractconverter.h index a243dca37..2229cfd2f 100644 --- a/src/libs/ifc/xml/vabstractconverter.h +++ b/src/libs/ifc/xml/vabstractconverter.h @@ -81,7 +81,7 @@ protected: void ValidateXML(const QString &schema) const; private: - Q_DISABLE_COPY(VAbstractConverter) + Q_DISABLE_COPY_MOVE(VAbstractConverter) // NOLINT QTemporaryFile m_tmpFile{}; diff --git a/src/libs/ifc/xml/vabstractmconverter.h b/src/libs/ifc/xml/vabstractmconverter.h index a45f343de..eb1e5f26b 100644 --- a/src/libs/ifc/xml/vabstractmconverter.h +++ b/src/libs/ifc/xml/vabstractmconverter.h @@ -51,7 +51,7 @@ protected: static QMap OldNamesToNewNames_InV0_3_3(); private: - Q_DISABLE_COPY(VAbstractMConverter) + Q_DISABLE_COPY_MOVE(VAbstractMConverter) // NOLINT }; #endif // VABSTRACTMCONVERTER_H diff --git a/src/libs/ifc/xml/vabstractpattern.cpp b/src/libs/ifc/xml/vabstractpattern.cpp index 650c9bf78..a72ddaf93 100644 --- a/src/libs/ifc/xml/vabstractpattern.cpp +++ b/src/libs/ifc/xml/vabstractpattern.cpp @@ -169,7 +169,7 @@ bool VAbstractPattern::patternLabelWasChanged = false; namespace { -Q_GLOBAL_STATIC_WITH_ARGS(const QString, dimensionDefValue, (QLatin1String("-1"))) +Q_GLOBAL_STATIC_WITH_ARGS(const QString, dimensionDefValue, (QLatin1String("-1"))) // NOLINT void ReadExpressionAttribute(QVector &expressions, const QDomElement &element, const QString &attribute) { diff --git a/src/libs/ifc/xml/vabstractpattern.h b/src/libs/ifc/xml/vabstractpattern.h index 185945e40..97f59f4f7 100644 --- a/src/libs/ifc/xml/vabstractpattern.h +++ b/src/libs/ifc/xml/vabstractpattern.h @@ -97,7 +97,7 @@ QT_WARNING_DISABLE_GCC("-Wsuggest-final-types") class VAbstractPattern : public VDomDocument { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit VAbstractPattern(QObject *parent = nullptr); virtual ~VAbstractPattern(); @@ -485,7 +485,7 @@ protected: auto ReadCompanyName() const -> QString; private: - Q_DISABLE_COPY(VAbstractPattern) + Q_DISABLE_COPY_MOVE(VAbstractPattern) // NOLINT QStringList ListIncrements() const; QVector ListPointExpressions() const; diff --git a/src/libs/ifc/xml/vdomdocument.cpp b/src/libs/ifc/xml/vdomdocument.cpp index 1a8c4a48c..8e229976d 100644 --- a/src/libs/ifc/xml/vdomdocument.cpp +++ b/src/libs/ifc/xml/vdomdocument.cpp @@ -234,7 +234,13 @@ bool LessThen(const QDomNode &element1, const QDomNode &element2) } } // namespace -Q_LOGGING_CATEGORY(vXML, "v.xml") +QT_WARNING_PUSH +QT_WARNING_DISABLE_CLANG("-Wmissing-prototypes") +QT_WARNING_DISABLE_INTEL(1418) + +Q_LOGGING_CATEGORY(vXML, "v.xml") // NOLINT + +QT_WARNING_POP const QString VDomDocument::AttrId = QStringLiteral("id"); const QString VDomDocument::AttrText = QStringLiteral("text"); diff --git a/src/libs/ifc/xml/vdomdocument.h b/src/libs/ifc/xml/vdomdocument.h index 42e392aa2..b1d2e3485 100644 --- a/src/libs/ifc/xml/vdomdocument.h +++ b/src/libs/ifc/xml/vdomdocument.h @@ -83,7 +83,7 @@ QT_WARNING_DISABLE_GCC("-Wnon-virtual-dtor") */ class VDomDocument : public QObject, public QDomDocument { - Q_OBJECT + Q_OBJECT // NOLINT public: static const QString AttrId; static const QString AttrText; @@ -161,7 +161,8 @@ private slots: void CacheRefreshed(); private: - Q_DISABLE_COPY(VDomDocument) + // cppcheck-suppress unknownMacro + Q_DISABLE_COPY_MOVE(VDomDocument) // NOLINT /** @brief Map used for finding element by id. */ QHash m_elementIdCache; QFutureWatcher> *m_watcher; diff --git a/src/libs/ifc/xml/vlabeltemplateconverter.h b/src/libs/ifc/xml/vlabeltemplateconverter.h index 6b2cb881d..d6f35e56b 100644 --- a/src/libs/ifc/xml/vlabeltemplateconverter.h +++ b/src/libs/ifc/xml/vlabeltemplateconverter.h @@ -56,7 +56,7 @@ protected: virtual bool IsReadOnly() const override {return false;} private: - Q_DISABLE_COPY(VLabelTemplateConverter) + Q_DISABLE_COPY_MOVE(VLabelTemplateConverter) // NOLINT static const QString LabelTemplateMinVerStr; }; diff --git a/src/libs/ifc/xml/vlayoutconverter.h b/src/libs/ifc/xml/vlayoutconverter.h index 3bd43352e..13faba11d 100644 --- a/src/libs/ifc/xml/vlayoutconverter.h +++ b/src/libs/ifc/xml/vlayoutconverter.h @@ -64,7 +64,7 @@ protected: void ToV0_1_2(); private: - Q_DISABLE_COPY(VLayoutConverter) + Q_DISABLE_COPY_MOVE(VLayoutConverter) // NOLINT static const QString LayoutMinVerStr; }; diff --git a/src/libs/ifc/xml/vpatternconverter.cpp b/src/libs/ifc/xml/vpatternconverter.cpp index 2fe35f3f7..5ec5b5254 100644 --- a/src/libs/ifc/xml/vpatternconverter.cpp +++ b/src/libs/ifc/xml/vpatternconverter.cpp @@ -70,105 +70,105 @@ namespace { // The list of all string we use for conversion // Better to use global variables because repeating QStringLiteral blows up code size -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strUnit, (QLatin1String("unit"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strVersion, (QLatin1String("version"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strName, (QLatin1String("name"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strBase, (QLatin1String("base"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strFormula, (QLatin1String("formula"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strId, (QLatin1String("id"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strKGrowth , (QLatin1String("kgrowth"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strKSize, (QLatin1String("ksize"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strPoint, (QLatin1String("point"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strLength, (QLatin1String("length"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strAngle, (QLatin1String("angle"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strC1Radius, (QLatin1String("c1Radius"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strC2Radius, (QLatin1String("c2Radius"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strCRadius, (QLatin1String("cRadius"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strArc, (QLatin1String("arc"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strAngle1, (QLatin1String("angle1"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strAngle2, (QLatin1String("angle2"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strRadius, (QLatin1String("radius"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strPathPoint, (QLatin1String("pathPoint"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strKAsm1, (QLatin1String("kAsm1"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strKAsm2, (QLatin1String("kAsm2"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strPath, (QLatin1String("path"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strType, (QLatin1String("type"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strCutArc, (QLatin1String("cutArc"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strSpline, (QLatin1String("spline"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strSplinePath, (QLatin1String("splinePath"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strCutSpline, (QLatin1String("cutSpline"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strCutSplinePath, (QLatin1String("cutSplinePath"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strColor, (QLatin1String("color"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strMeasurements, (QLatin1String("measurements"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strIncrement, (QLatin1String("increment"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strIncrements, (QLatin1String("increments"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strPreviewCalculations, (QLatin1String("previewCalculations"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strModeling, (QLatin1String("modeling"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strTools, (QLatin1String("tools"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strIdTool, (QLatin1String("idTool"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strIdObject, (QLatin1String("idObject"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strChildren, (QLatin1String("children"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strChild, (QLatin1String("child"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strPointOfIntersectionCurves, (QLatin1String("pointOfIntersectionCurves"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strCurveIntersectAxis, (QLatin1String("curveIntersectAxis"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strCurve, (QLatin1String("curve"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strCurve1, (QLatin1String("curve1"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strCurve2, (QLatin1String("curve2"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strModelingPath, (QLatin1String("modelingPath"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strModelingSpline, (QLatin1String("modelingSpline"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strPointFromArcAndTangent, (QLatin1String("pointFromArcAndTangent"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strPointOfIntersectionArcs, (QLatin1String("pointOfIntersectionArcs"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strFirstArc, (QLatin1String("firstArc"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strSecondArc, (QLatin1String("secondArc"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strDetail, (QLatin1String("detail"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strSupplement, (QLatin1String("supplement"))) -//Q_GLOBAL_STATIC_WITH_ARGS(const QString, strClosed, (QLatin1String("closed"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strWidth, (QLatin1String("width"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strHeight, (QLatin1String("height"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strNode, (QLatin1String("node"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strNodes, (QLatin1String("nodes"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strData, (QLatin1String("data"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strPatternInfo, (QLatin1String("patternInfo"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strGrainline, (QLatin1String("grainline"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strReverse, (QLatin1String("reverse"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strMx, (QLatin1String("mx"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strMy, (QLatin1String("my"))) -//Q_GLOBAL_STATIC_WITH_ARGS(const QString, strForbidFlipping, (QLatin1String("forbidFlipping"))) -//Q_GLOBAL_STATIC_WITH_ARGS(const QString, strInLayout, (QLatin1String("inLayout"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strSeamAllowance, (QLatin1String("seamAllowance"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strUUID, (QLatin1String("uuid"))) -//Q_GLOBAL_STATIC_WITH_ARGS(const QString, strNodeType, (QLatin1String("nodeType"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strDet, (QLatin1String("det"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strTypeObject, (QLatin1String("typeObject"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strReadOnly, (QLatin1String("readOnly"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strPatternLabel, (QLatin1String("patternLabel"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strImage, (QLatin1String("image"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strAuthor, (QLatin1String("author"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strDescription, (QLatin1String("description"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strNotes, (QLatin1String("notes"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strGradation, (QLatin1String("gradation"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strPatternName, (QLatin1String("patternName"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strPatternNum, (QLatin1String("patternNumber"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strCompanyName, (QLatin1String("company"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strCustomerName, (QLatin1String("customer"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strLine, (QLatin1String("line"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strText, (QLatin1String("text"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strBold, (QLatin1String("bold"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strItalic, (QLatin1String("italic"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strAlignment, (QLatin1String("alignment"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strFSIncrement, (QLatin1String("sfIncrement"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strShowDate, (QLatin1String("showDate"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strShowMeasurements, (QLatin1String("showMeasurements"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strSize, (QLatin1String("size"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strMCP, (QLatin1String("mcp"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strLetter, (QLatin1String("letter"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strMaterial , (QLatin1String("material"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strUserDefined, (QLatin1String("userDef"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strPlacement, (QLatin1String("placement"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strCutNumber, (QLatin1String("cutNumber"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strQuantity, (QLatin1String("quantity"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strExtension, (QLatin1String("extension"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strContentType, (QLatin1String("contentType"))) +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strUnit, (QLatin1String("unit"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strVersion, (QLatin1String("version"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strName, (QLatin1String("name"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strBase, (QLatin1String("base"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strFormula, (QLatin1String("formula"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strId, (QLatin1String("id"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strKGrowth , (QLatin1String("kgrowth"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strKSize, (QLatin1String("ksize"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strPoint, (QLatin1String("point"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strLength, (QLatin1String("length"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strAngle, (QLatin1String("angle"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strC1Radius, (QLatin1String("c1Radius"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strC2Radius, (QLatin1String("c2Radius"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strCRadius, (QLatin1String("cRadius"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strArc, (QLatin1String("arc"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strAngle1, (QLatin1String("angle1"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strAngle2, (QLatin1String("angle2"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strRadius, (QLatin1String("radius"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strPathPoint, (QLatin1String("pathPoint"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strKAsm1, (QLatin1String("kAsm1"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strKAsm2, (QLatin1String("kAsm2"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strPath, (QLatin1String("path"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strType, (QLatin1String("type"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strCutArc, (QLatin1String("cutArc"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strSpline, (QLatin1String("spline"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strSplinePath, (QLatin1String("splinePath"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strCutSpline, (QLatin1String("cutSpline"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strCutSplinePath, (QLatin1String("cutSplinePath"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strColor, (QLatin1String("color"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strMeasurements, (QLatin1String("measurements"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strIncrement, (QLatin1String("increment"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strIncrements, (QLatin1String("increments"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strPreviewCalculations, (QLatin1String("previewCalculations"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strModeling, (QLatin1String("modeling"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strTools, (QLatin1String("tools"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strIdTool, (QLatin1String("idTool"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strIdObject, (QLatin1String("idObject"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strChildren, (QLatin1String("children"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strChild, (QLatin1String("child"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strPointOfIntersectionCurves, (QLatin1String("pointOfIntersectionCurves"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strCurveIntersectAxis, (QLatin1String("curveIntersectAxis"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strCurve, (QLatin1String("curve"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strCurve1, (QLatin1String("curve1"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strCurve2, (QLatin1String("curve2"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strModelingPath, (QLatin1String("modelingPath"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strModelingSpline, (QLatin1String("modelingSpline"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strPointFromArcAndTangent, (QLatin1String("pointFromArcAndTangent"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strPointOfIntersectionArcs, (QLatin1String("pointOfIntersectionArcs"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strFirstArc, (QLatin1String("firstArc"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strSecondArc, (QLatin1String("secondArc"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strDetail, (QLatin1String("detail"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strSupplement, (QLatin1String("supplement"))) // NOLINT +//Q_GLOBAL_STATIC_WITH_ARGS(const QString, strClosed, (QLatin1String("closed"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strWidth, (QLatin1String("width"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strHeight, (QLatin1String("height"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strNode, (QLatin1String("node"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strNodes, (QLatin1String("nodes"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strData, (QLatin1String("data"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strPatternInfo, (QLatin1String("patternInfo"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strGrainline, (QLatin1String("grainline"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strReverse, (QLatin1String("reverse"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strMx, (QLatin1String("mx"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strMy, (QLatin1String("my"))) // NOLINT +//Q_GLOBAL_STATIC_WITH_ARGS(const QString, strForbidFlipping, (QLatin1String("forbidFlipping"))) // NOLINT +//Q_GLOBAL_STATIC_WITH_ARGS(const QString, strInLayout, (QLatin1String("inLayout"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strSeamAllowance, (QLatin1String("seamAllowance"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strUUID, (QLatin1String("uuid"))) // NOLINT +//Q_GLOBAL_STATIC_WITH_ARGS(const QString, strNodeType, (QLatin1String("nodeType"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strDet, (QLatin1String("det"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strTypeObject, (QLatin1String("typeObject"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strReadOnly, (QLatin1String("readOnly"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strPatternLabel, (QLatin1String("patternLabel"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strImage, (QLatin1String("image"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strAuthor, (QLatin1String("author"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strDescription, (QLatin1String("description"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strNotes, (QLatin1String("notes"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strGradation, (QLatin1String("gradation"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strPatternName, (QLatin1String("patternName"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strPatternNum, (QLatin1String("patternNumber"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strCompanyName, (QLatin1String("company"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strCustomerName, (QLatin1String("customer"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strLine, (QLatin1String("line"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strText, (QLatin1String("text"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strBold, (QLatin1String("bold"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strItalic, (QLatin1String("italic"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strAlignment, (QLatin1String("alignment"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strFSIncrement, (QLatin1String("sfIncrement"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strShowDate, (QLatin1String("showDate"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strShowMeasurements, (QLatin1String("showMeasurements"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strSize, (QLatin1String("size"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strMCP, (QLatin1String("mcp"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strLetter, (QLatin1String("letter"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strMaterial , (QLatin1String("material"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strUserDefined, (QLatin1String("userDef"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strPlacement, (QLatin1String("placement"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strCutNumber, (QLatin1String("cutNumber"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strQuantity, (QLatin1String("quantity"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strExtension, (QLatin1String("extension"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strContentType, (QLatin1String("contentType"))) // NOLINT } // anonymous namespace //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/ifc/xml/vpatternconverter.h b/src/libs/ifc/xml/vpatternconverter.h index 67b852ff3..5d3228bff 100644 --- a/src/libs/ifc/xml/vpatternconverter.h +++ b/src/libs/ifc/xml/vpatternconverter.h @@ -45,7 +45,7 @@ class QDomElement; class VPatternConverter final : public VAbstractConverter { - Q_DECLARE_TR_FUNCTIONS(VPatternConverter) + Q_DECLARE_TR_FUNCTIONS(VPatternConverter) // NOLINT public: explicit VPatternConverter(const QString &fileName); virtual ~VPatternConverter() Q_DECL_EQ_DEFAULT; @@ -71,7 +71,7 @@ protected: virtual bool IsReadOnly() const override; private: - Q_DISABLE_COPY(VPatternConverter) + Q_DISABLE_COPY_MOVE(VPatternConverter) // NOLINT static const QString PatternMinVerStr; void ToV0_2_0(); diff --git a/src/libs/ifc/xml/vpatternimage.h b/src/libs/ifc/xml/vpatternimage.h index 81dced06a..cfbd5eff2 100644 --- a/src/libs/ifc/xml/vpatternimage.h +++ b/src/libs/ifc/xml/vpatternimage.h @@ -36,7 +36,7 @@ class QMimeType; class VPatternImage { - Q_DECLARE_TR_FUNCTIONS(VPatternImage) + Q_DECLARE_TR_FUNCTIONS(VPatternImage) // NOLINT public: VPatternImage() = default; diff --git a/src/libs/ifc/xml/vvitconverter.cpp b/src/libs/ifc/xml/vvitconverter.cpp index 63626a9a8..38d2b1982 100644 --- a/src/libs/ifc/xml/vvitconverter.cpp +++ b/src/libs/ifc/xml/vvitconverter.cpp @@ -64,11 +64,11 @@ namespace { // The list of all string we use for conversion // Better to use global variables because repeating QStringLiteral blows up code size -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strTagRead_Only, (QLatin1String("read-only"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strGivenName, (QLatin1String("given-name"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strFamilyName, (QLatin1String("family-name"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strCustomer, (QLatin1String("customer"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strPersonal, (QLatin1String("personal"))) +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strTagRead_Only, (QLatin1String("read-only"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strGivenName, (QLatin1String("given-name"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strFamilyName, (QLatin1String("family-name"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strCustomer, (QLatin1String("customer"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strPersonal, (QLatin1String("personal"))) // NOLINT } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/ifc/xml/vvitconverter.h b/src/libs/ifc/xml/vvitconverter.h index f54764437..ea74ea7ce 100644 --- a/src/libs/ifc/xml/vvitconverter.h +++ b/src/libs/ifc/xml/vvitconverter.h @@ -41,7 +41,7 @@ class QDomElement; class VVITConverter final : public VAbstractMConverter { - Q_DECLARE_TR_FUNCTIONS(VVITConverter) + Q_DECLARE_TR_FUNCTIONS(VVITConverter) // NOLINT public: explicit VVITConverter(const QString &fileName); virtual ~VVITConverter() Q_DECL_EQ_DEFAULT; @@ -64,7 +64,7 @@ protected: virtual bool IsReadOnly() const override; private: - Q_DISABLE_COPY(VVITConverter) + Q_DISABLE_COPY_MOVE(VVITConverter) // NOLINT static const QString MeasurementMinVerStr; void AddNewTagsForV0_3_0(); diff --git a/src/libs/ifc/xml/vvstconverter.cpp b/src/libs/ifc/xml/vvstconverter.cpp index ad3724bdc..6b5928973 100644 --- a/src/libs/ifc/xml/vvstconverter.cpp +++ b/src/libs/ifc/xml/vvstconverter.cpp @@ -62,10 +62,10 @@ const QString VVSTConverter::CurrentSchema = QStringLiteral("://schema/mu namespace { -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strTagRead_Only, (QLatin1String("read-only"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strAttrCircumference, (QLatin1String("circumference"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strAttrMeasurement, (QLatin1String("measurement"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strTagDimension, (QLatin1String("dimension"))) +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strTagRead_Only, (QLatin1String("read-only"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strAttrCircumference, (QLatin1String("circumference"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strAttrMeasurement, (QLatin1String("measurement"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strTagDimension, (QLatin1String("dimension"))) // NOLINT } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/ifc/xml/vvstconverter.h b/src/libs/ifc/xml/vvstconverter.h index bfcb3003f..08ea7b6ce 100644 --- a/src/libs/ifc/xml/vvstconverter.h +++ b/src/libs/ifc/xml/vvstconverter.h @@ -41,7 +41,7 @@ class QDomElement; class VVSTConverter final : public VAbstractMConverter { - Q_DECLARE_TR_FUNCTIONS(VVSTConverter) + Q_DECLARE_TR_FUNCTIONS(VVSTConverter) // NOLINT public: explicit VVSTConverter(const QString &fileName); virtual ~VVSTConverter() Q_DECL_EQ_DEFAULT; @@ -64,7 +64,7 @@ protected: virtual bool IsReadOnly() const override; private: - Q_DISABLE_COPY(VVSTConverter) + Q_DISABLE_COPY_MOVE(VVSTConverter) // NOLINT static const QString MeasurementMinVerStr; void AddNewTagsForV0_4_0(); diff --git a/src/libs/ifc/xml/vwatermarkconverter.h b/src/libs/ifc/xml/vwatermarkconverter.h index d982a83c7..6a10d802b 100644 --- a/src/libs/ifc/xml/vwatermarkconverter.h +++ b/src/libs/ifc/xml/vwatermarkconverter.h @@ -55,7 +55,7 @@ protected: virtual bool IsReadOnly() const override {return false;} private: - Q_DISABLE_COPY(VWatermarkConverter) + Q_DISABLE_COPY_MOVE(VWatermarkConverter) // NOLINT static const QString WatermarkMinVerStr; void ToV1_1_0(); diff --git a/src/libs/qmuparser/qmudef.h b/src/libs/qmuparser/qmudef.h index 508ad6eb7..ba3408d0a 100644 --- a/src/libs/qmuparser/qmudef.h +++ b/src/libs/qmuparser/qmudef.h @@ -82,6 +82,15 @@ #endif // QT_VERSION < QT_VERSION_CHECK(5, 5, 0) +#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) +#define Q_DISABLE_MOVE(Class) \ +Class(Class &&) = delete; \ + Class &operator=(Class &&) = delete; +#define Q_DISABLE_COPY_MOVE(Class) \ +Q_DISABLE_COPY(Class) \ + Q_DISABLE_MOVE(Class) +#endif + QT_WARNING_PUSH QT_WARNING_DISABLE_GCC("-Wattributes") diff --git a/src/libs/qmuparser/qmuformulabase.h b/src/libs/qmuparser/qmuformulabase.h index 087b46d35..d8d2061be 100644 --- a/src/libs/qmuparser/qmuformulabase.h +++ b/src/libs/qmuparser/qmuformulabase.h @@ -51,7 +51,7 @@ protected: static qreal* AddVariable(const QString &a_szName, void *a_pUserData); void SetSepForEval(); private: - Q_DISABLE_COPY(QmuFormulaBase) + Q_DISABLE_COPY_MOVE(QmuFormulaBase) // NOLINT }; } // namespace qmu diff --git a/src/libs/qmuparser/qmuparserbytecode.cpp b/src/libs/qmuparser/qmuparserbytecode.cpp index 328626a3e..ab9aa5ee0 100644 --- a/src/libs/qmuparser/qmuparserbytecode.cpp +++ b/src/libs/qmuparser/qmuparserbytecode.cpp @@ -26,10 +26,10 @@ #include #include #include +#include #include "qmudef.h" #include "qmuparsererror.h" -#include "../vmisc/vmath.h" namespace qmu { @@ -38,7 +38,6 @@ namespace qmu * @brief Bytecode default constructor. */ QmuParserByteCode::QmuParserByteCode() - :m_iStackPos(0), m_iMaxStackSize(0), m_vRPN(), m_bEnableOptimizer(true) { m_vRPN.reserve(50); } @@ -50,8 +49,7 @@ QmuParserByteCode::QmuParserByteCode() * Implemented in Terms of Assign(const QParserByteCode &a_ByteCode) */ QmuParserByteCode::QmuParserByteCode(const QmuParserByteCode &a_ByteCode) - :m_iStackPos(a_ByteCode.m_iStackPos), m_iMaxStackSize(a_ByteCode.m_iMaxStackSize), m_vRPN(a_ByteCode.m_vRPN), - m_bEnableOptimizer(true) + :m_iStackPos(a_ByteCode.m_iStackPos), m_iMaxStackSize(a_ByteCode.m_iMaxStackSize), m_vRPN(a_ByteCode.m_vRPN) { Assign(a_ByteCode); } @@ -62,7 +60,7 @@ QmuParserByteCode::QmuParserByteCode(const QmuParserByteCode &a_ByteCode) * * Implemented in Terms of Assign(const QParserByteCode &a_ByteCode) */ -QmuParserByteCode& QmuParserByteCode::operator=(const QmuParserByteCode &a_ByteCode) +auto QmuParserByteCode::operator=(const QmuParserByteCode &a_ByteCode) -> QmuParserByteCode& { if (this != &a_ByteCode) { @@ -104,9 +102,9 @@ void QmuParserByteCode::AddVar(qreal *a_pVar) // optimization does not apply SToken tok{}; tok.Cmd = cmVAR; - tok.Val.ptr = a_pVar; - tok.Val.data = 1; - tok.Val.data2 = 0; + tok.Val.ptr = a_pVar; // NOLINT(cppcoreguidelines-pro-type-union-access) + tok.Val.data = 1; // NOLINT(cppcoreguidelines-pro-type-union-access) + tok.Val.data2 = 0; // NOLINT(cppcoreguidelines-pro-type-union-access) m_vRPN.push_back(tok); } @@ -132,9 +130,9 @@ void QmuParserByteCode::AddVal(qreal a_fVal) // If optimization does not apply SToken tok{}; tok.Cmd = cmVAL; - tok.Val.ptr = nullptr; - tok.Val.data = 0; - tok.Val.data2 = a_fVal; + tok.Val.ptr = nullptr; // NOLINT(cppcoreguidelines-pro-type-union-access) + tok.Val.data = 0; // NOLINT(cppcoreguidelines-pro-type-union-access) + tok.Val.data2 = a_fVal; // NOLINT(cppcoreguidelines-pro-type-union-access) m_vRPN.push_back(tok); } @@ -142,8 +140,8 @@ void QmuParserByteCode::AddVal(qreal a_fVal) void QmuParserByteCode::ConstantFolding(ECmdCode a_Oprt) { int sz = m_vRPN.size(); - qreal &x = m_vRPN[sz-2].Val.data2, - &y = m_vRPN[sz-1].Val.data2; + qreal &x = m_vRPN[sz-2].Val.data2, // NOLINT(cppcoreguidelines-pro-type-union-access) + &y = m_vRPN[sz-1].Val.data2; // NOLINT(cppcoreguidelines-pro-type-union-access) switch (a_Oprt) { case cmLAND: @@ -214,7 +212,124 @@ void QmuParserByteCode::ConstantFolding(ECmdCode a_Oprt) break; default: break; - } // switch opcode + } // switch opcode +} + +//--------------------------------------------------------------------------------------------------------------------- +void QmuParserByteCode::OpPOW(int sz, bool &bOptimized) +{ + if (m_vRPN.at(sz-2).Cmd == cmVAR && m_vRPN.at(sz-1).Cmd == cmVAL) //-V807 + { + if (qFuzzyCompare(m_vRPN.at(sz-1).Val.data2, 2)) //-V807 + { + m_vRPN[sz-2].Cmd = cmVARPOW2; + } + else if (qFuzzyCompare(m_vRPN.at(sz-1).Val.data2, 3)) + { + m_vRPN[sz-2].Cmd = cmVARPOW3; + } + else if (qFuzzyCompare(m_vRPN.at(sz-1).Val.data2, 4)) + { + m_vRPN[sz-2].Cmd = cmVARPOW4; + } + else + { + return; + } + m_vRPN.pop_back(); + bOptimized = true; + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void QmuParserByteCode::OpSUBADD(ECmdCode a_Oprt, int sz, bool &bOptimized) +{ + if ( (m_vRPN.at(sz-1).Cmd == cmVAR && m_vRPN.at(sz-2).Cmd == cmVAL) || + (m_vRPN.at(sz-1).Cmd == cmVAL && m_vRPN.at(sz-2).Cmd == cmVAR) || + (m_vRPN.at(sz-1).Cmd == cmVAL && m_vRPN.at(sz-2).Cmd == cmVARMUL) || + (m_vRPN.at(sz-1).Cmd == cmVARMUL && m_vRPN.at(sz-2).Cmd == cmVAL) || + (m_vRPN.at(sz-1).Cmd == cmVAR && m_vRPN.at(sz-2).Cmd == cmVAR && + m_vRPN.at(sz-2).Val.ptr == m_vRPN.at(sz-1).Val.ptr) || //-V807 + (m_vRPN.at(sz-1).Cmd == cmVAR && m_vRPN.at(sz-2).Cmd == cmVARMUL + && m_vRPN.at(sz-2).Val.ptr == m_vRPN.at(sz-1).Val.ptr) || + (m_vRPN.at(sz-1).Cmd == cmVARMUL && m_vRPN.at(sz-2).Cmd == cmVAR && + m_vRPN.at(sz-2).Val.ptr == m_vRPN.at(sz-1).Val.ptr) || + (m_vRPN.at(sz-1).Cmd == cmVARMUL && m_vRPN.at(sz-2).Cmd == cmVARMUL && + m_vRPN.at(sz-2).Val.ptr == m_vRPN.at(sz-1).Val.ptr) ) + { + assert( (m_vRPN.at(sz-2).Val.ptr==nullptr && m_vRPN.at(sz-1).Val.ptr!=nullptr) || + (m_vRPN.at(sz-2).Val.ptr!=nullptr && m_vRPN.at(sz-1).Val.ptr==nullptr) || + (m_vRPN.at(sz-2).Val.ptr == m_vRPN.at(sz-1).Val.ptr) ); + + m_vRPN[sz-2].Cmd = cmVARMUL; + m_vRPN[sz-2].Val.ptr = reinterpret_cast( //-V807 NOLINT(cppcoreguidelines-pro-type-reinterpret-cast) + reinterpret_cast(m_vRPN.at(sz-2).Val.ptr) | // NOLINT(cppcoreguidelines-pro-type-reinterpret-cast, hicpp-signed-bitwise) + reinterpret_cast(m_vRPN.at(sz-1).Val.ptr)); // variable NOLINT(cppcoreguidelines-pro-type-reinterpret-cast) + m_vRPN[sz-2].Val.data2 += ((a_Oprt==cmSUB) ? -1 : 1) * m_vRPN.at(sz-1).Val.data2; // offset + m_vRPN[sz-2].Val.data += ((a_Oprt==cmSUB) ? -1 : 1) * m_vRPN.at(sz-1).Val.data; // multiplikatior + m_vRPN.pop_back(); + bOptimized = true; + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void QmuParserByteCode::OpMUL(int sz, bool &bOptimized) +{ + if ( (m_vRPN.at(sz-1).Cmd == cmVAR && m_vRPN.at(sz-2).Cmd == cmVAL) || + (m_vRPN.at(sz-1).Cmd == cmVAL && m_vRPN.at(sz-2).Cmd == cmVAR) ) + { + m_vRPN[sz-2].Cmd = cmVARMUL; + m_vRPN[sz-2].Val.ptr = reinterpret_cast( // NOLINT(cppcoreguidelines-pro-type-reinterpret-cast) + reinterpret_cast(m_vRPN.at(sz-2).Val.ptr) | // NOLINT(cppcoreguidelines-pro-type-reinterpret-cast, hicpp-signed-bitwise) + reinterpret_cast(m_vRPN.at(sz-1).Val.ptr)); // NOLINT(cppcoreguidelines-pro-type-reinterpret-cast) + m_vRPN[sz-2].Val.data = m_vRPN.at(sz-2).Val.data2 + m_vRPN.at(sz-1).Val.data2; + m_vRPN[sz-2].Val.data2 = 0; + m_vRPN.pop_back(); + bOptimized = true; + } + else if ( (m_vRPN.at(sz-1).Cmd == cmVAL && m_vRPN.at(sz-2).Cmd == cmVARMUL) || + (m_vRPN.at(sz-1).Cmd == cmVARMUL && m_vRPN.at(sz-2).Cmd == cmVAL) ) + { + // Optimization: 2*(3*b+1) or (3*b+1)*2 -> 6*b+2 + m_vRPN[sz-2].Cmd = cmVARMUL; + m_vRPN[sz-2].Val.ptr = reinterpret_cast( // NOLINT(cppcoreguidelines-pro-type-reinterpret-cast) + reinterpret_cast(m_vRPN.at(sz-2).Val.ptr) | // NOLINT(cppcoreguidelines-pro-type-reinterpret-cast, hicpp-signed-bitwise) + reinterpret_cast(m_vRPN.at(sz-1).Val.ptr)); // NOLINT(cppcoreguidelines-pro-type-reinterpret-cast) + if (m_vRPN.at(sz-1).Cmd == cmVAL) + { + m_vRPN[sz-2].Val.data *= m_vRPN.at(sz-1).Val.data2; + m_vRPN[sz-2].Val.data2 *= m_vRPN.at(sz-1).Val.data2; + } + else + { + m_vRPN[sz-2].Val.data = m_vRPN.at(sz-1).Val.data * m_vRPN.at(sz-2).Val.data2; + m_vRPN[sz-2].Val.data2 = m_vRPN.at(sz-1).Val.data2 * m_vRPN.at(sz-2).Val.data2; + } + m_vRPN.pop_back(); + bOptimized = true; + } + else if (m_vRPN.at(sz-1).Cmd == cmVAR && m_vRPN.at(sz-2).Cmd == cmVAR && + m_vRPN.at(sz-1).Val.ptr == m_vRPN.at(sz-2).Val.ptr) + { + // Optimization: a*a -> a^2 + m_vRPN[sz-2].Cmd = cmVARPOW2; + m_vRPN.pop_back(); + bOptimized = true; + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void QmuParserByteCode::OpDIV(int sz, bool &bOptimized) +{ + if (m_vRPN.at(sz-1).Cmd == cmVAL && m_vRPN.at(sz-2).Cmd == cmVARMUL && + not qFuzzyIsNull(m_vRPN.at(sz-1).Val.data2)) + { + // Optimization: 4*a/2 -> 2*a + m_vRPN[sz-2].Val.data /= m_vRPN.at(sz-1).Val.data2; + m_vRPN[sz-2].Val.data2 /= m_vRPN.at(sz-1).Val.data2; + m_vRPN.pop_back(); + bOptimized = true; + } } QT_WARNING_PUSH @@ -235,150 +350,65 @@ QT_WARNING_DISABLE_MSVC(4826) */ void QmuParserByteCode::AddOp(ECmdCode a_Oprt) { + auto WriteValue = [this, a_Oprt](bool bOptimized) + { + if (not bOptimized) + { + --m_iStackPos; + SToken tok{}; + tok.Cmd = a_Oprt; + m_vRPN.push_back(tok); + } + }; + bool bOptimized = false; - if (m_bEnableOptimizer) + if (not m_bEnableOptimizer) { - int sz = m_vRPN.size(); + // If optimization can't be applied just write the value + WriteValue(bOptimized); + return; + } - // Check for foldable constants like: - // cmVAL cmVAL cmADD - // where cmADD can stand fopr any binary operator applied to - // two constant values. - if (sz>=2 && m_vRPN.at(sz-2).Cmd == cmVAL && m_vRPN.at(sz-1).Cmd == cmVAL) + int sz = m_vRPN.size(); + + // Check for foldable constants like: + // cmVAL cmVAL cmADD + // where cmADD can stand fopr any binary operator applied to + // two constant values. + if (sz>=2 && m_vRPN.at(sz-2).Cmd == cmVAL && m_vRPN.at(sz-1).Cmd == cmVAL) + { + ConstantFolding(a_Oprt); + bOptimized = true; + } + else + { + switch (a_Oprt) { - ConstantFolding(a_Oprt); - bOptimized = true; - } - else - { - switch (a_Oprt) - { - case cmPOW: - // Optimization for ploynomials of low order - if (m_vRPN.at(sz-2).Cmd == cmVAR && m_vRPN.at(sz-1).Cmd == cmVAL) //-V807 - { - if (qFuzzyCompare(m_vRPN.at(sz-1).Val.data2, 2)) //-V807 - { - m_vRPN[sz-2].Cmd = cmVARPOW2; - } - else if (qFuzzyCompare(m_vRPN.at(sz-1).Val.data2, 3)) - { - m_vRPN[sz-2].Cmd = cmVARPOW3; - } - else if (qFuzzyCompare(m_vRPN.at(sz-1).Val.data2, 4)) - { - m_vRPN[sz-2].Cmd = cmVARPOW4; - } - else - { - break; - } - m_vRPN.pop_back(); - bOptimized = true; - } - break; + case cmPOW: + // Optimization for ploynomials of low order + OpPOW(sz, bOptimized); + break; + case cmSUB: + case cmADD: + // Simple optimization based on pattern recognition for a shitload of different + // bytecode combinations of addition/subtraction + OpSUBADD(a_Oprt, sz, bOptimized); + break; + case cmMUL: + OpMUL(sz, bOptimized); + break; + case cmDIV: + OpDIV(sz, bOptimized); + break; + default: + break; - case cmSUB: - case cmADD: - // Simple optimization based on pattern recognition for a shitload of different - // bytecode combinations of addition/subtraction - if ( (m_vRPN.at(sz-1).Cmd == cmVAR && m_vRPN.at(sz-2).Cmd == cmVAL) || - (m_vRPN.at(sz-1).Cmd == cmVAL && m_vRPN.at(sz-2).Cmd == cmVAR) || - (m_vRPN.at(sz-1).Cmd == cmVAL && m_vRPN.at(sz-2).Cmd == cmVARMUL) || - (m_vRPN.at(sz-1).Cmd == cmVARMUL && m_vRPN.at(sz-2).Cmd == cmVAL) || - (m_vRPN.at(sz-1).Cmd == cmVAR && m_vRPN.at(sz-2).Cmd == cmVAR && - m_vRPN.at(sz-2).Val.ptr == m_vRPN.at(sz-1).Val.ptr) || //-V807 - (m_vRPN.at(sz-1).Cmd == cmVAR && m_vRPN.at(sz-2).Cmd == cmVARMUL - && m_vRPN.at(sz-2).Val.ptr == m_vRPN.at(sz-1).Val.ptr) || - (m_vRPN.at(sz-1).Cmd == cmVARMUL && m_vRPN.at(sz-2).Cmd == cmVAR && - m_vRPN.at(sz-2).Val.ptr == m_vRPN.at(sz-1).Val.ptr) || - (m_vRPN.at(sz-1).Cmd == cmVARMUL && m_vRPN.at(sz-2).Cmd == cmVARMUL && - m_vRPN.at(sz-2).Val.ptr == m_vRPN.at(sz-1).Val.ptr) ) - { - assert( (m_vRPN.at(sz-2).Val.ptr==nullptr && m_vRPN.at(sz-1).Val.ptr!=nullptr) || - (m_vRPN.at(sz-2).Val.ptr!=nullptr && m_vRPN.at(sz-1).Val.ptr==nullptr) || - (m_vRPN.at(sz-2).Val.ptr == m_vRPN.at(sz-1).Val.ptr) ); - - m_vRPN[sz-2].Cmd = cmVARMUL; - m_vRPN[sz-2].Val.ptr = reinterpret_cast( //-V807 - reinterpret_cast(m_vRPN.at(sz-2).Val.ptr) | - reinterpret_cast(m_vRPN.at(sz-1).Val.ptr)); // variable - m_vRPN[sz-2].Val.data2 += ((a_Oprt==cmSUB) ? -1 : 1) * m_vRPN.at(sz-1).Val.data2; // offset - m_vRPN[sz-2].Val.data += ((a_Oprt==cmSUB) ? -1 : 1) * m_vRPN.at(sz-1).Val.data; // multiplikatior - m_vRPN.pop_back(); - bOptimized = true; - } - break; - case cmMUL: - if ( (m_vRPN.at(sz-1).Cmd == cmVAR && m_vRPN.at(sz-2).Cmd == cmVAL) || - (m_vRPN.at(sz-1).Cmd == cmVAL && m_vRPN.at(sz-2).Cmd == cmVAR) ) - { - m_vRPN[sz-2].Cmd = cmVARMUL; - m_vRPN[sz-2].Val.ptr = reinterpret_cast( - reinterpret_cast(m_vRPN.at(sz-2).Val.ptr) | - reinterpret_cast(m_vRPN.at(sz-1).Val.ptr)); - m_vRPN[sz-2].Val.data = m_vRPN.at(sz-2).Val.data2 + m_vRPN.at(sz-1).Val.data2; - m_vRPN[sz-2].Val.data2 = 0; - m_vRPN.pop_back(); - bOptimized = true; - } - else if ( (m_vRPN.at(sz-1).Cmd == cmVAL && m_vRPN.at(sz-2).Cmd == cmVARMUL) || - (m_vRPN.at(sz-1).Cmd == cmVARMUL && m_vRPN.at(sz-2).Cmd == cmVAL) ) - { - // Optimization: 2*(3*b+1) or (3*b+1)*2 -> 6*b+2 - m_vRPN[sz-2].Cmd = cmVARMUL; - m_vRPN[sz-2].Val.ptr = reinterpret_cast( - reinterpret_cast(m_vRPN.at(sz-2).Val.ptr) | - reinterpret_cast(m_vRPN.at(sz-1).Val.ptr)); - if (m_vRPN.at(sz-1).Cmd == cmVAL) - { - m_vRPN[sz-2].Val.data *= m_vRPN.at(sz-1).Val.data2; - m_vRPN[sz-2].Val.data2 *= m_vRPN.at(sz-1).Val.data2; - } - else - { - m_vRPN[sz-2].Val.data = m_vRPN.at(sz-1).Val.data * m_vRPN.at(sz-2).Val.data2; - m_vRPN[sz-2].Val.data2 = m_vRPN.at(sz-1).Val.data2 * m_vRPN.at(sz-2).Val.data2; - } - m_vRPN.pop_back(); - bOptimized = true; - } - else if (m_vRPN.at(sz-1).Cmd == cmVAR && m_vRPN.at(sz-2).Cmd == cmVAR && - m_vRPN.at(sz-1).Val.ptr == m_vRPN.at(sz-2).Val.ptr) - { - // Optimization: a*a -> a^2 - m_vRPN[sz-2].Cmd = cmVARPOW2; - m_vRPN.pop_back(); - bOptimized = true; - } - break; - case cmDIV: - if (m_vRPN.at(sz-1).Cmd == cmVAL && m_vRPN.at(sz-2).Cmd == cmVARMUL && - not qFuzzyIsNull(m_vRPN.at(sz-1).Val.data2)) - { - // Optimization: 4*a/2 -> 2*a - m_vRPN[sz-2].Val.data /= m_vRPN.at(sz-1).Val.data2; - m_vRPN[sz-2].Val.data2 /= m_vRPN.at(sz-1).Val.data2; - m_vRPN.pop_back(); - bOptimized = true; - } - break; - default: - break; - - } // switch a_Oprt - } + } // switch a_Oprt } // If optimization can't be applied just write the value - if (bOptimized == false) - { - --m_iStackPos; - SToken tok{}; - tok.Cmd = a_Oprt; - m_vRPN.push_back(tok); - } + WriteValue(bOptimized); } QT_WARNING_POP @@ -520,16 +550,14 @@ void QmuParserByteCode::Finalize() } //--------------------------------------------------------------------------------------------------------------------- -const SToken* QmuParserByteCode::GetBase() const +auto QmuParserByteCode::GetBase() const -> const SToken* { - if (m_vRPN.size()==0) + if (m_vRPN.empty()) { throw QmuParserError(ecINTERNAL_ERROR); } - else - { - return &m_vRPN.at(0); - } + + return &m_vRPN.at(0); } //--------------------------------------------------------------------------------------------------------------------- @@ -554,7 +582,7 @@ void QmuParserByteCode::clear() */ void QmuParserByteCode::AsciiDump() { - if (m_vRPN.size() == false) + if (m_vRPN.empty()) { qDebug() << "No bytecode available\n"; return; diff --git a/src/libs/qmuparser/qmuparserbytecode.h b/src/libs/qmuparser/qmuparserbytecode.h index 8a3d9a8e6..1e11c7e83 100644 --- a/src/libs/qmuparser/qmuparserbytecode.h +++ b/src/libs/qmuparser/qmuparserbytecode.h @@ -88,42 +88,50 @@ class QmuParserByteCode public: QmuParserByteCode(); QmuParserByteCode(const QmuParserByteCode &a_ByteCode); - QmuParserByteCode& operator=(const QmuParserByteCode &a_ByteCode); - void Assign(const QmuParserByteCode &a_ByteCode); - void AddVar(qreal *a_pVar); - void AddVal(qreal a_fVal); - void AddOp(ECmdCode a_Oprt); - void AddIfElse(ECmdCode a_Oprt); - void AddAssignOp(qreal *a_pVar); - void AddFun(generic_fun_type a_pFun, int a_iArgc); - void AddBulkFun(generic_fun_type a_pFun, int a_iArgc); - void AddStrFun(generic_fun_type a_pFun, int a_iArgc, int a_iIdx); - void EnableOptimizer(bool bStat); - void Finalize(); - void clear(); - int GetMaxStackSize() const; - int GetSize() const; - const SToken* GetBase() const; - void AsciiDump(); + ~QmuParserByteCode()=default; + + auto operator=(const QmuParserByteCode &a_ByteCode) -> QmuParserByteCode&; + + void Assign(const QmuParserByteCode &a_ByteCode); + void AddVar(qreal *a_pVar); + void AddVal(qreal a_fVal); + void AddOp(ECmdCode a_Oprt); + void AddIfElse(ECmdCode a_Oprt); + void AddAssignOp(qreal *a_pVar); + void AddFun(generic_fun_type a_pFun, int a_iArgc); + void AddBulkFun(generic_fun_type a_pFun, int a_iArgc); + void AddStrFun(generic_fun_type a_pFun, int a_iArgc, int a_iIdx); + void EnableOptimizer(bool bStat); + void Finalize(); + void clear(); + auto GetMaxStackSize() const -> int; + auto GetSize() const -> int; + auto GetBase() const -> const SToken*; + void AsciiDump(); private: /** @brief Token type for internal use only. */ - typedef QmuParserToken token_type; + using token_type = QmuParserToken; /** @brief Token vector for storing the RPN. */ - typedef QVector rpn_type; + using rpn_type = QVector; /** @brief Position in the Calculation array. */ - unsigned m_iStackPos; + unsigned m_iStackPos{0}; /** @brief Maximum size needed for the stack. */ - unsigned m_iMaxStackSize; + unsigned m_iMaxStackSize{0}; /** @brief The actual rpn storage. */ - rpn_type m_vRPN; + rpn_type m_vRPN{}; - bool m_bEnableOptimizer; + bool m_bEnableOptimizer{true}; void ConstantFolding(ECmdCode a_Oprt); + + void OpPOW(int sz, bool &bOptimized); + void OpSUBADD(ECmdCode a_Oprt, int sz, bool &bOptimized); + void OpMUL(int sz, bool &bOptimized); + void OpDIV(int sz, bool &bOptimized); }; //--------------------------------------------------------------------------------------------------------------------- @@ -133,7 +141,7 @@ inline void QmuParserByteCode::EnableOptimizer(bool bStat) } //--------------------------------------------------------------------------------------------------------------------- -inline int QmuParserByteCode::GetMaxStackSize() const +inline auto QmuParserByteCode::GetMaxStackSize() const -> int { return static_cast(m_iMaxStackSize+1); } @@ -143,7 +151,7 @@ inline int QmuParserByteCode::GetMaxStackSize() const * @brief Returns the number of entries in the bytecode. */ // cppcheck-suppress unusedFunction -inline int QmuParserByteCode::GetSize() const +inline auto QmuParserByteCode::GetSize() const -> int { return m_vRPN.size(); } diff --git a/src/libs/qmuparser/qmuparsercallback.cpp b/src/libs/qmuparser/qmuparsercallback.cpp index d4ef51d15..9997a07fe 100644 --- a/src/libs/qmuparser/qmuparsercallback.cpp +++ b/src/libs/qmuparser/qmuparsercallback.cpp @@ -211,7 +211,7 @@ QmuParserCallback &QmuParserCallback::operator=(const QmuParserCallback &a_Fun) #ifdef Q_COMPILER_RVALUE_REFS //--------------------------------------------------------------------------------------------------------------------- QmuParserCallback::QmuParserCallback(QmuParserCallback &&a_Fun) Q_DECL_NOTHROW - : d (a_Fun.d) + : d (std::move(a_Fun.d)) {} //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/qmuparser/qmuparsercallback.h b/src/libs/qmuparser/qmuparsercallback.h index 86a6377c9..303de8bb6 100644 --- a/src/libs/qmuparser/qmuparsercallback.h +++ b/src/libs/qmuparser/qmuparsercallback.h @@ -121,6 +121,6 @@ inline QmuParserCallback* QmuParserCallback::Clone() const } // namespace qmu -Q_DECLARE_TYPEINFO(qmu::QmuParserCallback, Q_MOVABLE_TYPE); +Q_DECLARE_TYPEINFO(qmu::QmuParserCallback, Q_MOVABLE_TYPE); // NOLINT #endif diff --git a/src/libs/qmuparser/qmuparsererror.h b/src/libs/qmuparser/qmuparsererror.h index 2b4559690..9a85cd40c 100644 --- a/src/libs/qmuparser/qmuparsererror.h +++ b/src/libs/qmuparser/qmuparsererror.h @@ -36,6 +36,8 @@ #include "qmuparserdef.h" #include "qmutranslation.h" +#include "../vmisc/defglobal.h" + /** @file @brief This file defines the error class used by the parser. */ @@ -111,7 +113,8 @@ public: QString operator[] ( int a_iIdx ) const; private: - Q_DISABLE_COPY(QmuParserErrorMsg) + // cppcheck-suppress unknownMacro + Q_DISABLE_COPY_MOVE(QmuParserErrorMsg) // NOLINT QMap m_vErrMsg; ///< A map with the predefined error messages static const self_type m_Instance; ///< The instance pointer }; diff --git a/src/libs/qmuparser/qmuparsertest.h b/src/libs/qmuparser/qmuparsertest.h index 098fe1c06..66db9d8e1 100644 --- a/src/libs/qmuparser/qmuparsertest.h +++ b/src/libs/qmuparser/qmuparsertest.h @@ -60,7 +60,7 @@ namespace Test */ class QMUPARSERSHARED_EXPORT QmuParserTester : public QObject // final { - Q_OBJECT + Q_OBJECT // NOLINT public: typedef int ( QmuParserTester::*testfun_type ) (); @@ -70,7 +70,7 @@ public slots: void Run(); private: - Q_DISABLE_COPY(QmuParserTester) + Q_DISABLE_COPY_MOVE(QmuParserTester) // NOLINT QVector m_vTestFun; static int c_iCount; diff --git a/src/libs/qmuparser/qmuparsertoken.h b/src/libs/qmuparser/qmuparsertoken.h index 04bbc769a..c48a548f4 100644 --- a/src/libs/qmuparser/qmuparsertoken.h +++ b/src/libs/qmuparser/qmuparsertoken.h @@ -23,6 +23,7 @@ #define QMUPARSERTOKEN_H #include +#include #include #include #include @@ -66,10 +67,8 @@ public: * @throw nothrow * @sa ECmdCode */ - QmuParserToken() - : m_iCode ( cmUNKNOWN ), m_iType ( tpVOID ), m_pTok ( nullptr ), m_iIdx ( -1 ), m_strTok(), m_strVal(), - m_fVal(), m_pCallback() - {} + QmuParserToken() =default; + ~QmuParserToken() =default; //------------------------------------------------------------------------------ /** @@ -81,8 +80,6 @@ public: * @sa #Assign */ QmuParserToken ( const QmuParserToken &a_Tok ) - : m_iCode ( a_Tok.m_iCode ), m_iType ( a_Tok.m_iType ), m_pTok ( a_Tok.m_pTok ), m_iIdx ( a_Tok.m_iIdx ), - m_strTok( a_Tok.m_strTok ), m_strVal(a_Tok.m_strVal), m_fVal(a_Tok.m_fVal), m_pCallback() { Assign ( a_Tok ); } @@ -95,7 +92,7 @@ public: * Implemented by calling Assign(...). * @throw nothrow */ - QmuParserToken& operator= ( const QmuParserToken &a_Tok ) + auto operator= ( const QmuParserToken &a_Tok ) -> QmuParserToken& { if ( &a_Tok == this ) { @@ -136,7 +133,7 @@ public: * @post m_fVal = 0 * @post m_pTok = 0 */ - QmuParserToken& Set ( ECmdCode a_iType, const TString &a_strTok = TString() ) + auto Set ( ECmdCode a_iType, const TString &a_strTok = TString() ) -> QmuParserToken& { // The following types cant be set this way, they have special Set functions assert ( a_iType != cmVAR ); @@ -156,14 +153,14 @@ public: /** * @brief Set Callback type. */ - QmuParserToken& Set ( const QmuParserCallback &a_pCallback, const TString &a_sTok ) + auto Set ( const QmuParserCallback &a_pCallback, const TString &a_sTok ) -> QmuParserToken& { assert ( a_pCallback.GetAddr() ); m_iCode = a_pCallback.GetCode(); m_iType = tpVOID; m_strTok = a_sTok; - m_pCallback.reset ( new QmuParserCallback ( a_pCallback ) ); + m_pCallback = std::make_unique ( a_pCallback ); m_pTok = nullptr; m_iIdx = -1; @@ -178,7 +175,7 @@ public: * Member variables not necessary for value tokens will be invalidated. * @throw nothrow */ - QmuParserToken& SetVal ( TBase a_fVal, const TString &a_strTok = TString() ) + auto SetVal ( TBase a_fVal, const TString &a_strTok = TString() ) -> QmuParserToken& { m_iCode = cmVAL; m_iType = tpDBL; @@ -199,13 +196,13 @@ public: * Member variables not necessary for variable tokens will be invalidated. * @throw nothrow */ - QmuParserToken& SetVar ( TBase *a_pVar, const TString &a_strTok ) + auto SetVar ( TBase *a_pVar, const TString &a_strTok ) -> QmuParserToken& { m_iCode = cmVAR; m_iType = tpDBL; m_strTok = a_strTok; m_iIdx = -1; - m_pTok = reinterpret_cast ( a_pVar ); + m_pTok = reinterpret_cast ( a_pVar ); // NOLINT(cppcoreguidelines-pro-type-reinterpret-cast) m_pCallback.reset ( nullptr ); return *this; } @@ -217,7 +214,7 @@ public: * Member variables not necessary for variable tokens will be invalidated. * @throw nothrow */ - QmuParserToken& SetString ( const TString &a_strTok, int a_iSize ) + auto SetString ( const TString &a_strTok, int a_iSize ) -> QmuParserToken& { m_iCode = cmSTRING; m_iType = tpSTR; @@ -256,7 +253,7 @@ public: * @throw QmuParserError if #m_iIdx<0 or #m_iType!=cmSTRING * @return The index the result will take in the Bytecode calculatin array (#m_iIdx). */ - int GetIdx() const + auto GetIdx() const -> int { if ( m_iIdx < 0 || m_iCode != cmSTRING ) { @@ -273,35 +270,31 @@ public: * @return #m_iType * @throw nothrow */ - ECmdCode GetCode() const + auto GetCode() const -> ECmdCode { - if ( m_pCallback.get() ) + if ( m_pCallback ) { return m_pCallback->GetCode(); } - else - { - return m_iCode; - } + + return m_iCode; } //------------------------------------------------------------------------------ - ETypeCode GetType() const + auto GetType() const -> ETypeCode { - if ( m_pCallback.get() ) + if ( m_pCallback ) { return m_pCallback->GetType(); } - else - { - return m_iType; - } + + return m_iType; } //------------------------------------------------------------------------------ - int GetPri() const + auto GetPri() const -> int { - if ( m_pCallback.get() == nullptr) + if ( m_pCallback == nullptr) { throw QmuParserError ( ecINTERNAL_ERROR ); } @@ -315,9 +308,9 @@ public: } //------------------------------------------------------------------------------ - EOprtAssociativity GetAssociativity() const + auto GetAssociativity() const -> EOprtAssociativity { - if ( m_pCallback.get() == nullptr || m_pCallback->GetCode() != cmOPRT_BIN ) + if ( m_pCallback == nullptr || m_pCallback->GetCode() != cmOPRT_BIN ) { throw QmuParserError ( ecINTERNAL_ERROR ); } @@ -327,7 +320,7 @@ public: //------------------------------------------------------------------------------ template < class FunctionPtr > - static FunctionPtr union_cast( void* objectPtr ) + static auto union_cast( void* objectPtr ) -> FunctionPtr { union { @@ -358,7 +351,7 @@ public: * * @sa ECmdCode */ - generic_fun_type GetFuncAddr() const + auto GetFuncAddr() const -> generic_fun_type { return ( union_cast( m_pCallback.get() ) ) ? union_cast( m_pCallback->GetAddr() ) : union_cast(nullptr); @@ -371,14 +364,14 @@ public: * Only applicable to variable and value tokens. * @throw QmuParserError if token is no value/variable token. */ - TBase GetVal() const + auto GetVal() const -> TBase { switch ( m_iCode ) { case cmVAL: return m_fVal; case cmVAR: - return * ( reinterpret_cast(m_pTok) ); + return * ( reinterpret_cast(m_pTok) ); // NOLINT(cppcoreguidelines-pro-type-reinterpret-cast) case cmLE: case cmGE: case cmNEQ: @@ -425,14 +418,14 @@ public: * Valid only if m_iType==CmdVar. * @throw QmuParserError if token is no variable token. */ - TBase* GetVar() const + auto GetVar() const -> TBase* { if ( m_iCode != cmVAR ) { throw QmuParserError ( ecINTERNAL_ERROR ); } - return reinterpret_cast( m_pTok ); + return reinterpret_cast( m_pTok ); // NOLINT(cppcoreguidelines-pro-type-reinterpret-cast) } //------------------------------------------------------------------------------ @@ -441,7 +434,7 @@ public: * * Valid only if m_iType==CmdFUNC. */ - int GetArgCount() const + auto GetArgCount() const -> int { assert ( m_pCallback.get() ); @@ -463,19 +456,19 @@ public: * @throw nothrow * @sa m_strTok */ - const TString& GetAsString() const + auto GetAsString() const -> const TString& { return m_strTok; } private: - ECmdCode m_iCode; ///< Type of the token; The token type is a constant of type #ECmdCode. - ETypeCode m_iType; - void *m_pTok; ///< Stores Token pointer; not applicable for all tokens - int m_iIdx; ///< An otional index to an external buffer storing the token data - TString m_strTok; ///< Token string - TString m_strVal; ///< Value for string variables - qreal m_fVal; ///< the value - std::unique_ptr m_pCallback; + ECmdCode m_iCode{cmUNKNOWN}; ///< Type of the token; The token type is a constant of type #ECmdCode. + ETypeCode m_iType{tpVOID}; + void *m_pTok{nullptr}; ///< Stores Token pointer; not applicable for all tokens + int m_iIdx{-1}; ///< An otional index to an external buffer storing the token data + TString m_strTok{}; ///< Token string + TString m_strVal{}; ///< Value for string variables + qreal m_fVal{}; ///< the value + std::unique_ptr m_pCallback{}; }; } // namespace qmu diff --git a/src/libs/qmuparser/qmuparsertokenreader.cpp b/src/libs/qmuparser/qmuparsertokenreader.cpp index fbea37619..733d9ff8b 100644 --- a/src/libs/qmuparser/qmuparsertokenreader.cpp +++ b/src/libs/qmuparser/qmuparsertokenreader.cpp @@ -21,7 +21,7 @@ #include "qmuparsertokenreader.h" -#include +#include #include #include #include @@ -59,7 +59,7 @@ QmuParserTokenReader::QmuParserTokenReader ( const QmuParserTokenReader &a_Reade m_pInfixOprtDef( a_Reader.m_pInfixOprtDef ), m_pOprtDef( a_Reader.m_pOprtDef), m_pConstDef( a_Reader.m_pConstDef ), m_pStrVarDef( a_Reader.m_pStrVarDef ), m_pVarDef( a_Reader.m_pVarDef ), m_pFactory( a_Reader.m_pFactory ), m_pFactoryData( a_Reader.m_pFactoryData ), m_vIdentFun( a_Reader.m_vIdentFun ), - m_UsedVar( a_Reader.m_UsedVar ), m_fZero(0), m_iBrackets( a_Reader.m_iBrackets ), m_lastTok(), + m_UsedVar( a_Reader.m_UsedVar ), m_iBrackets( a_Reader.m_iBrackets ), m_cArgSep( a_Reader.m_cArgSep ) {} @@ -72,7 +72,7 @@ QmuParserTokenReader::QmuParserTokenReader ( const QmuParserTokenReader &a_Reade * @param a_Reader Object to copy to this token reader. * @throw nothrow */ -QmuParserTokenReader& QmuParserTokenReader::operator= ( const QmuParserTokenReader &a_Reader ) +auto QmuParserTokenReader::operator= ( const QmuParserTokenReader &a_Reader ) -> QmuParserTokenReader& { if ( &a_Reader != this ) { @@ -126,11 +126,7 @@ void QmuParserTokenReader::Assign ( const QmuParserTokenReader &a_Reader ) * @param a_pParent Parent parser object of the token reader. */ QmuParserTokenReader::QmuParserTokenReader ( QmuParserBase *a_pParent ) - : m_pParser ( a_pParent ), m_strFormula(), m_iPos ( 0 ), m_iSynFlags ( 0 ), m_bIgnoreUndefVar ( false ), - m_pFunDef ( nullptr ), m_pPostOprtDef ( nullptr ), m_pInfixOprtDef ( nullptr ), m_pOprtDef ( nullptr ), - m_pConstDef ( nullptr ), m_pStrVarDef ( nullptr ), m_pVarDef ( nullptr ), m_pFactory ( nullptr ), - m_pFactoryData ( nullptr ), m_vIdentFun(), m_UsedVar(), m_fZero ( 0 ), m_iBrackets ( 0 ), m_lastTok(), - m_cArgSep ( ';' ) + : m_pParser ( a_pParent ) { assert ( m_pParser ); SetParent ( m_pParser ); @@ -145,7 +141,7 @@ QmuParserTokenReader::QmuParserTokenReader ( QmuParserBase *a_pParent ) * @return A new QParserTokenReader object. * @throw nothrow */ -QmuParserTokenReader* QmuParserTokenReader::Clone ( QmuParserBase *a_pParent ) const +auto QmuParserTokenReader::Clone ( QmuParserBase *a_pParent ) const -> QmuParserTokenReader* { std::unique_ptr ptr ( new QmuParserTokenReader ( *this ) ); ptr->SetParent ( a_pParent ); @@ -153,7 +149,7 @@ QmuParserTokenReader* QmuParserTokenReader::Clone ( QmuParserBase *a_pParent ) c } //--------------------------------------------------------------------------------------------------------------------- -QmuParserTokenReader::token_type& QmuParserTokenReader::SaveBeforeReturn ( const token_type &tok ) +auto QmuParserTokenReader::SaveBeforeReturn ( const token_type &tok ) -> QmuParserTokenReader::token_type& { m_lastTok = tok; return m_lastTok; @@ -213,9 +209,8 @@ void QmuParserTokenReader::ReInit() /** * @brief Read the next token from the string. */ -QmuParserTokenReader::token_type QmuParserTokenReader::ReadNextToken(const QLocale &locale, bool cNumbers, - const QChar &decimal, - const QChar &thousand) +auto QmuParserTokenReader::ReadNextToken(const QLocale &locale, bool cNumbers, const QChar &decimal, + const QChar &thousand) -> QmuParserTokenReader::token_type { assert ( m_pParser ); @@ -296,7 +291,7 @@ QmuParserTokenReader::token_type QmuParserTokenReader::ReadNextToken(const QLoca } Error ( ecUNASSIGNABLE_TOKEN, m_iPos, m_strFormula.mid ( m_iPos ) ); - return token_type(); // never reached + return {}; // never reached } //--------------------------------------------------------------------------------------------------------------------- @@ -324,7 +319,7 @@ void QmuParserTokenReader::SetParent ( QmuParserBase *a_pParent ) */ QT_WARNING_PUSH QT_WARNING_DISABLE_MSVC(4309) -int QmuParserTokenReader::ExtractToken ( const QString &a_szCharSet, QString &a_sTok, int a_iPos ) const +auto QmuParserTokenReader::ExtractToken ( const QString &a_szCharSet, QString &a_sTok, int a_iPos ) const -> int { int iEnd = FindFirstNotOf(m_strFormula, a_szCharSet, a_iPos); @@ -350,7 +345,7 @@ int QmuParserTokenReader::ExtractToken ( const QString &a_szCharSet, QString &a_ * alphabetic characters are allowed in operator tokens. To avoid this this function checks specifically * for operator tokens. */ -int QmuParserTokenReader::ExtractOperatorToken ( QString &a_sTok, int a_iPos ) const +auto QmuParserTokenReader::ExtractOperatorToken ( QString &a_sTok, int a_iPos ) const -> int { int iEnd = FindFirstNotOf(m_strFormula, m_pParser->ValidOprtChars(), a_iPos); @@ -365,12 +360,10 @@ int QmuParserTokenReader::ExtractOperatorToken ( QString &a_sTok, int a_iPos ) c a_sTok = m_strFormula.mid(a_iPos, iEnd - a_iPos); return iEnd; } - else - { - // There is still the chance of having to deal with an operator consisting exclusively - // of alphabetic characters. - return ExtractToken (QStringLiteral("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), a_sTok, a_iPos ); - } + + // There is still the chance of having to deal with an operator consisting exclusively + // of alphabetic characters. + return ExtractToken (QStringLiteral("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), a_sTok, a_iPos ); } QT_WARNING_POP @@ -380,7 +373,7 @@ QT_WARNING_POP * @param a_Tok [out] Operator token if one is found. This can either be a binary operator or an infix operator token. * @return true if an operator token has been found. */ -bool QmuParserTokenReader::IsBuiltIn ( token_type &a_Tok ) +auto QmuParserTokenReader::IsBuiltIn ( token_type &a_Tok ) -> bool { const QStringList pOprtDef = QmuParserBase::GetOprtDef(); @@ -402,7 +395,7 @@ bool QmuParserTokenReader::IsBuiltIn ( token_type &a_Tok ) Error ( ecUNEXPECTED_OPERATOR, m_iPos, pOprtDef.at ( i ) ); } - if ( m_pParser->HasBuiltInOprt() == false) + if ( not m_pParser->HasBuiltInOprt()) { continue; } @@ -487,7 +480,7 @@ bool QmuParserTokenReader::IsBuiltIn ( token_type &a_Tok ) } //--------------------------------------------------------------------------------------------------------------------- -bool QmuParserTokenReader::IsArgSep ( token_type &a_Tok ) +auto QmuParserTokenReader::IsArgSep ( token_type &a_Tok ) -> bool { if ( m_strFormula.at ( m_iPos ) == m_cArgSep ) { @@ -518,7 +511,7 @@ bool QmuParserTokenReader::IsArgSep ( token_type &a_Tok ) * @param a_Tok [out] If an eof is found the corresponding token will be stored there. * @sa IsOprt, IsFunTok, IsStrFunTok, IsValTok, IsVarTok, IsString, IsInfixOpTok, IsPostOpTok */ -bool QmuParserTokenReader::IsEOF ( token_type &a_Tok ) +auto QmuParserTokenReader::IsEOF ( token_type &a_Tok ) -> bool { // check for EOF if ( m_iPos >= m_strFormula.size()) @@ -538,7 +531,7 @@ bool QmuParserTokenReader::IsEOF ( token_type &a_Tok ) if ( m_iBrackets > 0 ) { - Error ( ecMISSING_PARENS, m_iPos, ")" ); + Error ( ecMISSING_PARENS, m_iPos, QChar(')') ); } m_iSynFlags = 0; @@ -554,7 +547,7 @@ bool QmuParserTokenReader::IsEOF ( token_type &a_Tok ) * @brief Check if a string position contains a unary infix operator. * @return true if a function token has been found false otherwise. */ -bool QmuParserTokenReader::IsInfixOpTok ( token_type &a_Tok ) +auto QmuParserTokenReader::IsInfixOpTok ( token_type &a_Tok ) -> bool { QString sTok; int iEnd = ExtractToken ( m_pParser->ValidInfixOprtChars(), sTok, m_iPos ); @@ -593,7 +586,7 @@ bool QmuParserTokenReader::IsInfixOpTok ( token_type &a_Tok ) * @return true if a function token has been found false otherwise. * @pre [assert] m_pParser!=0 */ -bool QmuParserTokenReader::IsFunTok ( token_type &a_Tok ) +auto QmuParserTokenReader::IsFunTok ( token_type &a_Tok ) -> bool { QString strTok; int iEnd = ExtractToken ( m_pParser->ValidNameChars(), strTok, m_iPos ); @@ -602,7 +595,7 @@ bool QmuParserTokenReader::IsFunTok ( token_type &a_Tok ) return false; } - funmap_type::const_iterator item = m_pFunDef->find ( strTok ); + auto item = m_pFunDef->find ( strTok ); if ( item == m_pFunDef->end() ) { return false; @@ -632,7 +625,7 @@ bool QmuParserTokenReader::IsFunTok ( token_type &a_Tok ) * @param a_Tok [out] Operator token if one is found. This can either be a binary operator or an infix operator token. * @return true if an operator token has been found. */ -bool QmuParserTokenReader::IsOprt ( token_type &a_Tok ) +auto QmuParserTokenReader::IsOprt ( token_type &a_Tok ) -> bool { QString strTok; @@ -644,9 +637,9 @@ bool QmuParserTokenReader::IsOprt ( token_type &a_Tok ) // Check if the operator is a built in operator, if so ignore it here const QStringList &pOprtDef = QmuParserBase::GetOprtDef(); - QStringList::const_iterator constIterator; - for ( constIterator = pOprtDef.constBegin(); m_pParser->HasBuiltInOprt() && constIterator != pOprtDef.constEnd(); - ++constIterator ) + for ( auto constIterator = pOprtDef.constBegin(); + m_pParser->HasBuiltInOprt() && constIterator != pOprtDef.constEnd(); + ++constIterator ) { if ( ( *constIterator ) == strTok ) { @@ -701,7 +694,7 @@ bool QmuParserTokenReader::IsOprt ( token_type &a_Tok ) /** * @brief Check if a string position contains a unary post value operator. */ -bool QmuParserTokenReader::IsPostOpTok ( token_type &a_Tok ) +auto QmuParserTokenReader::IsPostOpTok ( token_type &a_Tok ) -> bool { // Do not check for postfix operators if they are not allowed at // the current expression index. @@ -758,8 +751,8 @@ bool QmuParserTokenReader::IsPostOpTok ( token_type &a_Tok ) * @param a_Tok [out] If a value token is found it will be placed here. * @return true if a value token has been found. */ -bool QmuParserTokenReader::IsValTok ( token_type &a_Tok, const QLocale &locale, bool cNumbers, const QChar &decimal, - const QChar &thousand ) +auto QmuParserTokenReader::IsValTok ( token_type &a_Tok, const QLocale &locale, bool cNumbers, const QChar &decimal, + const QChar &thousand ) -> bool { assert ( m_pConstDef ); assert ( m_pParser ); @@ -773,7 +766,7 @@ bool QmuParserTokenReader::IsValTok ( token_type &a_Tok, const QLocale &locale, iEnd = ExtractToken ( m_pParser->ValidNameChars(), strTok, m_iPos ); if ( iEnd != m_iPos ) { - valmap_type::const_iterator item = m_pConstDef->find ( strTok ); + auto item = m_pConstDef->find ( strTok ); if ( item != m_pConstDef->end() ) { m_iPos = iEnd; @@ -791,7 +784,7 @@ bool QmuParserTokenReader::IsValTok ( token_type &a_Tok, const QLocale &locale, // 3.call the value recognition functions provided by the user // Call user defined value recognition functions - std::list::const_iterator item = m_vIdentFun.begin(); + auto item = m_vIdentFun.begin(); for ( item = m_vIdentFun.begin(); item != m_vIdentFun.end(); ++item ) { int iStart = m_iPos; @@ -819,7 +812,7 @@ bool QmuParserTokenReader::IsValTok ( token_type &a_Tok, const QLocale &locale, * @param a_Tok [out] If a variable token has been found it will be placed here. * @return true if a variable token has been found. */ -bool QmuParserTokenReader::IsVarTok ( token_type &a_Tok ) +auto QmuParserTokenReader::IsVarTok ( token_type &a_Tok ) -> bool { if ( m_pVarDef->empty()) { @@ -833,7 +826,7 @@ bool QmuParserTokenReader::IsVarTok ( token_type &a_Tok ) return false; } - varmap_type::const_iterator item = m_pVarDef->find ( strTok ); + auto item = m_pVarDef->find ( strTok ); if ( item == m_pVarDef->end() ) { return false; @@ -858,7 +851,7 @@ bool QmuParserTokenReader::IsVarTok ( token_type &a_Tok ) } //--------------------------------------------------------------------------------------------------------------------- -bool QmuParserTokenReader::IsStrVarTok ( token_type &a_Tok ) +auto QmuParserTokenReader::IsStrVarTok ( token_type &a_Tok ) -> bool { if ( m_pStrVarDef == nullptr || m_pStrVarDef->empty() ) { @@ -872,7 +865,7 @@ bool QmuParserTokenReader::IsStrVarTok ( token_type &a_Tok ) return false; } - strmap_type::const_iterator item = m_pStrVarDef->find ( strTok ); + auto item = m_pStrVarDef->find ( strTok ); if ( item == m_pStrVarDef->end() ) { return false; @@ -884,7 +877,7 @@ bool QmuParserTokenReader::IsStrVarTok ( token_type &a_Tok ) } m_iPos = iEnd; - if ( m_pParser->m_vStringVarBuf.size() == false) + if ( m_pParser->m_vStringVarBuf.empty()) { Error ( ecINTERNAL_ERROR ); } @@ -904,7 +897,7 @@ bool QmuParserTokenReader::IsStrVarTok ( token_type &a_Tok ) * @return true if a variable token has been found. * @throw nothrow */ -bool QmuParserTokenReader::IsUndefVarTok ( token_type &a_Tok ) +auto QmuParserTokenReader::IsUndefVarTok ( token_type &a_Tok ) -> bool { QString strTok; int iEnd ( ExtractToken ( m_pParser->ValidNameChars(), strTok, m_iPos ) ); @@ -966,7 +959,7 @@ bool QmuParserTokenReader::IsUndefVarTok ( token_type &a_Tok ) * @return true if a string token has been found. * @sa IsOprt, IsFunTok, IsStrFunTok, IsValTok, IsVarTok, IsEOF, IsInfixOpTok, IsPostOpTok */ -bool QmuParserTokenReader::IsString ( token_type &a_Tok ) +auto QmuParserTokenReader::IsString ( token_type &a_Tok ) -> bool { if ( m_strFormula[m_iPos] != '"' ) { diff --git a/src/libs/qmuparser/qmuparsertokenreader.h b/src/libs/qmuparser/qmuparsertokenreader.h index 3a4766af3..3abfbd940 100644 --- a/src/libs/qmuparser/qmuparsertokenreader.h +++ b/src/libs/qmuparser/qmuparsertokenreader.h @@ -51,22 +51,24 @@ class QmuParserBase; class QmuParserTokenReader { private: - typedef QmuParserToken token_type; + using token_type = QmuParserToken; public: explicit QmuParserTokenReader(QmuParserBase *a_pParent); - QmuParserTokenReader* Clone(QmuParserBase *a_pParent) const; + ~QmuParserTokenReader()=default; - void AddValIdent(identfun_type a_pCallback); - void SetVarCreator(facfun_type a_pFactory, void *pUserData); - void SetFormula(const QString &a_strFormula); - void SetArgSep(char_type cArgSep); - int GetPos() const; - const QString& GetExpr() const; - varmap_type& GetUsedVar(); - QChar GetArgSep() const; - void IgnoreUndefVar(bool bIgnore); - void ReInit(); - token_type ReadNextToken(const QLocale &locale, bool cNumbers, const QChar &decimal, const QChar &thousand); + auto Clone(QmuParserBase *a_pParent) const -> QmuParserTokenReader*; + + void AddValIdent(identfun_type a_pCallback); + void SetVarCreator(facfun_type a_pFactory, void *pUserData); + void SetFormula(const QString &a_strFormula); + void SetArgSep(char_type cArgSep); + auto GetPos() const -> int; + auto GetExpr() const -> const QString&; + auto GetUsedVar() -> varmap_type&; + auto GetArgSep() const -> QChar; + void IgnoreUndefVar(bool bIgnore); + void ReInit(); + auto ReadNextToken(const QLocale &locale, bool cNumbers, const QChar &decimal, const QChar &thousand) -> token_type; private: /** @@ -78,70 +80,71 @@ private: */ enum ESynCodes { - noBO = 1 << 0, ///< to avoid i.e. "cos(7)(" - noBC = 1 << 1, ///< to avoid i.e. "sin)" or "()" - noVAL = 1 << 2, ///< to avoid i.e. "tan 2" or "sin(8)3.14" - noVAR = 1 << 3, ///< to avoid i.e. "sin a" or "sin(8)a" - noARG_SEP = 1 << 4, ///< to avoid i.e. ",," or "+," ... - noFUN = 1 << 5, ///< to avoid i.e. "sqrt cos" or "(1)sin" - noOPT = 1 << 6, ///< to avoid i.e. "(+)" - noPOSTOP = 1 << 7, ///< to avoid i.e. "(5!!)" "sin!" - noINFIXOP = 1 << 8, ///< to avoid i.e. "++4" "!!4" - noEND = 1 << 9, ///< to avoid unexpected end of formula - noSTR = 1 << 10, ///< to block numeric arguments on string functions - noASSIGN = 1 << 11, ///< to block assignement to constant i.e. "4=7" - noIF = 1 << 12, - noELSE = 1 << 13, - sfSTART_OF_LINE = noOPT | noBC | noPOSTOP | noASSIGN | noIF | noELSE | noARG_SEP, - noANY = ~0 ///< All of he above flags set + noBO = 1 << 0, ///< to avoid i.e. "cos(7)(" NOLINT(hicpp-signed-bitwise) + noBC = 1 << 1, ///< to avoid i.e. "sin)" or "()" NOLINT(hicpp-signed-bitwise) + noVAL = 1 << 2, ///< to avoid i.e. "tan 2" or "sin(8)3.14" NOLINT(hicpp-signed-bitwise) + noVAR = 1 << 3, ///< to avoid i.e. "sin a" or "sin(8)a" NOLINT(hicpp-signed-bitwise) + noARG_SEP = 1 << 4, ///< to avoid i.e. ",," or "+," ... NOLINT(hicpp-signed-bitwise) + noFUN = 1 << 5, ///< to avoid i.e. "sqrt cos" or "(1)sin" NOLINT(hicpp-signed-bitwise) + noOPT = 1 << 6, ///< to avoid i.e. "(+)" NOLINT(hicpp-signed-bitwise) + noPOSTOP = 1 << 7, ///< to avoid i.e. "(5!!)" "sin!" NOLINT(hicpp-signed-bitwise) + noINFIXOP = 1 << 8, ///< to avoid i.e. "++4" "!!4" NOLINT(hicpp-signed-bitwise) + noEND = 1 << 9, ///< to avoid unexpected end of formula NOLINT(hicpp-signed-bitwise) + noSTR = 1 << 10, ///< to block numeric arguments on string functions NOLINT(hicpp-signed-bitwise) + noASSIGN = 1 << 11, ///< to block assignement to constant i.e. "4=7" NOLINT(hicpp-signed-bitwise) + noIF = 1 << 12, // NOLINT(hicpp-signed-bitwise) + noELSE = 1 << 13, // NOLINT(hicpp-signed-bitwise) + sfSTART_OF_LINE = noOPT | noBC | noPOSTOP | noASSIGN | noIF | noELSE | noARG_SEP, // NOLINT(hicpp-signed-bitwise) + noANY = ~0 ///< All of he above flags set NOLINT(hicpp-signed-bitwise) }; + QmuParserBase *m_pParser; + QString m_strFormula{}; + int m_iPos{0}; + int m_iSynFlags{0}; + bool m_bIgnoreUndefVar{false}; + + const funmap_type *m_pFunDef{nullptr}; + const funmap_type *m_pPostOprtDef{nullptr}; + const funmap_type *m_pInfixOprtDef{nullptr}; + const funmap_type *m_pOprtDef{nullptr}; + const valmap_type *m_pConstDef{nullptr}; + const strmap_type *m_pStrVarDef{nullptr}; + varmap_type *m_pVarDef{nullptr}; ///< The only non const pointer to parser internals + facfun_type m_pFactory{nullptr}; + void *m_pFactoryData{nullptr}; + std::list m_vIdentFun{}; ///< Value token identification function + varmap_type m_UsedVar{}; + qreal m_fZero{0}; ///< Dummy value of zero, referenced by undefined variables + int m_iBrackets{0}; ///< Keep count open brackets + token_type m_lastTok{}; + QChar m_cArgSep{';'}; ///< The character used for separating function arguments + QmuParserTokenReader(const QmuParserTokenReader &a_Reader); - QmuParserTokenReader& operator=(const QmuParserTokenReader &a_Reader); - void Assign(const QmuParserTokenReader &a_Reader); + auto operator=(const QmuParserTokenReader &a_Reader) -> QmuParserTokenReader&; - void SetParent(QmuParserBase *a_pParent); - int ExtractToken(const QString &a_szCharSet, QString &a_strTok, int a_iPos) const; - int ExtractOperatorToken(QString &a_sTok, int a_iPos) const; + void Assign(const QmuParserTokenReader &a_Reader); - bool IsBuiltIn(token_type &a_Tok); - bool IsArgSep(token_type &a_Tok); - bool IsEOF(token_type &a_Tok); - bool IsInfixOpTok(token_type &a_Tok); - bool IsFunTok(token_type &a_Tok); - bool IsPostOpTok(token_type &a_Tok); - bool IsOprt(token_type &a_Tok); - bool IsValTok(token_type &a_Tok, const QLocale &locale, bool cNumbers, const QChar &decimal, - const QChar &thousand); - bool IsVarTok(token_type &a_Tok); - bool IsStrVarTok(token_type &a_Tok); - bool IsUndefVarTok(token_type &a_Tok); - bool IsString(token_type &a_Tok); + void SetParent(QmuParserBase *a_pParent); + auto ExtractToken(const QString &a_szCharSet, QString &a_strTok, int a_iPos) const -> int; + auto ExtractOperatorToken(QString &a_sTok, int a_iPos) const -> int; + + auto IsBuiltIn(token_type &a_Tok) -> bool; + auto IsArgSep(token_type &a_Tok) -> bool; + auto IsEOF(token_type &a_Tok) -> bool; + auto IsInfixOpTok(token_type &a_Tok) -> bool; + auto IsFunTok(token_type &a_Tok) -> bool; + auto IsPostOpTok(token_type &a_Tok) -> bool; + auto IsOprt(token_type &a_Tok) -> bool; + auto IsValTok(token_type &a_Tok, const QLocale &locale, bool cNumbers, const QChar &decimal, + const QChar &thousand) -> bool; + auto IsVarTok(token_type &a_Tok) -> bool; + auto IsStrVarTok(token_type &a_Tok) -> bool; + auto IsUndefVarTok(token_type &a_Tok) -> bool; + auto IsString(token_type &a_Tok) -> bool; void Q_NORETURN Error(EErrorCodes a_iErrc, int a_iPos = -1, const QString &a_sTok = QString() ) const; - token_type& SaveBeforeReturn(const token_type &tok); - - QmuParserBase *m_pParser; - QString m_strFormula; - int m_iPos; - int m_iSynFlags; - bool m_bIgnoreUndefVar; - - const funmap_type *m_pFunDef; - const funmap_type *m_pPostOprtDef; - const funmap_type *m_pInfixOprtDef; - const funmap_type *m_pOprtDef; - const valmap_type *m_pConstDef; - const strmap_type *m_pStrVarDef; - varmap_type *m_pVarDef; ///< The only non const pointer to parser internals - facfun_type m_pFactory; - void *m_pFactoryData; - std::list m_vIdentFun; ///< Value token identification function - varmap_type m_UsedVar; - qreal m_fZero; ///< Dummy value of zero, referenced by undefined variables - int m_iBrackets; ///< Keep count open brackets - token_type m_lastTok; - QChar m_cArgSep; ///< The character used for separating function arguments + auto SaveBeforeReturn(const token_type &tok) -> token_type&; }; //--------------------------------------------------------------------------------------------------------------------- @@ -151,7 +154,7 @@ private: * @return #m_iPos * @throw nothrow */ -inline int QmuParserTokenReader::GetPos() const +inline auto QmuParserTokenReader::GetPos() const -> int { return m_iPos; } @@ -163,7 +166,7 @@ inline int QmuParserTokenReader::GetPos() const * @return #m_strFormula * @throw nothrow */ -inline const QString& QmuParserTokenReader::GetExpr() const +inline auto QmuParserTokenReader::GetExpr() const -> const QString& { return m_strFormula; } @@ -172,7 +175,7 @@ inline const QString& QmuParserTokenReader::GetExpr() const /** * @brief Return a map containing the used variables only. */ -inline varmap_type& QmuParserTokenReader::GetUsedVar() +inline auto QmuParserTokenReader::GetUsedVar() -> varmap_type& { return m_UsedVar; } @@ -198,7 +201,7 @@ inline void QmuParserTokenReader::SetArgSep ( char_type cArgSep ) } //--------------------------------------------------------------------------------------------------------------------- -inline QChar QmuParserTokenReader::GetArgSep() const +inline auto QmuParserTokenReader::GetArgSep() const -> QChar { return m_cArgSep; } diff --git a/src/libs/qmuparser/qmutokenparser.h b/src/libs/qmuparser/qmutokenparser.h index 8a20e4104..3f939fc1b 100644 --- a/src/libs/qmuparser/qmutokenparser.h +++ b/src/libs/qmuparser/qmutokenparser.h @@ -49,7 +49,7 @@ protected: static qreal Warning(const QString &warningMsg, qreal value); private: - Q_DISABLE_COPY(QmuTokenParser) + Q_DISABLE_COPY_MOVE(QmuTokenParser) // NOLINT QmuTokenParser(); }; diff --git a/src/libs/vdxf/dxiface.h b/src/libs/vdxf/dxiface.h index bd40d9316..023d7a3c2 100644 --- a/src/libs/vdxf/dxiface.h +++ b/src/libs/vdxf/dxiface.h @@ -89,7 +89,7 @@ public: dx_ifaceBlock* mBlock; //container to store model entities private: - Q_DISABLE_COPY(dx_data) + Q_DISABLE_COPY_MOVE(dx_data) // NOLINT }; @@ -130,7 +130,7 @@ public: void AddASTMLayers(); private: - Q_DISABLE_COPY(dx_iface) + Q_DISABLE_COPY_MOVE(dx_iface) // NOLINT dxfRW* dxfW; //pointer to writer, needed to send data dx_data cData; // class to store or read data DRW::Version version; diff --git a/src/libs/vdxf/libdxfrw/drw_base.h b/src/libs/vdxf/libdxfrw/drw_base.h index 4da31789c..386a3b2b3 100644 --- a/src/libs/vdxf/libdxfrw/drw_base.h +++ b/src/libs/vdxf/libdxfrw/drw_base.h @@ -82,6 +82,15 @@ #endif // defined(__cplusplus) #endif // QT_VERSION < QT_VERSION_CHECK(5, 8, 0) +#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) +#define Q_DISABLE_MOVE(Class) \ +Class(Class &&) = delete; \ + Class &operator=(Class &&) = delete; +#define Q_DISABLE_COPY_MOVE(Class) \ +Q_DISABLE_COPY(Class) \ + Q_DISABLE_MOVE(Class) +#endif + typedef signed char dint8; /* 8 bit signed */ typedef signed short dint16; /* 16 bit signed */ typedef signed int dint32; /* 32 bit signed */ diff --git a/src/libs/vdxf/libdxfrw/drw_entities.h b/src/libs/vdxf/libdxfrw/drw_entities.h index 814102830..6e5afcd97 100644 --- a/src/libs/vdxf/libdxfrw/drw_entities.h +++ b/src/libs/vdxf/libdxfrw/drw_entities.h @@ -1091,7 +1091,8 @@ public: std::vector looplist; /*!< polyline list */ private: - Q_DISABLE_COPY(DRW_Hatch) + // cppcheck-suppress unknownMacro + Q_DISABLE_COPY_MOVE(DRW_Hatch) // NOLINT void clearEntities(){ pt = line = nullptr; pline = nullptr; @@ -1583,7 +1584,7 @@ public: std::vector vertexlist; /*!< vertex points list, code 10, 20 & 30 */ private: - Q_DISABLE_COPY(DRW_Leader) + Q_DISABLE_COPY_MOVE(DRW_Leader) // NOLINT DRW_Coord *vertexpoint; /*!< current control point to add data */ }; diff --git a/src/libs/vdxf/libdxfrw/intern/drw_dbg.h b/src/libs/vdxf/libdxfrw/intern/drw_dbg.h index 436b34dfe..fd507a7d9 100644 --- a/src/libs/vdxf/libdxfrw/intern/drw_dbg.h +++ b/src/libs/vdxf/libdxfrw/intern/drw_dbg.h @@ -60,7 +60,8 @@ public: void printPT(double x, double y, double z); private: - Q_DISABLE_COPY(DRW_dbg) + // cppcheck-suppress unknownMacro + Q_DISABLE_COPY_MOVE(DRW_dbg) // NOLINT DRW_dbg(); ~DRW_dbg(); static DRW_dbg *instance; diff --git a/src/libs/vdxf/libdxfrw/intern/drw_textcodec.h b/src/libs/vdxf/libdxfrw/intern/drw_textcodec.h index f9ccf70b8..041da8cf7 100644 --- a/src/libs/vdxf/libdxfrw/intern/drw_textcodec.h +++ b/src/libs/vdxf/libdxfrw/intern/drw_textcodec.h @@ -4,6 +4,7 @@ #include #include #include "../drw_base.h" +#include "../vmisc/defglobal.h" class QTextCodec; class QStringList; @@ -28,7 +29,8 @@ private: static auto correctCodePage(const std::string& s) -> std::string; private: - Q_DISABLE_COPY(DRW_TextCodec) + // cppcheck-suppress unknownMacro + Q_DISABLE_COPY_MOVE(DRW_TextCodec) // NOLINT DRW::Version version{DRW::UNKNOWNV}; std::string cp{}; QTextCodec *conv{nullptr}; diff --git a/src/libs/vdxf/libdxfrw/intern/dxfreader.h b/src/libs/vdxf/libdxfrw/intern/dxfreader.h index 9c7caf9ee..fda528dd7 100644 --- a/src/libs/vdxf/libdxfrw/intern/dxfreader.h +++ b/src/libs/vdxf/libdxfrw/intern/dxfreader.h @@ -14,6 +14,7 @@ #define DXFREADER_H #include "drw_textcodec.h" +#include "../vmisc/defglobal.h" class dxfReader { public: @@ -74,7 +75,7 @@ protected: unsigned long long int int64; //64 bits integer bool skip; //set to true for ascii dxf, false for binary private: - Q_DISABLE_COPY(dxfReader) + Q_DISABLE_COPY_MOVE(dxfReader) // NOLINT DRW_TextCodec decoder; bool m_bIgnoreComments {false}; }; diff --git a/src/libs/vdxf/libdxfrw/intern/dxfwriter.h b/src/libs/vdxf/libdxfrw/intern/dxfwriter.h index c36a168aa..9915e6f84 100644 --- a/src/libs/vdxf/libdxfrw/intern/dxfwriter.h +++ b/src/libs/vdxf/libdxfrw/intern/dxfwriter.h @@ -38,7 +38,7 @@ public: protected: std::ofstream *filestr; private: - Q_DISABLE_COPY(dxfWriter) + Q_DISABLE_COPY_MOVE(dxfWriter) // NOLINT DRW_TextCodec encoder; }; diff --git a/src/libs/vdxf/libdxfrw/libdxfrw.h b/src/libs/vdxf/libdxfrw/libdxfrw.h index f51bb0d77..59e10a2ca 100644 --- a/src/libs/vdxf/libdxfrw/libdxfrw.h +++ b/src/libs/vdxf/libdxfrw/libdxfrw.h @@ -79,7 +79,7 @@ public: DRW::error getError() const; private: - Q_DISABLE_COPY(dxfRW) + Q_DISABLE_COPY_MOVE(dxfRW) // NOLINT /// used by read() to parse the content of the file bool processDxf(); bool processHeader(); diff --git a/src/libs/vdxf/vdxfengine.h b/src/libs/vdxf/vdxfengine.h index 73c1ba996..64aaebbe5 100644 --- a/src/libs/vdxf/vdxfengine.h +++ b/src/libs/vdxf/vdxfengine.h @@ -101,7 +101,7 @@ public: QString ErrorString() const; private: - Q_DISABLE_COPY(VDxfEngine) + Q_DISABLE_COPY_MOVE(VDxfEngine) // NOLINT QSize size; double resolution; QString fileName; diff --git a/src/libs/vdxf/vdxfpaintdevice.h b/src/libs/vdxf/vdxfpaintdevice.h index a03e6df9f..54156cc04 100644 --- a/src/libs/vdxf/vdxfpaintdevice.h +++ b/src/libs/vdxf/vdxfpaintdevice.h @@ -80,7 +80,8 @@ public: protected: virtual int metric(PaintDeviceMetric metric) const override; private: - Q_DISABLE_COPY(VDxfPaintDevice) + // cppcheck-suppress unknownMacro + Q_DISABLE_COPY_MOVE(VDxfPaintDevice) // NOLINT VDxfEngine *engine; QString fileName; }; diff --git a/src/libs/vformat/vlabeltemplate.h b/src/libs/vformat/vlabeltemplate.h index 0b7f6b2b0..5970b2cdf 100644 --- a/src/libs/vformat/vlabeltemplate.h +++ b/src/libs/vformat/vlabeltemplate.h @@ -45,7 +45,7 @@ public: void AddLines(const QVector &lines); QVector ReadLines() const; private: - Q_DISABLE_COPY(VLabelTemplate) + Q_DISABLE_COPY_MOVE(VLabelTemplate) // NOLINT }; #endif // VLABELTEMPLATE_H diff --git a/src/libs/vformat/vmeasurements.cpp b/src/libs/vformat/vmeasurements.cpp index 13c97d71e..6c6982d8f 100644 --- a/src/libs/vformat/vmeasurements.cpp +++ b/src/libs/vformat/vmeasurements.cpp @@ -111,7 +111,7 @@ const QString VMeasurements::DimensionZ = QStringLiteral("z"); namespace { -Q_GLOBAL_STATIC_WITH_ARGS(const QString, defBirthDate, (QLatin1String("1800-01-01"))) +Q_GLOBAL_STATIC_WITH_ARGS(const QString, defBirthDate, (QLatin1String("1800-01-01"))) // NOLINT //--------------------------------------------------------------------------------------------------------------------- QString FileComment() diff --git a/src/libs/vformat/vmeasurements.h b/src/libs/vformat/vmeasurements.h index 7d88587e5..312731644 100644 --- a/src/libs/vformat/vmeasurements.h +++ b/src/libs/vformat/vmeasurements.h @@ -48,7 +48,7 @@ using VDimensions = QMap; class VMeasurements : public VDomDocument { - Q_DECLARE_TR_FUNCTIONS(VMeasurements) + Q_DECLARE_TR_FUNCTIONS(VMeasurements) // NOLINT public: explicit VMeasurements(VContainer *data); VMeasurements(Unit unit, VContainer *data); @@ -203,7 +203,7 @@ public: VContainer *GetData() const; private: - Q_DISABLE_COPY(VMeasurements) + Q_DISABLE_COPY_MOVE(VMeasurements) // NOLINT /** @brief data container with data. */ VContainer *data; diff --git a/src/libs/vformat/vpatternrecipe.h b/src/libs/vformat/vpatternrecipe.h index 8361dd612..46516c4b2 100644 --- a/src/libs/vformat/vpatternrecipe.h +++ b/src/libs/vformat/vpatternrecipe.h @@ -41,13 +41,13 @@ struct VFinalMeasurement; class VPatternRecipe : public VDomDocument { - Q_DECLARE_TR_FUNCTIONS(VPatternRecipe) + Q_DECLARE_TR_FUNCTIONS(VPatternRecipe) // NOLINT public: explicit VPatternRecipe(VAbstractPattern *pattern, QObject *parent = nullptr); virtual ~VPatternRecipe() Q_DECL_EQ_DEFAULT; private: - Q_DISABLE_COPY(VPatternRecipe) + Q_DISABLE_COPY_MOVE(VPatternRecipe) // NOLINT VAbstractPattern *m_pattern; diff --git a/src/libs/vformat/vwatermark.h b/src/libs/vformat/vwatermark.h index 24f1bedc0..f71251add 100644 --- a/src/libs/vformat/vwatermark.h +++ b/src/libs/vformat/vwatermark.h @@ -33,7 +33,7 @@ class VWatermark : public VDomDocument { - Q_DECLARE_TR_FUNCTIONS(VWatermark) + Q_DECLARE_TR_FUNCTIONS(VWatermark) // NOLINT public: VWatermark(); virtual ~VWatermark() Q_DECL_EQ_DEFAULT; @@ -57,7 +57,7 @@ public: static const QString AttrShow; private: - Q_DISABLE_COPY(VWatermark) + Q_DISABLE_COPY_MOVE(VWatermark) // NOLINT }; #endif // VWATERMARK_H diff --git a/src/libs/vgeometry/vabstractcurve.cpp b/src/libs/vgeometry/vabstractcurve.cpp index a19650a76..200c7f22a 100644 --- a/src/libs/vgeometry/vabstractcurve.cpp +++ b/src/libs/vgeometry/vabstractcurve.cpp @@ -64,7 +64,7 @@ VAbstractCurve &VAbstractCurve::operator=(const VAbstractCurve &curve) #ifdef Q_COMPILER_RVALUE_REFS //--------------------------------------------------------------------------------------------------------------------- VAbstractCurve::VAbstractCurve(VAbstractCurve &&curve) Q_DECL_NOTHROW - :VGObject(curve), d (curve.d) + :VGObject(std::move(curve)), d (std::move(curve.d)) {} //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vgeometry/vabstractcurve.h b/src/libs/vgeometry/vabstractcurve.h index d7ceed4d2..6ba6015ea 100644 --- a/src/libs/vgeometry/vabstractcurve.h +++ b/src/libs/vgeometry/vabstractcurve.h @@ -123,6 +123,6 @@ private: QT_WARNING_POP -Q_DECLARE_TYPEINFO(VAbstractCurve, Q_MOVABLE_TYPE); +Q_DECLARE_TYPEINFO(VAbstractCurve, Q_MOVABLE_TYPE); // NOLINT #endif // VABSTRACTCURVE_H diff --git a/src/libs/vgeometry/varc.cpp b/src/libs/vgeometry/varc.cpp index 22440aec3..e49241805 100644 --- a/src/libs/vgeometry/varc.cpp +++ b/src/libs/vgeometry/varc.cpp @@ -122,7 +122,7 @@ auto VArc::operator =(const VArc &arc) -> VArc & #ifdef Q_COMPILER_RVALUE_REFS //--------------------------------------------------------------------------------------------------------------------- VArc::VArc(VArc &&arc) Q_DECL_NOTHROW - : VAbstractArc(arc), d (arc.d) + : VAbstractArc(std::move(arc)), d (std::move(arc.d)) {} //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vgeometry/vcubicbezier.cpp b/src/libs/vgeometry/vcubicbezier.cpp index 45d861b39..353c8b8c3 100644 --- a/src/libs/vgeometry/vcubicbezier.cpp +++ b/src/libs/vgeometry/vcubicbezier.cpp @@ -66,8 +66,8 @@ VCubicBezier &VCubicBezier::operator=(const VCubicBezier &curve) #ifdef Q_COMPILER_RVALUE_REFS //--------------------------------------------------------------------------------------------------------------------- -VCubicBezier::VCubicBezier(const VCubicBezier &&curve) Q_DECL_NOTHROW - : VAbstractCubicBezier(curve), d(curve.d) +VCubicBezier::VCubicBezier(VCubicBezier &&curve) Q_DECL_NOTHROW + : VAbstractCubicBezier(std::move(curve)), d(std::move(curve.d)) {} //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vgeometry/vcubicbezier.h b/src/libs/vgeometry/vcubicbezier.h index b4647fb96..d69c0f98f 100644 --- a/src/libs/vgeometry/vcubicbezier.h +++ b/src/libs/vgeometry/vcubicbezier.h @@ -57,7 +57,7 @@ public: VCubicBezier &operator=(const VCubicBezier &curve); #ifdef Q_COMPILER_RVALUE_REFS - VCubicBezier(const VCubicBezier &&curve) Q_DECL_NOTHROW; + VCubicBezier(VCubicBezier &&curve) Q_DECL_NOTHROW; VCubicBezier &operator=(VCubicBezier &&curve) Q_DECL_NOTHROW; #endif @@ -90,6 +90,6 @@ private: QSharedDataPointer d; }; -Q_DECLARE_TYPEINFO(VCubicBezier, Q_MOVABLE_TYPE); +Q_DECLARE_TYPEINFO(VCubicBezier, Q_MOVABLE_TYPE); // NOLINT #endif // VCUBICBEZIER_H diff --git a/src/libs/vgeometry/vcubicbezierpath.cpp b/src/libs/vgeometry/vcubicbezierpath.cpp index 27f14548c..a162430e3 100644 --- a/src/libs/vgeometry/vcubicbezierpath.cpp +++ b/src/libs/vgeometry/vcubicbezierpath.cpp @@ -81,9 +81,9 @@ VCubicBezierPath &VCubicBezierPath::operator=(const VCubicBezierPath &curve) #ifdef Q_COMPILER_RVALUE_REFS //--------------------------------------------------------------------------------------------------------------------- -VCubicBezierPath::VCubicBezierPath(const VCubicBezierPath &&curve) Q_DECL_NOTHROW - : VAbstractCubicBezierPath(curve), - d(curve.d) +VCubicBezierPath::VCubicBezierPath(VCubicBezierPath &&curve) Q_DECL_NOTHROW + : VAbstractCubicBezierPath(std::move(curve)), + d(std::move(curve.d)) {} //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vgeometry/vcubicbezierpath.h b/src/libs/vgeometry/vcubicbezierpath.h index 0f7fdd899..aa797fa79 100644 --- a/src/libs/vgeometry/vcubicbezierpath.h +++ b/src/libs/vgeometry/vcubicbezierpath.h @@ -46,7 +46,7 @@ class VCubicBezierPathData; class VCubicBezierPath final : public VAbstractCubicBezierPath { - Q_DECLARE_TR_FUNCTIONS(VCubicBezierPath) + Q_DECLARE_TR_FUNCTIONS(VCubicBezierPath) // NOLINT public: explicit VCubicBezierPath(quint32 idObject = 0, Draw mode = Draw::Calculation); VCubicBezierPath(const VCubicBezierPath &curve); @@ -58,7 +58,7 @@ public: VCubicBezierPath &operator=(const VCubicBezierPath &curve); #ifdef Q_COMPILER_RVALUE_REFS - VCubicBezierPath(const VCubicBezierPath &&curve) Q_DECL_NOTHROW; + VCubicBezierPath(VCubicBezierPath &&curve) Q_DECL_NOTHROW; VCubicBezierPath &operator=(VCubicBezierPath &&curve) Q_DECL_NOTHROW; #endif @@ -91,6 +91,6 @@ private: QSharedDataPointer d; }; -Q_DECLARE_TYPEINFO(VCubicBezierPath, Q_MOVABLE_TYPE); +Q_DECLARE_TYPEINFO(VCubicBezierPath, Q_MOVABLE_TYPE); // NOLINT #endif // VCUBICBEZIERPATH_H diff --git a/src/libs/vgeometry/vgobject.cpp b/src/libs/vgeometry/vgobject.cpp index f6882d31f..6d6649bf9 100644 --- a/src/libs/vgeometry/vgobject.cpp +++ b/src/libs/vgeometry/vgobject.cpp @@ -131,8 +131,8 @@ VGObject &VGObject::operator=(const VGObject &obj) #ifdef Q_COMPILER_RVALUE_REFS //--------------------------------------------------------------------------------------------------------------------- -VGObject::VGObject(const VGObject &&obj) Q_DECL_NOTHROW - :d (obj.d) +VGObject::VGObject(VGObject &&obj) Q_DECL_NOTHROW + :d (std::move(obj.d)) {} //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vgeometry/vgobject.h b/src/libs/vgeometry/vgobject.h index 660d18208..bba4d64f7 100644 --- a/src/libs/vgeometry/vgobject.h +++ b/src/libs/vgeometry/vgobject.h @@ -63,7 +63,7 @@ public: VGObject& operator= (const VGObject &obj); #ifdef Q_COMPILER_RVALUE_REFS - VGObject(const VGObject &&obj) Q_DECL_NOTHROW; + VGObject(VGObject &&obj) Q_DECL_NOTHROW; VGObject &operator=(VGObject &&obj) Q_DECL_NOTHROW; #endif @@ -126,6 +126,6 @@ private: QT_WARNING_POP -Q_DECLARE_TYPEINFO(VGObject, Q_MOVABLE_TYPE); +Q_DECLARE_TYPEINFO(VGObject, Q_MOVABLE_TYPE); // NOLINT #endif // VGOBJECT_H diff --git a/src/libs/vgeometry/vplacelabelitem.cpp b/src/libs/vgeometry/vplacelabelitem.cpp index edbd3591a..5fbd4bfeb 100644 --- a/src/libs/vgeometry/vplacelabelitem.cpp +++ b/src/libs/vgeometry/vplacelabelitem.cpp @@ -228,8 +228,8 @@ VPlaceLabelItem &VPlaceLabelItem::operator=(const VPlaceLabelItem &item) #ifdef Q_COMPILER_RVALUE_REFS //--------------------------------------------------------------------------------------------------------------------- -VPlaceLabelItem::VPlaceLabelItem(const VPlaceLabelItem &&item) Q_DECL_NOTHROW - : VPointF(item), d(item.d) +VPlaceLabelItem::VPlaceLabelItem(VPlaceLabelItem &&item) Q_DECL_NOTHROW + : VPointF(std::move(item)), d(std::move(item.d)) {} //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vgeometry/vplacelabelitem.h b/src/libs/vgeometry/vplacelabelitem.h index 821993083..47c1639f6 100644 --- a/src/libs/vgeometry/vplacelabelitem.h +++ b/src/libs/vgeometry/vplacelabelitem.h @@ -48,7 +48,7 @@ public: VPlaceLabelItem &operator=(const VPlaceLabelItem &item); #ifdef Q_COMPILER_RVALUE_REFS - VPlaceLabelItem(const VPlaceLabelItem &&item) Q_DECL_NOTHROW; + VPlaceLabelItem(VPlaceLabelItem &&item) Q_DECL_NOTHROW; VPlaceLabelItem &operator=(VPlaceLabelItem &&item) Q_DECL_NOTHROW; #endif @@ -94,6 +94,6 @@ private: }; Q_DECLARE_METATYPE(VPlaceLabelItem) -Q_DECLARE_TYPEINFO(VPlaceLabelItem, Q_MOVABLE_TYPE); +Q_DECLARE_TYPEINFO(VPlaceLabelItem, Q_MOVABLE_TYPE); // NOLINT #endif // VPLACELABELITEM_H diff --git a/src/libs/vgeometry/vpointf.cpp b/src/libs/vgeometry/vpointf.cpp index ed15998d6..00ac077dc 100644 --- a/src/libs/vgeometry/vpointf.cpp +++ b/src/libs/vgeometry/vpointf.cpp @@ -104,8 +104,8 @@ VPointF &VPointF::operator =(const VPointF &point) #ifdef Q_COMPILER_RVALUE_REFS //--------------------------------------------------------------------------------------------------------------------- -VPointF::VPointF(const VPointF &&point) Q_DECL_NOTHROW - :VGObject(point), d(point.d) +VPointF::VPointF(VPointF &&point) Q_DECL_NOTHROW + :VGObject(std::move(point)), d(std::move(point.d)) {} //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vgeometry/vpointf.h b/src/libs/vgeometry/vpointf.h index 65ef2c99e..5b6bd8bfb 100644 --- a/src/libs/vgeometry/vpointf.h +++ b/src/libs/vgeometry/vpointf.h @@ -63,7 +63,7 @@ public: VPointF &operator=(const VPointF &point); #ifdef Q_COMPILER_RVALUE_REFS - VPointF(const VPointF &&point) Q_DECL_NOTHROW; + VPointF(VPointF &&point) Q_DECL_NOTHROW; VPointF &operator=(VPointF &&point) Q_DECL_NOTHROW; #endif @@ -97,7 +97,7 @@ private: }; Q_DECLARE_METATYPE(VPointF) -Q_DECLARE_TYPEINFO(VPointF, Q_MOVABLE_TYPE); +Q_DECLARE_TYPEINFO(VPointF, Q_MOVABLE_TYPE); // NOLINT QT_WARNING_POP diff --git a/src/libs/vgeometry/vspline.cpp b/src/libs/vgeometry/vspline.cpp index 6712c635a..b0fd2d022 100644 --- a/src/libs/vgeometry/vspline.cpp +++ b/src/libs/vgeometry/vspline.cpp @@ -270,8 +270,8 @@ auto VSpline::operator =(const VSpline &spline) -> VSpline & #ifdef Q_COMPILER_RVALUE_REFS //--------------------------------------------------------------------------------------------------------------------- VSpline::VSpline(VSpline &&spline) Q_DECL_NOTHROW - : VAbstractCubicBezier(spline), - d(spline.d) + : VAbstractCubicBezier(std::move(spline)), + d(std::move(spline.d)) {} //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vgeometry/vsplinepath.cpp b/src/libs/vgeometry/vsplinepath.cpp index bd4ac6c34..f13b55f43 100644 --- a/src/libs/vgeometry/vsplinepath.cpp +++ b/src/libs/vgeometry/vsplinepath.cpp @@ -317,9 +317,9 @@ VSplinePath &VSplinePath::operator =(const VSplinePath &path) #ifdef Q_COMPILER_RVALUE_REFS //--------------------------------------------------------------------------------------------------------------------- -VSplinePath::VSplinePath(const VSplinePath &&splPath) Q_DECL_NOTHROW - : VAbstractCubicBezierPath(splPath), - d(splPath.d) +VSplinePath::VSplinePath(VSplinePath &&splPath) Q_DECL_NOTHROW + : VAbstractCubicBezierPath(std::move(splPath)), + d(std::move(splPath.d)) {} //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vgeometry/vsplinepath.h b/src/libs/vgeometry/vsplinepath.h index 6990345e2..d87137b2f 100644 --- a/src/libs/vgeometry/vsplinepath.h +++ b/src/libs/vgeometry/vsplinepath.h @@ -52,7 +52,7 @@ class VSplinePathData; */ class VSplinePath final :public VAbstractCubicBezierPath { - Q_DECLARE_TR_FUNCTIONS(VSplinePath) + Q_DECLARE_TR_FUNCTIONS(VSplinePath) // NOLINT public: explicit VSplinePath(quint32 idObject = 0, Draw mode = Draw::Calculation); VSplinePath(const QVector &points, qreal kCurve = 1, quint32 idObject = 0, @@ -67,7 +67,7 @@ public: VSplinePoint &operator[](int indx); VSplinePath &operator=(const VSplinePath &path); #ifdef Q_COMPILER_RVALUE_REFS - VSplinePath(const VSplinePath&& splPath) Q_DECL_NOTHROW; + VSplinePath(VSplinePath&& splPath) Q_DECL_NOTHROW; VSplinePath &operator=(VSplinePath &&path) Q_DECL_NOTHROW; #endif @@ -101,6 +101,6 @@ private: QSharedDataPointer d; }; -Q_DECLARE_TYPEINFO(VSplinePath, Q_MOVABLE_TYPE); +Q_DECLARE_TYPEINFO(VSplinePath, Q_MOVABLE_TYPE); // NOLINT #endif // VSPLINEPATH_H diff --git a/src/libs/vgeometry/vsplinepoint.cpp b/src/libs/vgeometry/vsplinepoint.cpp index 508736708..cbf4a5437 100644 --- a/src/libs/vgeometry/vsplinepoint.cpp +++ b/src/libs/vgeometry/vsplinepoint.cpp @@ -77,8 +77,8 @@ VFSplinePoint &VFSplinePoint::operator=(const VFSplinePoint &point) #ifdef Q_COMPILER_RVALUE_REFS //--------------------------------------------------------------------------------------------------------------------- -VFSplinePoint::VFSplinePoint(const VFSplinePoint &&point) Q_DECL_NOTHROW - :d(point.d) +VFSplinePoint::VFSplinePoint(VFSplinePoint &&point) Q_DECL_NOTHROW + :d(std::move(point.d)) {} //--------------------------------------------------------------------------------------------------------------------- @@ -236,8 +236,8 @@ VSplinePoint &VSplinePoint::operator=(const VSplinePoint &point) #ifdef Q_COMPILER_RVALUE_REFS //--------------------------------------------------------------------------------------------------------------------- -VSplinePoint::VSplinePoint(const VSplinePoint &&point) Q_DECL_NOTHROW - : d(point.d) +VSplinePoint::VSplinePoint(VSplinePoint &&point) Q_DECL_NOTHROW + : d(std::move(point.d)) {} //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vgeometry/vsplinepoint.h b/src/libs/vgeometry/vsplinepoint.h index af537d024..8d53cecb6 100644 --- a/src/libs/vgeometry/vsplinepoint.h +++ b/src/libs/vgeometry/vsplinepoint.h @@ -53,7 +53,7 @@ public: VFSplinePoint &operator=(const VFSplinePoint &point); #ifdef Q_COMPILER_RVALUE_REFS - VFSplinePoint(const VFSplinePoint &&point) Q_DECL_NOTHROW; + VFSplinePoint(VFSplinePoint &&point) Q_DECL_NOTHROW; VFSplinePoint &operator=(VFSplinePoint &&point) Q_DECL_NOTHROW; #endif @@ -72,7 +72,7 @@ protected: }; Q_DECLARE_METATYPE(VFSplinePoint) -Q_DECLARE_TYPEINFO(VFSplinePoint, Q_MOVABLE_TYPE); +Q_DECLARE_TYPEINFO(VFSplinePoint, Q_MOVABLE_TYPE); // NOLINT class VSplinePointData; @@ -91,7 +91,7 @@ public: VSplinePoint &operator=(const VSplinePoint &point); #ifdef Q_COMPILER_RVALUE_REFS - VSplinePoint(const VSplinePoint &&point) Q_DECL_NOTHROW; + VSplinePoint(VSplinePoint &&point) Q_DECL_NOTHROW; VSplinePoint &operator=(VSplinePoint &&point) Q_DECL_NOTHROW; #endif @@ -122,6 +122,6 @@ protected: }; Q_DECLARE_METATYPE(VSplinePoint) -Q_DECLARE_TYPEINFO(VSplinePoint, Q_MOVABLE_TYPE); +Q_DECLARE_TYPEINFO(VSplinePoint, Q_MOVABLE_TYPE); // NOLINT #endif // VSPLINEPOINT_H diff --git a/src/libs/vlayout/dialogs/dialoglayoutscale.h b/src/libs/vlayout/dialogs/dialoglayoutscale.h index dc99ad49c..79097b774 100644 --- a/src/libs/vlayout/dialogs/dialoglayoutscale.h +++ b/src/libs/vlayout/dialogs/dialoglayoutscale.h @@ -30,6 +30,8 @@ #include +#include "../vmisc/defglobal.h" + namespace Ui { class DialogLayoutScale; @@ -37,7 +39,7 @@ namespace Ui class DialogLayoutScale final : public QDialog { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit DialogLayoutScale(bool printTiled, QWidget *parent = nullptr); @@ -62,7 +64,8 @@ private slots: void VerticalScaleChanged(double d); private: - Q_DISABLE_COPY(DialogLayoutScale) + // cppcheck-suppress unknownMacro + Q_DISABLE_COPY_MOVE(DialogLayoutScale) // NOLINT Ui::DialogLayoutScale *ui; bool isInitialized{false}; bool m_scaleConnected{true}; diff --git a/src/libs/vlayout/dialogs/vabstractlayoutdialog.h b/src/libs/vlayout/dialogs/vabstractlayoutdialog.h index 6ba849af1..9b7b89beb 100644 --- a/src/libs/vlayout/dialogs/vabstractlayoutdialog.h +++ b/src/libs/vlayout/dialogs/vabstractlayoutdialog.h @@ -32,6 +32,8 @@ #include #include +#include "../vmisc/defglobal.h" + enum class Unit : qint8; class VAbstractLayoutDialog : public QDialog @@ -73,7 +75,7 @@ protected: private: - Q_DISABLE_COPY(VAbstractLayoutDialog) + Q_DISABLE_COPY_MOVE(VAbstractLayoutDialog) // NOLINT }; #endif // VABSTRACTDIALOG_H diff --git a/src/libs/vlayout/dialogs/watermarkwindow.h b/src/libs/vlayout/dialogs/watermarkwindow.h index 1d65a835b..cd7204645 100644 --- a/src/libs/vlayout/dialogs/watermarkwindow.h +++ b/src/libs/vlayout/dialogs/watermarkwindow.h @@ -41,7 +41,7 @@ class WatermarkWindow; class WatermarkWindow : public QMainWindow { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit WatermarkWindow(const QString &patternPath, QWidget *parent = nullptr); @@ -71,7 +71,8 @@ private slots: void WatermarkChangesWereSaved(bool saved); private: - Q_DISABLE_COPY(WatermarkWindow) + // cppcheck-suppress unknownMacro + Q_DISABLE_COPY_MOVE(WatermarkWindow) // NOLINT Ui::WatermarkWindow *ui; QString m_patternPath; QString m_curFile{}; diff --git a/src/libs/vlayout/vabstractpiece.cpp b/src/libs/vlayout/vabstractpiece.cpp index 0680fc54c..e205e3a52 100644 --- a/src/libs/vlayout/vabstractpiece.cpp +++ b/src/libs/vlayout/vabstractpiece.cpp @@ -31,7 +31,6 @@ #include "../vmisc/vabstractvalapplication.h" #include "../vgeometry/vpointf.h" #include "../ifc/exception/vexception.h" -#include "../vmisc/vmath.h" #include "../vmisc/compatibility.h" #include "../vpatterndb/floatItemData/vgrainlinedata.h" #include "../vpatterndb/vcontainer.h" @@ -60,14 +59,14 @@ const qreal VSAPoint::minSAWidth = accuracyPointOnLine + accuracyPointOnLine*0.5 namespace { //--------------------------------------------------------------------------------------------------------------------- -inline bool IsSameDirection(QPointF p1, QPointF p2, QPointF px) +inline auto IsSameDirection(QPointF p1, QPointF p2, QPointF px) -> bool { return qAbs(QLineF(p1, p2).angle() - QLineF(p1, px).angle()) < 0.001; } //--------------------------------------------------------------------------------------------------------------------- // Do we create a point outside of a path? -inline bool IsOutsidePoint(QPointF p1, QPointF p2, QPointF px) +inline auto IsOutsidePoint(QPointF p1, QPointF p2, QPointF px) -> bool { QLineF seg1(p1, p2); QLineF seg2(p1, px); @@ -76,16 +75,16 @@ inline bool IsOutsidePoint(QPointF p1, QPointF p2, QPointF px) } //--------------------------------------------------------------------------------------------------------------------- -Q_DECL_CONSTEXPR qreal PointPosition(const QPointF &p, const QLineF &line) +Q_DECL_CONSTEXPR auto PointPosition(const QPointF &p, const QLineF &line) -> qreal { return (line.p2().x() - line.p1().x()) * (p.y() - line.p1().y()) - (line.p2().y() - line.p1().y()) * (p.x() - line.p1().x()); } //--------------------------------------------------------------------------------------------------------------------- -QVector AngleByLength(QVector points, QPointF p1, QPointF p2, QPointF p3, - const QLineF &bigLine1, QPointF sp2, const QLineF &bigLine2, const VSAPoint &p, - qreal width, bool *needRollback = nullptr) +auto AngleByLength(QVector points, QPointF p1, QPointF p2, QPointF p3, + const QLineF &bigLine1, QPointF sp2, const QLineF &bigLine2, const VSAPoint &p, + qreal width, bool *needRollback = nullptr) -> QVector { if (needRollback != nullptr) { @@ -216,9 +215,9 @@ QVector AngleByLength(QVector points, QPointF p1, QPoi } //--------------------------------------------------------------------------------------------------------------------- -QVector AngleByIntersection(const QVector &points, QPointF p1, QPointF p2, QPointF p3, - const QLineF &bigLine1, QPointF sp2, const QLineF &bigLine2, - const VSAPoint &p, qreal width, bool *needRollback = nullptr) +auto AngleByIntersection(const QVector &points, QPointF p1, QPointF p2, QPointF p3, + const QLineF &bigLine1, QPointF sp2, const QLineF &bigLine2, + const VSAPoint &p, qreal width, bool *needRollback = nullptr) -> QVector { { QLineF edge1(p2, p1); @@ -303,9 +302,9 @@ QVector AngleByIntersection(const QVector &points, QPo } //--------------------------------------------------------------------------------------------------------------------- -QVector AngleByFirstSymmetry(const QVector &points, QPointF p1, QPointF p2, QPointF p3, - const QLineF &bigLine1, QPointF sp2, const QLineF &bigLine2, - const VSAPoint &p, qreal width, bool *needRollback = nullptr) +auto AngleByFirstSymmetry(const QVector &points, QPointF p1, QPointF p2, QPointF p3, + const QLineF &bigLine1, QPointF sp2, const QLineF &bigLine2, + const VSAPoint &p, qreal width, bool *needRollback = nullptr) -> QVector { { QLineF edge1(p2, p1); @@ -384,9 +383,9 @@ QVector AngleByFirstSymmetry(const QVector &points, QP } //--------------------------------------------------------------------------------------------------------------------- -QVector AngleBySecondSymmetry(const QVector &points, QPointF p1, QPointF p2, QPointF p3, - const QLineF &bigLine1, QPointF sp2, const QLineF &bigLine2, - const VSAPoint &p, qreal width, bool *needRollback = nullptr) +auto AngleBySecondSymmetry(const QVector &points, QPointF p1, QPointF p2, QPointF p3, + const QLineF &bigLine1, QPointF sp2, const QLineF &bigLine2, + const VSAPoint &p, qreal width, bool *needRollback = nullptr) -> QVector { { QLineF edge1(p2, p1); @@ -467,9 +466,9 @@ QVector AngleBySecondSymmetry(const QVector &points, Q } //--------------------------------------------------------------------------------------------------------------------- -QVector AngleByFirstRightAngle(const QVector &points, QPointF p1, QPointF p2, QPointF p3, - const QLineF &bigLine1, QPointF sp2, const QLineF &bigLine2, - const VSAPoint &p, qreal width, bool *needRollback = nullptr) +auto AngleByFirstRightAngle(const QVector &points, QPointF p1, QPointF p2, QPointF p3, + const QLineF &bigLine1, QPointF sp2, const QLineF &bigLine2, + const VSAPoint &p, qreal width, bool *needRollback = nullptr) -> QVector { { QLineF edge1(p2, p1); @@ -517,29 +516,27 @@ QVector AngleByFirstRightAngle(const QVector &points, { return AngleByLength(points, p1, p2, p3, bigLine1, sp2, bigLine2, p, width, needRollback); } - else - { - pointsRA.append(seam.p2()); - QLineF loopLine(px, sp2); - const qreal length = loopLine.length()*0.98; - loopLine.setLength(length); + pointsRA.append(seam.p2()); - QLineF tmp(seam.p2(), seam.p1()); - tmp.setLength(tmp.length()+length); + QLineF loopLine(px, sp2); + const qreal length = loopLine.length()*0.98; + loopLine.setLength(length); - pointsRA.append(tmp.p2()); - pointsRA.append(loopLine.p2()); - } + QLineF tmp(seam.p2(), seam.p1()); + tmp.setLength(tmp.length()+length); + + pointsRA.append(tmp.p2()); + pointsRA.append(loopLine.p2()); } return pointsRA; } //--------------------------------------------------------------------------------------------------------------------- -QVector AngleBySecondRightAngle(QVector points, QPointF p1, QPointF p2, QPointF p3, - const QLineF &bigLine1, QPointF sp2, const QLineF &bigLine2, - const VSAPoint &p, qreal width, bool *needRollback = nullptr) +auto AngleBySecondRightAngle(QVector points, QPointF p1, QPointF p2, QPointF p3, const QLineF &bigLine1, + QPointF sp2, const QLineF &bigLine2, const VSAPoint &p, qreal width, + bool *needRollback = nullptr) -> QVector { { QLineF edge1(p2, p1); @@ -638,7 +635,7 @@ QVector AngleBySecondRightAngle(QVector points, QPoint } //--------------------------------------------------------------------------------------------------------------------- -QPointF SingleParallelPoint(const QPointF &p1, const QPointF &p2, qreal angle, qreal width) +auto SingleParallelPoint(const QPointF &p1, const QPointF &p2, qreal angle, qreal width) -> QPointF { QLineF pLine(p1, p2); pLine.setAngle( pLine.angle() + angle ); @@ -647,7 +644,7 @@ QPointF SingleParallelPoint(const QPointF &p1, const QPointF &p2, qreal angle, q } //--------------------------------------------------------------------------------------------------------------------- -QLineF SimpleParallelLine(const QPointF &p1, const QPointF &p2, qreal width) +auto SimpleParallelLine(const QPointF &p1, const QPointF &p2, qreal width) -> QLineF { const QLineF paralel = QLineF(SingleParallelPoint(p1, p2, 90, width), SingleParallelPoint(p2, p1, -90, width)); @@ -655,7 +652,7 @@ QLineF SimpleParallelLine(const QPointF &p1, const QPointF &p2, qreal width) } //--------------------------------------------------------------------------------------------------------------------- -QLineF BisectorLine(const QPointF &p1, const QPointF &p2, const QPointF &p3) +auto BisectorLine(const QPointF &p1, const QPointF &p2, const QPointF &p3) -> QLineF { QLineF line1(p2, p1); QLineF line2(p2, p3); @@ -679,7 +676,7 @@ QLineF BisectorLine(const QPointF &p1, const QPointF &p2, const QPointF &p3) } //--------------------------------------------------------------------------------------------------------------------- -qreal AngleBetweenBisectors(const QLineF &b1, const QLineF &b2) +auto AngleBetweenBisectors(const QLineF &b1, const QLineF &b2) -> qreal { const QLineF newB2 = b2.translated(-(b2.p1().x() - b1.p1().x()), -(b2.p1().y() - b1.p1().y())); @@ -700,7 +697,7 @@ qreal AngleBetweenBisectors(const QLineF &b1, const QLineF &b2) //--------------------------------------------------------------------------------------------------------------------- template -QVector CorrectPathDistortion(QVector path) +auto CorrectPathDistortion(QVector path) -> QVector { if (path.size() < 3) { @@ -737,7 +734,7 @@ QVector CorrectPathDistortion(QVector path) } //--------------------------------------------------------------------------------------------------------------------- -bool Rollback(QVector &points, const QLineF &edge) +auto Rollback(QVector &points, const QLineF &edge) -> bool { bool success = false; if (not points.isEmpty()) @@ -893,7 +890,7 @@ void RollbackBySecondEdgeRightAngle(QVector &ekvPoints, const QVect } //--------------------------------------------------------------------------------------------------------------------- -QVector CleanLoopArtifacts(const QVector &points) +auto CleanLoopArtifacts(const QVector &points) -> QVector { QVector cleaned; cleaned.reserve(points.size()); @@ -907,18 +904,18 @@ QVector CleanLoopArtifacts(const QVector &points) return cleaned; } -} +} // namespace // Friend functions //--------------------------------------------------------------------------------------------------------------------- -QDataStream &operator<<(QDataStream &dataStream, const VAbstractPiece &piece) +auto operator<<(QDataStream &dataStream, const VAbstractPiece &piece) -> QDataStream & { dataStream << *piece.d; return dataStream; } //--------------------------------------------------------------------------------------------------------------------- -QDataStream &operator>>(QDataStream &dataStream, VAbstractPiece &piece) +auto operator>>(QDataStream &dataStream, VAbstractPiece &piece) -> QDataStream & { dataStream >> *piece.d; return dataStream; @@ -935,7 +932,7 @@ VAbstractPiece::VAbstractPiece(const VAbstractPiece &piece) {} //--------------------------------------------------------------------------------------------------------------------- -VAbstractPiece &VAbstractPiece::operator=(const VAbstractPiece &piece) +auto VAbstractPiece::operator=(const VAbstractPiece &piece) -> VAbstractPiece & { if ( &piece == this ) { @@ -947,12 +944,12 @@ VAbstractPiece &VAbstractPiece::operator=(const VAbstractPiece &piece) #ifdef Q_COMPILER_RVALUE_REFS //--------------------------------------------------------------------------------------------------------------------- -VAbstractPiece::VAbstractPiece(const VAbstractPiece &&piece) Q_DECL_NOTHROW - :d (piece.d) +VAbstractPiece::VAbstractPiece(VAbstractPiece &&piece) Q_DECL_NOTHROW + :d (std::move(piece.d)) {} //--------------------------------------------------------------------------------------------------------------------- -VAbstractPiece &VAbstractPiece::operator=(VAbstractPiece &&piece) Q_DECL_NOTHROW +auto VAbstractPiece::operator=(VAbstractPiece &&piece) Q_DECL_NOTHROW -> VAbstractPiece & { std::swap(d, piece.d); return *this; @@ -964,7 +961,7 @@ VAbstractPiece::~VAbstractPiece() {} //--------------------------------------------------------------------------------------------------------------------- -QString VAbstractPiece::GetName() const +auto VAbstractPiece::GetName() const -> QString { return d->m_name; } @@ -976,7 +973,7 @@ void VAbstractPiece::SetName(const QString &value) } //--------------------------------------------------------------------------------------------------------------------- -bool VAbstractPiece::IsForbidFlipping() const +auto VAbstractPiece::IsForbidFlipping() const -> bool { return d->m_forbidFlipping; } @@ -993,7 +990,7 @@ void VAbstractPiece::SetForbidFlipping(bool value) } //--------------------------------------------------------------------------------------------------------------------- -bool VAbstractPiece::IsForceFlipping() const +auto VAbstractPiece::IsForceFlipping() const -> bool { return d->m_forceFlipping; } @@ -1010,7 +1007,7 @@ void VAbstractPiece::SetForceFlipping(bool value) } //--------------------------------------------------------------------------------------------------------------------- -bool VAbstractPiece::IsSeamAllowance() const +auto VAbstractPiece::IsSeamAllowance() const -> bool { return d->m_seamAllowance; } @@ -1022,7 +1019,7 @@ void VAbstractPiece::SetSeamAllowance(bool value) } //--------------------------------------------------------------------------------------------------------------------- -bool VAbstractPiece::IsSeamAllowanceBuiltIn() const +auto VAbstractPiece::IsSeamAllowanceBuiltIn() const -> bool { return d->m_seamAllowanceBuiltIn; } @@ -1034,7 +1031,7 @@ void VAbstractPiece::SetSeamAllowanceBuiltIn(bool value) } //--------------------------------------------------------------------------------------------------------------------- -bool VAbstractPiece::IsHideMainPath() const +auto VAbstractPiece::IsHideMainPath() const -> bool { return d->m_hideMainPath; } @@ -1046,7 +1043,7 @@ void VAbstractPiece::SetHideMainPath(bool value) } //--------------------------------------------------------------------------------------------------------------------- -qreal VAbstractPiece::GetSAWidth() const +auto VAbstractPiece::GetSAWidth() const -> qreal { return d->m_width; } @@ -1058,7 +1055,7 @@ void VAbstractPiece::SetSAWidth(qreal value) } //--------------------------------------------------------------------------------------------------------------------- -QVector VAbstractPiece::Equidistant(QVector points, qreal width, const QString &name) +auto VAbstractPiece::Equidistant(QVector points, qreal width, const QString &name) -> QVector { if (width < 0) { @@ -1159,7 +1156,7 @@ QVector VAbstractPiece::Equidistant(QVector points, qreal wid } //--------------------------------------------------------------------------------------------------------------------- -qreal VAbstractPiece::SumTrapezoids(const QVector &points) +auto VAbstractPiece::SumTrapezoids(const QVector &points) -> qreal { // Calculation a polygon area through the sum of the areas of trapezoids qreal s, res = 0; @@ -1195,11 +1192,11 @@ qreal VAbstractPiece::SumTrapezoids(const QVector &points) } //--------------------------------------------------------------------------------------------------------------------- -QVector VAbstractPiece::CheckLoops(const QVector &points) +auto VAbstractPiece::CheckLoops(const QVector &points) -> QVector { QVector rawPath; rawPath.reserve(points.size()); - for (auto &point : points) + for (const auto &point : points) { rawPath.append(point); } @@ -1326,13 +1323,13 @@ auto VAbstractPiece::CheckLoops(const QVector &points) -> QVector VAbstractPiece::EkvPoint(QVector points, const VSAPoint &p1Line1, - const VSAPoint &p2Line1, const VSAPoint &p1Line2, const VSAPoint &p2Line2, - qreal width, bool *needRollback) +auto VAbstractPiece::EkvPoint(QVector points, const VSAPoint &p1Line1, const VSAPoint &p2Line1, + const VSAPoint &p1Line2, const VSAPoint &p2Line2, qreal width, + bool *needRollback) -> QVector { if (width < 0) { // width can't be < 0 - return QVector(); + return {}; } width = qMax(width, VSAPoint::minSAWidth); @@ -1340,7 +1337,7 @@ QVector VAbstractPiece::EkvPoint(QVector points, const if (p2Line1 != p2Line2) { qDebug()<<"Last points of two lines must be equal."; - return QVector(); // Wrong edges + return {}; // Wrong edges } const QLineF bigLine1 = ParallelLine(p1Line1, p2Line1, width ); @@ -1488,20 +1485,18 @@ QT_WARNING_POP points.append(crosPoint); return points; } - else - {// but not enough far, fix it - line.setLength(localWidth); - points.append(line.p2()); - return points; - } - } - else - {// Wrong cross point, probably inside of a piece. Manually creating correct seam allowance - const QLineF bigEdge = SimpleParallelLine(bigLine1.p2(), bigLine2.p1(), localWidth ); - points.append(bigEdge.p1()); - points.append(bigEdge.p2()); + + // but not enough far, fix it + line.setLength(localWidth); + points.append(line.p2()); return points; } + + // Wrong cross point, probably inside of a piece. Manually creating correct seam allowance + const QLineF bigEdge = SimpleParallelLine(bigLine1.p2(), bigLine2.p1(), localWidth ); + points.append(bigEdge.p1()); + points.append(bigEdge.p2()); + return points; } } break; @@ -1518,14 +1513,14 @@ QT_WARNING_POP } //--------------------------------------------------------------------------------------------------------------------- -QLineF VAbstractPiece::ParallelLine(const VSAPoint &p1, const VSAPoint &p2, qreal width) +auto VAbstractPiece::ParallelLine(const VSAPoint &p1, const VSAPoint &p2, qreal width) -> QLineF { - return QLineF(SingleParallelPoint(p1, p2, 90, p1.GetSAAfter(width)), - SingleParallelPoint(p2, p1, -90, p2.GetSABefore(width))); + return {SingleParallelPoint(p1, p2, 90, p1.GetSAAfter(width)), + SingleParallelPoint(p2, p1, -90, p2.GetSABefore(width))}; } //--------------------------------------------------------------------------------------------------------------------- -bool VAbstractPiece::IsAllowanceValid(const QVector &base, const QVector &allowance) +auto VAbstractPiece::IsAllowanceValid(const QVector &base, const QVector &allowance) -> bool { if (base.size() < 3 || allowance.size() < 3) { @@ -1548,13 +1543,14 @@ bool VAbstractPiece::IsAllowanceValid(const QVector &base, const QVecto } //--------------------------------------------------------------------------------------------------------------------- -bool VAbstractPiece::IsEkvPointOnLine(const QPointF &iPoint, const QPointF &prevPoint, const QPointF &nextPoint) +auto VAbstractPiece::IsEkvPointOnLine(const QPointF &iPoint, const QPointF &prevPoint, const QPointF &nextPoint) -> bool { return VGObject::IsPointOnLineviaPDP(iPoint, prevPoint, nextPoint, accuracyPointOnLine/4.); } //--------------------------------------------------------------------------------------------------------------------- -bool VAbstractPiece::IsEkvPointOnLine(const VSAPoint &iPoint, const VSAPoint &prevPoint, const VSAPoint &nextPoint) +auto VAbstractPiece::IsEkvPointOnLine(const VSAPoint &iPoint, const VSAPoint &prevPoint, + const VSAPoint &nextPoint) -> bool { // See bug #671 const qreal tmpWidth = 10; @@ -1576,7 +1572,7 @@ bool VAbstractPiece::IsEkvPointOnLine(const VSAPoint &iPoint, const VSAPoint &pr } //--------------------------------------------------------------------------------------------------------------------- -qreal VAbstractPiece::GetMx() const +auto VAbstractPiece::GetMx() const -> qreal { return d->m_mx; } @@ -1588,7 +1584,7 @@ void VAbstractPiece::SetMx(qreal value) } //--------------------------------------------------------------------------------------------------------------------- -qreal VAbstractPiece::GetMy() const +auto VAbstractPiece::GetMy() const -> qreal { return d->m_my; } @@ -1600,7 +1596,7 @@ void VAbstractPiece::SetMy(qreal value) } //--------------------------------------------------------------------------------------------------------------------- -uint VAbstractPiece::GetPriority() const +auto VAbstractPiece::GetPriority() const -> uint { return d->m_priority; } @@ -1612,7 +1608,7 @@ void VAbstractPiece::SetPriority(uint value) } //--------------------------------------------------------------------------------------------------------------------- -QUuid VAbstractPiece::GetUUID() const +auto VAbstractPiece::GetUUID() const -> QUuid { return d->m_uuid; } @@ -1637,7 +1633,7 @@ auto VAbstractPiece::GetUniqueID() const -> QString } //--------------------------------------------------------------------------------------------------------------------- -qreal VSAPoint::GetSABefore(qreal width) const +auto VSAPoint::GetSABefore(qreal width) const -> qreal { if (m_before < 0) { @@ -1647,7 +1643,7 @@ qreal VSAPoint::GetSABefore(qreal width) const } //--------------------------------------------------------------------------------------------------------------------- -qreal VSAPoint::GetSAAfter(qreal width) const +auto VSAPoint::GetSAAfter(qreal width) const -> qreal { if (m_after < 0) { @@ -1657,13 +1653,13 @@ qreal VSAPoint::GetSAAfter(qreal width) const } //--------------------------------------------------------------------------------------------------------------------- -qreal VSAPoint::MaxLocalSA(qreal width) const +auto VSAPoint::MaxLocalSA(qreal width) const -> qreal { return qMax(GetSAAfter(width), GetSABefore(width)); } //--------------------------------------------------------------------------------------------------------------------- -qreal VSAPoint::PassmarkLength(qreal width) const +auto VSAPoint::PassmarkLength(qreal width) const -> qreal { if (not m_manualPassmarkLength) { @@ -1676,7 +1672,7 @@ qreal VSAPoint::PassmarkLength(qreal width) const } //--------------------------------------------------------------------------------------------------------------------- -QJsonObject VSAPoint::toJson() const +auto VSAPoint::toJson() const -> QJsonObject { QJsonObject pointObject; pointObject[QLatin1String("type")] = "VSAPoint"; @@ -1703,8 +1699,8 @@ QJsonObject VSAPoint::toJson() const //--------------------------------------------------------------------------------------------------------------------- // Because artificial loop can lead to wrong clipping we must rollback current seam allowance points -QVector VAbstractPiece::RollbackSeamAllowance(QVector points, const QLineF &cuttingEdge, - bool *success) +auto VAbstractPiece::RollbackSeamAllowance(QVector points, const QLineF &cuttingEdge, + bool *success) -> QVector { *success = false; QVector clipped; @@ -1748,8 +1744,8 @@ QVector VAbstractPiece::RollbackSeamAllowance(QVector //--------------------------------------------------------------------------------------------------------------------- -bool VAbstractPiece::IsItemContained(const QRectF &parentBoundingRect, const QVector &shape, qreal &dX, - qreal &dY) +auto VAbstractPiece::IsItemContained(const QRectF &parentBoundingRect, const QVector &shape, qreal &dX, + qreal &dY) -> bool { dX = 0; dY = 0; @@ -1797,23 +1793,23 @@ bool VAbstractPiece::IsItemContained(const QRectF &parentBoundingRect, const QVe } //--------------------------------------------------------------------------------------------------------------------- -QVector VAbstractPiece::CorrectPosition(const QRectF &parentBoundingRect, QVector points) +auto VAbstractPiece::CorrectPosition(const QRectF &parentBoundingRect, QVector points) -> QVector { qreal dX = 0; qreal dY = 0; if (not IsItemContained(parentBoundingRect, points, dX, dY)) { - for (int i =0; i < points.size(); ++i) + for (auto & point : points) { - points[i] = QPointF(points.at(i).x() + dX, points.at(i).y() + dY); + point = QPointF(point.x() + dX, point.y() + dY); } } return points; } //--------------------------------------------------------------------------------------------------------------------- -bool VAbstractPiece::FindGrainlineGeometry(const VGrainlineData& geom, const VContainer *pattern, qreal &length, - qreal &rotationAngle, QPointF &pos) +auto VAbstractPiece::FindGrainlineGeometry(const VGrainlineData& geom, const VContainer *pattern, qreal &length, + qreal &rotationAngle, QPointF &pos) -> bool { SCASSERT(pattern != nullptr) @@ -1892,8 +1888,8 @@ bool VAbstractPiece::FindGrainlineGeometry(const VGrainlineData& geom, const VCo } //--------------------------------------------------------------------------------------------------------------------- -QVector VAbstractPiece::GrainlinePoints(const VGrainlineData &geom, const VContainer *pattern, - const QRectF &boundingRect, qreal &dAng) +auto VAbstractPiece::GrainlinePoints(const VGrainlineData &geom, const VContainer *pattern, const QRectF &boundingRect, + qreal &dAng) -> QVector { SCASSERT(pattern != nullptr) @@ -1901,7 +1897,7 @@ QVector VAbstractPiece::GrainlinePoints(const VGrainlineData &geom, con qreal dLen = 0; if ( not FindGrainlineGeometry(geom, pattern, dLen, dAng, pt1)) { - return QVector(); + return {}; } qreal rotation = dAng; @@ -1940,7 +1936,7 @@ QVector VAbstractPiece::GrainlinePoints(const VGrainlineData &geom, con } //--------------------------------------------------------------------------------------------------------------------- -QPainterPath VAbstractPiece::PainterPath(const QVector &points) +auto VAbstractPiece::PainterPath(const QVector &points) -> QPainterPath { QPainterPath path; path.setFillRule(Qt::WindingFill); diff --git a/src/libs/vlayout/vabstractpiece.h b/src/libs/vlayout/vabstractpiece.h index 20abffa38..beab83021 100644 --- a/src/libs/vlayout/vabstractpiece.h +++ b/src/libs/vlayout/vabstractpiece.h @@ -35,8 +35,6 @@ #include #include -#include "../vmisc/diagnostic.h" -#include "../vmisc/def.h" #include "../vmisc/compatibility.h" #include "../vgeometry/vgobject.h" #include "vsapoint.h" @@ -50,101 +48,101 @@ class VRawSAPoint; class VAbstractPiece { - Q_DECLARE_TR_FUNCTIONS(VAbstractPiece) + Q_DECLARE_TR_FUNCTIONS(VAbstractPiece) // NOLINT public: VAbstractPiece(); VAbstractPiece(const VAbstractPiece &piece); virtual ~VAbstractPiece(); - VAbstractPiece &operator=(const VAbstractPiece &piece); + auto operator=(const VAbstractPiece &piece) -> VAbstractPiece &; #ifdef Q_COMPILER_RVALUE_REFS - VAbstractPiece(const VAbstractPiece &&piece) Q_DECL_NOTHROW; - VAbstractPiece &operator=(VAbstractPiece &&piece) Q_DECL_NOTHROW; + VAbstractPiece(VAbstractPiece &&piece) Q_DECL_NOTHROW; + auto operator=(VAbstractPiece &&piece) Q_DECL_NOTHROW -> VAbstractPiece &; #endif - QString GetName() const; - void SetName(const QString &value); + auto GetName() const -> QString; + void SetName(const QString &value); - bool IsForbidFlipping() const; + auto IsForbidFlipping() const -> bool; void SetForbidFlipping(bool value); - bool IsForceFlipping() const; + auto IsForceFlipping() const -> bool; void SetForceFlipping(bool value); - bool IsSeamAllowance() const; + auto IsSeamAllowance() const -> bool; void SetSeamAllowance(bool value); - bool IsSeamAllowanceBuiltIn() const; + auto IsSeamAllowanceBuiltIn() const -> bool; void SetSeamAllowanceBuiltIn(bool value); - bool IsHideMainPath() const; + auto IsHideMainPath() const -> bool; void SetHideMainPath(bool value); - qreal GetSAWidth() const; - void SetSAWidth(qreal value); + auto GetSAWidth() const -> qreal; + void SetSAWidth(qreal value); - qreal GetMx() const; - void SetMx(qreal value); + auto GetMx() const -> qreal; + void SetMx(qreal value); - qreal GetMy() const; - void SetMy(qreal value); + auto GetMy() const -> qreal; + void SetMy(qreal value); - uint GetPriority() const; + auto GetPriority() const -> uint; void SetPriority(uint value); - QUuid GetUUID() const; - void SetUUID(const QUuid &uuid); - void SetUUID(const QString &uuid); + auto GetUUID() const -> QUuid; + void SetUUID(const QUuid &uuid); + void SetUUID(const QString &uuid); /** * @brief GetUniqueID returns unique piece id. Combines UUID and gradation label. * @return unique piece id. */ - virtual QString GetUniqueID() const; + virtual auto GetUniqueID() const -> QString; - static QVector Equidistant(QVector points, qreal width, const QString &name); - static qreal SumTrapezoids(const QVector &points); - static QVector CheckLoops(const QVector &points); - static QVector CheckLoops(const QVector &points); - static QVector EkvPoint(QVector points, const VSAPoint &p1Line1, const VSAPoint &p2Line1, - const VSAPoint &p1Line2, const VSAPoint &p2Line2, qreal width, - bool *needRollback = nullptr); - static QLineF ParallelLine(const VSAPoint &p1, const VSAPoint &p2, qreal width); - static bool IsAllowanceValid(const QVector &base, const QVector &allowance); + static auto Equidistant(QVector points, qreal width, const QString &name) -> QVector; + static auto SumTrapezoids(const QVector &points) -> qreal; + static auto CheckLoops(const QVector &points) -> QVector; + static auto CheckLoops(const QVector &points) -> QVector; + static auto EkvPoint(QVector points, const VSAPoint &p1Line1, const VSAPoint &p2Line1, + const VSAPoint &p1Line2, const VSAPoint &p2Line2, qreal width, + bool *needRollback = nullptr) -> QVector; + static auto ParallelLine(const VSAPoint &p1, const VSAPoint &p2, qreal width) -> QLineF; + static auto IsAllowanceValid(const QVector &base, const QVector &allowance) -> bool; template - static bool IsInsidePolygon(const QVector &path, const QVector &polygon, - qreal accuracy = accuracyPointOnLine); + static auto IsInsidePolygon(const QVector &path, const QVector &polygon, + qreal accuracy = accuracyPointOnLine) -> bool; template - static QVector CorrectEquidistantPoints(const QVector &points, bool removeFirstAndLast = true); + static auto CorrectEquidistantPoints(const QVector &points, bool removeFirstAndLast = true) -> QVector; - static QVector RollbackSeamAllowance(QVector points, const QLineF &cuttingEdge, - bool *success); + static auto RollbackSeamAllowance(QVector points, const QLineF &cuttingEdge, + bool *success) -> QVector; - static QVector GrainlinePoints(const VGrainlineData &geom, const VContainer *pattern, - const QRectF &boundingRect, qreal &dAng); + static auto GrainlinePoints(const VGrainlineData &geom, const VContainer *pattern, + const QRectF &boundingRect, qreal &dAng) -> QVector; - static QPainterPath PainterPath(const QVector &points); + static auto PainterPath(const QVector &points) -> QPainterPath; - friend QDataStream& operator<< (QDataStream& dataStream, const VAbstractPiece& piece); - friend QDataStream& operator>> (QDataStream& dataStream, VAbstractPiece& piece); + friend auto operator<< (QDataStream& dataStream, const VAbstractPiece& piece) -> QDataStream&; + friend auto operator>> (QDataStream& dataStream, VAbstractPiece& piece) -> QDataStream&; protected: template - static QVector RemoveDublicates(const QVector &points, bool removeFirstAndLast = true); - static bool IsEkvPointOnLine(const QPointF &iPoint, const QPointF &prevPoint, const QPointF &nextPoint); - static bool IsEkvPointOnLine(const VSAPoint &iPoint, const VSAPoint &prevPoint, const VSAPoint &nextPoint); + static auto RemoveDublicates(const QVector &points, bool removeFirstAndLast = true) -> QVector; + static auto IsEkvPointOnLine(const QPointF &iPoint, const QPointF &prevPoint, const QPointF &nextPoint) -> bool; + static auto IsEkvPointOnLine(const VSAPoint &iPoint, const VSAPoint &prevPoint, const VSAPoint &nextPoint) -> bool; - static bool IsItemContained(const QRectF &parentBoundingRect, const QVector &shape, qreal &dX, - qreal &dY); - static QVector CorrectPosition(const QRectF &parentBoundingRect, QVector points); - static bool FindGrainlineGeometry(const VGrainlineData& geom, const VContainer *pattern, qreal &length, - qreal &rotationAngle, QPointF &pos); + static auto IsItemContained(const QRectF &parentBoundingRect, const QVector &shape, qreal &dX, + qreal &dY) -> bool; + static auto CorrectPosition(const QRectF &parentBoundingRect, QVector points) -> QVector; + static auto FindGrainlineGeometry(const VGrainlineData& geom, const VContainer *pattern, qreal &length, + qreal &rotationAngle, QPointF &pos) -> bool; private: QSharedDataPointer d; }; -Q_DECLARE_TYPEINFO(VAbstractPiece, Q_MOVABLE_TYPE); +Q_DECLARE_TYPEINFO(VAbstractPiece, Q_MOVABLE_TYPE); // NOLINT //--------------------------------------------------------------------------------------------------------------------- /** @@ -153,7 +151,7 @@ Q_DECLARE_TYPEINFO(VAbstractPiece, Q_MOVABLE_TYPE); * @return corrected list. */ template -QVector VAbstractPiece::CorrectEquidistantPoints(const QVector &points, bool removeFirstAndLast) +auto VAbstractPiece::CorrectEquidistantPoints(const QVector &points, bool removeFirstAndLast) -> QVector { // DumpVector(points, QStringLiteral("input.json.XXXXXX")); // Uncomment for dumping test data if (points.size()<4)//Better don't check if only three points. We can destroy equidistant. @@ -235,7 +233,7 @@ QVector VAbstractPiece::CorrectEquidistantPoints(const QVector &points, bo //--------------------------------------------------------------------------------------------------------------------- template -QVector VAbstractPiece::RemoveDublicates(const QVector &points, bool removeFirstAndLast) +auto VAbstractPiece::RemoveDublicates(const QVector &points, bool removeFirstAndLast) -> QVector { if (points.size() < 4) { @@ -281,7 +279,7 @@ QVector VAbstractPiece::RemoveDublicates(const QVector &points, bool remov //--------------------------------------------------------------------------------------------------------------------- template -bool VAbstractPiece::IsInsidePolygon(const QVector &path, const QVector &polygon, qreal accuracy) +auto VAbstractPiece::IsInsidePolygon(const QVector &path, const QVector &polygon, qreal accuracy) -> bool { // Edges must not intersect for (auto i = 0; i < path.count(); ++i) @@ -338,16 +336,8 @@ bool VAbstractPiece::IsInsidePolygon(const QVector &path, const QVector &p // Just instersection edges is not enough. The base must be inside of the allowance. QPolygonF allowancePolygon(polygon); - - for (auto &point : path) - { - if (not allowancePolygon.containsPoint(point, Qt::WindingFill)) - { - return false; - } - } - - return true; + return std::all_of(path.begin(), path.end(), [allowancePolygon](const T &point) + { return allowancePolygon.containsPoint(point, Qt::WindingFill); }); } #endif // VABSTRACTPIECE_H diff --git a/src/libs/vlayout/vabstractpiece_p.h b/src/libs/vlayout/vabstractpiece_p.h index 6aa88ad06..dff919d3b 100644 --- a/src/libs/vlayout/vabstractpiece_p.h +++ b/src/libs/vlayout/vabstractpiece_p.h @@ -47,7 +47,7 @@ QT_WARNING_DISABLE_GCC("-Wnon-virtual-dtor") class VAbstractPieceData : public QSharedData { - Q_DECLARE_TR_FUNCTIONS(VAbstractPieceData) + Q_DECLARE_TR_FUNCTIONS(VAbstractPieceData) // NOLINT public: VAbstractPieceData() {} diff --git a/src/libs/vlayout/vbank.cpp b/src/libs/vlayout/vbank.cpp index 88acd2297..20dfe72b4 100644 --- a/src/libs/vlayout/vbank.cpp +++ b/src/libs/vlayout/vbank.cpp @@ -31,18 +31,16 @@ #include #include -#include "../vmisc/diagnostic.h" #include "../vmisc/vabstractvalapplication.h" #include "../vmisc/compatibility.h" #include "vlayoutdef.h" #include "../ifc/exception/vexception.h" -#include "../vpatterndb/floatItemData/floatitemdef.h" QT_WARNING_PUSH QT_WARNING_DISABLE_CLANG("-Wmissing-prototypes") QT_WARNING_DISABLE_INTEL(1418) -Q_LOGGING_CATEGORY(lBank, "layout.bank") +Q_LOGGING_CATEGORY(lBank, "layout.bank") // NOLINT QT_WARNING_POP diff --git a/src/libs/vlayout/vbank.h b/src/libs/vlayout/vbank.h index ad0deba1a..960f46179 100644 --- a/src/libs/vlayout/vbank.h +++ b/src/libs/vlayout/vbank.h @@ -52,7 +52,7 @@ Q_DECLARE_LOGGING_CATEGORY(lBank) class VBank { - Q_DECLARE_TR_FUNCTIONS(VBank) + Q_DECLARE_TR_FUNCTIONS(VBank) // NOLINT public: VBank(); @@ -86,7 +86,7 @@ public: bool IsRotationNeeded() const; private: - Q_DISABLE_COPY(VBank) + Q_DISABLE_COPY_MOVE(VBank) // NOLINT QVector details{}; QMap> unsorted{}; diff --git a/src/libs/vlayout/vbestsquare.cpp b/src/libs/vlayout/vbestsquare.cpp index 1394c38e5..efc40caaf 100644 --- a/src/libs/vlayout/vbestsquare.cpp +++ b/src/libs/vlayout/vbestsquare.cpp @@ -73,8 +73,8 @@ VBestSquare &VBestSquare::operator=(const VBestSquare &res) #ifdef Q_COMPILER_RVALUE_REFS //--------------------------------------------------------------------------------------------------------------------- -VBestSquare::VBestSquare(const VBestSquare &&res) Q_DECL_NOTHROW - : d(res.d) +VBestSquare::VBestSquare(VBestSquare &&res) Q_DECL_NOTHROW + : d(std::move(res.d)) {} //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vlayout/vbestsquare.h b/src/libs/vlayout/vbestsquare.h index fdd6a0c23..9c51ce516 100644 --- a/src/libs/vlayout/vbestsquare.h +++ b/src/libs/vlayout/vbestsquare.h @@ -49,7 +49,7 @@ public: VBestSquare &operator=(const VBestSquare &res); #ifdef Q_COMPILER_RVALUE_REFS - VBestSquare(const VBestSquare &&res) Q_DECL_NOTHROW; + VBestSquare(VBestSquare &&res) Q_DECL_NOTHROW; VBestSquare &operator=(VBestSquare &&res) Q_DECL_NOTHROW; #endif @@ -78,6 +78,6 @@ private: }; -Q_DECLARE_TYPEINFO(VBestSquare, Q_MOVABLE_TYPE); +Q_DECLARE_TYPEINFO(VBestSquare, Q_MOVABLE_TYPE); // NOLINT #endif // VBESTSQUARE_H diff --git a/src/libs/vlayout/vcontour.cpp b/src/libs/vlayout/vcontour.cpp index fc47b945d..0800698bf 100644 --- a/src/libs/vlayout/vcontour.cpp +++ b/src/libs/vlayout/vcontour.cpp @@ -126,8 +126,8 @@ VContour &VContour::operator=(const VContour &contour) #ifdef Q_COMPILER_RVALUE_REFS //--------------------------------------------------------------------------------------------------------------------- -VContour::VContour(const VContour &&contour) Q_DECL_NOTHROW - :d (contour.d) +VContour::VContour(VContour &&contour) Q_DECL_NOTHROW + :d (std::move(contour.d)) {} //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vlayout/vcontour.h b/src/libs/vlayout/vcontour.h index 0d26b0ab1..58cb1ee65 100644 --- a/src/libs/vlayout/vcontour.h +++ b/src/libs/vlayout/vcontour.h @@ -55,7 +55,7 @@ public: VContour &operator=(const VContour &contour); #ifdef Q_COMPILER_RVALUE_REFS - VContour(const VContour &&contour) Q_DECL_NOTHROW; + VContour(VContour &&contour) Q_DECL_NOTHROW; VContour &operator=(VContour &&contour) Q_DECL_NOTHROW; #endif @@ -98,6 +98,6 @@ private: int EmptySheetEdgesCount() const; }; -Q_DECLARE_TYPEINFO(VContour, Q_MOVABLE_TYPE); +Q_DECLARE_TYPEINFO(VContour, Q_MOVABLE_TYPE); // NOLINT #endif // VCONTOUR_H diff --git a/src/libs/vlayout/vlayoutexporter.cpp b/src/libs/vlayout/vlayoutexporter.cpp index f378a5c50..9ed6a5f34 100644 --- a/src/libs/vlayout/vlayoutexporter.cpp +++ b/src/libs/vlayout/vlayoutexporter.cpp @@ -53,9 +53,9 @@ namespace { #ifdef Q_OS_WIN -Q_GLOBAL_STATIC_WITH_ARGS(const QString, PDFTOPS, (QLatin1String("pdftops.exe"))) +Q_GLOBAL_STATIC_WITH_ARGS(const QString, PDFTOPS, (QLatin1String("pdftops.exe"))) // NOLINT #else -Q_GLOBAL_STATIC_WITH_ARGS(const QString, PDFTOPS, (QLatin1String("pdftops"))) +Q_GLOBAL_STATIC_WITH_ARGS(const QString, PDFTOPS, (QLatin1String("pdftops"))) // NOLINT #endif //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vlayout/vlayoutexporter.h b/src/libs/vlayout/vlayoutexporter.h index 1966090f2..e5348a37a 100644 --- a/src/libs/vlayout/vlayoutexporter.h +++ b/src/libs/vlayout/vlayoutexporter.h @@ -42,7 +42,7 @@ class VLayoutPiece; class VLayoutExporter { - Q_DECLARE_TR_FUNCTIONS(VLayoutExporter) + Q_DECLARE_TR_FUNCTIONS(VLayoutExporter) // NOLINT public: VLayoutExporter() = default; diff --git a/src/libs/vlayout/vlayoutgenerator.h b/src/libs/vlayout/vlayoutgenerator.h index 8c0519be3..fc4b16509 100644 --- a/src/libs/vlayout/vlayoutgenerator.h +++ b/src/libs/vlayout/vlayoutgenerator.h @@ -49,7 +49,7 @@ class QElapsedTimer; class VLayoutGenerator :public QObject { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit VLayoutGenerator(QObject *parent = nullptr); virtual ~VLayoutGenerator() override; @@ -141,7 +141,7 @@ public slots: void Timeout(); private: - Q_DISABLE_COPY(VLayoutGenerator) + Q_DISABLE_COPY_MOVE(VLayoutGenerator) // NOLINT QVector papers; VBank *bank; qreal paperHeight; diff --git a/src/libs/vlayout/vlayoutpaper.cpp b/src/libs/vlayout/vlayoutpaper.cpp index 9c490381d..6ecf2157b 100644 --- a/src/libs/vlayout/vlayoutpaper.cpp +++ b/src/libs/vlayout/vlayoutpaper.cpp @@ -83,8 +83,8 @@ VLayoutPaper &VLayoutPaper::operator=(const VLayoutPaper &paper) #ifdef Q_COMPILER_RVALUE_REFS //--------------------------------------------------------------------------------------------------------------------- -VLayoutPaper::VLayoutPaper(const VLayoutPaper &&paper) Q_DECL_NOTHROW - :d (paper.d) +VLayoutPaper::VLayoutPaper(VLayoutPaper &&paper) Q_DECL_NOTHROW + :d (std::move(paper.d)) {} //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vlayout/vlayoutpaper.h b/src/libs/vlayout/vlayoutpaper.h index fa0ea88dd..a1cad1ade 100644 --- a/src/libs/vlayout/vlayoutpaper.h +++ b/src/libs/vlayout/vlayoutpaper.h @@ -59,7 +59,7 @@ public: VLayoutPaper &operator=(const VLayoutPaper &paper); #ifdef Q_COMPILER_RVALUE_REFS - VLayoutPaper(const VLayoutPaper &&paper) Q_DECL_NOTHROW; + VLayoutPaper(VLayoutPaper &&paper) Q_DECL_NOTHROW; VLayoutPaper &operator=(VLayoutPaper &&paper) Q_DECL_NOTHROW; #endif @@ -117,6 +117,6 @@ private: }; -Q_DECLARE_TYPEINFO(VLayoutPaper, Q_MOVABLE_TYPE); +Q_DECLARE_TYPEINFO(VLayoutPaper, Q_MOVABLE_TYPE); // NOLINT #endif // VLAYOUTPAPER_H diff --git a/src/libs/vlayout/vlayoutpiece.cpp b/src/libs/vlayout/vlayoutpiece.cpp index e17066036..f4e50746a 100644 --- a/src/libs/vlayout/vlayoutpiece.cpp +++ b/src/libs/vlayout/vlayoutpiece.cpp @@ -568,8 +568,8 @@ VLayoutPiece &VLayoutPiece::operator=(const VLayoutPiece &detail) #ifdef Q_COMPILER_RVALUE_REFS //--------------------------------------------------------------------------------------------------------------------- -VLayoutPiece::VLayoutPiece(const VLayoutPiece &&detail) Q_DECL_NOTHROW - :VAbstractPiece(detail), d(detail.d) +VLayoutPiece::VLayoutPiece(VLayoutPiece &&detail) Q_DECL_NOTHROW + :VAbstractPiece(std::move(detail)), d(std::move(detail.d)) {} //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vlayout/vlayoutpiece.h b/src/libs/vlayout/vlayoutpiece.h index 1afe12191..89b504d7f 100644 --- a/src/libs/vlayout/vlayoutpiece.h +++ b/src/libs/vlayout/vlayoutpiece.h @@ -62,7 +62,7 @@ QT_WARNING_DISABLE_GCC("-Wsuggest-final-methods") class VLayoutPiece :public VAbstractPiece { - Q_DECLARE_TR_FUNCTIONS(VLayoutPiece) + Q_DECLARE_TR_FUNCTIONS(VLayoutPiece) // NOLINT public: VLayoutPiece(); VLayoutPiece(const VLayoutPiece &detail); @@ -71,7 +71,7 @@ public: VLayoutPiece &operator=(const VLayoutPiece &detail); #ifdef Q_COMPILER_RVALUE_REFS - VLayoutPiece(const VLayoutPiece &&detail) Q_DECL_NOTHROW; + VLayoutPiece(VLayoutPiece &&detail) Q_DECL_NOTHROW; VLayoutPiece &operator=(VLayoutPiece &&detail) Q_DECL_NOTHROW; #endif @@ -224,6 +224,6 @@ private: QT_WARNING_POP -Q_DECLARE_TYPEINFO(VLayoutPiece, Q_MOVABLE_TYPE); +Q_DECLARE_TYPEINFO(VLayoutPiece, Q_MOVABLE_TYPE); // NOLINT #endif // VLAYOUTDETAIL_H diff --git a/src/libs/vlayout/vlayoutpiecepath.cpp b/src/libs/vlayout/vlayoutpiecepath.cpp index 0f61d5b0c..db6e844ed 100644 --- a/src/libs/vlayout/vlayoutpiecepath.cpp +++ b/src/libs/vlayout/vlayoutpiecepath.cpp @@ -81,8 +81,8 @@ VLayoutPiecePath &VLayoutPiecePath::operator=(const VLayoutPiecePath &path) #ifdef Q_COMPILER_RVALUE_REFS //--------------------------------------------------------------------------------------------------------------------- -VLayoutPiecePath::VLayoutPiecePath(const VLayoutPiecePath &&path) Q_DECL_NOTHROW - : d(path.d) +VLayoutPiecePath::VLayoutPiecePath(VLayoutPiecePath &&path) Q_DECL_NOTHROW + : d(std::move(path.d)) {} //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vlayout/vlayoutpiecepath.h b/src/libs/vlayout/vlayoutpiecepath.h index 450406601..bf035b908 100644 --- a/src/libs/vlayout/vlayoutpiecepath.h +++ b/src/libs/vlayout/vlayoutpiecepath.h @@ -47,7 +47,7 @@ public: VLayoutPiecePath &operator=(const VLayoutPiecePath &path); #ifdef Q_COMPILER_RVALUE_REFS - VLayoutPiecePath(const VLayoutPiecePath &&path) Q_DECL_NOTHROW; + VLayoutPiecePath(VLayoutPiecePath &&path) Q_DECL_NOTHROW; VLayoutPiecePath &operator=(VLayoutPiecePath &&path) Q_DECL_NOTHROW; #endif @@ -70,6 +70,6 @@ private: }; Q_DECLARE_METATYPE(VLayoutPiecePath) -Q_DECLARE_TYPEINFO(VLayoutPiecePath, Q_MOVABLE_TYPE); +Q_DECLARE_TYPEINFO(VLayoutPiecePath, Q_MOVABLE_TYPE); // NOLINT #endif // VLAYOUTPIECEPATH_H diff --git a/src/libs/vlayout/vposter.h b/src/libs/vlayout/vposter.h index b4e562f31..8ad8da402 100644 --- a/src/libs/vlayout/vposter.h +++ b/src/libs/vlayout/vposter.h @@ -59,11 +59,11 @@ struct PosterData QRect rect; // rect section }; -Q_DECLARE_TYPEINFO(PosterData, Q_MOVABLE_TYPE); +Q_DECLARE_TYPEINFO(PosterData, Q_MOVABLE_TYPE); // NOLINT class VPoster { - Q_DECLARE_TR_FUNCTIONS(VPoster) + Q_DECLARE_TR_FUNCTIONS(VPoster) // NOLINT public: explicit VPoster(const QPrinter *printer); diff --git a/src/libs/vlayout/vprintlayout.h b/src/libs/vlayout/vprintlayout.h index d3aafc2e2..0ea73d245 100644 --- a/src/libs/vlayout/vprintlayout.h +++ b/src/libs/vlayout/vprintlayout.h @@ -42,7 +42,7 @@ struct VWatermarkData; class VPrintLayout : public QObject { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit VPrintLayout(QObject *parent = nullptr); virtual ~VPrintLayout(); @@ -127,7 +127,7 @@ private slots: void PrintPages (QPrinter *printer); private: - Q_DISABLE_COPY(VPrintLayout) + Q_DISABLE_COPY_MOVE(VPrintLayout) // NOLINT QString m_fileName{}; QSizeF m_layoutPaperSize{}; diff --git a/src/libs/vlayout/vrawlayout.h b/src/libs/vlayout/vrawlayout.h index 23078048a..651d5acb7 100644 --- a/src/libs/vlayout/vrawlayout.h +++ b/src/libs/vlayout/vrawlayout.h @@ -45,7 +45,7 @@ private: class VRawLayout { - Q_DECLARE_TR_FUNCTIONS(VRawLayout) + Q_DECLARE_TR_FUNCTIONS(VRawLayout) // NOLINT public: VRawLayout(); diff --git a/src/libs/vlayout/vrawsapoint.h b/src/libs/vlayout/vrawsapoint.h index 785e6c489..7df23f1c7 100644 --- a/src/libs/vlayout/vrawsapoint.h +++ b/src/libs/vlayout/vrawsapoint.h @@ -55,7 +55,7 @@ private: }; Q_DECLARE_METATYPE(VRawSAPoint) -Q_DECLARE_TYPEINFO(VRawSAPoint, Q_MOVABLE_TYPE); +Q_DECLARE_TYPEINFO(VRawSAPoint, Q_MOVABLE_TYPE); // NOLINT //--------------------------------------------------------------------------------------------------------------------- Q_DECL_CONSTEXPR inline VRawSAPoint::VRawSAPoint() diff --git a/src/libs/vlayout/vsapoint.h b/src/libs/vlayout/vsapoint.h index 3bdc06b36..00ee4b3c2 100644 --- a/src/libs/vlayout/vsapoint.h +++ b/src/libs/vlayout/vsapoint.h @@ -83,7 +83,7 @@ private: }; Q_DECLARE_METATYPE(VSAPoint) -Q_DECLARE_TYPEINFO(VSAPoint, Q_MOVABLE_TYPE); +Q_DECLARE_TYPEINFO(VSAPoint, Q_MOVABLE_TYPE); // NOLINT //--------------------------------------------------------------------------------------------------------------------- Q_DECL_CONSTEXPR inline VSAPoint::VSAPoint() V_NOEXCEPT_EXPR (true) diff --git a/src/libs/vlayout/vtextmanager.h b/src/libs/vlayout/vtextmanager.h index 5e717f05c..0c9ecdf03 100644 --- a/src/libs/vlayout/vtextmanager.h +++ b/src/libs/vlayout/vtextmanager.h @@ -70,7 +70,7 @@ private: */ class VTextManager { - Q_DECLARE_TR_FUNCTIONS(VTextManager) + Q_DECLARE_TR_FUNCTIONS(VTextManager) // NOLINT public: VTextManager(); virtual ~VTextManager() = default; diff --git a/src/libs/vmisc/backport/qscopeguard.h b/src/libs/vmisc/backport/qscopeguard.h index 773e292a2..f461b04f9 100644 --- a/src/libs/vmisc/backport/qscopeguard.h +++ b/src/libs/vmisc/backport/qscopeguard.h @@ -68,7 +68,7 @@ private: : m_func(std::move(f)) { } - Q_DISABLE_COPY(QScopeGuard) + Q_DISABLE_COPY_MOVE(QScopeGuard) // NOLINT F m_func; bool m_invoke = true; friend QScopeGuard qScopeGuard(F); diff --git a/src/libs/vmisc/def.cpp b/src/libs/vmisc/def.cpp index 123e8fe54..361fc7f33 100644 --- a/src/libs/vmisc/def.cpp +++ b/src/libs/vmisc/def.cpp @@ -281,11 +281,11 @@ void InitHighDpiScaling(int argc, char *argv[]) } } -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strTMark, (QLatin1String("tMark"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strVMark, (QLatin1String("vMark"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strVMark2, (QLatin1String("vMark2"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strUMark, (QLatin1String("uMark"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strBoxMark, (QLatin1String("boxMark"))) +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strTMark, (QLatin1String("tMark"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strVMark, (QLatin1String("vMark"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strVMark2, (QLatin1String("vMark2"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strUMark, (QLatin1String("uMark"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strBoxMark, (QLatin1String("boxMark"))) // NOLINT //--------------------------------------------------------------------------------------------------------------------- QString PassmarkLineTypeToString(PassmarkLineType type) diff --git a/src/libs/vmisc/def.h b/src/libs/vmisc/def.h index c7b9850be..fbe8017d5 100644 --- a/src/libs/vmisc/def.h +++ b/src/libs/vmisc/def.h @@ -556,7 +556,7 @@ private: }; Q_DECLARE_METATYPE(CustomSARecord) -Q_DECLARE_TYPEINFO(CustomSARecord, Q_MOVABLE_TYPE); +Q_DECLARE_TYPEINFO(CustomSARecord, Q_MOVABLE_TYPE); // NOLINT /**************************************************************************** ** This file is derived from code bearing the following notice: ** The sole author of this file, Adam Higerd, has explicitly disclaimed all @@ -611,7 +611,7 @@ protected: } private: - Q_DISABLE_COPY(QxtPrivate) + Q_DISABLE_COPY_MOVE(QxtPrivate) // NOLINT PUB* qxt_p_ptr; }; @@ -651,7 +651,7 @@ public: return static_cast(pvt); } private: - Q_DISABLE_COPY(QxtPrivateInterface) + Q_DISABLE_COPY_MOVE(QxtPrivateInterface) // NOLINT QxtPrivate* pvt; }; diff --git a/src/libs/vmisc/defglobal.h b/src/libs/vmisc/defglobal.h index 7479967a1..7aff87ec8 100644 --- a/src/libs/vmisc/defglobal.h +++ b/src/libs/vmisc/defglobal.h @@ -30,8 +30,6 @@ #include -#include "backport/qoverload.h" - constexpr qreal PrintDPI = 96.0; #if QT_VERSION < QT_VERSION_CHECK(5, 7, 0) diff --git a/src/libs/vmisc/dialogs/dialogexporttocsv.h b/src/libs/vmisc/dialogs/dialogexporttocsv.h index d97dc3c1e..6954e685d 100644 --- a/src/libs/vmisc/dialogs/dialogexporttocsv.h +++ b/src/libs/vmisc/dialogs/dialogexporttocsv.h @@ -31,6 +31,8 @@ #include +#include "../vmisc/defglobal.h" + namespace Ui { class DialogExportToCSV; @@ -38,7 +40,7 @@ namespace Ui class DialogExportToCSV : public QDialog { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit DialogExportToCSV(QWidget *parent = nullptr); @@ -63,7 +65,8 @@ protected: virtual void showEvent(QShowEvent *event) override; private: - Q_DISABLE_COPY(DialogExportToCSV) + // cppcheck-suppress unknownMacro + Q_DISABLE_COPY_MOVE(DialogExportToCSV) // NOLINT Ui::DialogExportToCSV *ui; bool isInitialized; QString m_fileName; diff --git a/src/libs/vmisc/dialogs/dialogselectlanguage.h b/src/libs/vmisc/dialogs/dialogselectlanguage.h index c3593ce9c..bca913212 100644 --- a/src/libs/vmisc/dialogs/dialogselectlanguage.h +++ b/src/libs/vmisc/dialogs/dialogselectlanguage.h @@ -30,6 +30,8 @@ #include +#include "../vmisc/defglobal.h" + namespace Ui { class DialogSelectLanguage; @@ -37,7 +39,7 @@ class DialogSelectLanguage; class DialogSelectLanguage : public QDialog { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit DialogSelectLanguage(QWidget *parent = nullptr); @@ -46,7 +48,8 @@ public: QString Locale() const; private: - Q_DISABLE_COPY(DialogSelectLanguage) + // cppcheck-suppress unknownMacro + Q_DISABLE_COPY_MOVE(DialogSelectLanguage) // NOLINT Ui::DialogSelectLanguage *ui; }; diff --git a/src/libs/vmisc/qt_dispatch/qt_dispatch.h b/src/libs/vmisc/qt_dispatch/qt_dispatch.h index 51f03c7ff..592d0d935 100644 --- a/src/libs/vmisc/qt_dispatch/qt_dispatch.h +++ b/src/libs/vmisc/qt_dispatch/qt_dispatch.h @@ -19,7 +19,7 @@ typedef std::function voidBlock; class WorkerClass : public QObject { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit WorkerClass(QThread *thread) @@ -55,7 +55,7 @@ typedef std::function #include "../vmisc/def.h" -#include "../vmisc/vmath.h" #include "../vmisc/compatibility.h" #include "../vmisc/literals.h" -#include "../vpatterndb/pmsystems.h" const int VCommonSettings::defaultScrollingDuration = 300; const int VCommonSettings::scrollingDurationMin = 100; @@ -70,112 +68,111 @@ const qreal VCommonSettings::defaultScrollingAcceleration = 1.3; const qreal VCommonSettings::scrollingAccelerationMin = 1.0; const qreal VCommonSettings::scrollingAccelerationMax = 10.0; -Q_DECLARE_METATYPE(QMarginsF) +Q_DECLARE_METATYPE(QMarginsF) // NOLINT namespace { -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPathsIndividualMeasurements, (QLatin1String("paths/individual_measurements"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPathsMultisizeMeasurements, (QLatin1String("paths/standard_measurements"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPathsPattern, (QLatin1String("paths/pattern"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPathsTemplates, (QLatin1String("paths/templates"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPathsLabelTemplate, (QLatin1String("paths/labels"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPathsManualLayouts, (QLatin1String("paths/manualLayouts"))) +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPathsIndividualMeasurements, (QLatin1String("paths/individual_measurements"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPathsMultisizeMeasurements, (QLatin1String("paths/standard_measurements"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPathsPattern, (QLatin1String("paths/pattern"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPathsTemplates, (QLatin1String("paths/templates"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPathsLabelTemplate, (QLatin1String("paths/labels"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPathsManualLayouts, (QLatin1String("paths/manualLayouts"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationOsSeparator, (QLatin1String("configuration/osSeparator"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationAutosaveState, (QLatin1String("configuration/autosave/state"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationAutosaveTime , (QLatin1String("configuration/autosave/time"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationLocale, (QLatin1String("configuration/locale"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPMSystemCode, (QLatin1String("configuration/pmscode"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationUnit, (QLatin1String("configuration/unit"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationConfirmItemDeletion, (QLatin1String("configuration/confirm_item_deletion"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationConfirmFormatRewriting, (QLatin1String("configuration/confirm_format_rewriting"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationAskContinueIfLayoutStale, (QLatin1String("configuration/askContinueIfLayoutStale"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationToolBarStyle, (QLatin1String("configuration/tool_bar_style"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationFreeCurveMode, (QLatin1String("configuration/freeCurveMode"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationDoubleClickZoomFitBestCurrentPP, (QLatin1String("configuration/doubleClickZoomFitBestCurrentPP"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationDontUseNativeDialog, (QLatin1String("configuration/dontUseNativeDialog"))) +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationOsSeparator, (QLatin1String("configuration/osSeparator"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationAutosaveState, (QLatin1String("configuration/autosave/state"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationAutosaveTime , (QLatin1String("configuration/autosave/time"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationLocale, (QLatin1String("configuration/locale"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPMSystemCode, (QLatin1String("configuration/pmscode"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationUnit, (QLatin1String("configuration/unit"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationConfirmItemDeletion, (QLatin1String("configuration/confirm_item_deletion"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationConfirmFormatRewriting, (QLatin1String("configuration/confirm_format_rewriting"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationAskContinueIfLayoutStale, (QLatin1String("configuration/askContinueIfLayoutStale"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationToolBarStyle, (QLatin1String("configuration/tool_bar_style"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationFreeCurveMode, (QLatin1String("configuration/freeCurveMode"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationDoubleClickZoomFitBestCurrentPP, (QLatin1String("configuration/doubleClickZoomFitBestCurrentPP"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationDontUseNativeDialog, (QLatin1String("configuration/dontUseNativeDialog"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternUndo, (QLatin1String("pattern/undo"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternForbidFlipping, (QLatin1String("pattern/forbidFlipping"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternForceFlipping, (QLatin1String("pattern/forceFlipping"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternHideMainPath, (QLatin1String("pattern/hideMainPath"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingDoublePassmark, (QLatin1String("pattern/doublePassmark"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternDefaultSeamAllowance, (QLatin1String("pattern/defaultSeamAllowance"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternLabelFont, (QLatin1String("pattern/labelFont"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternLineWidth, (QLatin1String("pattern/lineWidth"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternCurveApproximationScale, (QLatin1String("pattern/curveApproximationScale"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternShowCurveDetails, (QLatin1String("pattern/showCurveDetails"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternPieceShowMainPath, (QLatin1String("pattern/pieceShowMainPath"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternLabelFontSize, (QLatin1String("pattern/labelFontSize"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternHideLabels, (QLatin1String("pattern/hideLabels"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternUseOpenGLRender, (QLatin1String("pattern/useOpenGLRender"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternGraphicalOutput, (QLatin1String("pattern/graphicalOutput"))) +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternUndo, (QLatin1String("pattern/undo"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternForbidFlipping, (QLatin1String("pattern/forbidFlipping"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternForceFlipping, (QLatin1String("pattern/forceFlipping"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternHideMainPath, (QLatin1String("pattern/hideMainPath"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingDoublePassmark, (QLatin1String("pattern/doublePassmark"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternDefaultSeamAllowance, (QLatin1String("pattern/defaultSeamAllowance"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternLabelFont, (QLatin1String("pattern/labelFont"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternLineWidth, (QLatin1String("pattern/lineWidth"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternCurveApproximationScale, (QLatin1String("pattern/curveApproximationScale"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternShowCurveDetails, (QLatin1String("pattern/showCurveDetails"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternPieceShowMainPath, (QLatin1String("pattern/pieceShowMainPath"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternLabelFontSize, (QLatin1String("pattern/labelFontSize"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternHideLabels, (QLatin1String("pattern/hideLabels"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternUseOpenGLRender, (QLatin1String("pattern/useOpenGLRender"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternGraphicalOutput, (QLatin1String("pattern/graphicalOutput"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingGeneralRecentFileList, (QLatin1String("recentFileList"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingGeneralRestoreFileList, (QLatin1String("restoreFileList"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingGeneralGeometry, (QLatin1String("geometry"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingGeneralWindowState, (QLatin1String("windowState"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingGeneralToolbarsState, (QLatin1String("toolbarsState"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationDarkMode, (QLatin1String("configuration/dark_mode"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPreferenceDialogSize, (QLatin1String("preferenceDialogSize"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingToolSeamAllowanceDialogSize, (QLatin1String("toolSeamAllowanceDialogSize"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingIncrementsDialogSize, (QLatin1String("toolIncrementsDialogSize"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingFormulaWizardDialogSize, (QLatin1String("formulaWizardDialogSize"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingFinalMeasurementsDialogSize, (QLatin1String("finalMeasurementsDialogSize"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutSettingsDialogSize, (QLatin1String("layoutSettingsDialogSize"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingAutomaticallyCheckUpdates, (QLatin1String("automaticallyCheckUpdates"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLatestSkippedVersion, (QLatin1String("lastestSkippedVersion"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingDateOfLastRemind, (QLatin1String("dateOfLastRemind"))) +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingGeneralRecentFileList, (QLatin1String("recentFileList"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingGeneralRestoreFileList, (QLatin1String("restoreFileList"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingGeneralGeometry, (QLatin1String("geometry"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingGeneralWindowState, (QLatin1String("windowState"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingGeneralToolbarsState, (QLatin1String("toolbarsState"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationDarkMode, (QLatin1String("configuration/dark_mode"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPreferenceDialogSize, (QLatin1String("preferenceDialogSize"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingToolSeamAllowanceDialogSize, (QLatin1String("toolSeamAllowanceDialogSize"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingIncrementsDialogSize, (QLatin1String("toolIncrementsDialogSize"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingFormulaWizardDialogSize, (QLatin1String("formulaWizardDialogSize"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingFinalMeasurementsDialogSize, (QLatin1String("finalMeasurementsDialogSize"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutSettingsDialogSize, (QLatin1String("layoutSettingsDialogSize"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingAutomaticallyCheckUpdates, (QLatin1String("automaticallyCheckUpdates"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLatestSkippedVersion, (QLatin1String("lastestSkippedVersion"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingDateOfLastRemind, (QLatin1String("dateOfLastRemind"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingCSVWithHeader, (QLatin1String("csv/withHeader"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingCSVCodec, (QLatin1String("csv/withCodec"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingCSVSeparator, (QLatin1String("csv/withSeparator"))) +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingCSVWithHeader, (QLatin1String("csv/withHeader"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingCSVCodec, (QLatin1String("csv/withCodec"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingCSVSeparator, (QLatin1String("csv/withSeparator"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLabelDateFormat, (QLatin1String("label/dateFormat"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLabelUserDateFormats, (QLatin1String("label/userDateFormats"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLabelTimeFormat, (QLatin1String("label/timeFormat"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLabelUserTimeFormats, (QLatin1String("label/userTimeFormats"))) +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLabelDateFormat, (QLatin1String("label/dateFormat"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLabelUserDateFormats, (QLatin1String("label/userDateFormats"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLabelTimeFormat, (QLatin1String("label/timeFormat"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLabelUserTimeFormats, (QLatin1String("label/userTimeFormats"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingScrollingDuration, (QLatin1String("scrolling/duration"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingScrollingUpdateInterval, (QLatin1String("scrolling/updateInterval"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingScrollingSensorMouseScale, - (QLatin1String("scrolling/sensorMouseScale"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingScrollingWheelMouseScale, (QLatin1String("scrolling/wheelMouseScale"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingScrollingAcceleration, (QLatin1String("scrolling/acceleration"))) +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingScrollingDuration, (QLatin1String("scrolling/duration"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingScrollingUpdateInterval, (QLatin1String("scrolling/updateInterval"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingScrollingSensorMouseScale, (QLatin1String("scrolling/sensorMouseScale"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingScrollingWheelMouseScale, (QLatin1String("scrolling/wheelMouseScale"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingScrollingAcceleration, (QLatin1String("scrolling/acceleration"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingTiledPDFMargins, (QLatin1String("tiledPDF/margins"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingTiledPDFOrientation, (QLatin1String("tiledPDF/orientation"))) +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingTiledPDFMargins, (QLatin1String("tiledPDF/margins"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingTiledPDFOrientation, (QLatin1String("tiledPDF/orientation"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingWatermarkEditorSize, (QLatin1String("watermarkEditorSize"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingWatermarkCustomColors, (QLatin1String("watermarkCustomColors"))) +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingWatermarkEditorSize, (QLatin1String("watermarkEditorSize"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingWatermarkCustomColors, (QLatin1String("watermarkCustomColors"))) // NOLINT // Reading settings file is very expensive, cache curve approximation to speed up getting value -qreal curveApproximationCached = -1; -Q_GLOBAL_STATIC(QString, localeCached) -qreal lineWidthCached = 0; -int labelFontSizeCached = 0; -int pieceShowMainPath = -1; -int scrollingDurationCached = -1; -int scrollingUpdateIntervalCached = -1; -qreal scrollingSensorMouseScaleCached = -1; -qreal scrollingWheelMouseScaleCached = -1; -qreal scrollingAccelerationCached = -1; +qreal curveApproximationCached = -1; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables) +Q_GLOBAL_STATIC(QString, localeCached) // NOLINT +qreal lineWidthCached = 0; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables) +int labelFontSizeCached = 0; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables) +int pieceShowMainPath = -1; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables) +int scrollingDurationCached = -1; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables) +int scrollingUpdateIntervalCached = -1; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables) +qreal scrollingSensorMouseScaleCached = -1; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables) +qreal scrollingWheelMouseScaleCached = -1; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables) +qreal scrollingAccelerationCached = -1; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables) //--------------------------------------------------------------------------------------------------------------------- -QStringList ClearFormats(const QStringList &predefinedFormats, QStringList formats) +auto ClearFormats(const QStringList &predefinedFormats, QStringList formats) -> QStringList { - for (auto &f : predefinedFormats) + for (const auto &f : predefinedFormats) { formats.removeAll(f); } return formats; } -} +} // namespace -Q_GLOBAL_STATIC_WITH_ARGS(const QString, commonIniFilename, (QLatin1String("common"))) +Q_GLOBAL_STATIC_WITH_ARGS(const QString, commonIniFilename, (QLatin1String("common"))) // NOLINT #if !defined(Q_OS_WIN) -const QString VCommonSettings::unixStandardSharePath = PKGDATADIR; +const QString VCommonSettings::unixStandardSharePath = QStringLiteral(PKGDATADIR); // NOLINT(cert-err58-cpp) #endif namespace @@ -232,14 +229,10 @@ void SymlinkCopyDirRecursive(const QString &fromDir, const QString &toDir, bool } else if (fileTo.isSymLink()) { - if (not fileTo.exists()) + if (not fileTo.exists() || replaceOnConflit) { // automatically fix broken symlink QFile::remove(to); } - else if (replaceOnConflit) - { - QFile::remove(to); - } else { continue; @@ -255,7 +248,7 @@ void SymlinkCopyDirRecursive(const QString &fromDir, const QString &toDir, bool const QString from = fromDir + QDir::separator() + copyDir; const QString to = toDir + QDir::separator() + copyDir; - if (dir.mkpath(to) == false) + if (not dir.mkpath(to)) { return; } @@ -265,7 +258,7 @@ void SymlinkCopyDirRecursive(const QString &fromDir, const QString &toDir, bool } //--------------------------------------------------------------------------------------------------------------------- -QString PrepareStandardFiles(const QString ¤tPath, const QString &standardPath, const QString &defPath) +auto PrepareStandardFiles(const QString ¤tPath, const QString &standardPath, const QString &defPath) -> QString { QDir standardPathDir(standardPath); QDir currentPathDir(currentPath); @@ -280,7 +273,7 @@ QString PrepareStandardFiles(const QString ¤tPath, const QString &standard } return currentPath; } -} +} // namespace //--------------------------------------------------------------------------------------------------------------------- VCommonSettings::VCommonSettings(Format format, Scope scope, const QString &organization, @@ -294,7 +287,7 @@ VCommonSettings::VCommonSettings(const QString &fileName, QSettings::Format form {} //--------------------------------------------------------------------------------------------------------------------- -QString VCommonSettings::SharePath(const QString &shareItem) +auto VCommonSettings::SharePath(const QString &shareItem) -> QString { #ifdef Q_OS_WIN return QCoreApplication::applicationDirPath() + shareItem; @@ -338,49 +331,50 @@ QString VCommonSettings::SharePath(const QString &shareItem) } //--------------------------------------------------------------------------------------------------------------------- -QString VCommonSettings::MultisizeTablesPath() +auto VCommonSettings::MultisizeTablesPath() -> QString { return SharePath(QStringLiteral("/tables/multisize")); } //--------------------------------------------------------------------------------------------------------------------- -QString VCommonSettings::StandardTemplatesPath() +auto VCommonSettings::StandardTemplatesPath() -> QString { return SharePath(QStringLiteral("/tables/templates")); } //--------------------------------------------------------------------------------------------------------------------- -QString VCommonSettings::LabelTemplatesPath() +auto VCommonSettings::LabelTemplatesPath() -> QString { return SharePath(QStringLiteral("/labels")); } //--------------------------------------------------------------------------------------------------------------------- -QString VCommonSettings::PrepareStandardTemplates(const QString & currentPath) +auto VCommonSettings::PrepareStandardTemplates(const QString & currentPath) -> QString { return PrepareStandardFiles(currentPath, StandardTemplatesPath(), GetDefPathTemplate()); } //--------------------------------------------------------------------------------------------------------------------- -QString VCommonSettings::PrepareMultisizeTables(const QString ¤tPath) +auto VCommonSettings::PrepareMultisizeTables(const QString ¤tPath) -> QString { return PrepareStandardFiles(currentPath, MultisizeTablesPath(), GetDefPathMultisizeMeasurements()); } //--------------------------------------------------------------------------------------------------------------------- -QString VCommonSettings::PrepareLabelTemplates(const QString ¤tPath) +auto VCommonSettings::PrepareLabelTemplates(const QString ¤tPath) -> QString { return PrepareStandardFiles(currentPath, LabelTemplatesPath(), GetDefPathLabelTemplate()); } //--------------------------------------------------------------------------------------------------------------------- -QString VCommonSettings::GetDefPathIndividualMeasurements() +auto VCommonSettings::GetDefPathIndividualMeasurements() -> QString { - return QDir::homePath() + QLatin1String("/valentina/") + tr("measurements") + QLatin1String("/") + tr("individual"); + return QDir::homePath() + QStringLiteral("/valentina/") + tr("measurements") + QStringLiteral("/") + + tr("individual"); } //--------------------------------------------------------------------------------------------------------------------- -QString VCommonSettings::GetPathIndividualMeasurements() const +auto VCommonSettings::GetPathIndividualMeasurements() const -> QString { QSettings settings(this->format(), this->scope(), this->organizationName(), *commonIniFilename); return settings.value(*settingPathsIndividualMeasurements, GetDefPathIndividualMeasurements()).toString(); @@ -395,13 +389,13 @@ void VCommonSettings::SetPathIndividualMeasurements(const QString &value) } //--------------------------------------------------------------------------------------------------------------------- -QString VCommonSettings::GetDefPathMultisizeMeasurements() +auto VCommonSettings::GetDefPathMultisizeMeasurements() -> QString { - return QDir::homePath() + QLatin1String("/valentina/") + tr("measurements") + QLatin1String("/") + tr("multisize"); + return QDir::homePath() + QStringLiteral("/valentina/") + tr("measurements") + QChar('/') + tr("multisize"); } //--------------------------------------------------------------------------------------------------------------------- -QString VCommonSettings::GetPathMultisizeMeasurements() const +auto VCommonSettings::GetPathMultisizeMeasurements() const -> QString { QSettings settings(this->format(), this->scope(), this->organizationName(), *commonIniFilename); return settings.value(*settingPathsMultisizeMeasurements, GetDefPathMultisizeMeasurements()).toString(); @@ -416,13 +410,13 @@ void VCommonSettings::SetPathMultisizeMeasurements(const QString &value) } //--------------------------------------------------------------------------------------------------------------------- -QString VCommonSettings::GetDefPathPattern() +auto VCommonSettings::GetDefPathPattern() -> QString { - return QDir::homePath() + QLatin1String("/valentina/") + tr("patterns"); + return QDir::homePath() + QStringLiteral("/valentina/") + tr("patterns"); } //--------------------------------------------------------------------------------------------------------------------- -QString VCommonSettings::GetPathPattern() const +auto VCommonSettings::GetPathPattern() const -> QString { QSettings settings(this->format(), this->scope(), this->organizationName(), *commonIniFilename); return settings.value(*settingPathsPattern, GetDefPathPattern()).toString(); @@ -437,13 +431,13 @@ void VCommonSettings::SetPathPattern(const QString &value) } //--------------------------------------------------------------------------------------------------------------------- -QString VCommonSettings::GetDefPathTemplate() +auto VCommonSettings::GetDefPathTemplate() -> QString { - return QDir::homePath() + QLatin1String("/valentina/") + tr("templates"); + return QDir::homePath() + QStringLiteral("/valentina/") + tr("templates"); } //--------------------------------------------------------------------------------------------------------------------- -QString VCommonSettings::GetPathTemplate() const +auto VCommonSettings::GetPathTemplate() const -> QString { QSettings settings(this->format(), this->scope(), this->organizationName(), *commonIniFilename); return settings.value(*settingPathsTemplates, GetDefPathTemplate()).toString(); @@ -458,13 +452,13 @@ void VCommonSettings::SetPathTemplate(const QString &value) } //--------------------------------------------------------------------------------------------------------------------- -QString VCommonSettings::GetDefPathLabelTemplate() +auto VCommonSettings::GetDefPathLabelTemplate() -> QString { - return QDir::homePath() + QLatin1String("/valentina/") + tr("label templates"); + return QDir::homePath() + QStringLiteral("/valentina/") + tr("label templates"); } //--------------------------------------------------------------------------------------------------------------------- -QString VCommonSettings::GetPathLabelTemplate() const +auto VCommonSettings::GetPathLabelTemplate() const -> QString { return value(*settingPathsLabelTemplate, GetDefPathLabelTemplate()).toString(); } @@ -476,13 +470,13 @@ void VCommonSettings::SetPathLabelTemplate(const QString &value) } //--------------------------------------------------------------------------------------------------------------------- -QString VCommonSettings::GetDefPathManualLayouts() +auto VCommonSettings::GetDefPathManualLayouts() -> QString { - return QDir::homePath() + QLatin1String("/valentina/") + tr("manual layouts"); + return QDir::homePath() + QStringLiteral("/valentina/") + tr("manual layouts"); } //--------------------------------------------------------------------------------------------------------------------- -QString VCommonSettings::GetPathManualLayouts() const +auto VCommonSettings::GetPathManualLayouts() const -> QString { return value(*settingPathsManualLayouts, GetDefPathManualLayouts()).toString(); } @@ -494,7 +488,7 @@ void VCommonSettings::SetPathManualLayouts(const QString &value) } //--------------------------------------------------------------------------------------------------------------------- -bool VCommonSettings::GetOsSeparator() const +auto VCommonSettings::GetOsSeparator() const -> bool { return value(*settingConfigurationOsSeparator, 1).toBool(); } @@ -506,7 +500,7 @@ void VCommonSettings::SetOsSeparator(const bool &value) } //--------------------------------------------------------------------------------------------------------------------- -bool VCommonSettings::GetAutosaveState() const +auto VCommonSettings::GetAutosaveState() const -> bool { return value(*settingConfigurationAutosaveState, 1).toBool(); } @@ -518,11 +512,11 @@ void VCommonSettings::SetAutosaveState(const bool &value) } //--------------------------------------------------------------------------------------------------------------------- -int VCommonSettings::GetAutosaveTime() const +auto VCommonSettings::GetAutosaveTime() const -> int { bool ok = false; int val = value(*settingConfigurationAutosaveTime, 1).toInt(&ok); - if (ok == false) + if (not ok) { qDebug()<<"Could not convert value"< bool } //--------------------------------------------------------------------------------------------------------------------- -QString VCommonSettings::GetLocale() const +auto VCommonSettings::GetLocale() const -> QString { if (localeCached->isEmpty()) { @@ -564,7 +558,7 @@ void VCommonSettings::SetLocale(const QString &value) } //--------------------------------------------------------------------------------------------------------------------- -QString VCommonSettings::GetPMSystemCode() const +auto VCommonSettings::GetPMSystemCode() const -> QString { return value(*settingPMSystemCode, "p998").toString(); } @@ -576,7 +570,7 @@ void VCommonSettings::SetPMSystemCode(const QString &value) } //--------------------------------------------------------------------------------------------------------------------- -QString VCommonSettings::GetUnit() const +auto VCommonSettings::GetUnit() const -> QString { return value(*settingConfigurationUnit, QLocale().measurementSystem() == QLocale::MetricSystem ? unitCM : unitINCH).toString(); @@ -589,7 +583,7 @@ void VCommonSettings::SetUnit(const QString &value) } //--------------------------------------------------------------------------------------------------------------------- -bool VCommonSettings::GetConfirmItemDelete() const +auto VCommonSettings::GetConfirmItemDelete() const -> bool { return value(*settingConfigurationConfirmItemDeletion, 1).toBool(); } @@ -601,7 +595,7 @@ void VCommonSettings::SetConfirmItemDelete(const bool &value) } //--------------------------------------------------------------------------------------------------------------------- -bool VCommonSettings::GetConfirmFormatRewriting() const +auto VCommonSettings::GetConfirmFormatRewriting() const -> bool { return value(*settingConfigurationConfirmFormatRewriting, 1).toBool(); } @@ -613,7 +607,7 @@ void VCommonSettings::SetConfirmFormatRewriting(const bool &value) } //--------------------------------------------------------------------------------------------------------------------- -bool VCommonSettings::GetAskContinueIfLayoutStale() const +auto VCommonSettings::GetAskContinueIfLayoutStale() const -> bool { return value(*settingConfigurationAskContinueIfLayoutStale, 1).toBool(); } @@ -625,7 +619,7 @@ void VCommonSettings::SetAskContinueIfLayoutStale(const bool &value) } //--------------------------------------------------------------------------------------------------------------------- -bool VCommonSettings::GetToolBarStyle() const +auto VCommonSettings::GetToolBarStyle() const -> bool { return value(*settingConfigurationToolBarStyle, 1).toBool(); } @@ -637,7 +631,7 @@ void VCommonSettings::SetToolBarStyle(const bool &value) } //--------------------------------------------------------------------------------------------------------------------- -bool VCommonSettings::GetDarkMode() const +auto VCommonSettings::GetDarkMode() const -> bool { return value(*settingConfigurationDarkMode, 0).toBool(); } @@ -650,7 +644,7 @@ void VCommonSettings::SetDarkMode(const bool &value) //--------------------------------------------------------------------------------------------------------------------- -bool VCommonSettings::IsFreeCurveMode() const +auto VCommonSettings::IsFreeCurveMode() const -> bool { return value(*settingConfigurationFreeCurveMode, 1).toBool(); } @@ -662,7 +656,7 @@ void VCommonSettings::SetFreeCurveMode(bool value) } //--------------------------------------------------------------------------------------------------------------------- -bool VCommonSettings::IsDoubleClickZoomFitBestCurrentPP() const +auto VCommonSettings::IsDoubleClickZoomFitBestCurrentPP() const -> bool { return value(*settingConfigurationDoubleClickZoomFitBestCurrentPP, 1).toBool(); } @@ -674,11 +668,11 @@ void VCommonSettings::SetDoubleClickZoomFitBestCurrentPP(bool value) } //--------------------------------------------------------------------------------------------------------------------- -int VCommonSettings::GetUndoCount() const +auto VCommonSettings::GetUndoCount() const -> int { bool ok = false; int val = value(*settingPatternUndo, 0).toInt(&ok); - if (ok == false) + if (not ok) { qDebug()<<"Could not convert value"< QStringList { const QStringList files = value(*settingGeneralRecentFileList).toStringList(); QStringList cleared; - for (auto &f : files) + for (const auto &f : files) { if (QFileInfo::exists(f)) { @@ -717,7 +711,7 @@ void VCommonSettings::SetRecentFileList(const QStringList &value) } //--------------------------------------------------------------------------------------------------------------------- -QStringList VCommonSettings::GetRestoreFileList() const +auto VCommonSettings::GetRestoreFileList() const -> QStringList { return value(*settingGeneralRestoreFileList).toStringList(); } @@ -729,7 +723,7 @@ void VCommonSettings::SetRestoreFileList(const QStringList &value) } //--------------------------------------------------------------------------------------------------------------------- -QByteArray VCommonSettings::GetGeometry() const +auto VCommonSettings::GetGeometry() const -> QByteArray { return value(*settingGeneralGeometry).toByteArray(); } @@ -741,7 +735,7 @@ void VCommonSettings::SetGeometry(const QByteArray &value) } //--------------------------------------------------------------------------------------------------------------------- -QByteArray VCommonSettings::GetWindowState() const +auto VCommonSettings::GetWindowState() const -> QByteArray { return value(*settingGeneralWindowState).toByteArray(); } @@ -753,7 +747,7 @@ void VCommonSettings::SetWindowState(const QByteArray &value) } //--------------------------------------------------------------------------------------------------------------------- -QByteArray VCommonSettings::GetToolbarsState() const +auto VCommonSettings::GetToolbarsState() const -> QByteArray { return value(*settingGeneralToolbarsState).toByteArray(); } @@ -765,7 +759,7 @@ void VCommonSettings::SetToolbarsState(const QByteArray &value) } //--------------------------------------------------------------------------------------------------------------------- -QSize VCommonSettings::GetPreferenceDialogSize() const +auto VCommonSettings::GetPreferenceDialogSize() const -> QSize { return value(*settingPreferenceDialogSize, QSize(0, 0)).toSize(); } @@ -777,7 +771,7 @@ void VCommonSettings::SetPreferenceDialogSize(const QSize& sz) } //--------------------------------------------------------------------------------------------------------------------- -QSize VCommonSettings::GetToolSeamAllowanceDialogSize() const +auto VCommonSettings::GetToolSeamAllowanceDialogSize() const -> QSize { return value(*settingToolSeamAllowanceDialogSize, QSize(0, 0)).toSize(); } @@ -789,7 +783,7 @@ void VCommonSettings::SetToolSeamAllowanceDialogSize(const QSize &sz) } //--------------------------------------------------------------------------------------------------------------------- -QSize VCommonSettings::GetFormulaWizardDialogSize() const +auto VCommonSettings::GetFormulaWizardDialogSize() const -> QSize { return value(*settingFormulaWizardDialogSize, QSize(0, 0)).toSize(); } @@ -801,7 +795,7 @@ void VCommonSettings::SetFormulaWizardDialogSize(const QSize &sz) } //--------------------------------------------------------------------------------------------------------------------- -QSize VCommonSettings::GetIncrementsDialogSize() const +auto VCommonSettings::GetIncrementsDialogSize() const -> QSize { return value(*settingIncrementsDialogSize, QSize(0, 0)).toSize(); } @@ -813,7 +807,7 @@ void VCommonSettings::SetIncrementsDialogSize(const QSize &sz) } //--------------------------------------------------------------------------------------------------------------------- -QSize VCommonSettings::GetFinalMeasurementsDialogSize() const +auto VCommonSettings::GetFinalMeasurementsDialogSize() const -> QSize { return value(*settingFinalMeasurementsDialogSize, QSize(0, 0)).toSize(); } @@ -837,7 +831,7 @@ void VCommonSettings::SetLayoutSettingsDialogSize(const QSize &sz) } //--------------------------------------------------------------------------------------------------------------------- -bool VCommonSettings::IsAutomaticallyCheckUpdates() const +auto VCommonSettings::IsAutomaticallyCheckUpdates() const -> bool { QSettings settings(this->format(), this->scope(), this->organizationName(), *commonIniFilename); return settings.value(*settingAutomaticallyCheckUpdates, true).toBool(); @@ -852,7 +846,7 @@ void VCommonSettings::SetAutomaticallyCheckUpdates(bool value) } //--------------------------------------------------------------------------------------------------------------------- -unsigned VCommonSettings::GetLatestSkippedVersion() const +auto VCommonSettings::GetLatestSkippedVersion() const -> unsigned { QSettings settings(this->format(), this->scope(), this->organizationName(), *commonIniFilename); return settings.value(*settingLatestSkippedVersion, 0x0).toUInt(); @@ -867,7 +861,7 @@ void VCommonSettings::SetLatestSkippedVersion(unsigned value) } //--------------------------------------------------------------------------------------------------------------------- -QDate VCommonSettings::GetDateOfLastRemind() const +auto VCommonSettings::GetDateOfLastRemind() const -> QDate { QSettings settings(this->format(), this->scope(), this->organizationName(), *commonIniFilename); return settings.value(*settingDateOfLastRemind, QDate(1900, 1, 1)).toDate(); @@ -882,7 +876,7 @@ void VCommonSettings::SetDateOfLastRemind(const QDate &date) } //--------------------------------------------------------------------------------------------------------------------- -bool VCommonSettings::GetForbidWorkpieceFlipping() const +auto VCommonSettings::GetForbidWorkpieceFlipping() const -> bool { return value(*settingPatternForbidFlipping, false).toBool(); } @@ -899,7 +893,7 @@ void VCommonSettings::SetForbidWorkpieceFlipping(bool value) } //--------------------------------------------------------------------------------------------------------------------- -bool VCommonSettings::GetForceWorkpieceFlipping() const +auto VCommonSettings::GetForceWorkpieceFlipping() const -> bool { return value(*settingPatternForceFlipping, false).toBool(); } @@ -916,7 +910,7 @@ void VCommonSettings::SetForceWorkpieceFlipping(bool value) } //--------------------------------------------------------------------------------------------------------------------- -bool VCommonSettings::IsHideMainPath() const +auto VCommonSettings::IsHideMainPath() const -> bool { return value(*settingPatternHideMainPath, false).toBool(); } @@ -928,7 +922,7 @@ void VCommonSettings::SetHideMainPath(bool value) } //--------------------------------------------------------------------------------------------------------------------- -bool VCommonSettings::IsDoublePassmark() const +auto VCommonSettings::IsDoublePassmark() const -> bool { return value(*settingDoublePassmark, false).toBool(); } @@ -947,14 +941,14 @@ void VCommonSettings::SetCSVWithHeader(bool withHeader) } //--------------------------------------------------------------------------------------------------------------------- -bool VCommonSettings::GetCSVWithHeader() const +auto VCommonSettings::GetCSVWithHeader() const -> bool { QSettings settings(this->format(), this->scope(), this->organizationName(), *commonIniFilename); return settings.value(*settingCSVWithHeader, GetDefCSVWithHeader()).toBool(); } //--------------------------------------------------------------------------------------------------------------------- -bool VCommonSettings::GetDefCSVWithHeader() +auto VCommonSettings::GetDefCSVWithHeader() -> bool { return false; } @@ -967,14 +961,14 @@ void VCommonSettings::SetCSVCodec(int mib) } //--------------------------------------------------------------------------------------------------------------------- -int VCommonSettings::GetCSVCodec() const +auto VCommonSettings::GetCSVCodec() const -> int { QSettings settings(this->format(), this->scope(), this->organizationName(), *commonIniFilename); return settings.value(*settingCSVCodec, GetDefCSVCodec()).toInt(); } //--------------------------------------------------------------------------------------------------------------------- -int VCommonSettings::GetDefCSVCodec() +auto VCommonSettings::GetDefCSVCodec() -> int { return QTextCodec::codecForLocale()->mibEnum(); } @@ -1001,7 +995,7 @@ void VCommonSettings::SetCSVSeparator(const QChar &separator) } //--------------------------------------------------------------------------------------------------------------------- -QChar VCommonSettings::GetCSVSeparator() const +auto VCommonSettings::GetCSVSeparator() const -> QChar { QSettings settings(this->format(), this->scope(), this->organizationName(), *commonIniFilename); const quint8 separator = static_cast(settings.value(*settingCSVSeparator, 3).toUInt()); @@ -1019,7 +1013,7 @@ QChar VCommonSettings::GetCSVSeparator() const } //--------------------------------------------------------------------------------------------------------------------- -QChar VCommonSettings::GetDefCSVSeparator() +auto VCommonSettings::GetDefCSVSeparator() -> QChar { return QChar(','); } @@ -1035,7 +1029,7 @@ void VCommonSettings::SetDefaultSeamAllowance(double value) * @brief returns the default seam allowance. The corresponding unit is the default unit. * @return the default seam allowance */ -double VCommonSettings::GetDefaultSeamAllowance() +auto VCommonSettings::GetDefaultSeamAllowance() -> double { double defaultValue; @@ -1057,7 +1051,7 @@ double VCommonSettings::GetDefaultSeamAllowance() bool ok = false; double val = value(*settingPatternDefaultSeamAllowance, -1).toDouble(&ok); - if (ok == false) + if (not ok) { qDebug()<< "Could not convert value"< QFont { return qvariant_cast(value(*settingPatternLabelFont, QApplication::font())); } @@ -1090,7 +1084,7 @@ void VCommonSettings::SetLabelFont(const QFont &f) } //--------------------------------------------------------------------------------------------------------------------- -int VCommonSettings::GetLabelFontSize() const +auto VCommonSettings::GetLabelFontSize() const -> int { if (labelFontSizeCached <= 0) { @@ -1114,13 +1108,13 @@ void VCommonSettings::SetLabelFontSize(int size) } //--------------------------------------------------------------------------------------------------------------------- -int VCommonSettings::GetDefLabelFontSize() +auto VCommonSettings::GetDefLabelFontSize() -> int { return 32; } //--------------------------------------------------------------------------------------------------------------------- -bool VCommonSettings::GetHideLabels() const +auto VCommonSettings::GetHideLabels() const -> bool { return value(*settingPatternHideLabels, false).toBool(); } @@ -1132,7 +1126,7 @@ void VCommonSettings::SetHideLabels(bool value) } //--------------------------------------------------------------------------------------------------------------------- -QString VCommonSettings::GetLabelDateFormat() const +auto VCommonSettings::GetLabelDateFormat() const -> QString { const QString format = value(*settingLabelDateFormat, ConstFirst (VCommonSettings::PredefinedDateFormats())).toString(); @@ -1148,7 +1142,7 @@ void VCommonSettings::SetLabelDateFormat(const QString &format) } //--------------------------------------------------------------------------------------------------------------------- -QStringList VCommonSettings::PredefinedDateFormats() +auto VCommonSettings::PredefinedDateFormats() -> QStringList { return QStringList { @@ -1176,7 +1170,7 @@ QStringList VCommonSettings::PredefinedDateFormats() } //--------------------------------------------------------------------------------------------------------------------- -QStringList VCommonSettings::GetUserDefinedDateFormats() const +auto VCommonSettings::GetUserDefinedDateFormats() const -> QStringList { return value(*settingLabelUserDateFormats, QStringList()).toStringList(); } @@ -1188,7 +1182,7 @@ void VCommonSettings::SetUserDefinedDateFormats(const QStringList &formats) } //--------------------------------------------------------------------------------------------------------------------- -QString VCommonSettings::GetLabelTimeFormat() const +auto VCommonSettings::GetLabelTimeFormat() const -> QString { const QString format = value(*settingLabelTimeFormat, ConstFirst (VCommonSettings::PredefinedTimeFormats())).toString(); @@ -1204,7 +1198,7 @@ void VCommonSettings::SetLabelTimeFormat(const QString &format) } //--------------------------------------------------------------------------------------------------------------------- -QStringList VCommonSettings::PredefinedTimeFormats() +auto VCommonSettings::PredefinedTimeFormats() -> QStringList { return QStringList { @@ -1216,7 +1210,7 @@ QStringList VCommonSettings::PredefinedTimeFormats() } //--------------------------------------------------------------------------------------------------------------------- -QStringList VCommonSettings::GetUserDefinedTimeFormats() const +auto VCommonSettings::GetUserDefinedTimeFormats() const -> QStringList { return value(*settingLabelUserTimeFormats, QStringList()).toStringList(); } @@ -1228,7 +1222,7 @@ void VCommonSettings::SetUserDefinedTimeFormats(const QStringList &formats) } //--------------------------------------------------------------------------------------------------------------------- -qreal VCommonSettings::GetCurveApproximationScale() const +auto VCommonSettings::GetCurveApproximationScale() const -> qreal { if (curveApproximationCached < 0) { @@ -1258,7 +1252,7 @@ void VCommonSettings::SetCurveApproximationScale(qreal value) } //--------------------------------------------------------------------------------------------------------------------- -bool VCommonSettings::IsShowCurveDetails() const +auto VCommonSettings::IsShowCurveDetails() const -> bool { return value(*settingPatternShowCurveDetails, false).toBool(); } @@ -1270,7 +1264,7 @@ void VCommonSettings::SetShowCurveDetails(bool value) } //--------------------------------------------------------------------------------------------------------------------- -bool VCommonSettings::IsPieceShowMainPath() const +auto VCommonSettings::IsPieceShowMainPath() const -> bool { if (pieceShowMainPath < 0) { @@ -1287,7 +1281,7 @@ void VCommonSettings::SetPieceShowMainPath(bool value) } //--------------------------------------------------------------------------------------------------------------------- -bool VCommonSettings::IsDontUseNativeDialog() const +auto VCommonSettings::IsDontUseNativeDialog() const -> bool { QSettings settings(this->format(), this->scope(), this->organizationName(), *commonIniFilename); return settings.value(*settingConfigurationDontUseNativeDialog, false).toBool(); @@ -1302,7 +1296,7 @@ void VCommonSettings::SetDontUseNativeDialog(bool value) } //--------------------------------------------------------------------------------------------------------------------- -qreal VCommonSettings::GetLineWidth() const +auto VCommonSettings::GetLineWidth() const -> qreal { if (lineWidthCached <= 0) { @@ -1321,19 +1315,19 @@ void VCommonSettings::SetLineWidth(qreal width) } //--------------------------------------------------------------------------------------------------------------------- -qreal VCommonSettings::WidthMainLine() const +auto VCommonSettings::WidthMainLine() const -> qreal { return GetLineWidth() / 25.4 * PrintDPI; } //--------------------------------------------------------------------------------------------------------------------- -qreal VCommonSettings::WidthHairLine() const +auto VCommonSettings::WidthHairLine() const -> qreal { return WidthMainLine()/3.0; } //--------------------------------------------------------------------------------------------------------------------- -int VCommonSettings::GetScrollingDuration() const +auto VCommonSettings::GetScrollingDuration() const -> int { QSettings settings(this->format(), this->scope(), this->organizationName(), *commonIniFilename); return GetCachedValue(settings, scrollingDurationCached, *settingScrollingDuration, defaultScrollingDuration, @@ -1350,7 +1344,7 @@ void VCommonSettings::SetScrollingDuration(int duration) } //--------------------------------------------------------------------------------------------------------------------- -int VCommonSettings::GetScrollingUpdateInterval() const +auto VCommonSettings::GetScrollingUpdateInterval() const -> int { QSettings settings(this->format(), this->scope(), this->organizationName(), *commonIniFilename); return GetCachedValue(settings, scrollingUpdateIntervalCached, *settingScrollingUpdateInterval, @@ -1367,7 +1361,7 @@ void VCommonSettings::SetScrollingUpdateInterval(int updateInterval) } //--------------------------------------------------------------------------------------------------------------------- -qreal VCommonSettings::GetSensorMouseScale() const +auto VCommonSettings::GetSensorMouseScale() const -> qreal { QSettings settings(this->format(), this->scope(), this->organizationName(), *commonIniFilename); return GetCachedValue(settings, scrollingSensorMouseScaleCached, *settingScrollingSensorMouseScale, @@ -1384,7 +1378,7 @@ void VCommonSettings::SetSensorMouseScale(qreal scale) } //--------------------------------------------------------------------------------------------------------------------- -qreal VCommonSettings::GetWheelMouseScale() const +auto VCommonSettings::GetWheelMouseScale() const -> qreal { QSettings settings(this->format(), this->scope(), this->organizationName(), *commonIniFilename); return GetCachedValue(settings, scrollingWheelMouseScaleCached, *settingScrollingWheelMouseScale, @@ -1401,7 +1395,7 @@ void VCommonSettings::SetWheelMouseScale(qreal scale) } //--------------------------------------------------------------------------------------------------------------------- -qreal VCommonSettings::GetScrollingAcceleration() const +auto VCommonSettings::GetScrollingAcceleration() const -> qreal { QSettings settings(this->format(), this->scope(), this->organizationName(), *commonIniFilename); return GetCachedValue(settings, scrollingAccelerationCached, *settingScrollingAcceleration, @@ -1418,7 +1412,7 @@ void VCommonSettings::SetScrollingAcceleration(qreal acceleration) } //--------------------------------------------------------------------------------------------------------------------- -bool VCommonSettings::IsOpenGLRender() const +auto VCommonSettings::IsOpenGLRender() const -> bool { QSettings settings(this->format(), this->scope(), this->organizationName(), *commonIniFilename); return settings.value(*settingPatternUseOpenGLRender, 0).toBool(); @@ -1433,7 +1427,7 @@ void VCommonSettings::SetOpenGLRender(bool value) } //--------------------------------------------------------------------------------------------------------------------- -bool VCommonSettings::GetGraphicalOutput() const +auto VCommonSettings::GetGraphicalOutput() const -> bool { QSettings settings(this->format(), this->scope(), this->organizationName(), *commonIniFilename); return settings.value(*settingPatternGraphicalOutput, 1).toBool(); @@ -1489,7 +1483,7 @@ void VCommonSettings::SetTiledPDFOrientation(PageOrientation value) } //--------------------------------------------------------------------------------------------------------------------- -QSize VCommonSettings::GetWatermarkEditorSize() const +auto VCommonSettings::GetWatermarkEditorSize() const -> QSize { return value(*settingWatermarkEditorSize, QSize(0, 0)).toSize(); } @@ -1501,7 +1495,7 @@ void VCommonSettings::SetWatermarkEditorSize(const QSize &sz) } //--------------------------------------------------------------------------------------------------------------------- -QVector VCommonSettings::GetWatermarkCustomColors() const +auto VCommonSettings::GetWatermarkCustomColors() const -> QVector { QSettings settings(this->format(), this->scope(), this->organizationName(), *commonIniFilename); QStringList colors = settings.value(*settingPatternGraphicalOutput, 1).toStringList(); @@ -1509,7 +1503,7 @@ QVector VCommonSettings::GetWatermarkCustomColors() const QVector customColors; customColors.reserve(colors.size()); - for (auto color : colors) + for (const auto &color : colors) { QColor c(color); if (c.isValid()) @@ -1539,7 +1533,7 @@ void VCommonSettings::SetWatermarkCustomColors(QVector colors) QStringList customColors; customColors.reserve(colors.size()); - for (auto color : colors) + for (const auto &color : colors) { customColors.append(color.name()); } diff --git a/src/libs/vmisc/vcommonsettings.h b/src/libs/vmisc/vcommonsettings.h index 4198c7435..8809c5a7f 100644 --- a/src/libs/vmisc/vcommonsettings.h +++ b/src/libs/vmisc/vcommonsettings.h @@ -45,204 +45,205 @@ class QMarginsF; class VCommonSettings : public QSettings { - Q_OBJECT + Q_OBJECT // NOLINT public: VCommonSettings(Format format, Scope scope, const QString &organization, const QString &application = QString(), QObject *parent = nullptr); VCommonSettings(const QString &fileName, Format format, QObject *parent = nullptr); + ~VCommonSettings() override =default; - static QString SharePath(const QString &shareItem); - static QString MultisizeTablesPath(); - static QString StandardTemplatesPath(); - static QString LabelTemplatesPath(); + static auto SharePath(const QString &shareItem) -> QString; + static auto MultisizeTablesPath() -> QString; + static auto StandardTemplatesPath() -> QString; + static auto LabelTemplatesPath() -> QString; - static QString PrepareStandardTemplates(const QString ¤tPath); - static QString PrepareMultisizeTables(const QString ¤tPath); - static QString PrepareLabelTemplates(const QString ¤tPath); + static auto PrepareStandardTemplates(const QString ¤tPath) -> QString; + static auto PrepareMultisizeTables(const QString ¤tPath) -> QString; + static auto PrepareLabelTemplates(const QString ¤tPath) -> QString; - static QString GetDefPathIndividualMeasurements(); - QString GetPathIndividualMeasurements() const; + static auto GetDefPathIndividualMeasurements() -> QString; + auto GetPathIndividualMeasurements() const -> QString; void SetPathIndividualMeasurements(const QString &value); - static QString GetDefPathMultisizeMeasurements(); - QString GetPathMultisizeMeasurements() const; + static auto GetDefPathMultisizeMeasurements() -> QString; + auto GetPathMultisizeMeasurements() const -> QString; void SetPathMultisizeMeasurements(const QString &value); - static QString GetDefPathPattern(); - QString GetPathPattern() const; + static auto GetDefPathPattern() -> QString; + auto GetPathPattern() const -> QString; void SetPathPattern(const QString &value); - static QString GetDefPathTemplate(); - QString GetPathTemplate() const; + static auto GetDefPathTemplate() -> QString; + auto GetPathTemplate() const -> QString; void SetPathTemplate(const QString &value); - static QString GetDefPathLabelTemplate(); - QString GetPathLabelTemplate() const; + static auto GetDefPathLabelTemplate() -> QString; + auto GetPathLabelTemplate() const -> QString; void SetPathLabelTemplate(const QString &value); - static QString GetDefPathManualLayouts(); - QString GetPathManualLayouts() const; + static auto GetDefPathManualLayouts() -> QString; + auto GetPathManualLayouts() const -> QString; void SetPathManualLayouts(const QString &value); - bool GetOsSeparator() const; + auto GetOsSeparator() const -> bool; void SetOsSeparator(const bool &value); - bool GetAutosaveState() const; + auto GetAutosaveState() const -> bool; void SetAutosaveState(const bool &value); - int GetAutosaveTime() const; + auto GetAutosaveTime() const -> int; void SetAutosaveTime(const int &value); - bool IsLocaleSelected() const; - QString GetLocale() const; + auto IsLocaleSelected() const -> bool; + auto GetLocale() const -> QString; void SetLocale(const QString &value); - QString GetPMSystemCode() const; + auto GetPMSystemCode() const -> QString; void SetPMSystemCode(const QString &value); - QString GetUnit() const; + auto GetUnit() const -> QString; void SetUnit(const QString &value); - bool GetConfirmItemDelete() const; + auto GetConfirmItemDelete() const -> bool; void SetConfirmItemDelete(const bool &value); - bool GetConfirmFormatRewriting() const; + auto GetConfirmFormatRewriting() const -> bool; void SetConfirmFormatRewriting(const bool &value); - bool GetAskContinueIfLayoutStale() const; + auto GetAskContinueIfLayoutStale() const -> bool; void SetAskContinueIfLayoutStale(const bool &value); - bool GetToolBarStyle() const; + auto GetToolBarStyle() const -> bool; void SetToolBarStyle(const bool &value); - bool GetDarkMode() const; + auto GetDarkMode() const -> bool; void SetDarkMode(const bool &value); - bool IsFreeCurveMode() const; + auto IsFreeCurveMode() const -> bool; void SetFreeCurveMode(bool value); - bool IsDoubleClickZoomFitBestCurrentPP() const; + auto IsDoubleClickZoomFitBestCurrentPP() const -> bool; void SetDoubleClickZoomFitBestCurrentPP(bool value); - int GetUndoCount() const; + auto GetUndoCount() const -> int; void SetUndoCount(const int &value); - QStringList GetRecentFileList() const; + auto GetRecentFileList() const -> QStringList; void SetRecentFileList(const QStringList &value); - QStringList GetRestoreFileList() const; + auto GetRestoreFileList() const -> QStringList; void SetRestoreFileList(const QStringList &value); - QByteArray GetGeometry() const; + auto GetGeometry() const -> QByteArray; void SetGeometry(const QByteArray &value); - QByteArray GetWindowState() const; + auto GetWindowState() const -> QByteArray; void SetWindowState(const QByteArray &value); - QByteArray GetToolbarsState() const; + auto GetToolbarsState() const -> QByteArray; void SetToolbarsState(const QByteArray &value); - QSize GetPreferenceDialogSize() const; + auto GetPreferenceDialogSize() const -> QSize; void SetPreferenceDialogSize(const QSize& sz); - QSize GetToolSeamAllowanceDialogSize() const; - void SetToolSeamAllowanceDialogSize(const QSize& sz); + auto GetToolSeamAllowanceDialogSize() const -> QSize; + void SetToolSeamAllowanceDialogSize(const QSize& sz); - QSize GetFormulaWizardDialogSize() const; - void SetFormulaWizardDialogSize(const QSize& sz); + auto GetFormulaWizardDialogSize() const -> QSize; + void SetFormulaWizardDialogSize(const QSize& sz); - QSize GetIncrementsDialogSize() const; - void SetIncrementsDialogSize(const QSize& sz); + auto GetIncrementsDialogSize() const -> QSize; + void SetIncrementsDialogSize(const QSize& sz); - QSize GetFinalMeasurementsDialogSize() const; - void SetFinalMeasurementsDialogSize(const QSize& sz); + auto GetFinalMeasurementsDialogSize() const -> QSize; + void SetFinalMeasurementsDialogSize(const QSize& sz); - QSize GetLayoutSettingsDialogSize() const; - void SetLayoutSettingsDialogSize(const QSize& sz); + auto GetLayoutSettingsDialogSize() const -> QSize; + void SetLayoutSettingsDialogSize(const QSize& sz); - bool IsAutomaticallyCheckUpdates() const; + auto IsAutomaticallyCheckUpdates() const -> bool; void SetAutomaticallyCheckUpdates(bool value); - unsigned GetLatestSkippedVersion() const; + auto GetLatestSkippedVersion() const -> unsigned; void SetLatestSkippedVersion(unsigned value); - QDate GetDateOfLastRemind() const; - void SetDateOfLastRemind(const QDate &date); + auto GetDateOfLastRemind() const -> QDate; + void SetDateOfLastRemind(const QDate &date); - bool GetForbidWorkpieceFlipping() const; + auto GetForbidWorkpieceFlipping() const -> bool; void SetForbidWorkpieceFlipping(bool value); - bool GetForceWorkpieceFlipping() const; + auto GetForceWorkpieceFlipping() const -> bool; void SetForceWorkpieceFlipping(bool value); - bool IsHideMainPath() const; + auto IsHideMainPath() const -> bool; void SetHideMainPath(bool value); - bool IsDoublePassmark() const; + auto IsDoublePassmark() const -> bool; void SetDoublePassmark(bool value); void SetCSVWithHeader(bool withHeader); - bool GetCSVWithHeader() const; - static bool GetDefCSVWithHeader(); + auto GetCSVWithHeader() const -> bool; + static auto GetDefCSVWithHeader() -> bool; void SetCSVCodec(int mib); - int GetCSVCodec() const; - static int GetDefCSVCodec(); + auto GetCSVCodec() const -> int; + static auto GetDefCSVCodec() -> int; - void SetCSVSeparator(const QChar &separator); - QChar GetCSVSeparator() const; - static QChar GetDefCSVSeparator(); + void SetCSVSeparator(const QChar &separator); + auto GetCSVSeparator() const -> QChar; + static auto GetDefCSVSeparator() -> QChar; void SetDefaultSeamAllowance(double value); - double GetDefaultSeamAllowance(); + auto GetDefaultSeamAllowance() -> double; - QFont GetLabelFont() const; - void SetLabelFont(const QFont &f); + auto GetLabelFont() const -> QFont; + void SetLabelFont(const QFont &f); - int GetLabelFontSize() const; + auto GetLabelFontSize() const -> int; void SetLabelFontSize(int size); - static int GetDefLabelFontSize(); + static auto GetDefLabelFontSize() -> int; - bool GetHideLabels() const; + auto GetHideLabels() const -> bool; void SetHideLabels(bool value); #if !defined(Q_OS_WIN) static const QString unixStandardSharePath; #endif - QString GetLabelDateFormat() const; - void SetLabelDateFormat(const QString &format); + auto GetLabelDateFormat() const -> QString; + void SetLabelDateFormat(const QString &format); - static QStringList PredefinedDateFormats(); - QStringList GetUserDefinedDateFormats() const; - void SetUserDefinedDateFormats(const QStringList &formats); + static auto PredefinedDateFormats() -> QStringList; + auto GetUserDefinedDateFormats() const -> QStringList; + void SetUserDefinedDateFormats(const QStringList &formats); - QString GetLabelTimeFormat() const; - void SetLabelTimeFormat(const QString &format); + auto GetLabelTimeFormat() const -> QString; + void SetLabelTimeFormat(const QString &format); - static QStringList PredefinedTimeFormats(); - QStringList GetUserDefinedTimeFormats() const; - void SetUserDefinedTimeFormats(const QStringList &formats); + static auto PredefinedTimeFormats() -> QStringList; + auto GetUserDefinedTimeFormats() const -> QStringList; + void SetUserDefinedTimeFormats(const QStringList &formats); - qreal GetCurveApproximationScale() const; - void SetCurveApproximationScale(qreal value); + auto GetCurveApproximationScale() const -> qreal; + void SetCurveApproximationScale(qreal value); - bool IsShowCurveDetails() const; + auto IsShowCurveDetails() const -> bool; void SetShowCurveDetails(bool value); - bool IsPieceShowMainPath() const; + auto IsPieceShowMainPath() const -> bool; void SetPieceShowMainPath(bool value); - bool IsDontUseNativeDialog() const; + auto IsDontUseNativeDialog() const -> bool; void SetDontUseNativeDialog(bool value); - static qreal DefaultLineWidth(); - static qreal MinimalLineWidth(); - static qreal MaximalLineWidth(); - qreal GetLineWidth() const; - void SetLineWidth(qreal width); - qreal WidthMainLine() const; - qreal WidthHairLine() const; + static auto DefaultLineWidth() -> qreal; + static auto MinimalLineWidth() -> qreal; + static auto MaximalLineWidth() -> qreal; + auto GetLineWidth() const -> qreal; + void SetLineWidth(qreal width); + auto WidthMainLine() const -> qreal; + auto WidthHairLine() const -> qreal; // settings for the tiled PDFs auto GetTiledPDFMargins(const Unit &unit) const -> QMarginsF; @@ -254,37 +255,37 @@ public: static const int defaultScrollingDuration; static const int scrollingDurationMin; static const int scrollingDurationMax; - int GetScrollingDuration() const; + auto GetScrollingDuration() const -> int; void SetScrollingDuration(int duration); static const int defaultScrollingUpdateInterval; static const int scrollingUpdateIntervalMin; static const int scrollingUpdateIntervalMax; - int GetScrollingUpdateInterval() const; + auto GetScrollingUpdateInterval() const -> int; void SetScrollingUpdateInterval(int updateInterval); static const qreal defaultSensorMouseScale; static const qreal sensorMouseScaleMin; static const qreal sensorMouseScaleMax; - qreal GetSensorMouseScale() const; + auto GetSensorMouseScale() const -> qreal; void SetSensorMouseScale(qreal scale); static const qreal defaultWheelMouseScale; static const qreal wheelMouseScaleMin; static const qreal wheelMouseScaleMax; - qreal GetWheelMouseScale() const; + auto GetWheelMouseScale() const -> qreal; void SetWheelMouseScale(qreal scale); static const qreal defaultScrollingAcceleration; static const qreal scrollingAccelerationMin; static const qreal scrollingAccelerationMax; - qreal GetScrollingAcceleration() const; + auto GetScrollingAcceleration() const -> qreal; void SetScrollingAcceleration(qreal acceleration); - bool IsOpenGLRender() const; + auto IsOpenGLRender() const -> bool; void SetOpenGLRender(bool value); - bool GetGraphicalOutput() const; + auto GetGraphicalOutput() const -> bool; void SetGraphicalOutput(const bool &value); auto GetWatermarkEditorSize() const -> QSize; @@ -296,38 +297,38 @@ public: protected: template - static T GetCachedValue(const QSettings &settings, T &cache, const QString &setting, T defValue, T valueMin, - T valueMax); + static auto GetCachedValue(const QSettings &settings, T &cache, const QString &setting, T defValue, T valueMin, + T valueMax) -> T; template - static T ValueOrDef(const QSettings &settings, const QString &setting, const T &defValue); + static auto ValueOrDef(const QSettings &settings, const QString &setting, const T &defValue) -> T; private: - Q_DISABLE_COPY(VCommonSettings) + Q_DISABLE_COPY_MOVE(VCommonSettings) // NOLINT }; //--------------------------------------------------------------------------------------------------------------------- -inline qreal VCommonSettings::DefaultLineWidth() +inline auto VCommonSettings::DefaultLineWidth() -> qreal { return 1.2; // mm } //--------------------------------------------------------------------------------------------------------------------- -inline qreal VCommonSettings::MinimalLineWidth() +inline auto VCommonSettings::MinimalLineWidth() -> qreal { return 0.5; // mm } //--------------------------------------------------------------------------------------------------------------------- -inline qreal VCommonSettings::MaximalLineWidth() +inline auto VCommonSettings::MaximalLineWidth() -> qreal { return 5.0; // mm } //--------------------------------------------------------------------------------------------------------------------- template -T VCommonSettings::GetCachedValue(const QSettings &settings, T &cache, const QString &setting, T defValue, T valueMin, - T valueMax) +auto VCommonSettings::GetCachedValue(const QSettings &settings, T &cache, const QString &setting, T defValue, + T valueMin, T valueMax) -> T { if (cache < 0) { @@ -339,7 +340,7 @@ T VCommonSettings::GetCachedValue(const QSettings &settings, T &cache, const QSt //--------------------------------------------------------------------------------------------------------------------- template -inline T VCommonSettings::ValueOrDef(const QSettings &settings, const QString &setting, const T &defValue) +inline auto VCommonSettings::ValueOrDef(const QSettings &settings, const QString &setting, const T &defValue) -> T { const QVariant val = settings.value(setting, QVariant::fromValue(defValue)); return val.canConvert() ? val.value() : defValue; @@ -347,19 +348,16 @@ inline T VCommonSettings::ValueOrDef(const QSettings &settings, const QString &s //--------------------------------------------------------------------------------------------------------------------- template <> -inline Cases VCommonSettings::ValueOrDef(const QSettings &settings, const QString &setting, - const Cases &defValue) +inline auto VCommonSettings::ValueOrDef(const QSettings &settings, const QString &setting, + const Cases &defValue) -> Cases { const QVariant val = settings.value(setting, QVariant::fromValue(static_cast(defValue))); - const int g = val.canConvert() ? val.value() : static_cast(defValue); + const int g = val.canConvert() ? val.toInt() : static_cast(defValue); if (g < static_cast(Cases::CaseThreeGroup) || g >= static_cast(Cases::UnknownCase)) { return defValue; } - else - { - return static_cast(g); - } + return static_cast(g); } #endif // VCOMMONSETTINGS_H diff --git a/src/libs/vmisc/vlockguard.h b/src/libs/vmisc/vlockguard.h index be89ffb8c..56060d72d 100644 --- a/src/libs/vmisc/vlockguard.h +++ b/src/libs/vmisc/vlockguard.h @@ -39,6 +39,7 @@ #include #include "../vmisc/diagnostic.h" +#include "../vmisc/defglobal.h" #include #include @@ -70,7 +71,8 @@ public: QString GetLockFile() const; private: - Q_DISABLE_COPY(VLockGuard) + // cppcheck-suppress unknownMacro + Q_DISABLE_COPY_MOVE(VLockGuard) // NOLINT QSharedPointer holder; int lockError; diff --git a/src/libs/vmisc/vtablesearch.h b/src/libs/vmisc/vtablesearch.h index 314aaf93f..f931e93d1 100644 --- a/src/libs/vmisc/vtablesearch.h +++ b/src/libs/vmisc/vtablesearch.h @@ -35,9 +35,11 @@ #include #include +#include "../vmisc/defglobal.h" + class VTableSearch: public QObject { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit VTableSearch(QTableWidget *table, QObject *parent = nullptr); @@ -71,7 +73,8 @@ signals: void HasResult(bool state); private: - Q_DISABLE_COPY(VTableSearch) + // cppcheck-suppress unknownMacro + Q_DISABLE_COPY_MOVE(VTableSearch) // NOLINT QTableWidget *table; int searchIndex{-1}; diff --git a/src/libs/vmisc/vvalentinasettings.cpp b/src/libs/vmisc/vvalentinasettings.cpp index 26c8e5262..91ceaf49d 100644 --- a/src/libs/vmisc/vvalentinasettings.cpp +++ b/src/libs/vmisc/vvalentinasettings.cpp @@ -50,96 +50,96 @@ Q_DECLARE_METATYPE(QMarginsF) namespace { -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationLabelLanguage, +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationLabelLanguage, // NOLINT (QLatin1String("configuration/label_language"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingAutoRefreshPatternMessage, +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingAutoRefreshPatternMessage, // NOLINT (QLatin1String("configuration/autoRefreshPatternMessage"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingToolPanelScaling, +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingToolPanelScaling, // NOLINT (QLatin1String("configuration/toolPanelScaling"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPathsLayout, (QLatin1String("paths/layout"))) +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPathsLayout, (QLatin1String("paths/layout"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternKnownMaterials, (QLatin1String("pattern/knownMaterials"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternRememberMaterials, (QLatin1String("pattern/rememberMaterials"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternBackgroundImageDefOpacity, +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternKnownMaterials, (QLatin1String("pattern/knownMaterials"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternRememberMaterials, (QLatin1String("pattern/rememberMaterials"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternBackgroundImageDefOpacity, // NOLINT (QLatin1String("pattern/backgroundImageDefOpacity"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutWidth, (QLatin1String("layout/width"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutSorting, (QLatin1String("layout/sorting"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutPaperHeight, (QLatin1String("layout/paperHeight"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutPaperWidth, (QLatin1String("layout/paperWidth"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutFollowGrainline, (QLatin1String("layout/followGrainline"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutManualPriority, (QLatin1String("layout/manualPriority"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutNestQuantity, (QLatin1String("layout/nestQuantity"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutAutoCropLength, (QLatin1String("layout/autoCropLength"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutAutoCropWidth, (QLatin1String("layout/autoCropWidth"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutSaveLength, (QLatin1String("layout/saveLength"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutPreferOneSheetSolution, +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutWidth, (QLatin1String("layout/width"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutSorting, (QLatin1String("layout/sorting"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutPaperHeight, (QLatin1String("layout/paperHeight"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutPaperWidth, (QLatin1String("layout/paperWidth"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutFollowGrainline, (QLatin1String("layout/followGrainline"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutManualPriority, (QLatin1String("layout/manualPriority"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutNestQuantity, (QLatin1String("layout/nestQuantity"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutAutoCropLength, (QLatin1String("layout/autoCropLength"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutAutoCropWidth, (QLatin1String("layout/autoCropWidth"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutSaveLength, (QLatin1String("layout/saveLength"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutPreferOneSheetSolution, // NOLINT (QLatin1String("layout/preferOneSheetSolution"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutUnitePages, (QLatin1String("layout/unitePages"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingFields, (QLatin1String("layout/fields"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingIgnoreFields, (QLatin1String("layout/ignoreFields"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingStripOptimization, (QLatin1String("layout/stripOptimization"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingMultiplier, (QLatin1String("layout/multiplier"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingTextAsPaths, (QLatin1String("layout/textAsPaths"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingNestingTime, (QLatin1String("layout/time"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingEfficiencyCoefficient, (QLatin1String("layout/efficiencyCoefficient"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutExportFormat, (QLatin1String("layout/exportFormat"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingDetailExportFormat, (QLatin1String("detail/exportFormat"))) +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutUnitePages, (QLatin1String("layout/unitePages"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingFields, (QLatin1String("layout/fields"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingIgnoreFields, (QLatin1String("layout/ignoreFields"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingStripOptimization, (QLatin1String("layout/stripOptimization"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingMultiplier, (QLatin1String("layout/multiplier"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingTextAsPaths, (QLatin1String("layout/textAsPaths"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingNestingTime, (QLatin1String("layout/time"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingEfficiencyCoefficient, (QLatin1String("layout/efficiencyCoefficient"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutExportFormat, (QLatin1String("layout/exportFormat"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingDetailExportFormat, (QLatin1String("detail/exportFormat"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingTiledPDFPaperHeight, (QLatin1String("tiledPDF/paperHeight"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingTiledPDFPaperWidth, (QLatin1String("tiledPDF/paperWidth"))) +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingTiledPDFPaperHeight, (QLatin1String("tiledPDF/paperHeight"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingTiledPDFPaperWidth, (QLatin1String("tiledPDF/paperWidth"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingdockWidgetGroupsActive, (QLatin1String("dockWidget/groupsActive"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingDockWidgetToolOptionsActive, +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingdockWidgetGroupsActive, (QLatin1String("dockWidget/groupsActive"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingDockWidgetToolOptionsActive, // NOLINT (QLatin1String("dockWidget/toolOptionsActive"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingDockWidgetPatternMessagesActive, +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingDockWidgetPatternMessagesActive, // NOLINT (QLatin1String("dockWidget/patternMessagesActive"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingDockWidgetBackgroundImagesActive, +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingDockWidgetBackgroundImagesActive, // NOLINT (QLatin1String("dockWidget/backgroundImagesActive"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternMessagesFontSize, (QLatin1String("font/patternMessagesSize"))) +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternMessagesFontSize, (QLatin1String("font/patternMessagesSize"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchHistoryHistory, (QLatin1String("searchHistory/history"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchHistoryIncrements, (QLatin1String("searchHistory/increments"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchHistoryPreviewCalculations, +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchHistoryHistory, (QLatin1String("searchHistory/history"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchHistoryIncrements, (QLatin1String("searchHistory/increments"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchHistoryPreviewCalculations, // NOLINT (QLatin1String("searchHistory/previewCalculations"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchHistoryFinalMeasurements, +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchHistoryFinalMeasurements, // NOLINT (QLatin1String("searchHistory/finalMeasurements"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsHistoryUseUnicodeProperties, +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsHistoryUseUnicodeProperties, // NOLINT (QLatin1String("searchOptions/historyUseUnicodeProperties"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsHistoryWholeWord, +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsHistoryWholeWord, // NOLINT (QLatin1String("searchOptions/historyWholeWord"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsHistoryRegexp, +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsHistoryRegexp, // NOLINT (QLatin1String("searchOptions/historyRegexp"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsHistoryMatchCase, +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsHistoryMatchCase, // NOLINT (QLatin1String("searchOptions/historyMatchCase"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsIncrementsUseUnicodeProperties, +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsIncrementsUseUnicodeProperties, // NOLINT (QLatin1String("searchOptions/incrementsUseUnicodeProperties"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsIncrementsWholeWord, +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsIncrementsWholeWord, // NOLINT (QLatin1String("searchOptions/incrementsWholeWord"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsIncrementsRegexp, +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsIncrementsRegexp, // NOLINT (QLatin1String("searchOptions/incrementsRegexp"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsIncrementsMatchCase, +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsIncrementsMatchCase, // NOLINT (QLatin1String("searchOptions/incrementsMatchCase"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsPreviewCalculationsUseUnicodeProperties, +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsPreviewCalculationsUseUnicodeProperties, // NOLINT (QLatin1String("searchOptions/previewCalculationsUseUnicodeProperties"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsPreviewCalculationsWholeWord, +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsPreviewCalculationsWholeWord, // NOLINT (QLatin1String("searchOptions/previewCalculationsWholeWord"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsPreviewCalculationsRegexp, +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsPreviewCalculationsRegexp, // NOLINT (QLatin1String("searchOptions/previewCalculationsRegexp"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsPreviewCalculationsMatchCase, +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsPreviewCalculationsMatchCase, // NOLINT (QLatin1String("searchOptions/previewCalculationsMatchCase"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsFinalMeasurementsUseUnicodeProperties, +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsFinalMeasurementsUseUnicodeProperties, // NOLINT (QLatin1String("searchOptions/finalMeasurementsUseUnicodeProperties"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsFinalMeasurementsWholeWord, +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsFinalMeasurementsWholeWord, // NOLINT (QLatin1String("searchOptions/finalMeasurementsWholeWord"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsFinalMeasurementsRegexp, +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsFinalMeasurementsRegexp, // NOLINT (QLatin1String("searchOptions/finalMeasurementsRegexp"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsFinalMeasurementsMatchCase, +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsFinalMeasurementsMatchCase, // NOLINT (QLatin1String("searchOptions/finalMeasurementsMatchCase"))) } // namespace diff --git a/src/libs/vmisc/vvalentinasettings.h b/src/libs/vmisc/vvalentinasettings.h index 557e7c891..ea6e984e5 100644 --- a/src/libs/vmisc/vvalentinasettings.h +++ b/src/libs/vmisc/vvalentinasettings.h @@ -41,7 +41,7 @@ class VValentinaSettings : public VCommonSettings { - Q_OBJECT + Q_OBJECT // NOLINT public: VValentinaSettings(Format format, Scope scope, const QString &organization, const QString &application = QString(), QObject *parent = nullptr); @@ -238,7 +238,7 @@ public: void SetBackgroundImageDefOpacity(int value); private: - Q_DISABLE_COPY(VValentinaSettings) + Q_DISABLE_COPY_MOVE(VValentinaSettings) // NOLINT template T GetCachedValue(T &cache, const QString &setting, T defValue, T valueMin, T valueMax) const; diff --git a/src/libs/vobj/vobjengine.h b/src/libs/vobj/vobjengine.h index 039aa81e7..caa75416e 100644 --- a/src/libs/vobj/vobjengine.h +++ b/src/libs/vobj/vobjengine.h @@ -39,6 +39,7 @@ #include #include "delaunay.h" +#include "../vmisc/defglobal.h" class QTextStream; @@ -71,7 +72,8 @@ public: void setResolution(int value); private: - Q_DISABLE_COPY(VObjEngine) + // cppcheck-suppress unknownMacro + Q_DISABLE_COPY_MOVE(VObjEngine) // NOLINT QSharedPointer stream; quint32 globalPointsCount; QSharedPointer outputDevice; diff --git a/src/libs/vobj/vobjpaintdevice.h b/src/libs/vobj/vobjpaintdevice.h index ede6e7d41..19507f1ad 100644 --- a/src/libs/vobj/vobjpaintdevice.h +++ b/src/libs/vobj/vobjpaintdevice.h @@ -36,6 +36,8 @@ #include #include +#include "../vmisc/defglobal.h" + class QIODevice; class VObjEngine; @@ -61,7 +63,8 @@ public: protected: virtual int metric(PaintDeviceMetric metric) const override; private: - Q_DISABLE_COPY(VObjPaintDevice) + // cppcheck-suppress unknownMacro + Q_DISABLE_COPY_MOVE(VObjPaintDevice) // NOLINT QSharedPointer engine; QString fileName; uint owns_iodevice; diff --git a/src/libs/vpatterndb/calculator.h b/src/libs/vpatterndb/calculator.h index 5ef7d6cc3..04a4b3c5a 100644 --- a/src/libs/vpatterndb/calculator.h +++ b/src/libs/vpatterndb/calculator.h @@ -68,7 +68,7 @@ protected: static qreal* VarFactory(const QString &a_szName, void *a_pUserData); static qreal Warning(const QString &warningMsg, qreal value); private: - Q_DISABLE_COPY(Calculator) + Q_DISABLE_COPY_MOVE(Calculator) // NOLINT QVector> m_varsValues; const QHash > *m_vars; }; diff --git a/src/libs/vpatterndb/floatItemData/vabstractfloatitemdata.cpp b/src/libs/vpatterndb/floatItemData/vabstractfloatitemdata.cpp index 02b99a20f..49f3619b9 100644 --- a/src/libs/vpatterndb/floatItemData/vabstractfloatitemdata.cpp +++ b/src/libs/vpatterndb/floatItemData/vabstractfloatitemdata.cpp @@ -52,8 +52,8 @@ VAbstractFloatItemData &VAbstractFloatItemData::operator=(const VAbstractFloatIt #ifdef Q_COMPILER_RVALUE_REFS //--------------------------------------------------------------------------------------------------------------------- -VAbstractFloatItemData::VAbstractFloatItemData(const VAbstractFloatItemData &&data) Q_DECL_NOTHROW - : d (data.d) +VAbstractFloatItemData::VAbstractFloatItemData(VAbstractFloatItemData &&data) Q_DECL_NOTHROW + : d (std::move(data.d)) {} //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vpatterndb/floatItemData/vabstractfloatitemdata.h b/src/libs/vpatterndb/floatItemData/vabstractfloatitemdata.h index 54eeaf457..6c6c3d197 100644 --- a/src/libs/vpatterndb/floatItemData/vabstractfloatitemdata.h +++ b/src/libs/vpatterndb/floatItemData/vabstractfloatitemdata.h @@ -44,7 +44,7 @@ public: VAbstractFloatItemData &operator=(const VAbstractFloatItemData &data); #ifdef Q_COMPILER_RVALUE_REFS - VAbstractFloatItemData(const VAbstractFloatItemData &&data) Q_DECL_NOTHROW; + VAbstractFloatItemData(VAbstractFloatItemData &&data) Q_DECL_NOTHROW; VAbstractFloatItemData &operator=(VAbstractFloatItemData &&data) Q_DECL_NOTHROW; #endif diff --git a/src/libs/vpatterndb/floatItemData/vgrainlinedata.cpp b/src/libs/vpatterndb/floatItemData/vgrainlinedata.cpp index 2cfb5c41e..fb43dae2a 100644 --- a/src/libs/vpatterndb/floatItemData/vgrainlinedata.cpp +++ b/src/libs/vpatterndb/floatItemData/vgrainlinedata.cpp @@ -57,9 +57,9 @@ VGrainlineData &VGrainlineData::operator=(const VGrainlineData &data) #ifdef Q_COMPILER_RVALUE_REFS //--------------------------------------------------------------------------------------------------------------------- -VGrainlineData::VGrainlineData(const VGrainlineData &&data) Q_DECL_NOTHROW - : VAbstractFloatItemData(data), - d (data.d) +VGrainlineData::VGrainlineData(VGrainlineData &&data) Q_DECL_NOTHROW + : VAbstractFloatItemData(std::move(data)), + d (std::move(data.d)) {} //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vpatterndb/floatItemData/vgrainlinedata.h b/src/libs/vpatterndb/floatItemData/vgrainlinedata.h index 22518035f..a8bcb030d 100644 --- a/src/libs/vpatterndb/floatItemData/vgrainlinedata.h +++ b/src/libs/vpatterndb/floatItemData/vgrainlinedata.h @@ -51,7 +51,7 @@ public: VGrainlineData &operator=(const VGrainlineData &data); #ifdef Q_COMPILER_RVALUE_REFS - VGrainlineData(const VGrainlineData &&data) Q_DECL_NOTHROW; + VGrainlineData(VGrainlineData &&data) Q_DECL_NOTHROW; VGrainlineData &operator=(VGrainlineData &&data) Q_DECL_NOTHROW; #endif diff --git a/src/libs/vpatterndb/floatItemData/vpatternlabeldata.cpp b/src/libs/vpatterndb/floatItemData/vpatternlabeldata.cpp index 5a17c0f94..f99e2a75a 100644 --- a/src/libs/vpatterndb/floatItemData/vpatternlabeldata.cpp +++ b/src/libs/vpatterndb/floatItemData/vpatternlabeldata.cpp @@ -56,9 +56,9 @@ VPatternLabelData &VPatternLabelData::operator=(const VPatternLabelData &data) #ifdef Q_COMPILER_RVALUE_REFS //--------------------------------------------------------------------------------------------------------------------- -VPatternLabelData::VPatternLabelData(const VPatternLabelData &&data) Q_DECL_NOTHROW - : VAbstractFloatItemData(data), - d (data.d) +VPatternLabelData::VPatternLabelData(VPatternLabelData &&data) Q_DECL_NOTHROW + : VAbstractFloatItemData(std::move(data)), + d (std::move(data.d)) {} //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vpatterndb/floatItemData/vpatternlabeldata.h b/src/libs/vpatterndb/floatItemData/vpatternlabeldata.h index 2e9a2918b..7dc83723a 100644 --- a/src/libs/vpatterndb/floatItemData/vpatternlabeldata.h +++ b/src/libs/vpatterndb/floatItemData/vpatternlabeldata.h @@ -48,7 +48,7 @@ public: VPatternLabelData &operator=(const VPatternLabelData &data); #ifdef Q_COMPILER_RVALUE_REFS - VPatternLabelData(const VPatternLabelData &&data) Q_DECL_NOTHROW; + VPatternLabelData(VPatternLabelData &&data) Q_DECL_NOTHROW; VPatternLabelData &operator=(VPatternLabelData &&data) Q_DECL_NOTHROW; #endif diff --git a/src/libs/vpatterndb/floatItemData/vpiecelabeldata.cpp b/src/libs/vpatterndb/floatItemData/vpiecelabeldata.cpp index 7a5adbcd1..b1279e8d2 100644 --- a/src/libs/vpatterndb/floatItemData/vpiecelabeldata.cpp +++ b/src/libs/vpatterndb/floatItemData/vpiecelabeldata.cpp @@ -57,9 +57,9 @@ VPieceLabelData &VPieceLabelData::operator=(const VPieceLabelData &data) #ifdef Q_COMPILER_RVALUE_REFS //--------------------------------------------------------------------------------------------------------------------- -VPieceLabelData::VPieceLabelData(const VPieceLabelData &&data) Q_DECL_NOTHROW - : VPatternLabelData(data), - d (data.d) +VPieceLabelData::VPieceLabelData(VPieceLabelData &&data) Q_DECL_NOTHROW + : VPatternLabelData(std::move(data)), + d (std::move(data.d)) {} //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vpatterndb/floatItemData/vpiecelabeldata.h b/src/libs/vpatterndb/floatItemData/vpiecelabeldata.h index 9fb53d511..5e2243d59 100644 --- a/src/libs/vpatterndb/floatItemData/vpiecelabeldata.h +++ b/src/libs/vpatterndb/floatItemData/vpiecelabeldata.h @@ -51,7 +51,7 @@ public: VPieceLabelData &operator=(const VPieceLabelData &data); #ifdef Q_COMPILER_RVALUE_REFS - VPieceLabelData(const VPieceLabelData &&data) Q_DECL_NOTHROW; + VPieceLabelData(VPieceLabelData &&data) Q_DECL_NOTHROW; VPieceLabelData &operator=(VPieceLabelData &&data) Q_DECL_NOTHROW; #endif diff --git a/src/libs/vpatterndb/variables/vcurvevariable.cpp b/src/libs/vpatterndb/variables/vcurvevariable.cpp index 7586faa38..c22cd333a 100644 --- a/src/libs/vpatterndb/variables/vcurvevariable.cpp +++ b/src/libs/vpatterndb/variables/vcurvevariable.cpp @@ -66,8 +66,8 @@ VCurveVariable &VCurveVariable::operator=(const VCurveVariable &var) #ifdef Q_COMPILER_RVALUE_REFS //--------------------------------------------------------------------------------------------------------------------- -VCurveVariable::VCurveVariable(const VCurveVariable &&var) Q_DECL_NOTHROW - :VInternalVariable(var), d(var.d) +VCurveVariable::VCurveVariable(VCurveVariable &&var) Q_DECL_NOTHROW + :VInternalVariable(std::move(var)), d(std::move(var.d)) {} //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vpatterndb/variables/vcurvevariable.h b/src/libs/vpatterndb/variables/vcurvevariable.h index 3bf75e444..4e375705f 100644 --- a/src/libs/vpatterndb/variables/vcurvevariable.h +++ b/src/libs/vpatterndb/variables/vcurvevariable.h @@ -49,7 +49,7 @@ public: VCurveVariable &operator=(const VCurveVariable &var); #ifdef Q_COMPILER_RVALUE_REFS - VCurveVariable(const VCurveVariable &&var) Q_DECL_NOTHROW; + VCurveVariable(VCurveVariable &&var) Q_DECL_NOTHROW; VCurveVariable &operator=(VCurveVariable &&var) Q_DECL_NOTHROW; #endif @@ -64,6 +64,6 @@ private: QSharedDataPointer d; }; -Q_DECLARE_TYPEINFO(VCurveVariable, Q_MOVABLE_TYPE); +Q_DECLARE_TYPEINFO(VCurveVariable, Q_MOVABLE_TYPE); // NOLINT #endif // VCURVEVARIABLE_H diff --git a/src/libs/vpatterndb/variables/vincrement.cpp b/src/libs/vpatterndb/variables/vincrement.cpp index 1d3727009..689958176 100644 --- a/src/libs/vpatterndb/variables/vincrement.cpp +++ b/src/libs/vpatterndb/variables/vincrement.cpp @@ -72,8 +72,8 @@ VIncrement &VIncrement::operator=(const VIncrement &incr) #ifdef Q_COMPILER_RVALUE_REFS //--------------------------------------------------------------------------------------------------------------------- -VIncrement::VIncrement(const VIncrement &&incr) Q_DECL_NOTHROW - :VVariable(incr), d(incr.d) +VIncrement::VIncrement(VIncrement &&incr) Q_DECL_NOTHROW + :VVariable(std::move(incr)), d(std::move(incr.d)) {} //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vpatterndb/variables/vincrement.h b/src/libs/vpatterndb/variables/vincrement.h index 44d88ac3a..bc16e1184 100644 --- a/src/libs/vpatterndb/variables/vincrement.h +++ b/src/libs/vpatterndb/variables/vincrement.h @@ -54,7 +54,7 @@ public: VIncrement &operator=(const VIncrement &incr); #ifdef Q_COMPILER_RVALUE_REFS - VIncrement(const VIncrement &&incr) Q_DECL_NOTHROW; + VIncrement(VIncrement &&incr) Q_DECL_NOTHROW; VIncrement &operator=(VIncrement &&incr) Q_DECL_NOTHROW; #endif @@ -78,6 +78,6 @@ private: QSharedDataPointer d; }; -Q_DECLARE_TYPEINFO(VIncrement, Q_MOVABLE_TYPE); +Q_DECLARE_TYPEINFO(VIncrement, Q_MOVABLE_TYPE); // NOLINT #endif // VINCREMENTTABLEROW_H diff --git a/src/libs/vpatterndb/variables/vinternalvariable.cpp b/src/libs/vpatterndb/variables/vinternalvariable.cpp index b9a99e618..e814ae8a2 100644 --- a/src/libs/vpatterndb/variables/vinternalvariable.cpp +++ b/src/libs/vpatterndb/variables/vinternalvariable.cpp @@ -51,8 +51,8 @@ VInternalVariable &VInternalVariable::operator=(const VInternalVariable &var) } //--------------------------------------------------------------------------------------------------------------------- -VInternalVariable::VInternalVariable(const VInternalVariable &&var) Q_DECL_NOTHROW - :d(var.d) +VInternalVariable::VInternalVariable(VInternalVariable &&var) Q_DECL_NOTHROW + :d(std::move(var.d)) {} #ifdef Q_COMPILER_RVALUE_REFS diff --git a/src/libs/vpatterndb/variables/vinternalvariable.h b/src/libs/vpatterndb/variables/vinternalvariable.h index 640e74832..330f2a253 100644 --- a/src/libs/vpatterndb/variables/vinternalvariable.h +++ b/src/libs/vpatterndb/variables/vinternalvariable.h @@ -52,7 +52,7 @@ public: VInternalVariable &operator=(const VInternalVariable &var); #ifdef Q_COMPILER_RVALUE_REFS - VInternalVariable(const VInternalVariable &&var) Q_DECL_NOTHROW; + VInternalVariable(VInternalVariable &&var) Q_DECL_NOTHROW; VInternalVariable &operator=(VInternalVariable &&var) Q_DECL_NOTHROW; #endif @@ -79,6 +79,6 @@ private: QT_WARNING_POP -Q_DECLARE_TYPEINFO(VInternalVariable, Q_MOVABLE_TYPE); +Q_DECLARE_TYPEINFO(VInternalVariable, Q_MOVABLE_TYPE); // NOLINT #endif // VINTERNALVARIABLE_H diff --git a/src/libs/vpatterndb/variables/vlineangle.cpp b/src/libs/vpatterndb/variables/vlineangle.cpp index 58a3dba92..298bc1ffb 100644 --- a/src/libs/vpatterndb/variables/vlineangle.cpp +++ b/src/libs/vpatterndb/variables/vlineangle.cpp @@ -79,8 +79,8 @@ VLineAngle &VLineAngle::operator=(const VLineAngle &var) } //--------------------------------------------------------------------------------------------------------------------- -VLineAngle::VLineAngle(const VLineAngle &&var) Q_DECL_NOTHROW - :VInternalVariable(var), d(var.d) +VLineAngle::VLineAngle(VLineAngle &&var) Q_DECL_NOTHROW + :VInternalVariable(std::move(var)), d(std::move(var.d)) {} #ifdef Q_COMPILER_RVALUE_REFS diff --git a/src/libs/vpatterndb/variables/vlineangle.h b/src/libs/vpatterndb/variables/vlineangle.h index e0540d8de..84b1acef7 100644 --- a/src/libs/vpatterndb/variables/vlineangle.h +++ b/src/libs/vpatterndb/variables/vlineangle.h @@ -50,7 +50,7 @@ public: VLineAngle &operator=(const VLineAngle &var); #ifdef Q_COMPILER_RVALUE_REFS - VLineAngle(const VLineAngle &&var) Q_DECL_NOTHROW; + VLineAngle(VLineAngle &&var) Q_DECL_NOTHROW; VLineAngle &operator=(VLineAngle &&var) Q_DECL_NOTHROW; #endif @@ -62,6 +62,6 @@ private: QSharedDataPointer d; }; -Q_DECLARE_TYPEINFO(VLineAngle, Q_MOVABLE_TYPE); +Q_DECLARE_TYPEINFO(VLineAngle, Q_MOVABLE_TYPE); // NOLINT #endif // VLINEANGLE_H diff --git a/src/libs/vpatterndb/variables/vlinelength.cpp b/src/libs/vpatterndb/variables/vlinelength.cpp index c6236a5d6..cb9d37886 100644 --- a/src/libs/vpatterndb/variables/vlinelength.cpp +++ b/src/libs/vpatterndb/variables/vlinelength.cpp @@ -77,8 +77,8 @@ VLengthLine &VLengthLine::operator=(const VLengthLine &var) } //--------------------------------------------------------------------------------------------------------------------- -VLengthLine::VLengthLine(const VLengthLine &&var) Q_DECL_NOTHROW - :VInternalVariable(var), d(var.d) +VLengthLine::VLengthLine(VLengthLine &&var) Q_DECL_NOTHROW + :VInternalVariable(std::move(var)), d(std::move(var.d)) {} #ifdef Q_COMPILER_RVALUE_REFS diff --git a/src/libs/vpatterndb/variables/vlinelength.h b/src/libs/vpatterndb/variables/vlinelength.h index b46170246..223e96b64 100644 --- a/src/libs/vpatterndb/variables/vlinelength.h +++ b/src/libs/vpatterndb/variables/vlinelength.h @@ -52,7 +52,7 @@ public: VLengthLine &operator=(const VLengthLine &var); #ifdef Q_COMPILER_RVALUE_REFS - VLengthLine(const VLengthLine &&var) Q_DECL_NOTHROW; + VLengthLine(VLengthLine &&var) Q_DECL_NOTHROW; VLengthLine &operator=(VLengthLine &&var) Q_DECL_NOTHROW; #endif @@ -64,6 +64,6 @@ private: QSharedDataPointer d; }; -Q_DECLARE_TYPEINFO(VLengthLine, Q_MOVABLE_TYPE); +Q_DECLARE_TYPEINFO(VLengthLine, Q_MOVABLE_TYPE); // NOLINT #endif // VLINELENGTH_H diff --git a/src/libs/vpatterndb/variables/vmeasurement.cpp b/src/libs/vpatterndb/variables/vmeasurement.cpp index 41e410861..b7f9fa9db 100644 --- a/src/libs/vpatterndb/variables/vmeasurement.cpp +++ b/src/libs/vpatterndb/variables/vmeasurement.cpp @@ -92,8 +92,8 @@ VMeasurement &VMeasurement::operator=(const VMeasurement &m) #ifdef Q_COMPILER_RVALUE_REFS //--------------------------------------------------------------------------------------------------------------------- -VMeasurement::VMeasurement(const VMeasurement &&m) Q_DECL_NOTHROW - :VVariable(m), d(m.d) +VMeasurement::VMeasurement(VMeasurement &&m) Q_DECL_NOTHROW + :VVariable(std::move(m)), d(std::move(m.d)) {} //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vpatterndb/variables/vmeasurement.h b/src/libs/vpatterndb/variables/vmeasurement.h index 664241ea6..0ba9d6b87 100644 --- a/src/libs/vpatterndb/variables/vmeasurement.h +++ b/src/libs/vpatterndb/variables/vmeasurement.h @@ -60,7 +60,7 @@ public: VMeasurement &operator=(const VMeasurement &m); #ifdef Q_COMPILER_RVALUE_REFS - VMeasurement(const VMeasurement &&m) Q_DECL_NOTHROW; + VMeasurement(VMeasurement &&m) Q_DECL_NOTHROW; VMeasurement &operator=(VMeasurement &&m) Q_DECL_NOTHROW; #endif @@ -127,6 +127,6 @@ private: qreal Correction() const; }; -Q_DECLARE_TYPEINFO(VMeasurement, Q_MOVABLE_TYPE); +Q_DECLARE_TYPEINFO(VMeasurement, Q_MOVABLE_TYPE); // NOLINT #endif // VMULTISIZETABLEROW_H diff --git a/src/libs/vpatterndb/variables/vvariable.cpp b/src/libs/vpatterndb/variables/vvariable.cpp index 826d4122e..180b3a57e 100644 --- a/src/libs/vpatterndb/variables/vvariable.cpp +++ b/src/libs/vpatterndb/variables/vvariable.cpp @@ -65,8 +65,8 @@ VVariable &VVariable::operator=(const VVariable &var) #ifdef Q_COMPILER_RVALUE_REFS //--------------------------------------------------------------------------------------------------------------------- -VVariable::VVariable(const VVariable &&var) Q_DECL_NOTHROW - :VInternalVariable(var), d(var.d) +VVariable::VVariable(VVariable &&var) Q_DECL_NOTHROW + :VInternalVariable(std::move(var)), d(std::move(var.d)) {} //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vpatterndb/variables/vvariable.h b/src/libs/vpatterndb/variables/vvariable.h index 04d35d750..8ab550e9a 100644 --- a/src/libs/vpatterndb/variables/vvariable.h +++ b/src/libs/vpatterndb/variables/vvariable.h @@ -52,7 +52,7 @@ public: VVariable &operator=(const VVariable &var); #ifdef Q_COMPILER_RVALUE_REFS - VVariable(const VVariable &&var) Q_DECL_NOTHROW; + VVariable(VVariable &&var) Q_DECL_NOTHROW; VVariable &operator=(VVariable &&var) Q_DECL_NOTHROW; #endif @@ -63,6 +63,6 @@ private: QSharedDataPointer d; }; -Q_DECLARE_TYPEINFO(VVariable, Q_MOVABLE_TYPE); +Q_DECLARE_TYPEINFO(VVariable, Q_MOVABLE_TYPE); // NOLINT #endif // VVARIABLE_H diff --git a/src/libs/vpatterndb/vcontainer.cpp b/src/libs/vpatterndb/vcontainer.cpp index 07a1bde22..84b89e8c6 100644 --- a/src/libs/vpatterndb/vcontainer.cpp +++ b/src/libs/vpatterndb/vcontainer.cpp @@ -43,8 +43,6 @@ #include "../vgeometry/vspline.h" #include "../vgeometry/varc.h" #include "../vgeometry/vellipticalarc.h" -#include "../vmisc/diagnostic.h" -#include "../vmisc/vabstractapplication.h" #include "../vmisc/literals.h" #include "variables/varcradius.h" #include "variables/vcurveangle.h" @@ -54,14 +52,13 @@ #include "variables/vlineangle.h" #include "variables/vlinelength.h" #include "variables/vmeasurement.h" -#include "variables/vvariable.h" #include "vtranslatevars.h" QT_WARNING_PUSH QT_WARNING_DISABLE_CLANG("-Wmissing-prototypes") QT_WARNING_DISABLE_INTEL(1418) -Q_LOGGING_CATEGORY(vCon, "v.container") +Q_LOGGING_CATEGORY(vCon, "v.container") // NOLINT QT_WARNING_POP @@ -121,8 +118,8 @@ VContainer &VContainer::operator =(const VContainer &data) #ifdef Q_COMPILER_RVALUE_REFS //--------------------------------------------------------------------------------------------------------------------- -VContainer::VContainer(const VContainer &&data) Q_DECL_NOTHROW - :d(data.d) +VContainer::VContainer(VContainer &&data) Q_DECL_NOTHROW + :d(std::move(data.d)) {} //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vpatterndb/vcontainer.h b/src/libs/vpatterndb/vcontainer.h index e07eb7dc7..675489660 100644 --- a/src/libs/vpatterndb/vcontainer.h +++ b/src/libs/vpatterndb/vcontainer.h @@ -121,7 +121,7 @@ QT_WARNING_POP */ class VContainer { - Q_DECLARE_TR_FUNCTIONS(VContainer) + Q_DECLARE_TR_FUNCTIONS(VContainer) // NOLINT public: VContainer(const VTranslateVars *trVars, const Unit *patternUnit, const QString &nspace); VContainer(const VContainer &data); @@ -131,7 +131,7 @@ public: VContainer &operator=(const VContainer &data); #ifdef Q_COMPILER_RVALUE_REFS - VContainer(const VContainer &&data) Q_DECL_NOTHROW; + VContainer(VContainer &&data) Q_DECL_NOTHROW; VContainer &operator=(VContainer &&data) Q_DECL_NOTHROW; #endif @@ -246,7 +246,7 @@ private: static void ClearNamespace(const QString &nspace); }; -Q_DECLARE_TYPEINFO(VContainer, Q_MOVABLE_TYPE); +Q_DECLARE_TYPEINFO(VContainer, Q_MOVABLE_TYPE); // NOLINT /* * Defintion of templated member functions of VContainer diff --git a/src/libs/vpatterndb/vformula.h b/src/libs/vpatterndb/vformula.h index 7fc937a07..eb8218f8b 100644 --- a/src/libs/vpatterndb/vformula.h +++ b/src/libs/vpatterndb/vformula.h @@ -49,7 +49,7 @@ class VFormulaData; class VFormula { - Q_DECLARE_TR_FUNCTIONS(VFormula) + Q_DECLARE_TR_FUNCTIONS(VFormula) // NOLINT public: VFormula(); VFormula(const QString &formula, const VContainer *container); @@ -93,6 +93,6 @@ private: void ResetState(); }; Q_DECLARE_METATYPE(VFormula) -Q_DECLARE_TYPEINFO(VFormula, Q_MOVABLE_TYPE); +Q_DECLARE_TYPEINFO(VFormula, Q_MOVABLE_TYPE); // NOLINT #endif // VFORMULA_H diff --git a/src/libs/vpatterndb/vformula_p.h b/src/libs/vpatterndb/vformula_p.h index 3cb9a1c35..0936f0fbe 100644 --- a/src/libs/vpatterndb/vformula_p.h +++ b/src/libs/vpatterndb/vformula_p.h @@ -44,7 +44,7 @@ QT_WARNING_DISABLE_GCC("-Wnon-virtual-dtor") class VFormulaData : public QSharedData { - Q_DECLARE_TR_FUNCTIONS(VFormulaData) + Q_DECLARE_TR_FUNCTIONS(VFormulaData) // NOLINT public: VFormulaData() {} diff --git a/src/libs/vpatterndb/vnodedetail.cpp b/src/libs/vpatterndb/vnodedetail.cpp index e7734714a..596733007 100644 --- a/src/libs/vpatterndb/vnodedetail.cpp +++ b/src/libs/vpatterndb/vnodedetail.cpp @@ -124,8 +124,8 @@ VNodeDetail &VNodeDetail::operator =(const VNodeDetail &node) #ifdef Q_COMPILER_RVALUE_REFS //--------------------------------------------------------------------------------------------------------------------- -VNodeDetail::VNodeDetail(const VNodeDetail &&node) Q_DECL_NOTHROW - :d (node.d) +VNodeDetail::VNodeDetail(VNodeDetail &&node) Q_DECL_NOTHROW + :d (std::move(node.d)) {} //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vpatterndb/vnodedetail.h b/src/libs/vpatterndb/vnodedetail.h index b0b071e07..e84a029a9 100644 --- a/src/libs/vpatterndb/vnodedetail.h +++ b/src/libs/vpatterndb/vnodedetail.h @@ -74,7 +74,7 @@ public: */ VNodeDetail &operator=(const VNodeDetail &node); #ifdef Q_COMPILER_RVALUE_REFS - VNodeDetail(const VNodeDetail &&node) Q_DECL_NOTHROW; + VNodeDetail(VNodeDetail &&node) Q_DECL_NOTHROW; VNodeDetail &operator=(VNodeDetail &&node) Q_DECL_NOTHROW; #endif @@ -139,6 +139,6 @@ private: }; Q_DECLARE_METATYPE(VNodeDetail) -Q_DECLARE_TYPEINFO(VNodeDetail, Q_MOVABLE_TYPE); +Q_DECLARE_TYPEINFO(VNodeDetail, Q_MOVABLE_TYPE); // NOLINT #endif // VNODEDETAIL_H diff --git a/src/libs/vpatterndb/vpassmark.h b/src/libs/vpatterndb/vpassmark.h index 648b7e34f..709fb82aa 100644 --- a/src/libs/vpatterndb/vpassmark.h +++ b/src/libs/vpatterndb/vpassmark.h @@ -67,7 +67,7 @@ struct VPiecePassmarkData }; Q_DECLARE_METATYPE(VPiecePassmarkData) -Q_DECLARE_TYPEINFO(VPiecePassmarkData, Q_MOVABLE_TYPE); +Q_DECLARE_TYPEINFO(VPiecePassmarkData, Q_MOVABLE_TYPE); // NOLINT QT_WARNING_POP diff --git a/src/libs/vpatterndb/vpiece.cpp b/src/libs/vpatterndb/vpiece.cpp index 0efdca90e..23e6a6a78 100644 --- a/src/libs/vpatterndb/vpiece.cpp +++ b/src/libs/vpatterndb/vpiece.cpp @@ -135,8 +135,8 @@ VPiece &VPiece::operator=(const VPiece &piece) #ifdef Q_COMPILER_RVALUE_REFS //--------------------------------------------------------------------------------------------------------------------- -VPiece::VPiece(const VPiece &&piece) Q_DECL_NOTHROW - : VAbstractPiece(piece), d (piece.d) +VPiece::VPiece(VPiece &&piece) Q_DECL_NOTHROW + : VAbstractPiece(std::move(piece)), d (std::move(piece.d)) {} //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vpatterndb/vpiece.h b/src/libs/vpatterndb/vpiece.h index a748bb145..3811decb1 100644 --- a/src/libs/vpatterndb/vpiece.h +++ b/src/libs/vpatterndb/vpiece.h @@ -48,7 +48,7 @@ class VPassmark; class VPiece : public VAbstractPiece { - Q_DECLARE_TR_FUNCTIONS(VPiece) + Q_DECLARE_TR_FUNCTIONS(VPiece) // NOLINT public: VPiece(); VPiece(const VPiece &piece); @@ -57,7 +57,7 @@ public: VPiece &operator=(const VPiece &piece); #ifdef Q_COMPILER_RVALUE_REFS - VPiece(const VPiece &&piece) Q_DECL_NOTHROW; + VPiece(VPiece &&piece) Q_DECL_NOTHROW; VPiece &operator=(VPiece &&piece) Q_DECL_NOTHROW; #endif @@ -165,6 +165,6 @@ private: qreal GlobalPassmarkLength(const VContainer *data) const; }; -Q_DECLARE_TYPEINFO(VPiece, Q_MOVABLE_TYPE); +Q_DECLARE_TYPEINFO(VPiece, Q_MOVABLE_TYPE); // NOLINT #endif // VPIECE_H diff --git a/src/libs/vpatterndb/vpiecenode.cpp b/src/libs/vpatterndb/vpiecenode.cpp index b2178a4d3..2370eb8c2 100644 --- a/src/libs/vpatterndb/vpiecenode.cpp +++ b/src/libs/vpatterndb/vpiecenode.cpp @@ -67,8 +67,8 @@ VPieceNode &VPieceNode::operator=(const VPieceNode &node) #ifdef Q_COMPILER_RVALUE_REFS //--------------------------------------------------------------------------------------------------------------------- -VPieceNode::VPieceNode(const VPieceNode &&node) Q_DECL_NOTHROW - : d (node.d) +VPieceNode::VPieceNode(VPieceNode &&node) Q_DECL_NOTHROW + : d (std::move(node.d)) {} //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vpatterndb/vpiecenode.h b/src/libs/vpatterndb/vpiecenode.h index 912e6019b..3627b2f27 100644 --- a/src/libs/vpatterndb/vpiecenode.h +++ b/src/libs/vpatterndb/vpiecenode.h @@ -49,7 +49,7 @@ public: VPieceNode &operator=(const VPieceNode &node); #ifdef Q_COMPILER_RVALUE_REFS - VPieceNode(const VPieceNode &&node) Q_DECL_NOTHROW; + VPieceNode(VPieceNode &&node) Q_DECL_NOTHROW; VPieceNode &operator=(VPieceNode &&node) Q_DECL_NOTHROW; #endif @@ -113,6 +113,6 @@ private: }; Q_DECLARE_METATYPE(VPieceNode) -Q_DECLARE_TYPEINFO(VPieceNode, Q_MOVABLE_TYPE); +Q_DECLARE_TYPEINFO(VPieceNode, Q_MOVABLE_TYPE); // NOLINT #endif // VPIECENODE_H diff --git a/src/libs/vpatterndb/vpiecepath.cpp b/src/libs/vpatterndb/vpiecepath.cpp index ebff04b19..f78a7da0d 100644 --- a/src/libs/vpatterndb/vpiecepath.cpp +++ b/src/libs/vpatterndb/vpiecepath.cpp @@ -221,8 +221,8 @@ VPiecePath &VPiecePath::operator=(const VPiecePath &path) #ifdef Q_COMPILER_RVALUE_REFS //--------------------------------------------------------------------------------------------------------------------- -VPiecePath::VPiecePath(const VPiecePath &&path) Q_DECL_NOTHROW - : d (path.d) +VPiecePath::VPiecePath(VPiecePath &&path) Q_DECL_NOTHROW + : d (std::move(path.d)) {} //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vpatterndb/vpiecepath.h b/src/libs/vpatterndb/vpiecepath.h index ffaef1573..2adb52f33 100644 --- a/src/libs/vpatterndb/vpiecepath.h +++ b/src/libs/vpatterndb/vpiecepath.h @@ -54,7 +54,7 @@ public: VPiecePath &operator=(const VPiecePath &path); #ifdef Q_COMPILER_RVALUE_REFS - VPiecePath(const VPiecePath &&path) Q_DECL_NOTHROW; + VPiecePath(VPiecePath &&path) Q_DECL_NOTHROW; VPiecePath &operator=(VPiecePath &&path) Q_DECL_NOTHROW; #endif @@ -145,7 +145,7 @@ private: QSharedDataPointer d; }; -Q_DECLARE_TYPEINFO(VPiecePath, Q_MOVABLE_TYPE); +Q_DECLARE_TYPEINFO(VPiecePath, Q_MOVABLE_TYPE); // NOLINT Q_DECLARE_METATYPE(VPiecePath) #endif // VPIECEPATH_H diff --git a/src/libs/vpatterndb/vtranslatemeasurements.h b/src/libs/vpatterndb/vtranslatemeasurements.h index a134fec36..665e5d2f4 100644 --- a/src/libs/vpatterndb/vtranslatemeasurements.h +++ b/src/libs/vpatterndb/vtranslatemeasurements.h @@ -34,6 +34,7 @@ #include #include "../qmuparser/qmutranslation.h" +#include "../vmisc/defglobal.h" class VTranslateMeasurements { @@ -56,7 +57,8 @@ protected: QMap measurements; private: - Q_DISABLE_COPY(VTranslateMeasurements) + // cppcheck-suppress unknownMacro + Q_DISABLE_COPY_MOVE(VTranslateMeasurements) // NOLINT QMap guiTexts; QMap descriptions; QMap numbers; diff --git a/src/libs/vpropertyexplorer/checkablemessagebox.cpp b/src/libs/vpropertyexplorer/checkablemessagebox.cpp index 7a7abf5e3..868c09054 100644 --- a/src/libs/vpropertyexplorer/checkablemessagebox.cpp +++ b/src/libs/vpropertyexplorer/checkablemessagebox.cpp @@ -105,7 +105,7 @@ public: QDialogButtonBox *buttonBox; QAbstractButton *clickedButton; private: - Q_DISABLE_COPY(CheckableMessageBoxPrivate) + Q_DISABLE_COPY_MOVE(CheckableMessageBoxPrivate) // NOLINT }; CheckableMessageBox::CheckableMessageBox(QWidget *parent) : diff --git a/src/libs/vpropertyexplorer/checkablemessagebox.h b/src/libs/vpropertyexplorer/checkablemessagebox.h index cad6efe62..fad2c0944 100644 --- a/src/libs/vpropertyexplorer/checkablemessagebox.h +++ b/src/libs/vpropertyexplorer/checkablemessagebox.h @@ -40,7 +40,7 @@ class CheckableMessageBoxPrivate; class VPROPERTYEXPLORERSHARED_EXPORT CheckableMessageBox : public QDialog { - Q_OBJECT + Q_OBJECT // NOLINT Q_PROPERTY(QString text READ text WRITE setText) Q_PROPERTY(QPixmap iconPixmap READ iconPixmap WRITE setIconPixmap) Q_PROPERTY(bool isChecked READ isChecked WRITE setChecked) @@ -128,7 +128,8 @@ private slots: void slotClicked(QAbstractButton *b); private: - Q_DISABLE_COPY(CheckableMessageBox) + // cppcheck-suppress unknownMacro + Q_DISABLE_COPY_MOVE(CheckableMessageBox) // NOLINT CheckableMessageBoxPrivate *d; enum DoNotAskAgainType{Question, Information}; diff --git a/src/libs/vpropertyexplorer/plugins/Vector3d/vvector3dproperty.h b/src/libs/vpropertyexplorer/plugins/Vector3d/vvector3dproperty.h index 75097b7f4..761f6a833 100644 --- a/src/libs/vpropertyexplorer/plugins/Vector3d/vvector3dproperty.h +++ b/src/libs/vpropertyexplorer/plugins/Vector3d/vvector3dproperty.h @@ -75,7 +75,7 @@ QT_WARNING_DISABLE_GCC("-Wsuggest-final-types") class VPROPERTYEXPLORERSHARED_EXPORT QVector3DProperty : public VProperty { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit QVector3DProperty(const QString& name); @@ -113,7 +113,7 @@ public: virtual QVariant getValue() const override; private: - Q_DISABLE_COPY(QVector3DProperty) + Q_DISABLE_COPY_MOVE(QVector3DProperty) // NOLINT }; QT_WARNING_POP diff --git a/src/libs/vpropertyexplorer/plugins/vboolproperty.h b/src/libs/vpropertyexplorer/plugins/vboolproperty.h index 8fcb95df3..29f276f46 100644 --- a/src/libs/vpropertyexplorer/plugins/vboolproperty.h +++ b/src/libs/vpropertyexplorer/plugins/vboolproperty.h @@ -42,7 +42,7 @@ QT_WARNING_DISABLE_GCC("-Wsuggest-final-types") //! The VBoolProperty can take two states: True or False. class VPROPERTYEXPLORERSHARED_EXPORT VBoolProperty : public VProperty { - Q_OBJECT + Q_OBJECT // NOLINT public: //! Default constructor explicit VBoolProperty(const QString& name); @@ -87,7 +87,7 @@ public slots: void StateChanged(); private: - Q_DISABLE_COPY(VBoolProperty) + Q_DISABLE_COPY_MOVE(VBoolProperty) // NOLINT }; QT_WARNING_POP diff --git a/src/libs/vpropertyexplorer/plugins/vcolorproperty.h b/src/libs/vpropertyexplorer/plugins/vcolorproperty.h index 0ae7cc280..ca78c8ea8 100644 --- a/src/libs/vpropertyexplorer/plugins/vcolorproperty.h +++ b/src/libs/vpropertyexplorer/plugins/vcolorproperty.h @@ -42,7 +42,7 @@ QT_WARNING_DISABLE_GCC("-Wsuggest-final-types") class VPROPERTYEXPLORERSHARED_EXPORT VColorProperty : public VProperty { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit VColorProperty(const QString &name); @@ -74,7 +74,7 @@ public: virtual VProperty* clone(bool include_children = true, VProperty* container = NULL) const override; private: - Q_DISABLE_COPY(VColorProperty) + Q_DISABLE_COPY_MOVE(VColorProperty) // NOLINT }; QT_WARNING_POP diff --git a/src/libs/vpropertyexplorer/plugins/vcolorpropertyeditor.h b/src/libs/vpropertyexplorer/plugins/vcolorpropertyeditor.h index 44bafb1e2..3d6fc109f 100644 --- a/src/libs/vpropertyexplorer/plugins/vcolorpropertyeditor.h +++ b/src/libs/vpropertyexplorer/plugins/vcolorpropertyeditor.h @@ -41,7 +41,7 @@ namespace VPE class VPROPERTYEXPLORERSHARED_EXPORT VColorPropertyEditor : public QWidget { - Q_OBJECT + Q_OBJECT // NOLINT public: //! Constructor taking a widget as parent @@ -82,7 +82,8 @@ private slots: void onToolButtonClicked(); private: - Q_DISABLE_COPY(VColorPropertyEditor) + // cppcheck-suppress unknownMacro + Q_DISABLE_COPY_MOVE(VColorPropertyEditor) // NOLINT QColor Color; QToolButton* ToolButton; QLabel* TextLabel; diff --git a/src/libs/vpropertyexplorer/plugins/vemptyproperty.h b/src/libs/vpropertyexplorer/plugins/vemptyproperty.h index 58847a7f5..1bf1b7b91 100644 --- a/src/libs/vpropertyexplorer/plugins/vemptyproperty.h +++ b/src/libs/vpropertyexplorer/plugins/vemptyproperty.h @@ -46,7 +46,7 @@ QT_WARNING_DISABLE_GCC("-Wsuggest-final-types") class VPROPERTYEXPLORERSHARED_EXPORT VEmptyProperty : public VProperty { - Q_OBJECT + Q_OBJECT // NOLINT public: //! Standard constructor, takes a name and a parent property as argument explicit VEmptyProperty(const QString& name); @@ -87,7 +87,7 @@ protected: explicit VEmptyProperty(VPropertyPrivate* d); private: - Q_DISABLE_COPY(VEmptyProperty) + Q_DISABLE_COPY_MOVE(VEmptyProperty) // NOLINT }; QT_WARNING_POP diff --git a/src/libs/vpropertyexplorer/plugins/venumproperty.h b/src/libs/vpropertyexplorer/plugins/venumproperty.h index e23e9bdfd..802f7fe77 100644 --- a/src/libs/vpropertyexplorer/plugins/venumproperty.h +++ b/src/libs/vpropertyexplorer/plugins/venumproperty.h @@ -43,7 +43,7 @@ QT_WARNING_DISABLE_GCC("-Wsuggest-final-methods") class VPROPERTYEXPLORERSHARED_EXPORT VEnumProperty : public VProperty { - Q_OBJECT + Q_OBJECT // NOLINT public: //! Constructor explicit VEnumProperty(const QString& name); @@ -105,7 +105,7 @@ protected: // No use of d-pointer in this case, because it is unlikely this will change. If it does, we can still add other //members by reimplementing the VPropertyPrivate class without touching this header file. private: - Q_DISABLE_COPY(VEnumProperty) + Q_DISABLE_COPY_MOVE(VEnumProperty) // NOLINT }; QT_WARNING_POP diff --git a/src/libs/vpropertyexplorer/plugins/vfileproperty.h b/src/libs/vpropertyexplorer/plugins/vfileproperty.h index b22c6d139..8cc83c123 100644 --- a/src/libs/vpropertyexplorer/plugins/vfileproperty.h +++ b/src/libs/vpropertyexplorer/plugins/vfileproperty.h @@ -44,7 +44,7 @@ QT_WARNING_DISABLE_GCC("-Wsuggest-final-methods") class VPROPERTYEXPLORERSHARED_EXPORT VFileProperty : public VProperty { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit VFileProperty(const QString &name); @@ -109,7 +109,7 @@ public: virtual void setDirectory(bool is_directory); private: - Q_DISABLE_COPY(VFileProperty) + Q_DISABLE_COPY_MOVE(VFileProperty) // NOLINT }; QT_WARNING_POP diff --git a/src/libs/vpropertyexplorer/plugins/vfilepropertyeditor.h b/src/libs/vpropertyexplorer/plugins/vfilepropertyeditor.h index 4b714aa3f..fb6ae3f29 100644 --- a/src/libs/vpropertyexplorer/plugins/vfilepropertyeditor.h +++ b/src/libs/vpropertyexplorer/plugins/vfilepropertyeditor.h @@ -42,7 +42,7 @@ QT_WARNING_DISABLE_GCC("-Wsuggest-final-types") class VPROPERTYEXPLORERSHARED_EXPORT VFileEditWidget : public QWidget { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit VFileEditWidget(QWidget* parent, bool is_directory = false); @@ -112,7 +112,7 @@ protected: bool Directory; private: - Q_DISABLE_COPY(VFileEditWidget) + Q_DISABLE_COPY_MOVE(VFileEditWidget) // NOLINT }; QT_WARNING_POP diff --git a/src/libs/vpropertyexplorer/plugins/vlabelproperty.h b/src/libs/vpropertyexplorer/plugins/vlabelproperty.h index f67c63316..2ce557e78 100644 --- a/src/libs/vpropertyexplorer/plugins/vlabelproperty.h +++ b/src/libs/vpropertyexplorer/plugins/vlabelproperty.h @@ -49,7 +49,7 @@ namespace VPE //! Class for holding a string property class VPROPERTYEXPLORERSHARED_EXPORT VLabelProperty : public VProperty { - Q_OBJECT + Q_OBJECT // NOLINT public: VLabelProperty(const QString& name, const QMap& settings); @@ -98,7 +98,7 @@ protected: int typeForParent; private: - Q_DISABLE_COPY(VLabelProperty) + Q_DISABLE_COPY_MOVE(VLabelProperty) // NOLINT }; } diff --git a/src/libs/vpropertyexplorer/plugins/vlinecolorproperty.h b/src/libs/vpropertyexplorer/plugins/vlinecolorproperty.h index a43f19f15..cc1e42722 100644 --- a/src/libs/vpropertyexplorer/plugins/vlinecolorproperty.h +++ b/src/libs/vpropertyexplorer/plugins/vlinecolorproperty.h @@ -48,7 +48,7 @@ namespace VPE class VPROPERTYEXPLORERSHARED_EXPORT VLineColorProperty : public VProperty { - Q_OBJECT + Q_OBJECT // NOLINT public: //! Constructor explicit VLineColorProperty(const QString& name); @@ -102,7 +102,7 @@ protected: // No use of d-pointer in this case, because it is unlikely this will change. If it does, we can still add other //members by reimplementing the VPropertyPrivate class without touching this header file. private: - Q_DISABLE_COPY(VLineColorProperty) + Q_DISABLE_COPY_MOVE(VLineColorProperty) // NOLINT }; } diff --git a/src/libs/vpropertyexplorer/plugins/vlinetypeproperty.h b/src/libs/vpropertyexplorer/plugins/vlinetypeproperty.h index 30a38248e..2c59b7c4a 100644 --- a/src/libs/vpropertyexplorer/plugins/vlinetypeproperty.h +++ b/src/libs/vpropertyexplorer/plugins/vlinetypeproperty.h @@ -49,7 +49,7 @@ namespace VPE class VPROPERTYEXPLORERSHARED_EXPORT VLineTypeProperty : public VProperty { - Q_OBJECT + Q_OBJECT // NOLINT public: //! Constructor explicit VLineTypeProperty(const QString& name); @@ -103,7 +103,7 @@ protected: // No use of d-pointer in this case, because it is unlikely this will change. If it does, we can still add other //members by reimplementing the VPropertyPrivate class without touching this header file. private: - Q_DISABLE_COPY(VLineTypeProperty) + Q_DISABLE_COPY_MOVE(VLineTypeProperty) // NOLINT }; } diff --git a/src/libs/vpropertyexplorer/plugins/vnumberproperty.h b/src/libs/vpropertyexplorer/plugins/vnumberproperty.h index 3c0fdc5e2..4d8cc52c4 100644 --- a/src/libs/vpropertyexplorer/plugins/vnumberproperty.h +++ b/src/libs/vpropertyexplorer/plugins/vnumberproperty.h @@ -85,7 +85,8 @@ public: public slots: void valueChanged(int i); private: - Q_DISABLE_COPY(VIntegerProperty) // NOLINT + // cppcheck-suppress unknownMacro + Q_DISABLE_COPY_MOVE(VIntegerProperty) // NOLINT double m_minValue; double m_maxValue; @@ -146,7 +147,7 @@ public slots: void valueChanged(int i); private: - Q_DISABLE_COPY(VDoubleProperty) + Q_DISABLE_COPY_MOVE(VDoubleProperty) // NOLINT double m_minValue; double m_maxValue; diff --git a/src/libs/vpropertyexplorer/plugins/vobjectproperty.h b/src/libs/vpropertyexplorer/plugins/vobjectproperty.h index d6b8654e0..d6dce19c2 100644 --- a/src/libs/vpropertyexplorer/plugins/vobjectproperty.h +++ b/src/libs/vpropertyexplorer/plugins/vobjectproperty.h @@ -42,7 +42,7 @@ namespace VPE class VPROPERTYEXPLORERSHARED_EXPORT VObjectProperty : public VProperty { - Q_OBJECT + Q_OBJECT // NOLINT public: //! Constructor explicit VObjectProperty(const QString& name); @@ -99,7 +99,7 @@ protected: //members by reimplementing the VPropertyPrivate class without touching this header file. private: - Q_DISABLE_COPY(VObjectProperty) + Q_DISABLE_COPY_MOVE(VObjectProperty) // NOLINT }; } diff --git a/src/libs/vpropertyexplorer/plugins/vpointfproperty.h b/src/libs/vpropertyexplorer/plugins/vpointfproperty.h index 5e3783d76..10440cb19 100644 --- a/src/libs/vpropertyexplorer/plugins/vpointfproperty.h +++ b/src/libs/vpropertyexplorer/plugins/vpointfproperty.h @@ -38,7 +38,7 @@ namespace VPE class VPROPERTYEXPLORERSHARED_EXPORT VPointFProperty : public VProperty { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit VPointFProperty(const QString& name); @@ -77,7 +77,7 @@ public: virtual QVariant getValue() const override; private: - Q_DISABLE_COPY(VPointFProperty) + Q_DISABLE_COPY_MOVE(VPointFProperty) // NOLINT }; } diff --git a/src/libs/vpropertyexplorer/plugins/vshortcutproperty.h b/src/libs/vpropertyexplorer/plugins/vshortcutproperty.h index 5891ddf5b..0f33b94e6 100644 --- a/src/libs/vpropertyexplorer/plugins/vshortcutproperty.h +++ b/src/libs/vpropertyexplorer/plugins/vshortcutproperty.h @@ -42,7 +42,7 @@ QT_WARNING_DISABLE_GCC("-Wsuggest-final-types") //! This property can be used to handle key shortcuts class VPROPERTYEXPLORERSHARED_EXPORT VShortcutProperty : public VProperty { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit VShortcutProperty(const QString &name); @@ -81,7 +81,7 @@ public: virtual void setValue(const QVariant& value) override; private: - Q_DISABLE_COPY(VShortcutProperty) + Q_DISABLE_COPY_MOVE(VShortcutProperty) // NOLINT }; QT_WARNING_POP diff --git a/src/libs/vpropertyexplorer/plugins/vshortcutpropertyeditor.h b/src/libs/vpropertyexplorer/plugins/vshortcutpropertyeditor.h index 8f845baad..2ed0e35f2 100644 --- a/src/libs/vpropertyexplorer/plugins/vshortcutpropertyeditor.h +++ b/src/libs/vpropertyexplorer/plugins/vshortcutpropertyeditor.h @@ -40,7 +40,7 @@ namespace VPE class VPROPERTYEXPLORERSHARED_EXPORT VShortcutEditWidget : public QWidget { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit VShortcutEditWidget(QWidget* parent); @@ -86,7 +86,7 @@ protected: QLineEdit* LineEdit; private: - Q_DISABLE_COPY(VShortcutEditWidget) + Q_DISABLE_COPY_MOVE(VShortcutEditWidget) // NOLINT }; } diff --git a/src/libs/vpropertyexplorer/plugins/vstringproperty.h b/src/libs/vpropertyexplorer/plugins/vstringproperty.h index 794eddff0..7cef18ab7 100644 --- a/src/libs/vpropertyexplorer/plugins/vstringproperty.h +++ b/src/libs/vpropertyexplorer/plugins/vstringproperty.h @@ -41,7 +41,7 @@ namespace VPE //! Class for holding a string property class VPROPERTYEXPLORERSHARED_EXPORT VStringProperty : public VProperty { - Q_OBJECT + Q_OBJECT // NOLINT public: VStringProperty(const QString& name, const QMap& settings); @@ -99,7 +99,7 @@ protected: virtual bool eventFilter(QObject *object, QEvent *event) override; private: - Q_DISABLE_COPY(VStringProperty) + Q_DISABLE_COPY_MOVE(VStringProperty) // NOLINT }; } diff --git a/src/libs/vpropertyexplorer/plugins/vtextproperty.h b/src/libs/vpropertyexplorer/plugins/vtextproperty.h index da006f486..f085bc75b 100644 --- a/src/libs/vpropertyexplorer/plugins/vtextproperty.h +++ b/src/libs/vpropertyexplorer/plugins/vtextproperty.h @@ -86,7 +86,7 @@ protected: bool readOnly; private: - Q_DISABLE_COPY(VTextProperty) + Q_DISABLE_COPY_MOVE(VTextProperty) // NOLINT }; QT_WARNING_POP diff --git a/src/libs/vpropertyexplorer/vproperty.h b/src/libs/vpropertyexplorer/vproperty.h index 130672fe9..9b2cafd4e 100644 --- a/src/libs/vpropertyexplorer/vproperty.h +++ b/src/libs/vpropertyexplorer/vproperty.h @@ -36,7 +36,9 @@ #include #include "vpropertyexplorer_global.h" +#if QT_VERSION < QT_VERSION_CHECK(5, 7, 0) #include "../vmisc/backport/qoverload.h" +#endif // QT_VERSION < QT_VERSION_CHECK(5, 7, 0) #include @@ -64,7 +66,7 @@ QT_WARNING_DISABLE_GCC("-Wsuggest-final-methods") class VPROPERTYEXPLORERSHARED_EXPORT VProperty : public QObject { - Q_OBJECT + Q_OBJECT // NOLINT public: enum DPC_DisplayColumn { @@ -227,7 +229,7 @@ protected: private: // Provide access functions for the d_ptr Q_DECLARE_PRIVATE(VProperty) - Q_DISABLE_COPY(VProperty) + Q_DISABLE_COPY_MOVE(VProperty) // NOLINT }; QT_WARNING_POP diff --git a/src/libs/vpropertyexplorer/vproperty_p.h b/src/libs/vpropertyexplorer/vproperty_p.h index add5c4cc8..dd94d5a4f 100644 --- a/src/libs/vpropertyexplorer/vproperty_p.h +++ b/src/libs/vpropertyexplorer/vproperty_p.h @@ -87,7 +87,7 @@ public: virtual ~VPropertyPrivate(); private: - Q_DISABLE_COPY(VPropertyPrivate) + Q_DISABLE_COPY_MOVE(VPropertyPrivate) // NOLINT }; QT_WARNING_POP diff --git a/src/libs/vpropertyexplorer/vpropertydelegate.h b/src/libs/vpropertyexplorer/vpropertydelegate.h index 6ec47defd..3c3574e17 100644 --- a/src/libs/vpropertyexplorer/vpropertydelegate.h +++ b/src/libs/vpropertyexplorer/vpropertydelegate.h @@ -36,7 +36,7 @@ namespace VPE class VPROPERTYEXPLORERSHARED_EXPORT VPropertyDelegate : public QStyledItemDelegate { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit VPropertyDelegate(QObject *parent = nullptr); virtual ~VPropertyDelegate() override; diff --git a/src/libs/vpropertyexplorer/vpropertyexplorer_global.h b/src/libs/vpropertyexplorer/vpropertyexplorer_global.h index 783cdda43..97a03fd12 100644 --- a/src/libs/vpropertyexplorer/vpropertyexplorer_global.h +++ b/src/libs/vpropertyexplorer/vpropertyexplorer_global.h @@ -29,4 +29,13 @@ # define VPROPERTYEXPLORERSHARED_EXPORT Q_DECL_IMPORT #endif +#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) +#define Q_DISABLE_MOVE(Class) \ +Class(Class &&) = delete; \ + Class &operator=(Class &&) = delete; +#define Q_DISABLE_COPY_MOVE(Class) \ +Q_DISABLE_COPY(Class) \ + Q_DISABLE_MOVE(Class) +#endif + #endif // VPROPERTYEXPLORER_GLOBAL_H diff --git a/src/libs/vpropertyexplorer/vpropertyfactorymanager.h b/src/libs/vpropertyexplorer/vpropertyfactorymanager.h index bfe9965fa..a8e5c2d60 100644 --- a/src/libs/vpropertyexplorer/vpropertyfactorymanager.h +++ b/src/libs/vpropertyexplorer/vpropertyfactorymanager.h @@ -29,6 +29,8 @@ #include "vpropertyexplorer_global.h" +#include "../vmisc/defglobal.h" + namespace VPE { @@ -38,7 +40,7 @@ class VPropertyFactoryManagerPrivate; class VPROPERTYEXPLORERSHARED_EXPORT VPropertyFactoryManager : public QObject { - Q_OBJECT + Q_OBJECT // NOLINT public: //! Constructor explicit VPropertyFactoryManager(QObject* parent = nullptr); @@ -89,7 +91,7 @@ protected: //! The default manager static VPropertyFactoryManager* DefaultManager; private: - Q_DISABLE_COPY(VPropertyFactoryManager) + Q_DISABLE_COPY_MOVE(VPropertyFactoryManager) // NOLINT }; } diff --git a/src/libs/vpropertyexplorer/vpropertyformview.h b/src/libs/vpropertyexplorer/vpropertyformview.h index 82054175d..1eb733a69 100644 --- a/src/libs/vpropertyexplorer/vpropertyformview.h +++ b/src/libs/vpropertyexplorer/vpropertyformview.h @@ -43,7 +43,7 @@ QT_WARNING_DISABLE_GCC("-Wsuggest-final-methods") //! This class populates a form layout with the properties in a model class VPROPERTYEXPLORERSHARED_EXPORT VPropertyFormView : public VPropertyFormWidget { - Q_OBJECT + Q_OBJECT // NOLINT public: //! Constructor explicit VPropertyFormView(QWidget *parent = nullptr); @@ -104,7 +104,7 @@ protected: virtual void connectPropertyFormWidget(VPropertyFormWidget* widget); private: - Q_DISABLE_COPY(VPropertyFormView) + Q_DISABLE_COPY_MOVE(VPropertyFormView) // NOLINT }; QT_WARNING_POP diff --git a/src/libs/vpropertyexplorer/vpropertyformview_p.h b/src/libs/vpropertyexplorer/vpropertyformview_p.h index 2bd6ee159..2990f0930 100644 --- a/src/libs/vpropertyexplorer/vpropertyformview_p.h +++ b/src/libs/vpropertyexplorer/vpropertyformview_p.h @@ -65,7 +65,7 @@ public: virtual ~VPropertyFormViewPrivate() override {} private: - Q_DISABLE_COPY(VPropertyFormViewPrivate) + Q_DISABLE_COPY_MOVE(VPropertyFormViewPrivate) // NOLINT }; QT_WARNING_POP diff --git a/src/libs/vpropertyexplorer/vpropertyformwidget.h b/src/libs/vpropertyexplorer/vpropertyformwidget.h index 6087dafc4..87285e44e 100644 --- a/src/libs/vpropertyexplorer/vpropertyformwidget.h +++ b/src/libs/vpropertyexplorer/vpropertyformwidget.h @@ -42,7 +42,7 @@ class VPropertySet; //! Class that displays the sub properties of a property using a form layout class VPROPERTYEXPLORERSHARED_EXPORT VPropertyFormWidget : public QGroupBox { - Q_OBJECT + Q_OBJECT // NOLINT public: //! Constructor VPropertyFormWidget(const QString& title, const QString& description, const QList& properties, @@ -100,7 +100,7 @@ protected: void commitData(const QWidget* editor); private: - Q_DISABLE_COPY(VPropertyFormWidget) + Q_DISABLE_COPY_MOVE(VPropertyFormWidget) // NOLINT }; } // Namespace VPE diff --git a/src/libs/vpropertyexplorer/vpropertymodel.h b/src/libs/vpropertyexplorer/vpropertymodel.h index c3fce3c11..2c82da2dd 100644 --- a/src/libs/vpropertyexplorer/vpropertymodel.h +++ b/src/libs/vpropertyexplorer/vpropertymodel.h @@ -66,7 +66,7 @@ QT_WARNING_DISABLE_GCC("-Wsuggest-final-methods") //! This might be more convenient in some cases. class VPROPERTYEXPLORERSHARED_EXPORT VPropertyModel : public QAbstractItemModel { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit VPropertyModel(QObject * parent = nullptr); virtual ~VPropertyModel() override; @@ -170,7 +170,7 @@ protected: VPropertyModelPrivate* d_ptr; private: - Q_DISABLE_COPY(VPropertyModel) + Q_DISABLE_COPY_MOVE(VPropertyModel) // NOLINT }; QT_WARNING_POP diff --git a/src/libs/vpropertyexplorer/vpropertymodel_p.h b/src/libs/vpropertyexplorer/vpropertymodel_p.h index 2ff582739..eb31ce19f 100644 --- a/src/libs/vpropertyexplorer/vpropertymodel_p.h +++ b/src/libs/vpropertyexplorer/vpropertymodel_p.h @@ -55,7 +55,8 @@ public: {} private: - Q_DISABLE_COPY(VPropertyModelPrivate) + // cppcheck-suppress unknownMacro + Q_DISABLE_COPY_MOVE(VPropertyModelPrivate) // NOLINT }; } diff --git a/src/libs/vpropertyexplorer/vpropertyset.cpp b/src/libs/vpropertyexplorer/vpropertyset.cpp index 3f028a6df..c950c1f3a 100644 --- a/src/libs/vpropertyexplorer/vpropertyset.cpp +++ b/src/libs/vpropertyexplorer/vpropertyset.cpp @@ -29,6 +29,8 @@ VPE::VPropertySet::VPropertySet() + // cppcheck-suppress noCopyConstructor + // cppcheck-suppress noOperatorEq : d_ptr(new VPropertySetPrivate()) { } diff --git a/src/libs/vpropertyexplorer/vpropertyset.h b/src/libs/vpropertyexplorer/vpropertyset.h index 5a246e454..e47867f78 100644 --- a/src/libs/vpropertyexplorer/vpropertyset.h +++ b/src/libs/vpropertyexplorer/vpropertyset.h @@ -139,11 +139,11 @@ protected: //! The data VPropertySetPrivate* d_ptr; private: - Q_DISABLE_COPY(VPropertySet) + Q_DISABLE_COPY_MOVE(VPropertySet) // NOLINT }; QT_WARNING_POP -} +} // namespace VPE #endif // VPROPERTYMODEL_H diff --git a/src/libs/vpropertyexplorer/vpropertyset_p.h b/src/libs/vpropertyexplorer/vpropertyset_p.h index 5c97ffd3d..63c47712a 100644 --- a/src/libs/vpropertyexplorer/vpropertyset_p.h +++ b/src/libs/vpropertyexplorer/vpropertyset_p.h @@ -26,6 +26,8 @@ #include #include +#include "vpropertyexplorer_global.h" + namespace VPE { @@ -47,7 +49,7 @@ public: {} private: - Q_DISABLE_COPY(VPropertySetPrivate) + Q_DISABLE_COPY_MOVE(VPropertySetPrivate) // NOLINT }; } diff --git a/src/libs/vpropertyexplorer/vpropertytreeview.h b/src/libs/vpropertyexplorer/vpropertytreeview.h index d0d873ed9..d2a5c12e5 100644 --- a/src/libs/vpropertyexplorer/vpropertytreeview.h +++ b/src/libs/vpropertyexplorer/vpropertytreeview.h @@ -30,6 +30,8 @@ #include "vpropertyexplorer_global.h" +#include "../vmisc/defglobal.h" + namespace VPE { @@ -39,7 +41,7 @@ class VPropertyTreeViewPrivate; class VPROPERTYEXPLORERSHARED_EXPORT VPropertyTreeView : public QTreeView { - Q_OBJECT + Q_OBJECT // NOLINT public: //! Default constructor explicit VPropertyTreeView(QWidget *parent = nullptr); @@ -66,7 +68,7 @@ protected: VPropertyTreeViewPrivate* d_ptr; private: - Q_DISABLE_COPY(VPropertyTreeView) + Q_DISABLE_COPY_MOVE(VPropertyTreeView) // NOLINT }; } // namespace VPE diff --git a/src/libs/vtest/abstracttest.h b/src/libs/vtest/abstracttest.h index c57bd142a..a1f42699b 100644 --- a/src/libs/vtest/abstracttest.h +++ b/src/libs/vtest/abstracttest.h @@ -65,7 +65,7 @@ class VRawSAPoint; class AbstractTest : public QObject { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit AbstractTest(QObject *parent = nullptr); diff --git a/src/libs/vtools/dialogs/support/dialogeditlabel.h b/src/libs/vtools/dialogs/support/dialogeditlabel.h index 8c55fb76a..dce679685 100644 --- a/src/libs/vtools/dialogs/support/dialogeditlabel.h +++ b/src/libs/vtools/dialogs/support/dialogeditlabel.h @@ -32,6 +32,8 @@ #include #include +#include "../vmisc/defglobal.h" + namespace Ui { class DialogEditLabel; @@ -46,7 +48,7 @@ class VContainer; class DialogEditLabel : public QDialog { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit DialogEditLabel(const VAbstractPattern *doc, const VContainer *data, QWidget *parent = nullptr); @@ -72,7 +74,8 @@ private slots: void SaveAdditionalFontSize(int i); private: - Q_DISABLE_COPY(DialogEditLabel) + // cppcheck-suppress unknownMacro + Q_DISABLE_COPY_MOVE(DialogEditLabel) // NOLINT Ui::DialogEditLabel *ui; QMenu *m_placeholdersMenu; const VAbstractPattern *m_doc; diff --git a/src/libs/vtools/dialogs/support/dialogundo.h b/src/libs/vtools/dialogs/support/dialogundo.h index 8df0cee30..c92c4304d 100644 --- a/src/libs/vtools/dialogs/support/dialogundo.h +++ b/src/libs/vtools/dialogs/support/dialogundo.h @@ -36,6 +36,8 @@ #include #include +#include "../vmisc/defglobal.h" + namespace Ui { class DialogUndo; @@ -45,7 +47,7 @@ enum class UndoButton {Undo, Fix, Cancel}; class DialogUndo : public QDialog { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit DialogUndo(QWidget *parent = nullptr); UndoButton Result() const; @@ -55,7 +57,8 @@ protected: private slots: void Cancel(); private: - Q_DISABLE_COPY(DialogUndo) + // cppcheck-suppress unknownMacro + Q_DISABLE_COPY_MOVE(DialogUndo) // NOLINT Ui::DialogUndo *ui; UndoButton result; }; diff --git a/src/libs/vtools/dialogs/tools/dialogalongline.cpp b/src/libs/vtools/dialogs/tools/dialogalongline.cpp index 480ffc25d..ffeeeaa9c 100644 --- a/src/libs/vtools/dialogs/tools/dialogalongline.cpp +++ b/src/libs/vtools/dialogs/tools/dialogalongline.cpp @@ -422,8 +422,7 @@ QString DialogAlongLine::GetTypeLine() const */ QString DialogAlongLine::GetFormula() const { - return VAbstractApplication::VApp()->TrVars() - ->TryFormulaFromUser(formula, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); + return VTranslateVars::TryFormulaFromUser(formula, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/dialogs/tools/dialogalongline.h b/src/libs/vtools/dialogs/tools/dialogalongline.h index 9cfda4c46..1163a6235 100644 --- a/src/libs/vtools/dialogs/tools/dialogalongline.h +++ b/src/libs/vtools/dialogs/tools/dialogalongline.h @@ -48,7 +48,7 @@ namespace Ui */ class DialogAlongLine final : public DialogTool { - Q_OBJECT + Q_OBJECT // NOLINT public: DialogAlongLine(const VContainer *data, quint32 toolId, QWidget *parent = nullptr); virtual ~DialogAlongLine() override; @@ -94,7 +94,7 @@ protected: virtual void closeEvent(QCloseEvent *event) override; virtual bool IsValid() const final; private: - Q_DISABLE_COPY(DialogAlongLine) + Q_DISABLE_COPY_MOVE(DialogAlongLine) // NOLINT /** @brief ui keeps information about user interface */ Ui::DialogAlongLine *ui; diff --git a/src/libs/vtools/dialogs/tools/dialogbisector.cpp b/src/libs/vtools/dialogs/tools/dialogbisector.cpp index ffd73e08f..9c23ca3af 100644 --- a/src/libs/vtools/dialogs/tools/dialogbisector.cpp +++ b/src/libs/vtools/dialogs/tools/dialogbisector.cpp @@ -403,8 +403,7 @@ QString DialogBisector::GetTypeLine() const */ QString DialogBisector::GetFormula() const { - return VAbstractApplication::VApp()->TrVars() - ->TryFormulaFromUser(formula, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); + return VTranslateVars::TryFormulaFromUser(formula, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/dialogs/tools/dialogbisector.h b/src/libs/vtools/dialogs/tools/dialogbisector.h index 960cc9a16..2d213350f 100644 --- a/src/libs/vtools/dialogs/tools/dialogbisector.h +++ b/src/libs/vtools/dialogs/tools/dialogbisector.h @@ -48,7 +48,7 @@ namespace Ui */ class DialogBisector final : public DialogTool { - Q_OBJECT + Q_OBJECT // NOLINT public: DialogBisector(const VContainer *data, quint32 toolId, QWidget *parent = nullptr); @@ -96,7 +96,7 @@ protected: virtual void closeEvent(QCloseEvent *event) override; virtual bool IsValid() const final; private: - Q_DISABLE_COPY(DialogBisector) + Q_DISABLE_COPY_MOVE(DialogBisector) // NOLINT /** @brief ui keeps information about user interface */ Ui::DialogBisector *ui; diff --git a/src/libs/vtools/dialogs/tools/dialogcubicbezier.h b/src/libs/vtools/dialogs/tools/dialogcubicbezier.h index a16a5b593..117e26604 100644 --- a/src/libs/vtools/dialogs/tools/dialogcubicbezier.h +++ b/src/libs/vtools/dialogs/tools/dialogcubicbezier.h @@ -47,7 +47,7 @@ namespace Ui class DialogCubicBezier : public DialogTool { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit DialogCubicBezier(const VContainer *data, quint32 toolId, QWidget *parent = nullptr); @@ -72,7 +72,7 @@ protected: private slots: void ValidateAlias(); private: - Q_DISABLE_COPY(DialogCubicBezier) + Q_DISABLE_COPY_MOVE(DialogCubicBezier) // NOLINT Ui::DialogCubicBezier *ui; /** @brief spl spline */ diff --git a/src/libs/vtools/dialogs/tools/dialogcubicbezierpath.h b/src/libs/vtools/dialogs/tools/dialogcubicbezierpath.h index ecea40812..97de231d9 100644 --- a/src/libs/vtools/dialogs/tools/dialogcubicbezierpath.h +++ b/src/libs/vtools/dialogs/tools/dialogcubicbezierpath.h @@ -48,7 +48,7 @@ namespace Ui class DialogCubicBezierPath : public DialogTool { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit DialogCubicBezierPath(const VContainer *data, quint32 toolId, QWidget *parent = nullptr); @@ -72,7 +72,7 @@ private slots: void ValidateAlias(); private: - Q_DISABLE_COPY(DialogCubicBezierPath) + Q_DISABLE_COPY_MOVE(DialogCubicBezierPath) // NOLINT Ui::DialogCubicBezierPath *ui; /** @brief path cubic bezier path */ diff --git a/src/libs/vtools/dialogs/tools/dialogcurveintersectaxis.cpp b/src/libs/vtools/dialogs/tools/dialogcurveintersectaxis.cpp index d3dc6ecc0..41de95491 100644 --- a/src/libs/vtools/dialogs/tools/dialogcurveintersectaxis.cpp +++ b/src/libs/vtools/dialogs/tools/dialogcurveintersectaxis.cpp @@ -141,8 +141,7 @@ void DialogCurveIntersectAxis::SetTypeLine(const QString &value) //--------------------------------------------------------------------------------------------------------------------- QString DialogCurveIntersectAxis::GetAngle() const { - return VAbstractApplication::VApp()->TrVars() - ->TryFormulaFromUser(formulaAngle, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); + return VTranslateVars::TryFormulaFromUser(formulaAngle, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/dialogs/tools/dialogcurveintersectaxis.h b/src/libs/vtools/dialogs/tools/dialogcurveintersectaxis.h index 00eea6e70..c4024fa1d 100644 --- a/src/libs/vtools/dialogs/tools/dialogcurveintersectaxis.h +++ b/src/libs/vtools/dialogs/tools/dialogcurveintersectaxis.h @@ -45,7 +45,7 @@ namespace Ui class DialogCurveIntersectAxis final : public DialogTool { - Q_OBJECT + Q_OBJECT // NOLINT public: DialogCurveIntersectAxis(const VContainer *data, quint32 toolId, QWidget *parent = nullptr); @@ -95,7 +95,7 @@ protected: private slots: void ValidateAlias(); private: - Q_DISABLE_COPY(DialogCurveIntersectAxis) + Q_DISABLE_COPY_MOVE(DialogCurveIntersectAxis) // NOLINT Ui::DialogCurveIntersectAxis *ui; QString formulaAngle; diff --git a/src/libs/vtools/dialogs/tools/dialogcutarc.cpp b/src/libs/vtools/dialogs/tools/dialogcutarc.cpp index 7189794ea..465ea932a 100644 --- a/src/libs/vtools/dialogs/tools/dialogcutarc.cpp +++ b/src/libs/vtools/dialogs/tools/dialogcutarc.cpp @@ -309,8 +309,7 @@ void DialogCutArc::SetPointName(const QString &value) */ QString DialogCutArc::GetFormula() const { - return VAbstractApplication::VApp()->TrVars() - ->TryFormulaFromUser(formula, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); + return VTranslateVars::TryFormulaFromUser(formula, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/dialogs/tools/dialogcutarc.h b/src/libs/vtools/dialogs/tools/dialogcutarc.h index 93b889706..20a3250b9 100644 --- a/src/libs/vtools/dialogs/tools/dialogcutarc.h +++ b/src/libs/vtools/dialogs/tools/dialogcutarc.h @@ -48,7 +48,7 @@ namespace Ui */ class DialogCutArc final : public DialogTool { - Q_OBJECT + Q_OBJECT // NOLINT public: DialogCutArc(const VContainer *data, quint32 toolId, QWidget *parent = nullptr); @@ -93,7 +93,7 @@ private slots: void ArcChanged(); void ValidateAlias(); private: - Q_DISABLE_COPY(DialogCutArc) + Q_DISABLE_COPY_MOVE(DialogCutArc) // NOLINT /** @brief ui keeps information about user interface */ Ui::DialogCutArc *ui; diff --git a/src/libs/vtools/dialogs/tools/dialogcutspline.cpp b/src/libs/vtools/dialogs/tools/dialogcutspline.cpp index 88ff124f2..807ea29f3 100644 --- a/src/libs/vtools/dialogs/tools/dialogcutspline.cpp +++ b/src/libs/vtools/dialogs/tools/dialogcutspline.cpp @@ -309,8 +309,7 @@ void DialogCutSpline::ShowVisualization() */ QString DialogCutSpline::GetFormula() const { - return VAbstractApplication::VApp()->TrVars() - ->TryFormulaFromUser(formula, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); + return VTranslateVars::TryFormulaFromUser(formula, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/dialogs/tools/dialogcutspline.h b/src/libs/vtools/dialogs/tools/dialogcutspline.h index 8d88c26b5..cfac25a72 100644 --- a/src/libs/vtools/dialogs/tools/dialogcutspline.h +++ b/src/libs/vtools/dialogs/tools/dialogcutspline.h @@ -48,7 +48,7 @@ namespace Ui */ class DialogCutSpline final : public DialogTool { - Q_OBJECT + Q_OBJECT // NOLINT public: DialogCutSpline(const VContainer *data, quint32 toolId, QWidget *parent = nullptr); virtual ~DialogCutSpline() override; @@ -90,7 +90,7 @@ private slots: void SplineChanged(); void ValidateAlias(); private: - Q_DISABLE_COPY(DialogCutSpline) + Q_DISABLE_COPY_MOVE(DialogCutSpline) // NOLINT /** @brief ui keeps information about user interface */ Ui::DialogCutSpline *ui; diff --git a/src/libs/vtools/dialogs/tools/dialogcutsplinepath.cpp b/src/libs/vtools/dialogs/tools/dialogcutsplinepath.cpp index 156a3de1c..6c7e00878 100644 --- a/src/libs/vtools/dialogs/tools/dialogcutsplinepath.cpp +++ b/src/libs/vtools/dialogs/tools/dialogcutsplinepath.cpp @@ -309,8 +309,7 @@ void DialogCutSplinePath::ShowVisualization() */ QString DialogCutSplinePath::GetFormula() const { - return VAbstractApplication::VApp()->TrVars() - ->TryFormulaFromUser(formula, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); + return VTranslateVars::TryFormulaFromUser(formula, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/dialogs/tools/dialogcutsplinepath.h b/src/libs/vtools/dialogs/tools/dialogcutsplinepath.h index f1f3ef399..5cb9591e2 100644 --- a/src/libs/vtools/dialogs/tools/dialogcutsplinepath.h +++ b/src/libs/vtools/dialogs/tools/dialogcutsplinepath.h @@ -48,7 +48,7 @@ namespace Ui */ class DialogCutSplinePath final : public DialogTool { - Q_OBJECT + Q_OBJECT // NOLINT public: DialogCutSplinePath(const VContainer *data, quint32 toolId, QWidget *parent = nullptr); virtual ~DialogCutSplinePath() override; @@ -90,7 +90,7 @@ private slots: void SplinePathChanged(); void ValidateAlias(); private: - Q_DISABLE_COPY(DialogCutSplinePath) + Q_DISABLE_COPY_MOVE(DialogCutSplinePath) // NOLINT /** @brief ui keeps information about user interface */ Ui::DialogCutSplinePath *ui; diff --git a/src/libs/vtools/dialogs/tools/dialogellipticalarc.cpp b/src/libs/vtools/dialogs/tools/dialogellipticalarc.cpp index 151ebf2ff..7c213a151 100644 --- a/src/libs/vtools/dialogs/tools/dialogellipticalarc.cpp +++ b/src/libs/vtools/dialogs/tools/dialogellipticalarc.cpp @@ -198,8 +198,7 @@ void DialogEllipticalArc::SetCenter(const quint32 &value) */ QString DialogEllipticalArc::GetRadius1() const { - return VAbstractApplication::VApp()->TrVars() - ->TryFormulaFromUser(radius1, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); + return VTranslateVars::TryFormulaFromUser(radius1, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); } //--------------------------------------------------------------------------------------------------------------------- @@ -232,8 +231,7 @@ void DialogEllipticalArc::SetRadius1(const QString &value) */ QString DialogEllipticalArc::GetRadius2() const { - return VAbstractApplication::VApp()->TrVars() - ->TryFormulaFromUser(radius2, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); + return VTranslateVars::TryFormulaFromUser(radius2, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); } //--------------------------------------------------------------------------------------------------------------------- @@ -266,8 +264,7 @@ void DialogEllipticalArc::SetRadius2(const QString &value) */ QString DialogEllipticalArc::GetF1() const { - return VAbstractApplication::VApp()->TrVars() - ->TryFormulaFromUser(f1, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); + return VTranslateVars::TryFormulaFromUser(f1, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); } //--------------------------------------------------------------------------------------------------------------------- @@ -300,8 +297,7 @@ void DialogEllipticalArc::SetF1(const QString &value) */ QString DialogEllipticalArc::GetF2() const { - return VAbstractApplication::VApp()->TrVars() - ->TryFormulaFromUser(f2, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); + return VTranslateVars::TryFormulaFromUser(f2, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); } //--------------------------------------------------------------------------------------------------------------------- @@ -334,8 +330,7 @@ void DialogEllipticalArc::SetF2(const QString &value) */ QString DialogEllipticalArc::GetRotationAngle() const { - return VAbstractApplication::VApp()->TrVars() - ->TryFormulaFromUser(rotationAngle, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); + return VTranslateVars::TryFormulaFromUser(rotationAngle, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/dialogs/tools/dialogellipticalarc.h b/src/libs/vtools/dialogs/tools/dialogellipticalarc.h index 69d798775..10cb5e7c3 100644 --- a/src/libs/vtools/dialogs/tools/dialogellipticalarc.h +++ b/src/libs/vtools/dialogs/tools/dialogellipticalarc.h @@ -45,7 +45,7 @@ namespace Ui class DialogEllipticalArc : public DialogTool { - Q_OBJECT + Q_OBJECT // NOLINT public: DialogEllipticalArc(const VContainer *data, quint32 toolId, QWidget *parent = nullptr); virtual ~DialogEllipticalArc() override; @@ -110,7 +110,7 @@ private slots: void ValidateAlias(); private: - Q_DISABLE_COPY(DialogEllipticalArc) + Q_DISABLE_COPY_MOVE(DialogEllipticalArc) // NOLINT /** @brief ui keeps information about user interface */ Ui::DialogEllipticalArc *ui; diff --git a/src/libs/vtools/dialogs/tools/dialogendline.cpp b/src/libs/vtools/dialogs/tools/dialogendline.cpp index 8d95b66b8..43fc686c5 100644 --- a/src/libs/vtools/dialogs/tools/dialogendline.cpp +++ b/src/libs/vtools/dialogs/tools/dialogendline.cpp @@ -427,8 +427,7 @@ QString DialogEndLine::GetTypeLine() const */ QString DialogEndLine::GetFormula() const { - return VAbstractApplication::VApp()->TrVars() - ->TryFormulaFromUser(formulaLength, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); + return VTranslateVars::TryFormulaFromUser(formulaLength, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); } //--------------------------------------------------------------------------------------------------------------------- @@ -438,8 +437,7 @@ QString DialogEndLine::GetFormula() const */ QString DialogEndLine::GetAngle() const { - return VAbstractApplication::VApp()->TrVars() - ->TryFormulaFromUser(formulaAngle, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); + return VTranslateVars::TryFormulaFromUser(formulaAngle, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/dialogs/tools/dialogendline.h b/src/libs/vtools/dialogs/tools/dialogendline.h index 8dc68fb60..68780ee86 100644 --- a/src/libs/vtools/dialogs/tools/dialogendline.h +++ b/src/libs/vtools/dialogs/tools/dialogendline.h @@ -48,7 +48,7 @@ namespace Ui */ class DialogEndLine : public DialogTool { - Q_OBJECT + Q_OBJECT // NOLINT public: DialogEndLine(const VContainer *data, quint32 toolId, QWidget *parent = nullptr); virtual ~DialogEndLine() override; @@ -96,7 +96,7 @@ protected: virtual void closeEvent(QCloseEvent *event) override; virtual bool IsValid() const final; private: - Q_DISABLE_COPY(DialogEndLine) + Q_DISABLE_COPY_MOVE(DialogEndLine) // NOLINT /** @brief ui keeps information about user interface */ Ui::DialogEndLine *ui; diff --git a/src/libs/vtools/dialogs/tools/dialogflippingbyaxis.h b/src/libs/vtools/dialogs/tools/dialogflippingbyaxis.h index e64ba3fd4..fb07128c9 100644 --- a/src/libs/vtools/dialogs/tools/dialogflippingbyaxis.h +++ b/src/libs/vtools/dialogs/tools/dialogflippingbyaxis.h @@ -49,7 +49,7 @@ namespace Ui class DialogFlippingByAxis : public DialogTool { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit DialogFlippingByAxis(const VContainer *data, quint32 toolId, QWidget *parent = nullptr); @@ -106,7 +106,7 @@ private slots: void PointChanged(); private: - Q_DISABLE_COPY(DialogFlippingByAxis) + Q_DISABLE_COPY_MOVE(DialogFlippingByAxis) // NOLINT Ui::DialogFlippingByAxis *ui; diff --git a/src/libs/vtools/dialogs/tools/dialogflippingbyline.h b/src/libs/vtools/dialogs/tools/dialogflippingbyline.h index fe3d459b3..98261e419 100644 --- a/src/libs/vtools/dialogs/tools/dialogflippingbyline.h +++ b/src/libs/vtools/dialogs/tools/dialogflippingbyline.h @@ -49,7 +49,7 @@ namespace Ui class DialogFlippingByLine : public DialogTool { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit DialogFlippingByLine(const VContainer *data, quint32 toolId, QWidget *parent = nullptr); @@ -106,7 +106,7 @@ private slots: void PointChanged(); private: - Q_DISABLE_COPY(DialogFlippingByLine) + Q_DISABLE_COPY_MOVE(DialogFlippingByLine) // NOLINT Ui::DialogFlippingByLine *ui; diff --git a/src/libs/vtools/dialogs/tools/dialoggroup.h b/src/libs/vtools/dialogs/tools/dialoggroup.h index ca9632c89..7871bb4d1 100644 --- a/src/libs/vtools/dialogs/tools/dialoggroup.h +++ b/src/libs/vtools/dialogs/tools/dialoggroup.h @@ -45,7 +45,7 @@ namespace Ui class DialogGroup : public DialogTool { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit DialogGroup(const VContainer *data, quint32 toolId, QWidget *parent = nullptr); @@ -73,7 +73,7 @@ private slots: void NameChanged(); private: - Q_DISABLE_COPY(DialogGroup) + Q_DISABLE_COPY_MOVE(DialogGroup) // NOLINT Ui::DialogGroup *ui; QMap group; bool flagName; diff --git a/src/libs/vtools/dialogs/tools/dialogheight.h b/src/libs/vtools/dialogs/tools/dialogheight.h index 835c8e078..59d528751 100644 --- a/src/libs/vtools/dialogs/tools/dialogheight.h +++ b/src/libs/vtools/dialogs/tools/dialogheight.h @@ -48,7 +48,7 @@ namespace Ui */ class DialogHeight final : public DialogTool { - Q_OBJECT + Q_OBJECT // NOLINT public: DialogHeight(const VContainer *data, quint32 toolId, QWidget *parent = nullptr); virtual ~DialogHeight() override; @@ -84,7 +84,7 @@ protected: virtual void SaveData() override; virtual bool IsValid() const final; private: - Q_DISABLE_COPY(DialogHeight) + Q_DISABLE_COPY_MOVE(DialogHeight) // NOLINT /** @brief ui keeps information about user interface */ Ui::DialogHeight *ui; diff --git a/src/libs/vtools/dialogs/tools/dialogline.h b/src/libs/vtools/dialogs/tools/dialogline.h index 5eef73b11..c9aaefd06 100644 --- a/src/libs/vtools/dialogs/tools/dialogline.h +++ b/src/libs/vtools/dialogs/tools/dialogline.h @@ -48,7 +48,7 @@ namespace Ui */ class DialogLine : public DialogTool { - Q_OBJECT + Q_OBJECT // NOLINT public: DialogLine(const VContainer *data, quint32 toolId, QWidget *parent = nullptr); virtual ~DialogLine() override; @@ -78,7 +78,7 @@ protected: virtual void SaveData() override; virtual bool IsValid() const final; private: - Q_DISABLE_COPY(DialogLine) + Q_DISABLE_COPY_MOVE(DialogLine) // NOLINT /** @brief ui keeps information about user interface */ Ui::DialogLine *ui; diff --git a/src/libs/vtools/dialogs/tools/dialoglineintersect.h b/src/libs/vtools/dialogs/tools/dialoglineintersect.h index 7c4b88bec..ec94fbcf2 100644 --- a/src/libs/vtools/dialogs/tools/dialoglineintersect.h +++ b/src/libs/vtools/dialogs/tools/dialoglineintersect.h @@ -48,7 +48,7 @@ namespace Ui */ class DialogLineIntersect : public DialogTool { - Q_OBJECT + Q_OBJECT // NOLINT public: DialogLineIntersect(const VContainer *data, quint32 toolId, QWidget *parent = nullptr); virtual ~DialogLineIntersect() override; @@ -82,7 +82,7 @@ protected: virtual void SaveData() override; virtual bool IsValid() const final; private: - Q_DISABLE_COPY(DialogLineIntersect) + Q_DISABLE_COPY_MOVE(DialogLineIntersect) // NOLINT /** @brief ui keeps information about user interface */ Ui::DialogLineIntersect *ui; diff --git a/src/libs/vtools/dialogs/tools/dialoglineintersectaxis.cpp b/src/libs/vtools/dialogs/tools/dialoglineintersectaxis.cpp index 891f9e1d9..b4a070ddd 100644 --- a/src/libs/vtools/dialogs/tools/dialoglineintersectaxis.cpp +++ b/src/libs/vtools/dialogs/tools/dialoglineintersectaxis.cpp @@ -150,8 +150,7 @@ void DialogLineIntersectAxis::SetTypeLine(const QString &value) //--------------------------------------------------------------------------------------------------------------------- QString DialogLineIntersectAxis::GetAngle() const { - return VAbstractApplication::VApp()->TrVars() - ->TryFormulaFromUser(formulaAngle, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); + return VTranslateVars::TryFormulaFromUser(formulaAngle, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/dialogs/tools/dialoglineintersectaxis.h b/src/libs/vtools/dialogs/tools/dialoglineintersectaxis.h index 524d17d40..368d3ab21 100644 --- a/src/libs/vtools/dialogs/tools/dialoglineintersectaxis.h +++ b/src/libs/vtools/dialogs/tools/dialoglineintersectaxis.h @@ -45,7 +45,7 @@ namespace Ui class DialogLineIntersectAxis : public DialogTool { - Q_OBJECT + Q_OBJECT // NOLINT public: DialogLineIntersectAxis(const VContainer *data, quint32 toolId, QWidget *parent = nullptr); @@ -91,7 +91,7 @@ protected: virtual void closeEvent(QCloseEvent *event) override; virtual bool IsValid() const final; private: - Q_DISABLE_COPY(DialogLineIntersectAxis) + Q_DISABLE_COPY_MOVE(DialogLineIntersectAxis) // NOLINT Ui::DialogLineIntersectAxis *ui; QString formulaAngle; diff --git a/src/libs/vtools/dialogs/tools/dialogmove.cpp b/src/libs/vtools/dialogs/tools/dialogmove.cpp index 2f1cfb063..f081816a0 100644 --- a/src/libs/vtools/dialogs/tools/dialogmove.cpp +++ b/src/libs/vtools/dialogs/tools/dialogmove.cpp @@ -168,8 +168,7 @@ DialogMove::~DialogMove() //--------------------------------------------------------------------------------------------------------------------- QString DialogMove::GetAngle() const { - return VAbstractApplication::VApp()->TrVars() - ->TryFormulaFromUser(formulaAngle, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); + return VTranslateVars::TryFormulaFromUser(formulaAngle, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); } //--------------------------------------------------------------------------------------------------------------------- @@ -194,8 +193,7 @@ void DialogMove::SetAngle(const QString &value) //--------------------------------------------------------------------------------------------------------------------- QString DialogMove::GetLength() const { - return VAbstractApplication::VApp()->TrVars() - ->TryFormulaFromUser(formulaLength, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); + return VTranslateVars::TryFormulaFromUser(formulaLength, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); } //--------------------------------------------------------------------------------------------------------------------- @@ -220,8 +218,7 @@ void DialogMove::SetLength(const QString &value) //--------------------------------------------------------------------------------------------------------------------- QString DialogMove::GetRotationAngle() const { - return VAbstractApplication::VApp()->TrVars() - ->TryFormulaFromUser(formulaRotationAngle, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); + return VTranslateVars::TryFormulaFromUser(formulaRotationAngle, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/dialogs/tools/dialogmove.h b/src/libs/vtools/dialogs/tools/dialogmove.h index d30fb23af..3ba534472 100644 --- a/src/libs/vtools/dialogs/tools/dialogmove.h +++ b/src/libs/vtools/dialogs/tools/dialogmove.h @@ -48,7 +48,7 @@ namespace Ui class DialogMove : public DialogTool { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit DialogMove(const VContainer *data, quint32 toolId, QWidget *parent = nullptr); @@ -119,7 +119,7 @@ protected: virtual bool IsValid() const final; private: - Q_DISABLE_COPY(DialogMove) + Q_DISABLE_COPY_MOVE(DialogMove) // NOLINT Ui::DialogMove *ui; /** @brief timerAngle timer of check formula of angle */ diff --git a/src/libs/vtools/dialogs/tools/dialognormal.cpp b/src/libs/vtools/dialogs/tools/dialognormal.cpp index 6732727ed..dc9ea3080 100644 --- a/src/libs/vtools/dialogs/tools/dialognormal.cpp +++ b/src/libs/vtools/dialogs/tools/dialognormal.cpp @@ -376,8 +376,7 @@ QString DialogNormal::GetTypeLine() const */ QString DialogNormal::GetFormula() const { - return VAbstractApplication::VApp()->TrVars() - ->TryFormulaFromUser(formula, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); + return VTranslateVars::TryFormulaFromUser(formula, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/dialogs/tools/dialognormal.h b/src/libs/vtools/dialogs/tools/dialognormal.h index 4d558f401..81782d1b0 100644 --- a/src/libs/vtools/dialogs/tools/dialognormal.h +++ b/src/libs/vtools/dialogs/tools/dialognormal.h @@ -48,7 +48,7 @@ namespace Ui */ class DialogNormal : public DialogTool { - Q_OBJECT + Q_OBJECT // NOLINT public: DialogNormal(const VContainer *data, quint32 toolId, QWidget *parent = nullptr); virtual ~DialogNormal() override; @@ -94,7 +94,7 @@ protected: virtual void closeEvent(QCloseEvent *event) override; virtual bool IsValid() const final; private: - Q_DISABLE_COPY(DialogNormal) + Q_DISABLE_COPY_MOVE(DialogNormal) // NOLINT /** @brief ui keeps information about user interface */ Ui::DialogNormal *ui; diff --git a/src/libs/vtools/dialogs/tools/dialogpointfromarcandtangent.h b/src/libs/vtools/dialogs/tools/dialogpointfromarcandtangent.h index dc8fd5274..4ca99e38e 100644 --- a/src/libs/vtools/dialogs/tools/dialogpointfromarcandtangent.h +++ b/src/libs/vtools/dialogs/tools/dialogpointfromarcandtangent.h @@ -46,7 +46,7 @@ namespace Ui class DialogPointFromArcAndTangent : public DialogTool { - Q_OBJECT + Q_OBJECT // NOLINT public: DialogPointFromArcAndTangent(const VContainer *data, quint32 toolId, QWidget *parent = nullptr); @@ -79,7 +79,7 @@ protected: virtual bool IsValid() const final; private: - Q_DISABLE_COPY(DialogPointFromArcAndTangent) + Q_DISABLE_COPY_MOVE(DialogPointFromArcAndTangent) // NOLINT Ui::DialogPointFromArcAndTangent *ui; diff --git a/src/libs/vtools/dialogs/tools/dialogpointfromcircleandtangent.cpp b/src/libs/vtools/dialogs/tools/dialogpointfromcircleandtangent.cpp index 37f06b24e..33e208a3d 100644 --- a/src/libs/vtools/dialogs/tools/dialogpointfromcircleandtangent.cpp +++ b/src/libs/vtools/dialogs/tools/dialogpointfromcircleandtangent.cpp @@ -147,9 +147,8 @@ void DialogPointFromCircleAndTangent::SetCircleCenterId(const quint32 &value) //--------------------------------------------------------------------------------------------------------------------- QString DialogPointFromCircleAndTangent::GetCircleRadius() const { - return VAbstractApplication::VApp()->TrVars() - ->TryFormulaFromUser(ui->plainTextEditRadius->toPlainText(), - VAbstractApplication::VApp()->Settings()->GetOsSeparator()); + return VTranslateVars::TryFormulaFromUser(ui->plainTextEditRadius->toPlainText(), + VAbstractApplication::VApp()->Settings()->GetOsSeparator()); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/dialogs/tools/dialogpointfromcircleandtangent.h b/src/libs/vtools/dialogs/tools/dialogpointfromcircleandtangent.h index 4783cb864..9434995a2 100644 --- a/src/libs/vtools/dialogs/tools/dialogpointfromcircleandtangent.h +++ b/src/libs/vtools/dialogs/tools/dialogpointfromcircleandtangent.h @@ -46,7 +46,7 @@ namespace Ui class DialogPointFromCircleAndTangent : public DialogTool { - Q_OBJECT + Q_OBJECT // NOLINT public: DialogPointFromCircleAndTangent(const VContainer *data, quint32 toolId, QWidget *parent = nullptr); @@ -88,7 +88,7 @@ protected: virtual bool IsValid() const final; private: - Q_DISABLE_COPY(DialogPointFromCircleAndTangent) + Q_DISABLE_COPY_MOVE(DialogPointFromCircleAndTangent) // NOLINT Ui::DialogPointFromCircleAndTangent *ui; diff --git a/src/libs/vtools/dialogs/tools/dialogpointofcontact.cpp b/src/libs/vtools/dialogs/tools/dialogpointofcontact.cpp index b9404cb86..3cf1e9726 100644 --- a/src/libs/vtools/dialogs/tools/dialogpointofcontact.cpp +++ b/src/libs/vtools/dialogs/tools/dialogpointofcontact.cpp @@ -354,8 +354,7 @@ void DialogPointOfContact::SetPointName(const QString &value) */ QString DialogPointOfContact::getRadius() const { - return VAbstractApplication::VApp()->TrVars() - ->TryFormulaFromUser(radius, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); + return VTranslateVars::TryFormulaFromUser(radius, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/dialogs/tools/dialogpointofcontact.h b/src/libs/vtools/dialogs/tools/dialogpointofcontact.h index 290f6812d..0c2b3f8c3 100644 --- a/src/libs/vtools/dialogs/tools/dialogpointofcontact.h +++ b/src/libs/vtools/dialogs/tools/dialogpointofcontact.h @@ -49,7 +49,7 @@ namespace Ui */ class DialogPointOfContact : public DialogTool { - Q_OBJECT + Q_OBJECT // NOLINT public: DialogPointOfContact(const VContainer *data, quint32 toolId, QWidget *parent = nullptr); virtual ~DialogPointOfContact() override; @@ -89,7 +89,7 @@ protected: virtual void closeEvent(QCloseEvent *event) override; virtual bool IsValid() const final; private: - Q_DISABLE_COPY(DialogPointOfContact) + Q_DISABLE_COPY_MOVE(DialogPointOfContact) // NOLINT /** @brief ui keeps information about user interface */ Ui::DialogPointOfContact *ui; diff --git a/src/libs/vtools/dialogs/tools/dialogpointofintersection.h b/src/libs/vtools/dialogs/tools/dialogpointofintersection.h index c978c5380..a2f814169 100644 --- a/src/libs/vtools/dialogs/tools/dialogpointofintersection.h +++ b/src/libs/vtools/dialogs/tools/dialogpointofintersection.h @@ -48,7 +48,7 @@ namespace Ui */ class DialogPointOfIntersection : public DialogTool { - Q_OBJECT + Q_OBJECT // NOLINT public: DialogPointOfIntersection(const VContainer *data, quint32 toolId, QWidget *parent = nullptr); virtual ~DialogPointOfIntersection() override; @@ -75,7 +75,7 @@ protected: virtual void SaveData() override; virtual bool IsValid() const final; private: - Q_DISABLE_COPY(DialogPointOfIntersection) + Q_DISABLE_COPY_MOVE(DialogPointOfIntersection) // NOLINT /** @brief ui keeps information about user interface */ Ui::DialogPointOfIntersection *ui; diff --git a/src/libs/vtools/dialogs/tools/dialogpointofintersectionarcs.h b/src/libs/vtools/dialogs/tools/dialogpointofintersectionarcs.h index fdc244e78..986da98ba 100644 --- a/src/libs/vtools/dialogs/tools/dialogpointofintersectionarcs.h +++ b/src/libs/vtools/dialogs/tools/dialogpointofintersectionarcs.h @@ -46,7 +46,7 @@ namespace Ui class DialogPointOfIntersectionArcs : public DialogTool { - Q_OBJECT + Q_OBJECT // NOLINT public: DialogPointOfIntersectionArcs(const VContainer *data, quint32 toolId, QWidget *parent = nullptr); @@ -80,7 +80,7 @@ protected: virtual bool IsValid() const final; private: - Q_DISABLE_COPY(DialogPointOfIntersectionArcs) + Q_DISABLE_COPY_MOVE(DialogPointOfIntersectionArcs) // NOLINT Ui::DialogPointOfIntersectionArcs *ui; diff --git a/src/libs/vtools/dialogs/tools/dialogpointofintersectioncircles.cpp b/src/libs/vtools/dialogs/tools/dialogpointofintersectioncircles.cpp index a6f9b16a9..1f7d1910e 100644 --- a/src/libs/vtools/dialogs/tools/dialogpointofintersectioncircles.cpp +++ b/src/libs/vtools/dialogs/tools/dialogpointofintersectioncircles.cpp @@ -183,9 +183,8 @@ void DialogPointOfIntersectionCircles::SetSecondCircleCenterId(const quint32 &va //--------------------------------------------------------------------------------------------------------------------- QString DialogPointOfIntersectionCircles::GetFirstCircleRadius() const { - return VAbstractApplication::VApp()->TrVars() - ->TryFormulaFromUser(ui->plainTextEditCircle1Radius->toPlainText(), - VAbstractApplication::VApp()->Settings()->GetOsSeparator()); + return VTranslateVars::TryFormulaFromUser(ui->plainTextEditCircle1Radius->toPlainText(), + VAbstractApplication::VApp()->Settings()->GetOsSeparator()); } //--------------------------------------------------------------------------------------------------------------------- @@ -210,9 +209,8 @@ void DialogPointOfIntersectionCircles::SetFirstCircleRadius(const QString &value //--------------------------------------------------------------------------------------------------------------------- QString DialogPointOfIntersectionCircles::GetSecondCircleRadius() const { - return VAbstractApplication::VApp()->TrVars() - ->TryFormulaFromUser(ui->plainTextEditCircle2Radius->toPlainText(), - VAbstractApplication::VApp()->Settings()->GetOsSeparator()); + return VTranslateVars::TryFormulaFromUser(ui->plainTextEditCircle2Radius->toPlainText(), + VAbstractApplication::VApp()->Settings()->GetOsSeparator()); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/dialogs/tools/dialogpointofintersectioncircles.h b/src/libs/vtools/dialogs/tools/dialogpointofintersectioncircles.h index 0ae691ecf..5101e8210 100644 --- a/src/libs/vtools/dialogs/tools/dialogpointofintersectioncircles.h +++ b/src/libs/vtools/dialogs/tools/dialogpointofintersectioncircles.h @@ -46,7 +46,7 @@ namespace Ui class DialogPointOfIntersectionCircles : public DialogTool { - Q_OBJECT + Q_OBJECT // NOLINT public: DialogPointOfIntersectionCircles(const VContainer *data, quint32 toolId, QWidget *parent = nullptr); @@ -96,7 +96,7 @@ protected: virtual bool IsValid() const final; private: - Q_DISABLE_COPY(DialogPointOfIntersectionCircles) + Q_DISABLE_COPY_MOVE(DialogPointOfIntersectionCircles) // NOLINT Ui::DialogPointOfIntersectionCircles *ui; diff --git a/src/libs/vtools/dialogs/tools/dialogpointofintersectioncurves.h b/src/libs/vtools/dialogs/tools/dialogpointofintersectioncurves.h index f8b07aa62..3a7088c4f 100644 --- a/src/libs/vtools/dialogs/tools/dialogpointofintersectioncurves.h +++ b/src/libs/vtools/dialogs/tools/dialogpointofintersectioncurves.h @@ -45,7 +45,7 @@ class DialogPointOfIntersectionCurves; class DialogPointOfIntersectionCurves : public DialogTool { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit DialogPointOfIntersectionCurves(const VContainer *data, quint32 toolId, QWidget *parent = nullptr); @@ -98,7 +98,7 @@ private slots: void ValidateAlias(); private: - Q_DISABLE_COPY(DialogPointOfIntersectionCurves) + Q_DISABLE_COPY_MOVE(DialogPointOfIntersectionCurves) // NOLINT Ui::DialogPointOfIntersectionCurves *ui; diff --git a/src/libs/vtools/dialogs/tools/dialogrotation.cpp b/src/libs/vtools/dialogs/tools/dialogrotation.cpp index fa9106e75..6e5cc8fee 100644 --- a/src/libs/vtools/dialogs/tools/dialogrotation.cpp +++ b/src/libs/vtools/dialogs/tools/dialogrotation.cpp @@ -145,8 +145,7 @@ void DialogRotation::SetOrigPointId(quint32 value) //--------------------------------------------------------------------------------------------------------------------- QString DialogRotation::GetAngle() const { - return VAbstractApplication::VApp()->TrVars() - ->TryFormulaFromUser(formulaAngle, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); + return VTranslateVars::TryFormulaFromUser(formulaAngle, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/dialogs/tools/dialogrotation.h b/src/libs/vtools/dialogs/tools/dialogrotation.h index 63d4e6618..232040e79 100644 --- a/src/libs/vtools/dialogs/tools/dialogrotation.h +++ b/src/libs/vtools/dialogs/tools/dialogrotation.h @@ -48,7 +48,7 @@ namespace Ui class DialogRotation : public DialogTool { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit DialogRotation(const VContainer *data, quint32 toolId, QWidget *parent = nullptr); virtual ~DialogRotation(); @@ -109,7 +109,7 @@ private slots: void PointChanged(); private: - Q_DISABLE_COPY(DialogRotation) + Q_DISABLE_COPY_MOVE(DialogRotation) // NOLINT Ui::DialogRotation *ui; /** @brief timerAngle timer of check formula of angle */ diff --git a/src/libs/vtools/dialogs/tools/dialogshoulderpoint.cpp b/src/libs/vtools/dialogs/tools/dialogshoulderpoint.cpp index 66a4558a3..b8c15c28d 100644 --- a/src/libs/vtools/dialogs/tools/dialogshoulderpoint.cpp +++ b/src/libs/vtools/dialogs/tools/dialogshoulderpoint.cpp @@ -389,8 +389,7 @@ QString DialogShoulderPoint::GetTypeLine() const */ QString DialogShoulderPoint::GetFormula() const { - return VAbstractApplication::VApp()->TrVars() - ->TryFormulaFromUser(formula, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); + return VTranslateVars::TryFormulaFromUser(formula, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/dialogs/tools/dialogshoulderpoint.h b/src/libs/vtools/dialogs/tools/dialogshoulderpoint.h index 95d0f9fda..89c019ec4 100644 --- a/src/libs/vtools/dialogs/tools/dialogshoulderpoint.h +++ b/src/libs/vtools/dialogs/tools/dialogshoulderpoint.h @@ -48,7 +48,7 @@ namespace Ui */ class DialogShoulderPoint : public DialogTool { - Q_OBJECT + Q_OBJECT // NOLINT public: DialogShoulderPoint(const VContainer *data, quint32 toolId, QWidget *parent = nullptr); virtual ~DialogShoulderPoint() override; @@ -94,7 +94,7 @@ protected: virtual void closeEvent(QCloseEvent *event) override; virtual bool IsValid() const final; private: - Q_DISABLE_COPY(DialogShoulderPoint) + Q_DISABLE_COPY_MOVE(DialogShoulderPoint) // NOLINT /** @brief ui keeps information about user interface */ Ui::DialogShoulderPoint *ui; diff --git a/src/libs/vtools/dialogs/tools/dialogsinglepoint.h b/src/libs/vtools/dialogs/tools/dialogsinglepoint.h index 5d3fa2828..29e033b9f 100644 --- a/src/libs/vtools/dialogs/tools/dialogsinglepoint.h +++ b/src/libs/vtools/dialogs/tools/dialogsinglepoint.h @@ -48,7 +48,7 @@ namespace Ui */ class DialogSinglePoint : public DialogTool { - Q_OBJECT + Q_OBJECT // NOLINT public: DialogSinglePoint(const VContainer *data, quint32 toolId, QWidget *parent = nullptr); virtual ~DialogSinglePoint() override; @@ -70,7 +70,7 @@ protected: virtual void SaveData() override; virtual bool IsValid() const final; private: - Q_DISABLE_COPY(DialogSinglePoint) + Q_DISABLE_COPY_MOVE(DialogSinglePoint) // NOLINT /** @brief ui keeps information about user interface */ Ui::DialogSinglePoint *ui; diff --git a/src/libs/vtools/dialogs/tools/dialogspline.cpp b/src/libs/vtools/dialogs/tools/dialogspline.cpp index 06032b215..d8b854f1e 100644 --- a/src/libs/vtools/dialogs/tools/dialogspline.cpp +++ b/src/libs/vtools/dialogs/tools/dialogspline.cpp @@ -278,9 +278,8 @@ void DialogSpline::FXAngle1() { auto* dialog = new DialogEditWrongFormula(data, toolId, this); dialog->setWindowTitle(tr("Edit first control point angle")); - QString angle1F = VAbstractApplication::VApp()->TrVars() - ->TryFormulaFromUser(ui->plainTextEditAngle1F->toPlainText(), - VAbstractApplication::VApp()->Settings()->GetOsSeparator()); + QString angle1F = VTranslateVars::TryFormulaFromUser(ui->plainTextEditAngle1F->toPlainText(), + VAbstractApplication::VApp()->Settings()->GetOsSeparator()); dialog->SetFormula(angle1F); dialog->setPostfix(degreeSymbol); if (dialog->exec() == QDialog::Accepted) @@ -303,9 +302,8 @@ void DialogSpline::FXAngle2() { auto* dialog = new DialogEditWrongFormula(data, toolId, this); dialog->setWindowTitle(tr("Edit second control point angle")); - QString angle2F = VAbstractApplication::VApp()->TrVars() - ->TryFormulaFromUser(ui->plainTextEditAngle2F->toPlainText(), - VAbstractApplication::VApp()->Settings()->GetOsSeparator()); + QString angle2F = VTranslateVars::TryFormulaFromUser(ui->plainTextEditAngle2F->toPlainText(), + VAbstractApplication::VApp()->Settings()->GetOsSeparator()); dialog->SetFormula(angle2F); dialog->setPostfix(degreeSymbol); if (dialog->exec() == QDialog::Accepted) @@ -328,9 +326,8 @@ void DialogSpline::FXLength1() { auto* dialog = new DialogEditWrongFormula(data, toolId, this); dialog->setWindowTitle(tr("Edit first control point length")); - QString length1F = VAbstractApplication::VApp()->TrVars() - ->TryFormulaFromUser(ui->plainTextEditLength1F->toPlainText(), - VAbstractApplication::VApp()->Settings()->GetOsSeparator()); + QString length1F = VTranslateVars::TryFormulaFromUser(ui->plainTextEditLength1F->toPlainText(), + VAbstractApplication::VApp()->Settings()->GetOsSeparator()); dialog->SetFormula(length1F); dialog->setPostfix(UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true)); if (dialog->exec() == QDialog::Accepted) @@ -353,9 +350,8 @@ void DialogSpline::FXLength2() { auto* dialog = new DialogEditWrongFormula(data, toolId, this); dialog->setWindowTitle(tr("Edit second control point length")); - QString length2F = VAbstractApplication::VApp()->TrVars() - ->TryFormulaFromUser(ui->plainTextEditLength2F->toPlainText(), - VAbstractApplication::VApp()->Settings()->GetOsSeparator()); + QString length2F = VTranslateVars::TryFormulaFromUser(ui->plainTextEditLength2F->toPlainText(), + VAbstractApplication::VApp()->Settings()->GetOsSeparator()); dialog->SetFormula(length2F); dialog->setPostfix(UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true)); if (dialog->exec() == QDialog::Accepted) @@ -484,10 +480,10 @@ VSpline DialogSpline::CurrentSpline() const const bool separator = VAbstractApplication::VApp()->Settings()->GetOsSeparator(); - angle1F = VAbstractApplication::VApp()->TrVars()->TryFormulaFromUser(angle1F, separator); - angle2F = VAbstractApplication::VApp()->TrVars()->TryFormulaFromUser(angle2F, separator); - length1F = VAbstractApplication::VApp()->TrVars()->TryFormulaFromUser(length1F, separator); - length2F = VAbstractApplication::VApp()->TrVars()->TryFormulaFromUser(length2F, separator); + angle1F = VTranslateVars::TryFormulaFromUser(angle1F, separator); + angle2F = VTranslateVars::TryFormulaFromUser(angle2F, separator); + length1F = VTranslateVars::TryFormulaFromUser(length1F, separator); + length2F = VTranslateVars::TryFormulaFromUser(length2F, separator); VSpline spline(*GetP1(), *GetP4(), angle1, angle1F, angle2, angle2F, length1, length1F, length2, length2F); spline.SetApproximationScale(ui->doubleSpinBoxApproximationScale->value()); diff --git a/src/libs/vtools/dialogs/tools/dialogspline.h b/src/libs/vtools/dialogs/tools/dialogspline.h index 92f40a14f..fa0507343 100644 --- a/src/libs/vtools/dialogs/tools/dialogspline.h +++ b/src/libs/vtools/dialogs/tools/dialogspline.h @@ -50,7 +50,7 @@ namespace Ui */ class DialogSpline : public DialogTool { - Q_OBJECT + Q_OBJECT // NOLINT public: DialogSpline(const VContainer *data, quint32 toolId, QWidget *parent = nullptr); virtual ~DialogSpline() override; @@ -91,7 +91,7 @@ private slots: void ValidateAlias(); private: - Q_DISABLE_COPY(DialogSpline) + Q_DISABLE_COPY_MOVE(DialogSpline) // NOLINT /** @brief ui keeps information about user interface */ Ui::DialogSpline *ui; diff --git a/src/libs/vtools/dialogs/tools/dialogsplinepath.h b/src/libs/vtools/dialogs/tools/dialogsplinepath.h index 36f68bbea..203a5c87f 100644 --- a/src/libs/vtools/dialogs/tools/dialogsplinepath.h +++ b/src/libs/vtools/dialogs/tools/dialogsplinepath.h @@ -51,7 +51,7 @@ namespace Ui */ class DialogSplinePath : public DialogTool { - Q_OBJECT + Q_OBJECT // NOLINT public: DialogSplinePath(const VContainer *data, quint32 toolId, QWidget *parent = nullptr); virtual ~DialogSplinePath() override; @@ -91,7 +91,7 @@ private slots: void ValidateAlias(); private: - Q_DISABLE_COPY(DialogSplinePath) + Q_DISABLE_COPY_MOVE(DialogSplinePath) // NOLINT /** @brief ui keeps information about user interface */ Ui::DialogSplinePath *ui; diff --git a/src/libs/vtools/dialogs/tools/dialogtool.cpp b/src/libs/vtools/dialogs/tools/dialogtool.cpp index 0ba53a89b..a7b91d651 100644 --- a/src/libs/vtools/dialogs/tools/dialogtool.cpp +++ b/src/libs/vtools/dialogs/tools/dialogtool.cpp @@ -61,12 +61,8 @@ #include #include "../ifc/xml/vdomdocument.h" -#include "../qmuparser/qmudef.h" -#include "../qmuparser/qmuparsererror.h" #include "../vgeometry/vpointf.h" -#include "../vpatterndb/calculator.h" #include "../vpatterndb/vcontainer.h" -#include "../vpatterndb/vtranslatevars.h" #include "../vpatterndb/vpiecenode.h" #include "../../tools/vabstracttool.h" #include "../ifc/xml/vabstractpattern.h" @@ -75,7 +71,13 @@ template class QSharedPointer; -Q_LOGGING_CATEGORY(vDialog, "v.dialog") +QT_WARNING_PUSH +QT_WARNING_DISABLE_CLANG("-Wmissing-prototypes") +QT_WARNING_DISABLE_INTEL(1418) + +Q_LOGGING_CATEGORY(vDialog, "v.dialog") // NOLINT + +QT_WARNING_POP //--------------------------------------------------------------------------------------------------------------------- /** diff --git a/src/libs/vtools/dialogs/tools/dialogtool.h b/src/libs/vtools/dialogs/tools/dialogtool.h index a0965de26..915df420d 100644 --- a/src/libs/vtools/dialogs/tools/dialogtool.h +++ b/src/libs/vtools/dialogs/tools/dialogtool.h @@ -79,7 +79,7 @@ QT_WARNING_DISABLE_GCC("-Wsuggest-final-methods") */ class DialogTool : public QDialog { - Q_OBJECT + Q_OBJECT // NOLINT public: DialogTool(const VContainer *data, quint32 toolId, QWidget *parent = nullptr); virtual ~DialogTool() override; @@ -222,7 +222,7 @@ protected: void InitNodeAngles(QComboBox *box); private: - Q_DISABLE_COPY(DialogTool) + Q_DISABLE_COPY_MOVE(DialogTool) // NOLINT void FillList(QComboBox *box, const QMap &list)const; template diff --git a/src/libs/vtools/dialogs/tools/dialogtriangle.h b/src/libs/vtools/dialogs/tools/dialogtriangle.h index f9930b00b..938981b02 100644 --- a/src/libs/vtools/dialogs/tools/dialogtriangle.h +++ b/src/libs/vtools/dialogs/tools/dialogtriangle.h @@ -48,7 +48,7 @@ namespace Ui */ class DialogTriangle : public DialogTool { - Q_OBJECT + Q_OBJECT // NOLINT public: DialogTriangle(const VContainer *data, quint32 toolId, QWidget *parent = nullptr); virtual ~DialogTriangle() override; @@ -81,7 +81,7 @@ protected: virtual void SaveData() override; virtual bool IsValid() const final; private: - Q_DISABLE_COPY(DialogTriangle) + Q_DISABLE_COPY_MOVE(DialogTriangle) // NOLINT /** @brief ui keeps information about user interface */ Ui::DialogTriangle *ui; diff --git a/src/libs/vtools/dialogs/tools/dialogtruedarts.h b/src/libs/vtools/dialogs/tools/dialogtruedarts.h index 6843b740c..2fa234e63 100644 --- a/src/libs/vtools/dialogs/tools/dialogtruedarts.h +++ b/src/libs/vtools/dialogs/tools/dialogtruedarts.h @@ -45,7 +45,7 @@ namespace Ui class DialogTrueDarts : public DialogTool { - Q_OBJECT + Q_OBJECT // NOLINT public: DialogTrueDarts(const VContainer *data, quint32 toolId, QWidget *parent = nullptr); @@ -88,7 +88,7 @@ protected: virtual bool IsValid() const final; private: - Q_DISABLE_COPY(DialogTrueDarts) + Q_DISABLE_COPY_MOVE(DialogTrueDarts) // NOLINT Ui::DialogTrueDarts *ui; QString d1PointName; diff --git a/src/libs/vtools/dialogs/tools/dialoguniondetails.h b/src/libs/vtools/dialogs/tools/dialoguniondetails.h index 00c00dcb1..5578a2f1b 100644 --- a/src/libs/vtools/dialogs/tools/dialoguniondetails.h +++ b/src/libs/vtools/dialogs/tools/dialoguniondetails.h @@ -48,7 +48,7 @@ namespace Ui */ class DialogUnionDetails : public DialogTool { - Q_OBJECT + Q_OBJECT // NOLINT public: DialogUnionDetails(const VContainer *data, quint32 toolId, QWidget *parent = nullptr); virtual ~DialogUnionDetails() override; @@ -64,7 +64,7 @@ public slots: protected: virtual bool IsValid() const final {return true;} private: - Q_DISABLE_COPY(DialogUnionDetails) + Q_DISABLE_COPY_MOVE(DialogUnionDetails) // NOLINT /** @brief ui keeps information about user interface */ Ui::DialogUnionDetails *ui; diff --git a/src/libs/vtools/dialogs/tools/piece/dialogduplicatedetail.h b/src/libs/vtools/dialogs/tools/piece/dialogduplicatedetail.h index 2c1d57ffb..8f53837a8 100644 --- a/src/libs/vtools/dialogs/tools/piece/dialogduplicatedetail.h +++ b/src/libs/vtools/dialogs/tools/piece/dialogduplicatedetail.h @@ -37,7 +37,7 @@ namespace Ui class DialogDuplicateDetail : public DialogTool { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit DialogDuplicateDetail(const VContainer *data, quint32 toolId, QWidget *parent = nullptr); @@ -53,7 +53,7 @@ public slots: protected: virtual bool IsValid() const final {return true;} private: - Q_DISABLE_COPY(DialogDuplicateDetail) + Q_DISABLE_COPY_MOVE(DialogDuplicateDetail) // NOLINT Ui::DialogDuplicateDetail *ui; quint32 m_idDetail; qreal m_mx; diff --git a/src/libs/vtools/dialogs/tools/piece/dialoginsertnode.h b/src/libs/vtools/dialogs/tools/piece/dialoginsertnode.h index 831a51678..29fc1de49 100644 --- a/src/libs/vtools/dialogs/tools/piece/dialoginsertnode.h +++ b/src/libs/vtools/dialogs/tools/piece/dialoginsertnode.h @@ -39,7 +39,7 @@ namespace Ui class DialogInsertNode : public DialogTool { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit DialogInsertNode(const VContainer *data, quint32 toolId, QWidget *parent = nullptr); @@ -66,7 +66,7 @@ private slots: void NodeNumberChanged(int val); private: - Q_DISABLE_COPY(DialogInsertNode) + Q_DISABLE_COPY_MOVE(DialogInsertNode) // NOLINT Ui::DialogInsertNode *ui; QVector m_nodes{}; diff --git a/src/libs/vtools/dialogs/tools/piece/dialogpatternmaterials.h b/src/libs/vtools/dialogs/tools/piece/dialogpatternmaterials.h index 6ba52a9fd..71d02cd31 100644 --- a/src/libs/vtools/dialogs/tools/piece/dialogpatternmaterials.h +++ b/src/libs/vtools/dialogs/tools/piece/dialogpatternmaterials.h @@ -31,6 +31,8 @@ #include +#include "../vmisc/defglobal.h" + namespace Ui { class DialogPatternMaterials; @@ -40,7 +42,7 @@ class VComboBoxDelegate; class DialogPatternMaterials : public QDialog { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit DialogPatternMaterials(const QMap &list, bool rememberPM, QWidget *parent = nullptr); @@ -51,7 +53,8 @@ public: QStringList GetKnownMaterials() const; private: - Q_DISABLE_COPY(DialogPatternMaterials) + // cppcheck-suppress unknownMacro + Q_DISABLE_COPY_MOVE(DialogPatternMaterials) // NOLINT Ui::DialogPatternMaterials *ui; QStringList m_knownMaterials; diff --git a/src/libs/vtools/dialogs/tools/piece/dialogpiecepath.cpp b/src/libs/vtools/dialogs/tools/piece/dialogpiecepath.cpp index 6544e58fa..8920bb60a 100644 --- a/src/libs/vtools/dialogs/tools/piece/dialogpiecepath.cpp +++ b/src/libs/vtools/dialogs/tools/piece/dialogpiecepath.cpp @@ -921,9 +921,8 @@ void DialogPiecePath::EvalPassmarkLength() Eval(formulaData, m_flagFormulaPassmarkLength); - UpdateNodePassmarkLength(VAbstractApplication::VApp()->TrVars() - ->TryFormulaFromUser(ui->plainTextEditPassmarkLength->toPlainText(), - VAbstractApplication::VApp()->Settings()->GetOsSeparator())); + UpdateNodePassmarkLength(VTranslateVars::TryFormulaFromUser( + ui->plainTextEditPassmarkLength->toPlainText(), VAbstractApplication::VApp()->Settings()->GetOsSeparator())); } //--------------------------------------------------------------------------------------------------------------------- @@ -1584,8 +1583,7 @@ void DialogPiecePath::SetPieceId(quint32 id) QString DialogPiecePath::GetFormulaSAWidth() const { QString width = ui->plainTextEditFormulaWidth->toPlainText(); - return VAbstractApplication::VApp()->TrVars() - ->TryFormulaFromUser(width, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); + return VTranslateVars::TryFormulaFromUser(width, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); } //--------------------------------------------------------------------------------------------------------------------- @@ -1702,24 +1700,21 @@ void DialogPiecePath::NewItem(const VPieceNode &node) QString DialogPiecePath::GetFormulaSAWidthBefore() const { QString width = ui->plainTextEditFormulaWidthBefore->toPlainText(); - return VAbstractApplication::VApp()->TrVars() - ->TryFormulaFromUser(width, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); + return VTranslateVars::TryFormulaFromUser(width, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); } //--------------------------------------------------------------------------------------------------------------------- QString DialogPiecePath::GetFormulaSAWidthAfter() const { QString width = ui->plainTextEditFormulaWidthAfter->toPlainText(); - return VAbstractApplication::VApp()->TrVars() - ->TryFormulaFromUser(width, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); + return VTranslateVars::TryFormulaFromUser(width, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); } //--------------------------------------------------------------------------------------------------------------------- QString DialogPiecePath::GetFormulaVisible() const { QString formula = ui->plainTextEditFormulaVisible->toPlainText(); - return VAbstractApplication::VApp()->TrVars() - ->TryFormulaFromUser(formula, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); + return VTranslateVars::TryFormulaFromUser(formula, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); } //--------------------------------------------------------------------------------------------------------------------- @@ -1740,8 +1735,7 @@ void DialogPiecePath::SetFormulaVisible(const QString &formula) QString DialogPiecePath::GetFormulaPassmarkLength() const { QString formula = ui->plainTextEditPassmarkLength->toPlainText(); - return VAbstractApplication::VApp()->TrVars() - ->TryFormulaFromUser(formula, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); + return VTranslateVars::TryFormulaFromUser(formula, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/dialogs/tools/piece/dialogpiecepath.h b/src/libs/vtools/dialogs/tools/piece/dialogpiecepath.h index 22c35f548..9fddc835e 100644 --- a/src/libs/vtools/dialogs/tools/piece/dialogpiecepath.h +++ b/src/libs/vtools/dialogs/tools/piece/dialogpiecepath.h @@ -38,7 +38,7 @@ namespace Ui class DialogPiecePath : public DialogTool { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit DialogPiecePath(const VContainer *data, quint32 toolId, QWidget *parent = nullptr); virtual ~DialogPiecePath(); @@ -100,7 +100,7 @@ private slots: void SetMoveControls(); private: - Q_DISABLE_COPY(DialogPiecePath) + Q_DISABLE_COPY_MOVE(DialogPiecePath) // NOLINT Ui::DialogPiecePath *ui; bool m_showMode; qreal m_saWidth; diff --git a/src/libs/vtools/dialogs/tools/piece/dialogpin.h b/src/libs/vtools/dialogs/tools/piece/dialogpin.h index 1921d7b28..d1e3c2927 100644 --- a/src/libs/vtools/dialogs/tools/piece/dialogpin.h +++ b/src/libs/vtools/dialogs/tools/piece/dialogpin.h @@ -38,7 +38,7 @@ namespace Ui class DialogPin : public DialogTool { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit DialogPin(const VContainer *data, quint32 toolId, QWidget *parent = nullptr); virtual ~DialogPin(); @@ -61,7 +61,7 @@ protected: virtual bool IsValid() const final; private: - Q_DISABLE_COPY(DialogPin) + Q_DISABLE_COPY_MOVE(DialogPin) // NOLINT Ui::DialogPin *ui; bool m_showMode; bool m_flagPoint; diff --git a/src/libs/vtools/dialogs/tools/piece/dialogplacelabel.cpp b/src/libs/vtools/dialogs/tools/piece/dialogplacelabel.cpp index e5c97d449..f478f3530 100644 --- a/src/libs/vtools/dialogs/tools/piece/dialogplacelabel.cpp +++ b/src/libs/vtools/dialogs/tools/piece/dialogplacelabel.cpp @@ -126,9 +126,8 @@ void DialogPlaceLabel::SetLabelType(PlaceLabelType type) //--------------------------------------------------------------------------------------------------------------------- QString DialogPlaceLabel::GetWidth() const { - return VAbstractApplication::VApp()->TrVars() - ->TryFormulaFromUser(ui->plainTextEditFormulaWidth->toPlainText(), - VAbstractApplication::VApp()->Settings()->GetOsSeparator()); + return VTranslateVars::TryFormulaFromUser(ui->plainTextEditFormulaWidth->toPlainText(), + VAbstractApplication::VApp()->Settings()->GetOsSeparator()); } //--------------------------------------------------------------------------------------------------------------------- @@ -154,9 +153,8 @@ void DialogPlaceLabel::SetWidth(const QString &value) //--------------------------------------------------------------------------------------------------------------------- QString DialogPlaceLabel::GetHeight() const { - return VAbstractApplication::VApp()->TrVars() - ->TryFormulaFromUser(ui->plainTextEditFormulaHeight->toPlainText(), - VAbstractApplication::VApp()->Settings()->GetOsSeparator()); + return VTranslateVars::TryFormulaFromUser(ui->plainTextEditFormulaHeight->toPlainText(), + VAbstractApplication::VApp()->Settings()->GetOsSeparator()); } //--------------------------------------------------------------------------------------------------------------------- @@ -182,9 +180,8 @@ void DialogPlaceLabel::SetHeight(const QString &value) //--------------------------------------------------------------------------------------------------------------------- QString DialogPlaceLabel::GetAngle() const { - return VAbstractApplication::VApp()->TrVars() - ->TryFormulaFromUser(ui->plainTextEditFormulaAngle->toPlainText(), - VAbstractApplication::VApp()->Settings()->GetOsSeparator()); + return VTranslateVars::TryFormulaFromUser(ui->plainTextEditFormulaAngle->toPlainText(), + VAbstractApplication::VApp()->Settings()->GetOsSeparator()); } //--------------------------------------------------------------------------------------------------------------------- @@ -553,8 +550,7 @@ void DialogPlaceLabel::CheckPoint() QString DialogPlaceLabel::GetFormulaVisible() const { QString formula = ui->plainTextEditFormulaVisible->toPlainText(); - return VAbstractApplication::VApp()->TrVars() - ->TryFormulaFromUser(formula, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); + return VTranslateVars::TryFormulaFromUser(formula, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/dialogs/tools/piece/dialogplacelabel.h b/src/libs/vtools/dialogs/tools/piece/dialogplacelabel.h index d7bb580ed..04e10123a 100644 --- a/src/libs/vtools/dialogs/tools/piece/dialogplacelabel.h +++ b/src/libs/vtools/dialogs/tools/piece/dialogplacelabel.h @@ -39,7 +39,7 @@ class VPlaceLabelItem; class DialogPlaceLabel : public DialogTool { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit DialogPlaceLabel(const VContainer *data, quint32 toolId, QWidget *parent = nullptr); @@ -95,7 +95,7 @@ private slots: void FXVisible(); private: - Q_DISABLE_COPY(DialogPlaceLabel) + Q_DISABLE_COPY_MOVE(DialogPlaceLabel) // NOLINT Ui::DialogPlaceLabel *ui; bool m_showMode; diff --git a/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp b/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp index 4040103af..f22c4ca18 100644 --- a/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp +++ b/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp @@ -79,8 +79,8 @@ void EnableDefButton(QPushButton *defButton, const QString &formula) QString GetFormulaFromUser(QPlainTextEdit *textEdit) { SCASSERT(textEdit != nullptr) - return VAbstractApplication::VApp()->TrVars() - ->TryFormulaFromUser(textEdit->toPlainText(), VAbstractApplication::VApp()->Settings()->GetOsSeparator()); + return VTranslateVars::TryFormulaFromUser(textEdit->toPlainText(), + VAbstractApplication::VApp()->Settings()->GetOsSeparator()); } //--------------------------------------------------------------------------------------------------------------------- @@ -2037,9 +2037,8 @@ void DialogSeamAllowance::EditGrainlineFormula() DialogEditWrongFormula dlg(data, NULL_ID, this); dlg.setWindowTitle(title); - dlg.SetFormula(VAbstractApplication::VApp()->TrVars() - ->TryFormulaFromUser(pleFormula->toPlainText(), - VAbstractApplication::VApp()->Settings()->GetOsSeparator())); + dlg.SetFormula(VTranslateVars::TryFormulaFromUser(pleFormula->toPlainText(), + VAbstractApplication::VApp()->Settings()->GetOsSeparator())); dlg.setCheckZero(bCheckZero); if (dlg.exec() == QDialog::Accepted) { @@ -2095,9 +2094,8 @@ void DialogSeamAllowance::EditDLFormula() DialogEditWrongFormula dlg(data, NULL_ID, this); dlg.setWindowTitle(title); - dlg.SetFormula(VAbstractApplication::VApp()->TrVars() - ->TryFormulaFromUser(pleFormula->toPlainText(), - VAbstractApplication::VApp()->Settings()->GetOsSeparator())); + dlg.SetFormula(VTranslateVars::TryFormulaFromUser(pleFormula->toPlainText(), + VAbstractApplication::VApp()->Settings()->GetOsSeparator())); dlg.setCheckZero(bCheckZero); if (dlg.exec() == QDialog::Accepted) { @@ -2156,9 +2154,8 @@ void DialogSeamAllowance::EditPLFormula() DialogEditWrongFormula dlg(data, NULL_ID, this); dlg.setWindowTitle(title); - dlg.SetFormula(VAbstractApplication::VApp()->TrVars() - ->TryFormulaFromUser(pleFormula->toPlainText(), - VAbstractApplication::VApp()->Settings()->GetOsSeparator())); + dlg.SetFormula(VTranslateVars::TryFormulaFromUser(pleFormula->toPlainText(), + VAbstractApplication::VApp()->Settings()->GetOsSeparator())); dlg.setCheckZero(bCheckZero); if (dlg.exec() == QDialog::Accepted) { @@ -3463,8 +3460,7 @@ void DialogSeamAllowance::InitAllPinComboboxes() QString DialogSeamAllowance::GetFormulaSAWidth() const { QString width = uiTabPaths->plainTextEditFormulaWidth->toPlainText(); - return VAbstractApplication::VApp()->TrVars() - ->TryFormulaFromUser(width, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); + return VTranslateVars::TryFormulaFromUser(width, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.h b/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.h index dc0b46a37..1a36d4006 100644 --- a/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.h +++ b/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.h @@ -53,7 +53,7 @@ class VUndoCommand; class DialogSeamAllowance : public DialogTool { - Q_OBJECT + Q_OBJECT // NOLINT public: DialogSeamAllowance(const VContainer *data, VAbstractPattern *doc, quint32 toolId, @@ -167,7 +167,7 @@ private slots: void InsertGradationPlaceholder(); private: - Q_DISABLE_COPY(DialogSeamAllowance) + Q_DISABLE_COPY_MOVE(DialogSeamAllowance) // NOLINT Ui::DialogSeamAllowance *ui; Ui::TabPaths *uiTabPaths; diff --git a/src/libs/vtools/tools/backgroundimage/vbackgroundimageitem.h b/src/libs/vtools/tools/backgroundimage/vbackgroundimageitem.h index 8aad79a08..aaad5478a 100644 --- a/src/libs/vtools/tools/backgroundimage/vbackgroundimageitem.h +++ b/src/libs/vtools/tools/backgroundimage/vbackgroundimageitem.h @@ -41,7 +41,7 @@ class VAbstractPattern; class VBackgroundImageItem : public QGraphicsObject { - Q_OBJECT + Q_OBJECT // NOLINT public: VBackgroundImageItem(const VBackgroundPatternImage &image, VAbstractPattern *doc, QGraphicsItem *parent = nullptr); ~VBackgroundImageItem() override = default; @@ -112,7 +112,7 @@ private slots: private: // cppcheck-suppress unknownMacro - Q_DISABLE_COPY_MOVE(VBackgroundImageItem) + Q_DISABLE_COPY_MOVE(VBackgroundImageItem) // NOLINT VBackgroundPatternImage m_image; VAbstractPattern *m_doc; diff --git a/src/libs/vtools/tools/backgroundimage/vbackgroundsvgitem.h b/src/libs/vtools/tools/backgroundimage/vbackgroundsvgitem.h index 1e4c934ca..6feea2281 100644 --- a/src/libs/vtools/tools/backgroundimage/vbackgroundsvgitem.h +++ b/src/libs/vtools/tools/backgroundimage/vbackgroundsvgitem.h @@ -38,7 +38,7 @@ class QSvgRenderer; class VBackgroundSVGItem : public VBackgroundImageItem { - Q_OBJECT + Q_OBJECT // NOLINT public: VBackgroundSVGItem(const VBackgroundPatternImage &image, VAbstractPattern *doc, QGraphicsItem *parent = nullptr); ~VBackgroundSVGItem() override; @@ -53,7 +53,7 @@ private slots: void RepaintItem(); private: - Q_DISABLE_COPY_MOVE(VBackgroundSVGItem) + Q_DISABLE_COPY_MOVE(VBackgroundSVGItem) // NOLINT QSvgRenderer *m_renderer{nullptr}; diff --git a/src/libs/vtools/tools/drawTools/operation/flipping/vabstractflipping.h b/src/libs/vtools/tools/drawTools/operation/flipping/vabstractflipping.h index 54257be92..2bc2d3a43 100644 --- a/src/libs/vtools/tools/drawTools/operation/flipping/vabstractflipping.h +++ b/src/libs/vtools/tools/drawTools/operation/flipping/vabstractflipping.h @@ -35,7 +35,7 @@ class VAbstractFlipping : public VAbstractOperation { - Q_OBJECT + Q_OBJECT // NOLINT public: virtual ~VAbstractFlipping() Q_DECL_EQ_DEFAULT; protected: @@ -76,7 +76,7 @@ protected: const QPointF &secondPoint, const QString &suffix, VContainer *data, quint32 id); private: - Q_DISABLE_COPY(VAbstractFlipping) + Q_DISABLE_COPY_MOVE(VAbstractFlipping) // NOLINT }; //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/tools/drawTools/operation/flipping/vtoolflippingbyaxis.h b/src/libs/vtools/tools/drawTools/operation/flipping/vtoolflippingbyaxis.h index 812dfbdb8..020ed62f5 100644 --- a/src/libs/vtools/tools/drawTools/operation/flipping/vtoolflippingbyaxis.h +++ b/src/libs/vtools/tools/drawTools/operation/flipping/vtoolflippingbyaxis.h @@ -47,7 +47,7 @@ struct VToolFlippingByAxisInitData : VAbstractOperationInitData class VToolFlippingByAxis : public VAbstractFlipping { - Q_OBJECT + Q_OBJECT // NOLINT public: virtual ~VToolFlippingByAxis() Q_DECL_EQ_DEFAULT; virtual void setDialog() override; @@ -76,7 +76,7 @@ protected: virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj) override; virtual QString MakeToolTip() const override; private: - Q_DISABLE_COPY(VToolFlippingByAxis) + Q_DISABLE_COPY_MOVE(VToolFlippingByAxis) // NOLINT quint32 m_originPointId; AxisType m_axisType; diff --git a/src/libs/vtools/tools/drawTools/operation/flipping/vtoolflippingbyline.h b/src/libs/vtools/tools/drawTools/operation/flipping/vtoolflippingbyline.h index 73432375a..d90ec72a5 100644 --- a/src/libs/vtools/tools/drawTools/operation/flipping/vtoolflippingbyline.h +++ b/src/libs/vtools/tools/drawTools/operation/flipping/vtoolflippingbyline.h @@ -48,7 +48,7 @@ struct VToolFlippingByLineInitData : VAbstractOperationInitData class VToolFlippingByLine : public VAbstractFlipping { - Q_OBJECT + Q_OBJECT // NOLINT public: virtual ~VToolFlippingByLine() Q_DECL_EQ_DEFAULT; virtual void setDialog() override; @@ -75,7 +75,7 @@ protected: virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj) override; virtual QString MakeToolTip() const override; private: - Q_DISABLE_COPY(VToolFlippingByLine) + Q_DISABLE_COPY_MOVE(VToolFlippingByLine) // NOLINT quint32 m_firstLinePointId; quint32 m_secondLinePointId; diff --git a/src/libs/vtools/tools/drawTools/operation/vabstractoperation.h b/src/libs/vtools/tools/drawTools/operation/vabstractoperation.h index 3733b87d4..3541ff4cd 100644 --- a/src/libs/vtools/tools/drawTools/operation/vabstractoperation.h +++ b/src/libs/vtools/tools/drawTools/operation/vabstractoperation.h @@ -70,7 +70,7 @@ struct VAbstractOperationInitData : VDrawToolInitData // And i don't know how to fix it. class VAbstractOperation : public VDrawTool, public QGraphicsLineItem { - Q_OBJECT + Q_OBJECT // NOLINT // Fix warning "Class implements the interface QGraphicsItem but does not list it // in Q_INTERFACES. qobject_cast to QGraphicsItem will not work!" Q_INTERFACES(QGraphicsItem) @@ -179,7 +179,7 @@ protected: static void CreateVisibilityGroup(const VAbstractOperationInitData & initData); private: - Q_DISABLE_COPY(VAbstractOperation) + Q_DISABLE_COPY_MOVE(VAbstractOperation) // NOLINT void AllowCurveHover(bool enabled, GOType type); void AllowCurveSelecting(bool enabled, GOType type); diff --git a/src/libs/vtools/tools/drawTools/operation/vtoolmove.h b/src/libs/vtools/tools/drawTools/operation/vtoolmove.h index 1b27befd8..9f258ec03 100644 --- a/src/libs/vtools/tools/drawTools/operation/vtoolmove.h +++ b/src/libs/vtools/tools/drawTools/operation/vtoolmove.h @@ -63,7 +63,7 @@ struct VToolMoveInitData : VAbstractOperationInitData class VToolMove : public VAbstractOperation { - Q_OBJECT + Q_OBJECT // NOLINT public: virtual ~VToolMove() Q_DECL_EQ_DEFAULT; virtual void setDialog() override; @@ -98,7 +98,7 @@ protected: virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj) override; virtual QString MakeToolTip() const override; private: - Q_DISABLE_COPY(VToolMove) + Q_DISABLE_COPY_MOVE(VToolMove) // NOLINT QString formulaAngle; QString formulaRotationAngle; QString formulaLength; diff --git a/src/libs/vtools/tools/drawTools/operation/vtoolrotation.h b/src/libs/vtools/tools/drawTools/operation/vtoolrotation.h index 354ee2a83..545283aec 100644 --- a/src/libs/vtools/tools/drawTools/operation/vtoolrotation.h +++ b/src/libs/vtools/tools/drawTools/operation/vtoolrotation.h @@ -59,7 +59,7 @@ struct VToolRotationInitData : VAbstractOperationInitData class VToolRotation : public VAbstractOperation { - Q_OBJECT + Q_OBJECT // NOLINT public: virtual ~VToolRotation() Q_DECL_EQ_DEFAULT; virtual void setDialog() override; @@ -89,7 +89,7 @@ protected: virtual QString MakeToolTip() const override; private: - Q_DISABLE_COPY(VToolRotation) + Q_DISABLE_COPY_MOVE(VToolRotation) // NOLINT quint32 origPointId; QString formulaAngle; diff --git a/src/libs/vtools/tools/drawTools/toolcurve/vabstractspline.h b/src/libs/vtools/tools/drawTools/toolcurve/vabstractspline.h index feb920d6c..c7f79f72a 100644 --- a/src/libs/vtools/tools/drawTools/toolcurve/vabstractspline.h +++ b/src/libs/vtools/tools/drawTools/toolcurve/vabstractspline.h @@ -71,7 +71,7 @@ struct VAbstractSplineInitData : VDrawToolInitData class VAbstractSpline:public VDrawTool, public QGraphicsPathItem { - Q_OBJECT + Q_OBJECT // NOLINT public: VAbstractSpline(VAbstractPattern *doc, VContainer *data, quint32 id, const QString ¬es, QGraphicsItem * parent = nullptr); @@ -157,7 +157,7 @@ protected: static void InitElArcToolConnections(VMainGraphicsScene *scene, T *tool); private: - Q_DISABLE_COPY(VAbstractSpline) + Q_DISABLE_COPY_MOVE(VAbstractSpline) // NOLINT void InitDefShape(); }; @@ -258,7 +258,7 @@ public: QString CenterPointName() const; private: - Q_DISABLE_COPY(VToolAbstractArc) + Q_DISABLE_COPY_MOVE(VToolAbstractArc) // NOLINT }; #endif // VABSTRACTSPLINE_H diff --git a/src/libs/vtools/tools/drawTools/toolcurve/vtoolarc.h b/src/libs/vtools/tools/drawTools/toolcurve/vtoolarc.h index 598ac148b..6a7e0c727 100644 --- a/src/libs/vtools/tools/drawTools/toolcurve/vtoolarc.h +++ b/src/libs/vtools/tools/drawTools/toolcurve/vtoolarc.h @@ -64,7 +64,7 @@ struct VToolArcInitData : VAbstractSplineInitData */ class VToolArc :public VToolAbstractArc { - Q_OBJECT + Q_OBJECT // NOLINT public: virtual void setDialog() override; static VToolArc* Create(const QPointer &dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, @@ -99,7 +99,7 @@ protected: virtual void SetVisualization() override; virtual QString MakeToolTip() const override; private: - Q_DISABLE_COPY(VToolArc) + Q_DISABLE_COPY_MOVE(VToolArc) // NOLINT VToolArc(const VToolArcInitData &initData, QGraphicsItem * parent = nullptr); virtual ~VToolArc()=default; diff --git a/src/libs/vtools/tools/drawTools/toolcurve/vtoolarcwithlength.h b/src/libs/vtools/tools/drawTools/toolcurve/vtoolarcwithlength.h index 2f8d96b6e..9da963a6a 100644 --- a/src/libs/vtools/tools/drawTools/toolcurve/vtoolarcwithlength.h +++ b/src/libs/vtools/tools/drawTools/toolcurve/vtoolarcwithlength.h @@ -61,7 +61,7 @@ struct VToolArcWithLengthInitData : VAbstractSplineInitData class VToolArcWithLength : public VToolAbstractArc { - Q_OBJECT + Q_OBJECT // NOLINT public: virtual void setDialog() override; static VToolArcWithLength* Create(const QPointer &dialog, VMainGraphicsScene *scene, @@ -96,7 +96,7 @@ protected: virtual void SetVisualization() override; virtual QString MakeToolTip() const override; private: - Q_DISABLE_COPY(VToolArcWithLength) + Q_DISABLE_COPY_MOVE(VToolArcWithLength) // NOLINT VToolArcWithLength(const VToolArcWithLengthInitData &initData, QGraphicsItem *parent = nullptr); virtual ~VToolArcWithLength()=default; diff --git a/src/libs/vtools/tools/drawTools/toolcurve/vtoolcubicbezier.h b/src/libs/vtools/tools/drawTools/toolcurve/vtoolcubicbezier.h index 442ec4432..49790694e 100644 --- a/src/libs/vtools/tools/drawTools/toolcurve/vtoolcubicbezier.h +++ b/src/libs/vtools/tools/drawTools/toolcurve/vtoolcubicbezier.h @@ -60,7 +60,7 @@ QT_WARNING_POP class VToolCubicBezier : public VAbstractSpline { - Q_OBJECT + Q_OBJECT // NOLINT public: virtual ~VToolCubicBezier() Q_DECL_EQ_DEFAULT; virtual void setDialog() override; @@ -90,7 +90,7 @@ protected: virtual void SetVisualization() override; virtual void RefreshGeometry() override; private: - Q_DISABLE_COPY(VToolCubicBezier) + Q_DISABLE_COPY_MOVE(VToolCubicBezier) // NOLINT VToolCubicBezier(const VToolCubicBezierInitData &initData, QGraphicsItem *parent = nullptr); diff --git a/src/libs/vtools/tools/drawTools/toolcurve/vtoolcubicbezierpath.h b/src/libs/vtools/tools/drawTools/toolcurve/vtoolcubicbezierpath.h index b2799f9a9..0ae936554 100644 --- a/src/libs/vtools/tools/drawTools/toolcurve/vtoolcubicbezierpath.h +++ b/src/libs/vtools/tools/drawTools/toolcurve/vtoolcubicbezierpath.h @@ -60,7 +60,7 @@ QT_WARNING_POP class VToolCubicBezierPath:public VAbstractSpline { - Q_OBJECT + Q_OBJECT // NOLINT public: virtual ~VToolCubicBezierPath() Q_DECL_EQ_DEFAULT; virtual void setDialog() override; @@ -87,7 +87,7 @@ protected: virtual void SetVisualization() override; virtual void RefreshGeometry() override; private: - Q_DISABLE_COPY(VToolCubicBezierPath) + Q_DISABLE_COPY_MOVE(VToolCubicBezierPath) // NOLINT VToolCubicBezierPath(const VToolCubicBezierPathInitData &initData, QGraphicsItem * parent = nullptr); diff --git a/src/libs/vtools/tools/drawTools/toolcurve/vtoolellipticalarc.h b/src/libs/vtools/tools/drawTools/toolcurve/vtoolellipticalarc.h index 92ee2ea09..5d1269901 100644 --- a/src/libs/vtools/tools/drawTools/toolcurve/vtoolellipticalarc.h +++ b/src/libs/vtools/tools/drawTools/toolcurve/vtoolellipticalarc.h @@ -68,7 +68,7 @@ struct VToolEllipticalArcInitData : VAbstractSplineInitData */ class VToolEllipticalArc : public VToolAbstractArc { - Q_OBJECT + Q_OBJECT // NOLINT public: virtual void setDialog() override; static VToolEllipticalArc* Create(const QPointer &dialog, VMainGraphicsScene *scene, @@ -106,7 +106,7 @@ protected: virtual QString MakeToolTip() const override; private: - Q_DISABLE_COPY(VToolEllipticalArc) + Q_DISABLE_COPY_MOVE(VToolEllipticalArc) // NOLINT VToolEllipticalArc(const VToolEllipticalArcInitData &initData, QGraphicsItem *parent = nullptr); virtual ~VToolEllipticalArc()=default; }; diff --git a/src/libs/vtools/tools/drawTools/toolcurve/vtoolspline.h b/src/libs/vtools/tools/drawTools/toolcurve/vtoolspline.h index dfc413ae7..a6b082f14 100644 --- a/src/libs/vtools/tools/drawTools/toolcurve/vtoolspline.h +++ b/src/libs/vtools/tools/drawTools/toolcurve/vtoolspline.h @@ -72,7 +72,7 @@ struct VToolSplineInitData : VAbstractSplineInitData */ class VToolSpline:public VAbstractSpline { - Q_OBJECT + Q_OBJECT // NOLINT public: virtual ~VToolSpline() =default; virtual void setDialog() override; @@ -110,7 +110,7 @@ protected: private slots: void CurveReleased(); private: - Q_DISABLE_COPY(VToolSpline) + Q_DISABLE_COPY_MOVE(VToolSpline) // NOLINT QPointF oldPosition; bool moved; diff --git a/src/libs/vtools/tools/drawTools/toolcurve/vtoolsplinepath.h b/src/libs/vtools/tools/drawTools/toolcurve/vtoolsplinepath.h index 27f42f8dc..693057c43 100644 --- a/src/libs/vtools/tools/drawTools/toolcurve/vtoolsplinepath.h +++ b/src/libs/vtools/tools/drawTools/toolcurve/vtoolsplinepath.h @@ -71,7 +71,7 @@ struct VToolSplinePathInitData : VAbstractSplineInitData */ class VToolSplinePath:public VAbstractSpline { - Q_OBJECT + Q_OBJECT // NOLINT public: virtual ~VToolSplinePath() =default; virtual void setDialog() override; @@ -121,7 +121,7 @@ protected: private slots: void CurveReleased(); private: - Q_DISABLE_COPY(VToolSplinePath) + Q_DISABLE_COPY_MOVE(VToolSplinePath) // NOLINT QPointF oldPosition; int splIndex; diff --git a/src/libs/vtools/tools/drawTools/toolpoint/tooldoublepoint/vtooldoublepoint.h b/src/libs/vtools/tools/drawTools/toolpoint/tooldoublepoint/vtooldoublepoint.h index c9612c5d8..d197d9045 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/tooldoublepoint/vtooldoublepoint.h +++ b/src/libs/vtools/tools/drawTools/toolpoint/tooldoublepoint/vtooldoublepoint.h @@ -46,7 +46,7 @@ class VSimplePoint; class VToolDoublePoint: public VAbstractPoint, public QGraphicsPathItem { - Q_OBJECT + Q_OBJECT // NOLINT public: VToolDoublePoint(VAbstractPattern *doc, VContainer *data, quint32 id, quint32 p1id, quint32 p2id, const QString ¬es, QGraphicsItem * parent = nullptr); @@ -102,7 +102,7 @@ protected: QString ComplexToolTip(quint32 itemId) const; private: - Q_DISABLE_COPY(VToolDoublePoint) + Q_DISABLE_COPY_MOVE(VToolDoublePoint) // NOLINT }; #endif // VTOOLDOUBLEPOINT_H diff --git a/src/libs/vtools/tools/drawTools/toolpoint/tooldoublepoint/vtooltruedarts.h b/src/libs/vtools/tools/drawTools/toolpoint/tooldoublepoint/vtooltruedarts.h index 5d62bf281..91b500131 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/tooldoublepoint/vtooltruedarts.h +++ b/src/libs/vtools/tools/drawTools/toolpoint/tooldoublepoint/vtooltruedarts.h @@ -84,7 +84,7 @@ struct VToolTrueDartsInitData : VDrawToolInitData class VToolTrueDarts : public VToolDoublePoint { - Q_OBJECT + Q_OBJECT // NOLINT public: static void FindPoint(const QPointF &baseLineP1, const QPointF &baseLineP2, const QPointF &dartP1, const QPointF &dartP2, const QPointF &dartP3, QPointF &p1, QPointF &p2); @@ -115,7 +115,7 @@ protected: virtual void SetVisualization() override; private: - Q_DISABLE_COPY(VToolTrueDarts) + Q_DISABLE_COPY_MOVE(VToolTrueDarts) // NOLINT quint32 baseLineP1Id; quint32 baseLineP2Id; quint32 dartP1Id; diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcut.h b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcut.h index 58ac516c6..82ea0554b 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcut.h +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcut.h @@ -59,7 +59,7 @@ struct VToolCutInitData : VToolSinglePointInitData class VToolCut : public VToolSinglePoint { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit VToolCut(const VToolCutInitData &initData, QGraphicsItem * parent = nullptr); virtual int type() const override {return Type;} @@ -99,7 +99,7 @@ protected: void ShowToolVisualization(bool show); private: - Q_DISABLE_COPY(VToolCut) + Q_DISABLE_COPY_MOVE(VToolCut) // NOLINT }; //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutarc.h b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutarc.h index 0dc8c464d..8871bcebe 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutarc.h +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutarc.h @@ -48,7 +48,7 @@ template class QSharedPointer; */ class VToolCutArc : public VToolCut { - Q_OBJECT + Q_OBJECT // NOLINT public: virtual void setDialog() override; static VToolCutArc* Create(const QPointer &dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, @@ -68,7 +68,7 @@ protected: virtual void SetVisualization() override; virtual QString MakeToolTip() const override; private: - Q_DISABLE_COPY(VToolCutArc) + Q_DISABLE_COPY_MOVE(VToolCutArc) // NOLINT explicit VToolCutArc(const VToolCutInitData &initData, QGraphicsItem *parent = nullptr); }; diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutspline.h b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutspline.h index 953a1a18e..03d0b4161 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutspline.h +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutspline.h @@ -48,7 +48,7 @@ template class QSharedPointer; */ class VToolCutSpline : public VToolCut { - Q_OBJECT + Q_OBJECT // NOLINT public: virtual void setDialog() override; static VToolCutSpline *Create(const QPointer &dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, @@ -69,7 +69,7 @@ protected: virtual void SetVisualization() override; virtual QString MakeToolTip() const override; private: - Q_DISABLE_COPY(VToolCutSpline) + Q_DISABLE_COPY_MOVE(VToolCutSpline) // NOLINT explicit VToolCutSpline(const VToolCutInitData &initData, QGraphicsItem * parent = nullptr); }; diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutsplinepath.h b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutsplinepath.h index d800b297f..f9b8627e9 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutsplinepath.h +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutsplinepath.h @@ -50,7 +50,7 @@ template class QSharedPointer; */ class VToolCutSplinePath : public VToolCut { - Q_OBJECT + Q_OBJECT // NOLINT public: virtual void setDialog() override; static VToolCutSplinePath *Create(const QPointer &dialog, VMainGraphicsScene *scene, @@ -76,7 +76,7 @@ protected: virtual void SetVisualization() override; virtual QString MakeToolTip() const override; private: - Q_DISABLE_COPY(VToolCutSplinePath) + Q_DISABLE_COPY_MOVE(VToolCutSplinePath) // NOLINT VToolCutSplinePath(const VToolCutInitData &initData, QGraphicsItem *parent = nullptr); }; diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolalongline.h b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolalongline.h index fedddf7e2..20487b1a9 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolalongline.h +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolalongline.h @@ -62,7 +62,7 @@ struct VToolAlongLineInitData : VToolLinePointInitData */ class VToolAlongLine : public VToolLinePoint { - Q_OBJECT + Q_OBJECT // NOLINT public: virtual void setDialog() override; static VToolAlongLine* Create(const QPointer &dialog, VMainGraphicsScene *scene, @@ -86,7 +86,7 @@ protected: virtual void SetVisualization() override; virtual QString MakeToolTip() const override; private: - Q_DISABLE_COPY(VToolAlongLine) + Q_DISABLE_COPY_MOVE(VToolAlongLine) // NOLINT /** @brief secondPointId id second point of line. */ quint32 secondPointId; diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolbisector.h b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolbisector.h index 9e3f0d2f4..3daceeb83 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolbisector.h +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolbisector.h @@ -65,7 +65,7 @@ struct VToolBisectorInitData : VToolLinePointInitData */ class VToolBisector : public VToolLinePoint { - Q_OBJECT + Q_OBJECT // NOLINT public: static qreal BisectorAngle(const QPointF &firstPoint, const QPointF &secondPoint, const QPointF &thirdPoint); static QPointF FindPoint(const QPointF &firstPoint, const QPointF &secondPoint, const QPointF &thirdPoint, @@ -92,7 +92,7 @@ protected: virtual void ReadToolAttributes(const QDomElement &domElement) override; virtual void SetVisualization() override; private: - Q_DISABLE_COPY(VToolBisector) + Q_DISABLE_COPY_MOVE(VToolBisector) // NOLINT /** @brief firstPointId id first point of angle. */ quint32 firstPointId; diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolcurveintersectaxis.h b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolcurveintersectaxis.h index 9df6b4988..b0aff0f3b 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolcurveintersectaxis.h +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolcurveintersectaxis.h @@ -58,7 +58,7 @@ struct VToolCurveIntersectAxisInitData : VToolLinePointInitData class VToolCurveIntersectAxis : public VToolLinePoint { - Q_OBJECT + Q_OBJECT // NOLINT public: virtual ~VToolCurveIntersectAxis() Q_DECL_EQ_DEFAULT; virtual void setDialog() override; @@ -93,7 +93,7 @@ protected: void SetSegments(const QPair &segments); private: - Q_DISABLE_COPY(VToolCurveIntersectAxis) + Q_DISABLE_COPY_MOVE(VToolCurveIntersectAxis) // NOLINT QString formulaAngle; quint32 curveId; QPair m_segments{}; diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolendline.h b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolendline.h index 33bdb6915..70ee37e41 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolendline.h +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolendline.h @@ -63,7 +63,7 @@ struct VToolEndLineInitData : VToolLinePointInitData */ class VToolEndLine : public VToolLinePoint { - Q_OBJECT + Q_OBJECT // NOLINT public: virtual ~VToolEndLine() Q_DECL_EQ_DEFAULT; virtual void setDialog() override; @@ -86,7 +86,7 @@ protected: virtual void ReadToolAttributes(const QDomElement &domElement) override; virtual void SetVisualization() override; private: - Q_DISABLE_COPY(VToolEndLine) + Q_DISABLE_COPY_MOVE(VToolEndLine) // NOLINT QString formulaAngle; diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolheight.h b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolheight.h index d7562eb52..be3ec1f70 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolheight.h +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolheight.h @@ -64,7 +64,7 @@ struct VToolHeightInitData : VToolLinePointInitData */ class VToolHeight: public VToolLinePoint { - Q_OBJECT + Q_OBJECT // NOLINT public: virtual void setDialog() override; static VToolHeight *Create(const QPointer &dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, @@ -89,7 +89,7 @@ protected: virtual void SetVisualization() override; virtual QString MakeToolTip() const override; private: - Q_DISABLE_COPY(VToolHeight) + Q_DISABLE_COPY_MOVE(VToolHeight) // NOLINT /** @brief p1LineId id first point of line. */ quint32 p1LineId; diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoollineintersectaxis.h b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoollineintersectaxis.h index c65624513..a67d937a3 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoollineintersectaxis.h +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoollineintersectaxis.h @@ -64,7 +64,7 @@ struct VToolLineIntersectAxisInitData : VToolLinePointInitData class VToolLineIntersectAxis : public VToolLinePoint { - Q_OBJECT + Q_OBJECT // NOLINT public: virtual ~VToolLineIntersectAxis() Q_DECL_EQ_DEFAULT; virtual void setDialog() override; @@ -97,7 +97,7 @@ protected: virtual QString MakeToolTip() const override; virtual void hoverEnterEvent(QGraphicsSceneHoverEvent *event) override; private: - Q_DISABLE_COPY(VToolLineIntersectAxis) + Q_DISABLE_COPY_MOVE(VToolLineIntersectAxis) // NOLINT QString formulaAngle; quint32 firstPointId; diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoollinepoint.h b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoollinepoint.h index ba1f7ae37..873073f03 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoollinepoint.h +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoollinepoint.h @@ -59,7 +59,7 @@ struct VToolLinePointInitData : VToolSinglePointInitData */ class VToolLinePoint : public VToolSinglePoint { - Q_OBJECT + Q_OBJECT // NOLINT public: VToolLinePoint(VAbstractPattern *doc, VContainer *data, const quint32 &id, const QString &typeLine, const QString &lineColor, const QString &formula, const quint32 &basePointId, const qreal &angle, @@ -108,7 +108,7 @@ protected: virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent *event) override; virtual QString MakeToolTip() const override; private: - Q_DISABLE_COPY(VToolLinePoint) + Q_DISABLE_COPY_MOVE(VToolLinePoint) // NOLINT }; #endif // VTOOLLINEPOINT_H diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolnormal.h b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolnormal.h index 8ac458242..2dc5b61d5 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolnormal.h +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolnormal.h @@ -65,7 +65,7 @@ struct VToolNormalInitData : VToolLinePointInitData */ class VToolNormal : public VToolLinePoint { - Q_OBJECT + Q_OBJECT // NOLINT public: virtual void setDialog() override; static VToolNormal* Create(const QPointer &dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, @@ -90,7 +90,7 @@ protected: virtual void ReadToolAttributes(const QDomElement &domElement) override; virtual void SetVisualization() override; private: - Q_DISABLE_COPY(VToolNormal) + Q_DISABLE_COPY_MOVE(VToolNormal) // NOLINT /** @brief secondPointId id second line point. */ quint32 secondPointId; diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolshoulderpoint.h b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolshoulderpoint.h index 6facfc50c..7af948ad2 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolshoulderpoint.h +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolshoulderpoint.h @@ -66,7 +66,7 @@ struct VToolShoulderPointInitData : VToolLinePointInitData */ class VToolShoulderPoint : public VToolLinePoint { - Q_OBJECT + Q_OBJECT // NOLINT public: virtual void setDialog() override; static QPointF FindPoint(const QPointF &p1Line, const QPointF &p2Line, const QPointF &pShoulder, @@ -99,7 +99,7 @@ protected: private slots: virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 id=NULL_ID) override; private: - Q_DISABLE_COPY(VToolShoulderPoint) + Q_DISABLE_COPY_MOVE(VToolShoulderPoint) // NOLINT /** @brief p2Line id second line point. */ quint32 p2Line; diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolbasepoint.h b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolbasepoint.h index 5a778b7a6..1a7b5aefc 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolbasepoint.h +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolbasepoint.h @@ -65,7 +65,7 @@ struct VToolBasePointInitData : VToolSinglePointInitData */ class VToolBasePoint : public VToolSinglePoint { - Q_OBJECT + Q_OBJECT // NOLINT public: virtual ~VToolBasePoint() =default; virtual void setDialog() override; @@ -100,7 +100,7 @@ protected: private slots: virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 id=NULL_ID) override; private: - Q_DISABLE_COPY(VToolBasePoint) + Q_DISABLE_COPY_MOVE(VToolBasePoint) // NOLINT QString namePP; diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoollineintersect.h b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoollineintersect.h index d8c48a737..178ba084b 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoollineintersect.h +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoollineintersect.h @@ -64,7 +64,7 @@ struct VToolLineIntersectInitData : VToolSinglePointInitData */ class VToolLineIntersect:public VToolSinglePoint { - Q_OBJECT + Q_OBJECT // NOLINT public: virtual void setDialog() override; static VToolLineIntersect *Create(const QPointer &dialog, VMainGraphicsScene *scene, @@ -91,7 +91,7 @@ protected: virtual void SetVisualization() override; virtual QString MakeToolTip() const override; private: - Q_DISABLE_COPY(VToolLineIntersect) + Q_DISABLE_COPY_MOVE(VToolLineIntersect) // NOLINT /** @brief p1Line1 id first point first line. */ quint32 p1Line1; diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromarcandtangent.h b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromarcandtangent.h index 74a11bfc2..61428e696 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromarcandtangent.h +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromarcandtangent.h @@ -60,7 +60,7 @@ struct VToolPointFromArcAndTangentInitData : VToolSinglePointInitData class VToolPointFromArcAndTangent : public VToolSinglePoint { - Q_OBJECT + Q_OBJECT // NOLINT public: virtual void setDialog() override; static VToolPointFromArcAndTangent *Create(const QPointer &dialog, VMainGraphicsScene *scene, @@ -88,7 +88,7 @@ protected: virtual void ReadToolAttributes(const QDomElement &domElement) override; virtual void SetVisualization() override; private: - Q_DISABLE_COPY(VToolPointFromArcAndTangent) + Q_DISABLE_COPY_MOVE(VToolPointFromArcAndTangent) // NOLINT quint32 arcId; quint32 tangentPointId; diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromcircleandtangent.h b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromcircleandtangent.h index 8bd9ad455..2865b225d 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromcircleandtangent.h +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromcircleandtangent.h @@ -63,7 +63,7 @@ struct VToolPointFromCircleAndTangentInitData : VToolSinglePointInitData class VToolPointFromCircleAndTangent : public VToolSinglePoint { - Q_OBJECT + Q_OBJECT // NOLINT public: virtual void setDialog() override; static VToolPointFromCircleAndTangent *Create(const QPointer &dialog, VMainGraphicsScene *scene, @@ -95,7 +95,7 @@ protected: virtual void ReadToolAttributes(const QDomElement &domElement) override; virtual void SetVisualization() override; private: - Q_DISABLE_COPY(VToolPointFromCircleAndTangent) + Q_DISABLE_COPY_MOVE(VToolPointFromCircleAndTangent) // NOLINT quint32 circleCenterId; quint32 tangentPointId; diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofcontact.h b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofcontact.h index 0897654e8..608c5c447 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofcontact.h +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofcontact.h @@ -66,7 +66,7 @@ struct VToolPointOfContactInitData : VToolSinglePointInitData */ class VToolPointOfContact : public VToolSinglePoint { - Q_OBJECT + Q_OBJECT // NOLINT public: virtual void setDialog() override; static bool FindPoint(qreal radius, const QPointF ¢er, const QPointF &firstPoint, @@ -97,7 +97,7 @@ protected: virtual void SetVisualization() override; virtual QString MakeToolTip() const override; private: - Q_DISABLE_COPY(VToolPointOfContact) + Q_DISABLE_COPY_MOVE(VToolPointOfContact) // NOLINT /** @brief radius string with formula radius arc. */ QString arcRadius; diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersection.h b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersection.h index 32d2085c6..eb1ea6ae7 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersection.h +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersection.h @@ -60,7 +60,7 @@ struct VToolPointOfIntersectionInitData : VToolSinglePointInitData */ class VToolPointOfIntersection : public VToolSinglePoint { - Q_OBJECT + Q_OBJECT // NOLINT public: virtual void setDialog() override; static VToolPointOfIntersection *Create(const QPointer &dialog, VMainGraphicsScene *scene, @@ -84,7 +84,7 @@ protected: private slots: virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 id=NULL_ID) override; private: - Q_DISABLE_COPY(VToolPointOfIntersection) + Q_DISABLE_COPY_MOVE(VToolPointOfIntersection) // NOLINT /** @brief firstPointId id first line point. */ quint32 firstPointId; diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectionarcs.h b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectionarcs.h index 6aebf5c82..3e276abe9 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectionarcs.h +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectionarcs.h @@ -60,7 +60,7 @@ struct VToolPointOfIntersectionArcsInitData : VToolSinglePointInitData class VToolPointOfIntersectionArcs : public VToolSinglePoint { - Q_OBJECT + Q_OBJECT // NOLINT public: virtual void setDialog() override; @@ -90,7 +90,7 @@ protected: virtual void ReadToolAttributes(const QDomElement &domElement) override; virtual void SetVisualization() override; private: - Q_DISABLE_COPY(VToolPointOfIntersectionArcs) + Q_DISABLE_COPY_MOVE(VToolPointOfIntersectionArcs) // NOLINT /** @brief firstArcId id first arc. */ quint32 firstArcId; diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncircles.h b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncircles.h index d52361a3b..4428f2497 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncircles.h +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncircles.h @@ -65,7 +65,7 @@ struct VToolPointOfIntersectionCirclesInitData : VToolSinglePointInitData class VToolPointOfIntersectionCircles : public VToolSinglePoint { - Q_OBJECT + Q_OBJECT // NOLINT public: virtual void setDialog() override; static VToolPointOfIntersectionCircles *Create(const QPointer &dialog, VMainGraphicsScene *scene, @@ -100,7 +100,7 @@ protected: virtual void ReadToolAttributes(const QDomElement &domElement) override; virtual void SetVisualization() override; private: - Q_DISABLE_COPY(VToolPointOfIntersectionCircles) + Q_DISABLE_COPY_MOVE(VToolPointOfIntersectionCircles) // NOLINT quint32 firstCircleCenterId; quint32 secondCircleCenterId; diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncurves.h b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncurves.h index f316f5ca4..4f729034b 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncurves.h +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncurves.h @@ -61,7 +61,7 @@ struct VToolPointOfIntersectionCurvesInitData : VToolSinglePointInitData class VToolPointOfIntersectionCurves : public VToolSinglePoint { - Q_OBJECT + Q_OBJECT // NOLINT public: virtual void setDialog() override; static VToolPointOfIntersectionCurves *Create(const QPointer &dialog, VMainGraphicsScene *scene, @@ -97,7 +97,7 @@ protected: void SetCurve1Segments(const QPair &segments); void SetCurve2Segments(const QPair &segments); private: - Q_DISABLE_COPY(VToolPointOfIntersectionCurves) + Q_DISABLE_COPY_MOVE(VToolPointOfIntersectionCurves) // NOLINT quint32 firstCurveId; quint32 secondCurveId; diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolsinglepoint.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolsinglepoint.cpp index dd531ecea..f381c9505 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolsinglepoint.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolsinglepoint.cpp @@ -46,10 +46,8 @@ #include "../../../../undocommands/label/movelabel.h" #include "../../../../undocommands/label/showlabel.h" #include "../ifc/exception/vexception.h" -#include "../ifc/exception/vexceptionbadid.h" #include "../ifc/ifcdef.h" #include "../ifc/xml/vabstractpattern.h" -#include "../vmisc/diagnostic.h" #include "../vgeometry/vgobject.h" #include "../vgeometry/vpointf.h" #include "../vgeometry/vabstractcubicbezierpath.h" @@ -71,7 +69,7 @@ QT_WARNING_PUSH QT_WARNING_DISABLE_CLANG("-Wmissing-prototypes") QT_WARNING_DISABLE_INTEL(1418) -Q_LOGGING_CATEGORY(vToolSinglePoint, "v.toolSinglePoint") +Q_LOGGING_CATEGORY(vToolSinglePoint, "v.toolSinglePoint") // NOLINT QT_WARNING_POP diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolsinglepoint.h b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolsinglepoint.h index 9cf2a4e26..4d660454f 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolsinglepoint.h +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolsinglepoint.h @@ -65,7 +65,7 @@ struct VToolSinglePointInitData : VDrawToolInitData */ class VToolSinglePoint: public VAbstractPoint, public VScenePoint { - Q_OBJECT + Q_OBJECT // NOLINT public: VToolSinglePoint(VAbstractPattern *doc, VContainer *data, quint32 id, const QString ¬es, QGraphicsItem * parent = nullptr); @@ -113,7 +113,7 @@ protected: static QPair InitSegments(GOType curveType, qreal segLength, const VPointF *p, quint32 curveId, VContainer *data, const QString &alias1, const QString &alias2); private: - Q_DISABLE_COPY(VToolSinglePoint) // NOLINT + Q_DISABLE_COPY_MOVE(VToolSinglePoint) // NOLINT }; //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtooltriangle.h b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtooltriangle.h index b70b830fa..a5ca2978b 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtooltriangle.h +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtooltriangle.h @@ -66,7 +66,7 @@ struct VToolTriangleInitData : VToolSinglePointInitData */ class VToolTriangle : public VToolSinglePoint { - Q_OBJECT + Q_OBJECT // NOLINT public: virtual void setDialog() override; static VToolTriangle *Create(const QPointer &dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, @@ -106,7 +106,7 @@ protected: private slots: virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 id=NULL_ID) override; private: - Q_DISABLE_COPY(VToolTriangle) + Q_DISABLE_COPY_MOVE(VToolTriangle) // NOLINT /** @brief axisP1Id id first axis point. */ quint32 axisP1Id; diff --git a/src/libs/vtools/tools/drawTools/toolpoint/vabstractpoint.h b/src/libs/vtools/tools/drawTools/toolpoint/vabstractpoint.h index 50b8f47c8..b3557c9c9 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/vabstractpoint.h +++ b/src/libs/vtools/tools/drawTools/toolpoint/vabstractpoint.h @@ -51,7 +51,7 @@ class VAbstractPoint: public VDrawTool { - Q_OBJECT + Q_OBJECT // NOLINT public: VAbstractPoint(VAbstractPattern *doc, VContainer *data, quint32 id, const QString ¬es); virtual ~VAbstractPoint() Q_DECL_EQ_DEFAULT; @@ -72,7 +72,7 @@ protected: static void InitToolConnections(VMainGraphicsScene *scene, T *tool); private: - Q_DISABLE_COPY(VAbstractPoint) + Q_DISABLE_COPY_MOVE(VAbstractPoint) // NOLINT }; //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/tools/drawTools/vdrawtool.h b/src/libs/vtools/tools/drawTools/vdrawtool.h index 2574a2f2e..f05e8935b 100644 --- a/src/libs/vtools/tools/drawTools/vdrawtool.h +++ b/src/libs/vtools/tools/drawTools/vdrawtool.h @@ -69,7 +69,7 @@ struct VDrawToolInitData : VAbstractToolInitData */ class VDrawTool : public VInteractiveTool { - Q_OBJECT + Q_OBJECT // NOLINT public: VDrawTool(VAbstractPattern *doc, VContainer *data, quint32 id, const QString ¬es, QObject *parent = nullptr); @@ -146,7 +146,7 @@ protected: template static void InitDrawToolConnections(VMainGraphicsScene *scene, T *tool); private: - Q_DISABLE_COPY(VDrawTool) + Q_DISABLE_COPY_MOVE(VDrawTool) // NOLINT }; //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/tools/drawTools/vtoolline.h b/src/libs/vtools/tools/drawTools/vtoolline.h index 55f190018..b2f79ea74 100644 --- a/src/libs/vtools/tools/drawTools/vtoolline.h +++ b/src/libs/vtools/tools/drawTools/vtoolline.h @@ -65,7 +65,7 @@ struct VToolLineInitData : VDrawToolInitData */ class VToolLine: public VDrawTool, public VScaledLine { - Q_OBJECT + Q_OBJECT // NOLINT public: virtual void setDialog() override; static VToolLine *Create(const QPointer &dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, @@ -114,7 +114,7 @@ protected: virtual void SetVisualization() override; virtual QString MakeToolTip() const override; private: - Q_DISABLE_COPY(VToolLine) + Q_DISABLE_COPY_MOVE(VToolLine) // NOLINT /** @brief firstPoint id first line point. */ quint32 firstPoint; diff --git a/src/libs/vtools/tools/nodeDetails/vabstractnode.h b/src/libs/vtools/tools/nodeDetails/vabstractnode.h index 9378c003f..dd8b257c4 100644 --- a/src/libs/vtools/tools/nodeDetails/vabstractnode.h +++ b/src/libs/vtools/tools/nodeDetails/vabstractnode.h @@ -60,7 +60,7 @@ struct VAbstractNodeInitData : VAbstractToolInitData */ class VAbstractNode : public VAbstractTool { - Q_OBJECT + Q_OBJECT // NOLINT public: VAbstractNode(VAbstractPattern *doc, VContainer *data, const quint32 &id, const quint32 &idNode, const QString &drawName = QString(), const quint32 &idTool = 0, QObject *parent = nullptr); @@ -100,7 +100,7 @@ protected: virtual void ShowNode()=0; virtual void HideNode()=0; private: - Q_DISABLE_COPY(VAbstractNode) + Q_DISABLE_COPY_MOVE(VAbstractNode) // NOLINT }; //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/tools/nodeDetails/vnodearc.h b/src/libs/vtools/tools/nodeDetails/vnodearc.h index 40f58614e..c040f576e 100644 --- a/src/libs/vtools/tools/nodeDetails/vnodearc.h +++ b/src/libs/vtools/tools/nodeDetails/vnodearc.h @@ -45,7 +45,7 @@ */ class VNodeArc :public VAbstractNode { - Q_OBJECT + Q_OBJECT // NOLINT public: static void Create(const VAbstractNodeInitData &initData); @@ -60,7 +60,8 @@ protected: virtual void ShowNode() override {} virtual void HideNode() override {} private: - Q_DISABLE_COPY(VNodeArc) + // cppcheck-suppress unknownMacro + Q_DISABLE_COPY_MOVE(VNodeArc) // NOLINT explicit VNodeArc(const VAbstractNodeInitData &initData, QObject *qoParent = nullptr); }; diff --git a/src/libs/vtools/tools/nodeDetails/vnodeellipticalarc.h b/src/libs/vtools/tools/nodeDetails/vnodeellipticalarc.h index 2e80bf590..03524e913 100644 --- a/src/libs/vtools/tools/nodeDetails/vnodeellipticalarc.h +++ b/src/libs/vtools/tools/nodeDetails/vnodeellipticalarc.h @@ -42,7 +42,7 @@ class VNodeEllipticalArc :public VAbstractNode { - Q_OBJECT + Q_OBJECT // NOLINT public: static void Create(const VAbstractNodeInitData &initData); @@ -57,7 +57,8 @@ protected: virtual void ShowNode() override {} virtual void HideNode() override {} private: - Q_DISABLE_COPY(VNodeEllipticalArc) + // cppcheck-suppress unknownMacro + Q_DISABLE_COPY_MOVE(VNodeEllipticalArc) // NOLINT explicit VNodeEllipticalArc(const VAbstractNodeInitData &initData, QObject *qoParent = nullptr); }; diff --git a/src/libs/vtools/tools/nodeDetails/vnodepoint.h b/src/libs/vtools/tools/nodeDetails/vnodepoint.h index e46e82be4..0a5618552 100644 --- a/src/libs/vtools/tools/nodeDetails/vnodepoint.h +++ b/src/libs/vtools/tools/nodeDetails/vnodepoint.h @@ -48,7 +48,7 @@ */ class VNodePoint: public VAbstractNode, public VScenePoint { - Q_OBJECT + Q_OBJECT // NOLINT public: static void Create(const VAbstractNodeInitData &initData); @@ -88,7 +88,8 @@ protected: virtual void contextMenuEvent(QGraphicsSceneContextMenuEvent *event) override; virtual void hoverEnterEvent(QGraphicsSceneHoverEvent *event) override; private: - Q_DISABLE_COPY(VNodePoint) + // cppcheck-suppress unknownMacro + Q_DISABLE_COPY_MOVE(VNodePoint) // NOLINT VNodePoint(const VAbstractNodeInitData &initData, QObject *qoParent = nullptr, QGraphicsItem *parent = nullptr); diff --git a/src/libs/vtools/tools/nodeDetails/vnodespline.h b/src/libs/vtools/tools/nodeDetails/vnodespline.h index 655090516..207fbd3eb 100644 --- a/src/libs/vtools/tools/nodeDetails/vnodespline.h +++ b/src/libs/vtools/tools/nodeDetails/vnodespline.h @@ -45,7 +45,7 @@ */ class VNodeSpline:public VAbstractNode { - Q_OBJECT + Q_OBJECT // NOLINT public: static VNodeSpline *Create(const VAbstractNodeInitData &initData); @@ -60,7 +60,8 @@ protected: virtual void ShowNode() override {} virtual void HideNode() override {} private: - Q_DISABLE_COPY(VNodeSpline) + // cppcheck-suppress unknownMacro + Q_DISABLE_COPY_MOVE(VNodeSpline) // NOLINT explicit VNodeSpline(const VAbstractNodeInitData &initData, QObject *qoParent = nullptr); }; diff --git a/src/libs/vtools/tools/nodeDetails/vnodesplinepath.h b/src/libs/vtools/tools/nodeDetails/vnodesplinepath.h index 2bae52a42..8261db55d 100644 --- a/src/libs/vtools/tools/nodeDetails/vnodesplinepath.h +++ b/src/libs/vtools/tools/nodeDetails/vnodesplinepath.h @@ -45,7 +45,7 @@ */ class VNodeSplinePath : public VAbstractNode { - Q_OBJECT + Q_OBJECT // NOLINT public: static void Create(const VAbstractNodeInitData &initData); @@ -60,7 +60,8 @@ protected: virtual void ShowNode() override {} virtual void HideNode() override {} private: - Q_DISABLE_COPY(VNodeSplinePath) + // cppcheck-suppress unknownMacro + Q_DISABLE_COPY_MOVE(VNodeSplinePath) // NOLINT explicit VNodeSplinePath(const VAbstractNodeInitData &initData, QObject *qoParent = nullptr); }; diff --git a/src/libs/vtools/tools/nodeDetails/vtoolpiecepath.h b/src/libs/vtools/tools/nodeDetails/vtoolpiecepath.h index 8c69c0ef1..b48565f7b 100644 --- a/src/libs/vtools/tools/nodeDetails/vtoolpiecepath.h +++ b/src/libs/vtools/tools/nodeDetails/vtoolpiecepath.h @@ -47,7 +47,7 @@ struct VToolPiecePathInitData : VAbstractNodeInitData class VToolPiecePath : public VAbstractNode, public QGraphicsPathItem { - Q_OBJECT + Q_OBJECT // NOLINT public: static VToolPiecePath* Create(const QPointer &dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data); @@ -76,7 +76,8 @@ protected: virtual void HideNode() override; virtual void ToolCreation(const Source &typeCreation) override; private: - Q_DISABLE_COPY(VToolPiecePath) + // cppcheck-suppress unknownMacro + Q_DISABLE_COPY_MOVE(VToolPiecePath) // NOLINT quint32 m_pieceId; diff --git a/src/libs/vtools/tools/nodeDetails/vtoolpin.h b/src/libs/vtools/tools/nodeDetails/vtoolpin.h index a8777d98d..4cfb1e668 100644 --- a/src/libs/vtools/tools/nodeDetails/vtoolpin.h +++ b/src/libs/vtools/tools/nodeDetails/vtoolpin.h @@ -47,7 +47,7 @@ struct VToolPinInitData : VAbstractNodeInitData class VToolPin : public VAbstractNode { - Q_OBJECT + Q_OBJECT // NOLINT public: static VToolPin* Create(const QPointer &dialog, VAbstractPattern *doc, VContainer *data); static VToolPin *Create(VToolPinInitData initData); @@ -63,7 +63,8 @@ protected: virtual void ShowNode() override {} virtual void HideNode() override {} private: - Q_DISABLE_COPY(VToolPin) + // cppcheck-suppress unknownMacro + Q_DISABLE_COPY_MOVE(VToolPin) // NOLINT quint32 m_pieceId; diff --git a/src/libs/vtools/tools/nodeDetails/vtoolplacelabel.h b/src/libs/vtools/tools/nodeDetails/vtoolplacelabel.h index dd6e97c34..4b3e6b5ca 100644 --- a/src/libs/vtools/tools/nodeDetails/vtoolplacelabel.h +++ b/src/libs/vtools/tools/nodeDetails/vtoolplacelabel.h @@ -50,7 +50,7 @@ struct VToolPlaceLabelInitData : VAbstractNodeInitData class VToolPlaceLabel : public VAbstractNode { - Q_OBJECT + Q_OBJECT // NOLINT public: static VToolPlaceLabel* Create(const QPointer &dialog, VAbstractPattern *doc, VContainer *data); static VToolPlaceLabel* Create(VToolPlaceLabelInitData &initData); @@ -68,7 +68,8 @@ protected: virtual void ShowNode() override {} virtual void HideNode() override {} private: - Q_DISABLE_COPY(VToolPlaceLabel) + // cppcheck-suppress unknownMacro + Q_DISABLE_COPY_MOVE(VToolPlaceLabel) // NOLINT quint32 m_pieceId; diff --git a/src/libs/vtools/tools/toolsdef.h b/src/libs/vtools/tools/toolsdef.h index e68211300..f7b78e9b0 100644 --- a/src/libs/vtools/tools/toolsdef.h +++ b/src/libs/vtools/tools/toolsdef.h @@ -45,7 +45,7 @@ struct SourceItem }; Q_DECLARE_METATYPE(SourceItem) -Q_DECLARE_TYPEINFO(SourceItem, Q_MOVABLE_TYPE); +Q_DECLARE_TYPEINFO(SourceItem, Q_MOVABLE_TYPE); // NOLINT // Default label position const int labelMX = 10; diff --git a/src/libs/vtools/tools/vabstracttool.h b/src/libs/vtools/tools/vabstracttool.h index 9f3d68a34..d93e1a48a 100644 --- a/src/libs/vtools/tools/vabstracttool.h +++ b/src/libs/vtools/tools/vabstracttool.h @@ -83,7 +83,7 @@ QT_WARNING_POP */ class VAbstractTool: public VDataTool { - Q_OBJECT + Q_OBJECT // NOLINT public: VAbstractTool(VAbstractPattern *doc, VContainer *data, quint32 id, QObject *parent = nullptr); virtual ~VAbstractTool() override; @@ -181,7 +181,7 @@ protected: static quint32 PrepareNode(const VPieceNode &node, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data); private: - Q_DISABLE_COPY(VAbstractTool) + Q_DISABLE_COPY_MOVE(VAbstractTool) // NOLINT }; //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/tools/vdatatool.cpp b/src/libs/vtools/tools/vdatatool.cpp index c73c74e6a..8c65eb240 100644 --- a/src/libs/vtools/tools/vdatatool.cpp +++ b/src/libs/vtools/tools/vdatatool.cpp @@ -30,7 +30,13 @@ #include "../vmisc/def.h" -Q_LOGGING_CATEGORY(vTool, "v.tool") +QT_WARNING_PUSH +QT_WARNING_DISABLE_CLANG("-Wmissing-prototypes") +QT_WARNING_DISABLE_INTEL(1418) + +Q_LOGGING_CATEGORY(vTool, "v.tool") // NOLINT + +QT_WARNING_POP //--------------------------------------------------------------------------------------------------------------------- /** diff --git a/src/libs/vtools/tools/vdatatool.h b/src/libs/vtools/tools/vdatatool.h index 429fb9186..798157293 100644 --- a/src/libs/vtools/tools/vdatatool.h +++ b/src/libs/vtools/tools/vdatatool.h @@ -46,7 +46,7 @@ Q_DECLARE_LOGGING_CATEGORY(vTool) */ class VDataTool : public QObject { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit VDataTool(VContainer *data, QObject *parent = nullptr); virtual ~VDataTool() Q_DECL_EQ_DEFAULT; @@ -63,7 +63,7 @@ protected: /** @brief _referens keep count tools what use this tool. If value more than 1 you can't delete tool. */ quint32 _referens; private: - Q_DISABLE_COPY(VDataTool) + Q_DISABLE_COPY_MOVE(VDataTool) // NOLINT }; //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/tools/vinteractivetool.h b/src/libs/vtools/tools/vinteractivetool.h index 85f075f72..413d7ef25 100644 --- a/src/libs/vtools/tools/vinteractivetool.h +++ b/src/libs/vtools/tools/vinteractivetool.h @@ -36,7 +36,7 @@ class VInteractiveTool : public VAbstractTool { - Q_OBJECT + Q_OBJECT // NOLINT public: VInteractiveTool(VAbstractPattern *doc, VContainer *data, quint32 id, QObject *parent = nullptr); virtual ~VInteractiveTool() Q_DECL_EQ_DEFAULT; @@ -56,7 +56,7 @@ protected: virtual void SaveDialogChange(const QString &undoText = QString())=0; private: - Q_DISABLE_COPY(VInteractiveTool) + Q_DISABLE_COPY_MOVE(VInteractiveTool) // NOLINT }; #endif // VINTERACTIVETOOL_H diff --git a/src/libs/vtools/tools/vtoolseamallowance.h b/src/libs/vtools/tools/vtoolseamallowance.h index a481c40b6..3fe2206db 100644 --- a/src/libs/vtools/tools/vtoolseamallowance.h +++ b/src/libs/vtools/tools/vtoolseamallowance.h @@ -57,7 +57,7 @@ struct VToolSeamAllowanceInitData : VAbstractToolInitData class VToolSeamAllowance : public VInteractiveTool, public QGraphicsPathItem { - Q_OBJECT + Q_OBJECT // NOLINT public: virtual ~VToolSeamAllowance() Q_DECL_EQ_DEFAULT; @@ -174,7 +174,7 @@ private slots: void TogglePassmarkLineType(quint32 id, PassmarkLineType type); private: - Q_DISABLE_COPY(VToolSeamAllowance) + Q_DISABLE_COPY_MOVE(VToolSeamAllowance) // NOLINT QPainterPath m_mainPath; // Must be first to prevent crash QRectF m_pieceBoundingRect{}; diff --git a/src/libs/vtools/tools/vtooluniondetails.cpp b/src/libs/vtools/tools/vtooluniondetails.cpp index f3c14902d..f5b34e3e9 100644 --- a/src/libs/vtools/tools/vtooluniondetails.cpp +++ b/src/libs/vtools/tools/vtooluniondetails.cpp @@ -42,7 +42,6 @@ #include #include "../dialogs/tools/dialoguniondetails.h" -#include "../ifc/xml/vabstractconverter.h" #include "../ifc/xml/vdomdocument.h" #include "../ifc/xml/vpatternconverter.h" #include "../ifc/exception/vexceptionwrongid.h" @@ -56,7 +55,6 @@ #include "../vgeometry/vspline.h" #include "../vgeometry/vsplinepoint.h" #include "../vgeometry/vplacelabelitem.h" -#include "../vmisc/diagnostic.h" #include "../vmisc/vabstractapplication.h" #include "../vpatterndb/vcontainer.h" #include "../vpatterndb/vpiecepath.h" @@ -71,7 +69,6 @@ #include "nodeDetails/vtoolpin.h" #include "nodeDetails/vtoolplacelabel.h" #include "vdatatool.h" -#include "vnodedetail.h" #include "vtoolseamallowance.h" const QString VToolUnionDetails::ToolType = QStringLiteral("unionDetails"); @@ -93,7 +90,7 @@ QT_WARNING_PUSH QT_WARNING_DISABLE_CLANG("-Wmissing-prototypes") QT_WARNING_DISABLE_INTEL(1418) -Q_LOGGING_CATEGORY(vToolUnion, "v.toolUnion") +Q_LOGGING_CATEGORY(vToolUnion, "v.toolUnion") // NOLINT QT_WARNING_POP diff --git a/src/libs/vtools/tools/vtooluniondetails.h b/src/libs/vtools/tools/vtooluniondetails.h index 4350dc43f..ebfc26746 100644 --- a/src/libs/vtools/tools/vtooluniondetails.h +++ b/src/libs/vtools/tools/vtooluniondetails.h @@ -74,7 +74,7 @@ struct VToolUnionDetailsInitData : VAbstractToolInitData */ class VToolUnionDetails : public VAbstractTool { - Q_OBJECT + Q_OBJECT // NOLINT public: static VToolUnionDetails *Create(const QPointer &dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data); @@ -113,7 +113,8 @@ protected: virtual void AddToFile() override; virtual void SetVisualization() override {} private: - Q_DISABLE_COPY(VToolUnionDetails) + // cppcheck-suppress unknownMacro + Q_DISABLE_COPY_MOVE(VToolUnionDetails) // NOLINT /** @brief d1 first detail id. */ quint32 d1id; diff --git a/src/libs/vtools/undocommands/addpatternpiece.h b/src/libs/vtools/undocommands/addpatternpiece.h index 63f86c075..0528ac8cf 100644 --- a/src/libs/vtools/undocommands/addpatternpiece.h +++ b/src/libs/vtools/undocommands/addpatternpiece.h @@ -40,7 +40,7 @@ class AddPatternPiece : public VUndoCommand { - Q_OBJECT + Q_OBJECT // NOLINT public: AddPatternPiece(const QDomElement &xml, VAbstractPattern *doc, const QString &namePP, QUndoCommand *parent = nullptr); @@ -48,7 +48,8 @@ public: virtual void undo() override; virtual void redo() override; private: - Q_DISABLE_COPY(AddPatternPiece) + // cppcheck-suppress unknownMacro + Q_DISABLE_COPY_MOVE(AddPatternPiece) // NOLINT QString namePP; }; diff --git a/src/libs/vtools/undocommands/addpiece.h b/src/libs/vtools/undocommands/addpiece.h index 9ff45b23e..c605aa276 100644 --- a/src/libs/vtools/undocommands/addpiece.h +++ b/src/libs/vtools/undocommands/addpiece.h @@ -42,7 +42,7 @@ class AddPiece : public VUndoCommand { - Q_OBJECT + Q_OBJECT // NOLINT public: AddPiece(const QDomElement &xml, VAbstractPattern *doc, VContainer data, VMainGraphicsScene *scene, const QString &drawName = QString(), QUndoCommand *parent = nullptr); @@ -53,7 +53,7 @@ public: // cppcheck-suppress unusedFunction virtual void redo() override; private: - Q_DISABLE_COPY(AddPiece) + Q_DISABLE_COPY_MOVE(AddPiece) // NOLINT VPiece m_detail; QString m_drawName; diff --git a/src/libs/vtools/undocommands/addtocalc.h b/src/libs/vtools/undocommands/addtocalc.h index 2dba22dec..523a5db67 100644 --- a/src/libs/vtools/undocommands/addtocalc.h +++ b/src/libs/vtools/undocommands/addtocalc.h @@ -40,7 +40,7 @@ class AddToCalc : public VUndoCommand { - Q_OBJECT + Q_OBJECT // NOLINT public: AddToCalc(const QDomElement &xml, VAbstractPattern *doc, QUndoCommand *parent = nullptr); virtual ~AddToCalc() =default; @@ -49,7 +49,8 @@ public: protected: virtual void RedoFullParsing() override; private: - Q_DISABLE_COPY(AddToCalc) + // cppcheck-suppress unknownMacro + Q_DISABLE_COPY_MOVE(AddToCalc) // NOLINT const QString nameActivDraw; quint32 cursor; }; diff --git a/src/libs/vtools/undocommands/deletepatternpiece.h b/src/libs/vtools/undocommands/deletepatternpiece.h index 3edc3c2a7..4c8b80908 100644 --- a/src/libs/vtools/undocommands/deletepatternpiece.h +++ b/src/libs/vtools/undocommands/deletepatternpiece.h @@ -40,14 +40,15 @@ class DeletePatternPiece : public VUndoCommand { - Q_OBJECT + Q_OBJECT // NOLINT public: DeletePatternPiece(VAbstractPattern *doc, const QString &namePP, QUndoCommand *parent = nullptr); virtual ~DeletePatternPiece() override; virtual void undo() override; virtual void redo() override; private: - Q_DISABLE_COPY(DeletePatternPiece) + // cppcheck-suppress unknownMacro + Q_DISABLE_COPY_MOVE(DeletePatternPiece) // NOLINT QString namePP; QDomElement patternPiece; QString previousPPName; diff --git a/src/libs/vtools/undocommands/deletepiece.h b/src/libs/vtools/undocommands/deletepiece.h index 467648861..a97fd6030 100644 --- a/src/libs/vtools/undocommands/deletepiece.h +++ b/src/libs/vtools/undocommands/deletepiece.h @@ -37,7 +37,7 @@ class DeletePiece : public VUndoCommand { - Q_OBJECT + Q_OBJECT // NOLINT public: DeletePiece(VAbstractPattern *doc, quint32 id, const VContainer &data, VMainGraphicsScene *scene, QUndoCommand *parent = nullptr); @@ -46,7 +46,7 @@ public: virtual void undo() override; virtual void redo() override; private: - Q_DISABLE_COPY(DeletePiece) + Q_DISABLE_COPY_MOVE(DeletePiece) // NOLINT QDomNode m_parentNode; quint32 m_siblingId; diff --git a/src/libs/vtools/undocommands/deltool.h b/src/libs/vtools/undocommands/deltool.h index 00fc3005a..da045be9f 100644 --- a/src/libs/vtools/undocommands/deltool.h +++ b/src/libs/vtools/undocommands/deltool.h @@ -40,14 +40,15 @@ class DelTool : public VUndoCommand { - Q_OBJECT + Q_OBJECT // NOLINT public: DelTool(VAbstractPattern *doc, quint32 id, QUndoCommand *parent = nullptr); virtual ~DelTool() override =default; virtual void undo() override; virtual void redo() override; private: - Q_DISABLE_COPY(DelTool) + // cppcheck-suppress unknownMacro + Q_DISABLE_COPY_MOVE(DelTool) // NOLINT QDomNode parentNode{}; quint32 siblingId{NULL_ID}; const QString nameActivDraw; diff --git a/src/libs/vtools/undocommands/image/addbackgroundimage.h b/src/libs/vtools/undocommands/image/addbackgroundimage.h index fdfd1b287..0492e3c32 100644 --- a/src/libs/vtools/undocommands/image/addbackgroundimage.h +++ b/src/libs/vtools/undocommands/image/addbackgroundimage.h @@ -37,7 +37,7 @@ class AddBackgroundImage : public VUndoCommand { - Q_OBJECT + Q_OBJECT // NOLINT public: AddBackgroundImage(const VBackgroundPatternImage& image, VAbstractPattern *doc, QUndoCommand *parent = nullptr); ~AddBackgroundImage() override =default; @@ -48,7 +48,7 @@ signals: void DeleteItem(const QUuid &id); private: // cppcheck-suppress unknownMacro - Q_DISABLE_COPY_MOVE(AddBackgroundImage) + Q_DISABLE_COPY_MOVE(AddBackgroundImage) // NOLINT VBackgroundPatternImage m_image; }; diff --git a/src/libs/vtools/undocommands/image/deletebackgroundimage.h b/src/libs/vtools/undocommands/image/deletebackgroundimage.h index 08c527ac6..47d724ea8 100644 --- a/src/libs/vtools/undocommands/image/deletebackgroundimage.h +++ b/src/libs/vtools/undocommands/image/deletebackgroundimage.h @@ -38,7 +38,7 @@ class DeleteBackgroundImage : public VUndoCommand { - Q_OBJECT + Q_OBJECT // NOLINT public: DeleteBackgroundImage(const VBackgroundPatternImage& image, VAbstractPattern *doc, QUndoCommand *parent = nullptr); ~DeleteBackgroundImage() override =default; @@ -49,7 +49,7 @@ signals: void DeleteItem(const QUuid &id); private: // cppcheck-suppress unknownMacro - Q_DISABLE_COPY_MOVE(DeleteBackgroundImage) + Q_DISABLE_COPY_MOVE(DeleteBackgroundImage) // NOLINT VBackgroundPatternImage m_image; int m_index{-1}; }; diff --git a/src/libs/vtools/undocommands/image/hideallbackgroundimages.h b/src/libs/vtools/undocommands/image/hideallbackgroundimages.h index 5b8dad798..37bd59953 100644 --- a/src/libs/vtools/undocommands/image/hideallbackgroundimages.h +++ b/src/libs/vtools/undocommands/image/hideallbackgroundimages.h @@ -44,7 +44,7 @@ public: void redo() override; private: // cppcheck-suppress unknownMacro - Q_DISABLE_COPY_MOVE(HideAllBackgroundImages) + Q_DISABLE_COPY_MOVE(HideAllBackgroundImages) // NOLINT bool m_hide; QMap m_oldVisibility{}; }; diff --git a/src/libs/vtools/undocommands/image/hidebackgroundimage.h b/src/libs/vtools/undocommands/image/hidebackgroundimage.h index 92052655c..ec244d916 100644 --- a/src/libs/vtools/undocommands/image/hidebackgroundimage.h +++ b/src/libs/vtools/undocommands/image/hidebackgroundimage.h @@ -44,7 +44,7 @@ public: void redo() override; private: // cppcheck-suppress unknownMacro - Q_DISABLE_COPY_MOVE(HideBackgroundImage) + Q_DISABLE_COPY_MOVE(HideBackgroundImage) // NOLINT QUuid m_id; bool m_hide; bool m_oldVisibility{false}; diff --git a/src/libs/vtools/undocommands/image/holdallbackgroundimages.h b/src/libs/vtools/undocommands/image/holdallbackgroundimages.h index 3432793a9..515ddc5c3 100644 --- a/src/libs/vtools/undocommands/image/holdallbackgroundimages.h +++ b/src/libs/vtools/undocommands/image/holdallbackgroundimages.h @@ -43,7 +43,7 @@ public: void redo() override; private: // cppcheck-suppress unknownMacro - Q_DISABLE_COPY_MOVE(HoldAllBackgroundImages) + Q_DISABLE_COPY_MOVE(HoldAllBackgroundImages) // NOLINT bool m_hold; QMap m_oldHold{}; }; diff --git a/src/libs/vtools/undocommands/image/holdbackgroundimage.h b/src/libs/vtools/undocommands/image/holdbackgroundimage.h index bc6559c73..e64e10fbd 100644 --- a/src/libs/vtools/undocommands/image/holdbackgroundimage.h +++ b/src/libs/vtools/undocommands/image/holdbackgroundimage.h @@ -44,7 +44,7 @@ public: void redo() override; private: // cppcheck-suppress unknownMacro - Q_DISABLE_COPY_MOVE(HoldBackgroundImage) + Q_DISABLE_COPY_MOVE(HoldBackgroundImage) // NOLINT QUuid m_id; bool m_hold; bool m_oldHold{false}; diff --git a/src/libs/vtools/undocommands/image/movebackgroundimage.h b/src/libs/vtools/undocommands/image/movebackgroundimage.h index e51574717..1ba14395a 100644 --- a/src/libs/vtools/undocommands/image/movebackgroundimage.h +++ b/src/libs/vtools/undocommands/image/movebackgroundimage.h @@ -39,7 +39,7 @@ class MoveBackgroundImage : public VUndoCommand { - Q_OBJECT + Q_OBJECT // NOLINT public: MoveBackgroundImage(QUuid id, qreal dx, qreal dy, VAbstractPattern *doc, bool allowMerge = false, QUndoCommand *parent = nullptr); @@ -58,7 +58,7 @@ public: private: // cppcheck-suppress unknownMacro - Q_DISABLE_COPY_MOVE(MoveBackgroundImage) + Q_DISABLE_COPY_MOVE(MoveBackgroundImage) // NOLINT QUuid m_id; qreal m_dx; diff --git a/src/libs/vtools/undocommands/image/opaquebackgroundimage.h b/src/libs/vtools/undocommands/image/opaquebackgroundimage.h index 12e4aadb3..3132dfa20 100644 --- a/src/libs/vtools/undocommands/image/opaquebackgroundimage.h +++ b/src/libs/vtools/undocommands/image/opaquebackgroundimage.h @@ -43,7 +43,7 @@ public: void redo() override; private: // cppcheck-suppress unknownMacro - Q_DISABLE_COPY_MOVE(OpaqueBackgroundImage) + Q_DISABLE_COPY_MOVE(OpaqueBackgroundImage) // NOLINT QUuid m_id; qreal m_opacity; qreal m_oldOpacity{1.0}; diff --git a/src/libs/vtools/undocommands/image/renamebackgroundimage.h b/src/libs/vtools/undocommands/image/renamebackgroundimage.h index f3f66e8e7..0d8b3f371 100644 --- a/src/libs/vtools/undocommands/image/renamebackgroundimage.h +++ b/src/libs/vtools/undocommands/image/renamebackgroundimage.h @@ -44,7 +44,7 @@ public: void redo() override; private: // cppcheck-suppress unknownMacro - Q_DISABLE_COPY_MOVE(RenameBackgroundImage) + Q_DISABLE_COPY_MOVE(RenameBackgroundImage) // NOLINT QUuid m_id; QString m_name; QString m_oldName{}; diff --git a/src/libs/vtools/undocommands/image/resetbackgroundimage.h b/src/libs/vtools/undocommands/image/resetbackgroundimage.h index aed6bd7b1..ba1348ad1 100644 --- a/src/libs/vtools/undocommands/image/resetbackgroundimage.h +++ b/src/libs/vtools/undocommands/image/resetbackgroundimage.h @@ -48,7 +48,7 @@ public: private: // cppcheck-suppress unknownMacro - Q_DISABLE_COPY_MOVE(ResetBackgroundImage) + Q_DISABLE_COPY_MOVE(ResetBackgroundImage) // NOLINT QUuid m_id; QTransform m_oldMatrix{}; diff --git a/src/libs/vtools/undocommands/image/rotatebackgroundimage.h b/src/libs/vtools/undocommands/image/rotatebackgroundimage.h index 512bccdfd..d518580a8 100644 --- a/src/libs/vtools/undocommands/image/rotatebackgroundimage.h +++ b/src/libs/vtools/undocommands/image/rotatebackgroundimage.h @@ -57,7 +57,7 @@ public: private: // cppcheck-suppress unknownMacro - Q_DISABLE_COPY_MOVE(RotateBackgroundImage) + Q_DISABLE_COPY_MOVE(RotateBackgroundImage) // NOLINT QUuid m_id; QTransform m_matrix; diff --git a/src/libs/vtools/undocommands/image/scalebackgroundimage.h b/src/libs/vtools/undocommands/image/scalebackgroundimage.h index 7d2389c9a..8c869dd80 100644 --- a/src/libs/vtools/undocommands/image/scalebackgroundimage.h +++ b/src/libs/vtools/undocommands/image/scalebackgroundimage.h @@ -40,7 +40,7 @@ class ScaleBackgroundImage : public VUndoCommand { - Q_OBJECT + Q_OBJECT // NOLINT public: ScaleBackgroundImage(QUuid id, const QTransform &matrix, VAbstractPattern *doc, bool allowMerge = false, QUndoCommand *parent = nullptr); @@ -58,7 +58,7 @@ public: private: // cppcheck-suppress unknownMacro - Q_DISABLE_COPY_MOVE(ScaleBackgroundImage) + Q_DISABLE_COPY_MOVE(ScaleBackgroundImage) // NOLINT QUuid m_id; QTransform m_matrix; diff --git a/src/libs/vtools/undocommands/image/zvaluemovebackgroundimage.h b/src/libs/vtools/undocommands/image/zvaluemovebackgroundimage.h index f5f8643e1..ecdc270f3 100644 --- a/src/libs/vtools/undocommands/image/zvaluemovebackgroundimage.h +++ b/src/libs/vtools/undocommands/image/zvaluemovebackgroundimage.h @@ -51,7 +51,7 @@ public: void redo() override; private: // cppcheck-suppress unknownMacro - Q_DISABLE_COPY_MOVE(ZValueMoveBackgroundImage) + Q_DISABLE_COPY_MOVE(ZValueMoveBackgroundImage) // NOLINT QUuid m_id; ZValueMove m_move; QHash m_oldValues{}; diff --git a/src/libs/vtools/undocommands/label/moveabstractlabel.h b/src/libs/vtools/undocommands/label/moveabstractlabel.h index 67513b1b2..5e2ad2650 100644 --- a/src/libs/vtools/undocommands/label/moveabstractlabel.h +++ b/src/libs/vtools/undocommands/label/moveabstractlabel.h @@ -41,7 +41,7 @@ class QGraphicsScene; class MoveAbstractLabel : public VUndoCommand { - Q_OBJECT + Q_OBJECT // NOLINT public: MoveAbstractLabel(VAbstractPattern *doc, quint32 pointId, const QPointF &pos, QUndoCommand *parent = nullptr); virtual ~MoveAbstractLabel()=default; @@ -57,7 +57,7 @@ protected: virtual void Do(const QPointF &pos)=0; private: - Q_DISABLE_COPY(MoveAbstractLabel) + Q_DISABLE_COPY_MOVE(MoveAbstractLabel) // NOLINT }; //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/undocommands/label/movedoublelabel.h b/src/libs/vtools/undocommands/label/movedoublelabel.h index 843e362b4..c33924e4c 100644 --- a/src/libs/vtools/undocommands/label/movedoublelabel.h +++ b/src/libs/vtools/undocommands/label/movedoublelabel.h @@ -41,7 +41,7 @@ enum class MoveDoublePoint: qint8 { FirstPoint, SecondPoint }; class MoveDoubleLabel : public MoveAbstractLabel { - Q_OBJECT + Q_OBJECT // NOLINT public: MoveDoubleLabel(VAbstractPattern *doc, const QPointF &pos, MoveDoublePoint type, quint32 toolId, quint32 pointId, QUndoCommand *parent = nullptr); @@ -55,7 +55,8 @@ public: protected: virtual void Do(const QPointF &pos) override; private: - Q_DISABLE_COPY(MoveDoubleLabel) + // cppcheck-suppress unknownMacro + Q_DISABLE_COPY_MOVE(MoveDoubleLabel) // NOLINT MoveDoublePoint m_type; quint32 m_idTool; //Need for resizing scene rect diff --git a/src/libs/vtools/undocommands/label/movelabel.h b/src/libs/vtools/undocommands/label/movelabel.h index cd7f550a1..cfb5eb4b7 100644 --- a/src/libs/vtools/undocommands/label/movelabel.h +++ b/src/libs/vtools/undocommands/label/movelabel.h @@ -39,7 +39,7 @@ class MoveLabel : public MoveAbstractLabel { - Q_OBJECT + Q_OBJECT // NOLINT public: MoveLabel(VAbstractPattern *doc, const QPointF &pos, const quint32 &id, QUndoCommand *parent = nullptr); virtual ~MoveLabel()=default; @@ -49,7 +49,8 @@ public: protected: virtual void Do(const QPointF &pos) override; private: - Q_DISABLE_COPY(MoveLabel) + // cppcheck-suppress unknownMacro + Q_DISABLE_COPY_MOVE(MoveLabel) // NOLINT //Need for resizing scene rect QGraphicsScene *m_scene; }; diff --git a/src/libs/vtools/undocommands/label/operationmovelabel.h b/src/libs/vtools/undocommands/label/operationmovelabel.h index 46616c358..754f71943 100644 --- a/src/libs/vtools/undocommands/label/operationmovelabel.h +++ b/src/libs/vtools/undocommands/label/operationmovelabel.h @@ -40,7 +40,7 @@ class OperationMoveLabel : public MoveAbstractLabel { - Q_OBJECT + Q_OBJECT // NOLINT public: OperationMoveLabel(quint32 idTool, VAbstractPattern *doc, const QPointF &pos, quint32 idPoint, QUndoCommand *parent = nullptr); @@ -53,7 +53,8 @@ public: protected: virtual void Do(const QPointF &pos) override; private: - Q_DISABLE_COPY(OperationMoveLabel) + // cppcheck-suppress unknownMacro + Q_DISABLE_COPY_MOVE(OperationMoveLabel) // NOLINT quint32 m_idTool; //Need for resizing scene rect QGraphicsScene *m_scene; diff --git a/src/libs/vtools/undocommands/label/operationshowlabel.h b/src/libs/vtools/undocommands/label/operationshowlabel.h index 1c0e09e52..587b5a93a 100644 --- a/src/libs/vtools/undocommands/label/operationshowlabel.h +++ b/src/libs/vtools/undocommands/label/operationshowlabel.h @@ -35,7 +35,7 @@ class QGraphicsScene; class OperationShowLabel : public VUndoCommand { - Q_OBJECT + Q_OBJECT // NOLINT public: OperationShowLabel(VAbstractPattern *doc, quint32 idTool, quint32 idPoint, bool visible, QUndoCommand *parent = nullptr); @@ -45,7 +45,8 @@ public: virtual void redo() override; private: - Q_DISABLE_COPY(OperationShowLabel) + // cppcheck-suppress unknownMacro + Q_DISABLE_COPY_MOVE(OperationShowLabel) // NOLINT bool m_visible; bool m_oldVisible; //Need for resizing scene rect diff --git a/src/libs/vtools/undocommands/label/showdoublelabel.h b/src/libs/vtools/undocommands/label/showdoublelabel.h index 13250b5be..0a66b00d2 100644 --- a/src/libs/vtools/undocommands/label/showdoublelabel.h +++ b/src/libs/vtools/undocommands/label/showdoublelabel.h @@ -37,7 +37,7 @@ enum class ShowDoublePoint: qint8 { FirstPoint, SecondPoint }; class ShowDoubleLabel : public VUndoCommand { - Q_OBJECT + Q_OBJECT // NOLINT public: ShowDoubleLabel(VAbstractPattern *doc, quint32 toolId, quint32 pointId, bool visible, ShowDoublePoint type, QUndoCommand *parent = nullptr); @@ -46,7 +46,8 @@ public: virtual void undo() override; virtual void redo() override; private: - Q_DISABLE_COPY(ShowDoubleLabel) + // cppcheck-suppress unknownMacro + Q_DISABLE_COPY_MOVE(ShowDoubleLabel) // NOLINT bool m_visible; bool m_oldVisible; //Need for resizing scene rect diff --git a/src/libs/vtools/undocommands/label/showlabel.h b/src/libs/vtools/undocommands/label/showlabel.h index 5f2b5a690..2edbf7152 100644 --- a/src/libs/vtools/undocommands/label/showlabel.h +++ b/src/libs/vtools/undocommands/label/showlabel.h @@ -35,7 +35,7 @@ class QGraphicsScene; class ShowLabel : public VUndoCommand { - Q_OBJECT + Q_OBJECT // NOLINT public: ShowLabel(VAbstractPattern *doc, quint32 id, bool visible, QUndoCommand *parent = nullptr); virtual ~ShowLabel()=default; @@ -43,7 +43,8 @@ public: virtual void undo() override; virtual void redo() override; private: - Q_DISABLE_COPY(ShowLabel) + // cppcheck-suppress unknownMacro + Q_DISABLE_COPY_MOVE(ShowLabel) // NOLINT bool m_visible; bool m_oldVisible; //Need for resizing scene rect diff --git a/src/libs/vtools/undocommands/movepiece.h b/src/libs/vtools/undocommands/movepiece.h index 4b80f8537..6f1de12fc 100644 --- a/src/libs/vtools/undocommands/movepiece.h +++ b/src/libs/vtools/undocommands/movepiece.h @@ -41,7 +41,7 @@ class QGraphicsScene; class MovePiece : public VUndoCommand { - Q_OBJECT + Q_OBJECT // NOLINT public: MovePiece(VAbstractPattern *doc, const double &x, const double &y, const quint32 &id, QGraphicsScene *scene, QUndoCommand *parent = nullptr); @@ -59,7 +59,8 @@ public: double getNewX() const; double getNewY() const; private: - Q_DISABLE_COPY(MovePiece) + // cppcheck-suppress unknownMacro + Q_DISABLE_COPY_MOVE(MovePiece) // NOLINT double m_oldX; double m_oldY; diff --git a/src/libs/vtools/undocommands/movespline.h b/src/libs/vtools/undocommands/movespline.h index 0cadb3d17..800e6b8f2 100644 --- a/src/libs/vtools/undocommands/movespline.h +++ b/src/libs/vtools/undocommands/movespline.h @@ -42,7 +42,7 @@ class QGraphicsScene; class MoveSpline : public VUndoCommand { - Q_OBJECT + Q_OBJECT // NOLINT public: MoveSpline(VAbstractPattern *doc, const VSpline &oldSpl, const VSpline &newSpl, const quint32 &id, QUndoCommand *parent = nullptr); @@ -54,7 +54,8 @@ public: quint32 getSplineId() const; VSpline getNewSpline() const; private: - Q_DISABLE_COPY(MoveSpline) + // cppcheck-suppress unknownMacro + Q_DISABLE_COPY_MOVE(MoveSpline) // NOLINT VSpline oldSpline; VSpline newSpline; QGraphicsScene *scene; diff --git a/src/libs/vtools/undocommands/movesplinepath.h b/src/libs/vtools/undocommands/movesplinepath.h index 48b8b008d..a6ce38efd 100644 --- a/src/libs/vtools/undocommands/movesplinepath.h +++ b/src/libs/vtools/undocommands/movesplinepath.h @@ -42,7 +42,7 @@ class QGraphicsScene; class MoveSplinePath : public VUndoCommand { - Q_OBJECT + Q_OBJECT // NOLINT public: MoveSplinePath(VAbstractPattern *doc, const VSplinePath &oldSplPath, const VSplinePath &newSplPath, const quint32 &id, QUndoCommand *parent = nullptr); @@ -54,7 +54,8 @@ public: quint32 getSplinePathId() const; VSplinePath getNewSplinePath() const; private: - Q_DISABLE_COPY(MoveSplinePath) + // cppcheck-suppress unknownMacro + Q_DISABLE_COPY_MOVE(MoveSplinePath) // NOLINT VSplinePath oldSplinePath; VSplinePath newSplinePath; QGraphicsScene *scene; diff --git a/src/libs/vtools/undocommands/movespoint.h b/src/libs/vtools/undocommands/movespoint.h index 27a3ae8d8..f26be95fb 100644 --- a/src/libs/vtools/undocommands/movespoint.h +++ b/src/libs/vtools/undocommands/movespoint.h @@ -41,7 +41,7 @@ class QGraphicsScene; class MoveSPoint : public VUndoCommand { - Q_OBJECT + Q_OBJECT // NOLINT public: MoveSPoint(VAbstractPattern *doc, const double &x, const double &y, const quint32 &id, QGraphicsScene *scene, QUndoCommand *parent = nullptr); @@ -55,7 +55,8 @@ public: double getNewY() const; void Do(double x, double y); private: - Q_DISABLE_COPY(MoveSPoint) + // cppcheck-suppress unknownMacro + Q_DISABLE_COPY_MOVE(MoveSPoint) // NOLINT double oldX; double oldY; double newX; diff --git a/src/libs/vtools/undocommands/renamepp.h b/src/libs/vtools/undocommands/renamepp.h index f85b4cab3..0ac9266f6 100644 --- a/src/libs/vtools/undocommands/renamepp.h +++ b/src/libs/vtools/undocommands/renamepp.h @@ -39,7 +39,7 @@ class RenamePP :public VUndoCommand { - Q_OBJECT + Q_OBJECT // NOLINT public: RenamePP(VAbstractPattern *doc, const QString &newPPname, QComboBox *combo, QUndoCommand *parent = nullptr); virtual ~RenamePP() override; @@ -51,7 +51,8 @@ public: QString getNewPPname() const; QString getOldPPname() const; private: - Q_DISABLE_COPY(RenamePP) + // cppcheck-suppress unknownMacro + Q_DISABLE_COPY_MOVE(RenamePP) // NOLINT QComboBox *combo; QString newPPname; QString oldPPname; diff --git a/src/libs/vtools/undocommands/savepieceoptions.h b/src/libs/vtools/undocommands/savepieceoptions.h index 2082962b4..d68d42273 100644 --- a/src/libs/vtools/undocommands/savepieceoptions.h +++ b/src/libs/vtools/undocommands/savepieceoptions.h @@ -36,7 +36,7 @@ class SavePieceOptions : public VUndoCommand { - Q_OBJECT + Q_OBJECT // NOLINT public: SavePieceOptions(const VPiece &oldDet, const VPiece &newDet, VAbstractPattern *doc, quint32 id, QUndoCommand *parent = nullptr); @@ -51,7 +51,8 @@ public: signals: void UpdateGroups(); private: - Q_DISABLE_COPY(SavePieceOptions) + // cppcheck-suppress unknownMacro + Q_DISABLE_COPY_MOVE(SavePieceOptions) // NOLINT const VPiece m_oldDet; VPiece m_newDet; diff --git a/src/libs/vtools/undocommands/savepiecepathoptions.h b/src/libs/vtools/undocommands/savepiecepathoptions.h index c91638963..e4ae1a456 100644 --- a/src/libs/vtools/undocommands/savepiecepathoptions.h +++ b/src/libs/vtools/undocommands/savepiecepathoptions.h @@ -36,7 +36,7 @@ class SavePiecePathOptions : public VUndoCommand { - Q_OBJECT + Q_OBJECT // NOLINT public: SavePiecePathOptions(quint32 pieceId, const VPiecePath &oldPath, const VPiecePath &newPath, VAbstractPattern *doc, VContainer *data, quint32 id, QUndoCommand *parent = nullptr); @@ -49,7 +49,8 @@ public: quint32 PathId() const; VPiecePath NewPath() const; private: - Q_DISABLE_COPY(SavePiecePathOptions) + // cppcheck-suppress unknownMacro + Q_DISABLE_COPY_MOVE(SavePiecePathOptions) // NOLINT const VPiecePath m_oldPath; VPiecePath m_newPath; diff --git a/src/libs/vtools/undocommands/saveplacelabeloptions.h b/src/libs/vtools/undocommands/saveplacelabeloptions.h index c9bc5e32f..53336bda5 100644 --- a/src/libs/vtools/undocommands/saveplacelabeloptions.h +++ b/src/libs/vtools/undocommands/saveplacelabeloptions.h @@ -33,7 +33,7 @@ class SavePlaceLabelOptions : public VUndoCommand { - Q_OBJECT + Q_OBJECT // NOLINT public: SavePlaceLabelOptions(quint32 pieceId, const VPlaceLabelItem &oldLabel, const VPlaceLabelItem &newLabel, VAbstractPattern *doc, VContainer *data, quint32 id, QUndoCommand *parent = nullptr); @@ -47,7 +47,8 @@ public: quint32 LabelId() const; VPlaceLabelItem NewLabel() const; private: - Q_DISABLE_COPY(SavePlaceLabelOptions) + // cppcheck-suppress unknownMacro + Q_DISABLE_COPY_MOVE(SavePlaceLabelOptions) // NOLINT const VPlaceLabelItem m_oldLabel; VPlaceLabelItem m_newLabel; diff --git a/src/libs/vtools/undocommands/savetooloptions.h b/src/libs/vtools/undocommands/savetooloptions.h index eb0dde6ab..4414d880f 100644 --- a/src/libs/vtools/undocommands/savetooloptions.h +++ b/src/libs/vtools/undocommands/savetooloptions.h @@ -40,7 +40,7 @@ class SaveToolOptions : public VUndoCommand { - Q_OBJECT + Q_OBJECT // NOLINT public: SaveToolOptions(const QDomElement &oldXml, const QDomElement &newXml, const QList &oldDependencies, const QList &newDependencies, VAbstractPattern *doc, const quint32 &id, @@ -55,7 +55,8 @@ public: quint32 getToolId() const; QList NewDependencies() const; private: - Q_DISABLE_COPY(SaveToolOptions) + // cppcheck-suppress unknownMacro + Q_DISABLE_COPY_MOVE(SaveToolOptions) // NOLINT const QDomElement oldXml; QDomElement newXml; const QList oldDependencies; diff --git a/src/libs/vtools/undocommands/togglepiecestate.h b/src/libs/vtools/undocommands/togglepiecestate.h index f74606aae..b267a203c 100644 --- a/src/libs/vtools/undocommands/togglepiecestate.h +++ b/src/libs/vtools/undocommands/togglepiecestate.h @@ -39,7 +39,7 @@ class TogglePieceInLayout : public VUndoCommand { - Q_OBJECT + Q_OBJECT // NOLINT public: TogglePieceInLayout(quint32 id, bool state, VContainer *data, VAbstractPattern *doc, QUndoCommand *parent = nullptr); @@ -49,7 +49,8 @@ public: signals: void Toggled(quint32 id); private: - Q_DISABLE_COPY(TogglePieceInLayout) + // cppcheck-suppress unknownMacro + Q_DISABLE_COPY_MOVE(TogglePieceInLayout) // NOLINT quint32 m_id; VContainer *m_data; bool m_oldState; @@ -62,7 +63,7 @@ enum class ForceForbidFlippingType : qint8 {ForceFlipping, ForbidFlipping}; class TogglePieceForceForbidFlipping : public VUndoCommand { - Q_OBJECT + Q_OBJECT // NOLINT public: TogglePieceForceForbidFlipping(quint32 id, bool state, ForceForbidFlippingType type, VContainer *data, VAbstractPattern *doc, QUndoCommand *parent = nullptr); @@ -70,7 +71,7 @@ public: virtual void undo() override; virtual void redo() override; private: - Q_DISABLE_COPY(TogglePieceForceForbidFlipping) + Q_DISABLE_COPY_MOVE(TogglePieceForceForbidFlipping) // NOLINT quint32 m_id; VContainer *m_data; ForceForbidFlippingType m_type; diff --git a/src/libs/vtools/undocommands/undogroup.h b/src/libs/vtools/undocommands/undogroup.h index e3185fc8c..aae4bc345 100644 --- a/src/libs/vtools/undocommands/undogroup.h +++ b/src/libs/vtools/undocommands/undogroup.h @@ -40,7 +40,7 @@ class AddGroup : public VUndoCommand { - Q_OBJECT + Q_OBJECT // NOLINT public: AddGroup(const QDomElement &xml, VAbstractPattern *doc, QUndoCommand *parent = nullptr); virtual ~AddGroup()=default; @@ -49,13 +49,14 @@ public: signals: void UpdateGroups(); private: - Q_DISABLE_COPY(AddGroup) + // cppcheck-suppress unknownMacro + Q_DISABLE_COPY_MOVE(AddGroup) // NOLINT const QString nameActivDraw; }; class RenameGroup : public VUndoCommand { - Q_OBJECT + Q_OBJECT // NOLINT public: RenameGroup(VAbstractPattern *doc, quint32 id, const QString &name, QUndoCommand *parent = nullptr); virtual ~RenameGroup()=default; @@ -64,14 +65,14 @@ public: signals: void UpdateGroups(); private: - Q_DISABLE_COPY(RenameGroup) + Q_DISABLE_COPY_MOVE(RenameGroup) // NOLINT QString newName; QString oldName{}; }; class ChangeGroupOptions : public VUndoCommand { - Q_OBJECT + Q_OBJECT // NOLINT public: ChangeGroupOptions(VAbstractPattern *doc, quint32 id, const QString &name, const QStringList &tags, QUndoCommand *parent = nullptr); @@ -81,7 +82,7 @@ public: signals: void UpdateGroups(); private: - Q_DISABLE_COPY(ChangeGroupOptions) + Q_DISABLE_COPY_MOVE(ChangeGroupOptions) // NOLINT QString newName; QString oldName{}; QStringList newTags; @@ -90,7 +91,7 @@ private: class AddItemToGroup : public VUndoCommand { - Q_OBJECT + Q_OBJECT // NOLINT public: AddItemToGroup(const QDomElement &xml, VAbstractPattern *doc, quint32 groupId, QUndoCommand *parent = nullptr); virtual ~AddItemToGroup()=default; @@ -101,13 +102,13 @@ signals: protected: void performUndoRedo(bool isUndo); private: - Q_DISABLE_COPY(AddItemToGroup) + Q_DISABLE_COPY_MOVE(AddItemToGroup) // NOLINT const QString nameActivDraw; }; class RemoveItemFromGroup : public VUndoCommand { - Q_OBJECT + Q_OBJECT // NOLINT public: RemoveItemFromGroup(const QDomElement &xml, VAbstractPattern *doc, quint32 groupId, QUndoCommand *parent = nullptr); virtual ~RemoveItemFromGroup()=default; @@ -118,13 +119,13 @@ signals: protected: void performUndoRedo(bool isUndo); private: - Q_DISABLE_COPY(RemoveItemFromGroup) + Q_DISABLE_COPY_MOVE(RemoveItemFromGroup) // NOLINT const QString nameActivDraw; }; class ChangeGroupVisibility : public VUndoCommand { - Q_OBJECT + Q_OBJECT // NOLINT public: ChangeGroupVisibility(VAbstractPattern *doc, vidtype id, bool visible, QUndoCommand *parent = nullptr); virtual ~ChangeGroupVisibility()=default; @@ -135,7 +136,7 @@ signals: void UpdateGroup(vidtype id, bool visible); private: - Q_DISABLE_COPY(ChangeGroupVisibility) + Q_DISABLE_COPY_MOVE(ChangeGroupVisibility) // NOLINT bool m_oldVisibility{true}; bool m_newVisibility{true}; @@ -146,7 +147,7 @@ private: class ChangeMultipleGroupsVisibility : public VUndoCommand { - Q_OBJECT + Q_OBJECT // NOLINT public: ChangeMultipleGroupsVisibility(VAbstractPattern *doc, const QVector &groups, bool visible, QUndoCommand *parent = nullptr); @@ -158,7 +159,7 @@ signals: void UpdateMultipleGroups(const QMap &groups); private: - Q_DISABLE_COPY(ChangeMultipleGroupsVisibility) + Q_DISABLE_COPY_MOVE(ChangeMultipleGroupsVisibility) // NOLINT QVector m_groups; bool m_newVisibility{true}; @@ -168,7 +169,7 @@ private: class DelGroup : public VUndoCommand { - Q_OBJECT + Q_OBJECT // NOLINT public: DelGroup(VAbstractPattern *doc, quint32 id, QUndoCommand *parent = nullptr); virtual ~DelGroup()=default; @@ -177,7 +178,7 @@ public: signals: void UpdateGroups(); private: - Q_DISABLE_COPY(DelGroup) + Q_DISABLE_COPY_MOVE(DelGroup) // NOLINT const QString nameActivDraw; }; diff --git a/src/libs/vtools/undocommands/vundocommand.cpp b/src/libs/vtools/undocommands/vundocommand.cpp index dd72c9b3f..095da114d 100644 --- a/src/libs/vtools/undocommands/vundocommand.cpp +++ b/src/libs/vtools/undocommands/vundocommand.cpp @@ -34,11 +34,16 @@ #include "../ifc/ifcdef.h" #include "../vmisc/def.h" #include "../vmisc/customevents.h" -#include "../vpatterndb/vnodedetail.h" #include "../vpatterndb/vpiecenode.h" #include "../tools/drawTools/operation/vabstractoperation.h" -Q_LOGGING_CATEGORY(vUndo, "v.undo") +QT_WARNING_PUSH +QT_WARNING_DISABLE_CLANG("-Wmissing-prototypes") +QT_WARNING_DISABLE_INTEL(1418) + +Q_LOGGING_CATEGORY(vUndo, "v.undo") // NOLINT + +QT_WARNING_POP //--------------------------------------------------------------------------------------------------------------------- VUndoCommand::VUndoCommand(const QDomElement &xml, VAbstractPattern *doc, QUndoCommand *parent) diff --git a/src/libs/vtools/undocommands/vundocommand.h b/src/libs/vtools/undocommands/vundocommand.h index 3ef89afee..470b03df6 100644 --- a/src/libs/vtools/undocommands/vundocommand.h +++ b/src/libs/vtools/undocommands/vundocommand.h @@ -70,7 +70,7 @@ class VPattern; class VUndoCommand : public QObject, public QUndoCommand { - Q_OBJECT + Q_OBJECT // NOLINT public: VUndoCommand(const QDomElement &xml, VAbstractPattern *doc, QUndoCommand *parent = nullptr); virtual ~VUndoCommand() =default; @@ -98,7 +98,7 @@ protected: QDomElement GetDestinationObject(quint32 idTool, quint32 idPoint) const; private: - Q_DISABLE_COPY(VUndoCommand) + Q_DISABLE_COPY_MOVE(VUndoCommand) // NOLINT }; #endif // VUNDOCOMMAND_H diff --git a/src/libs/vtools/visualization/line/operation/visoperation.h b/src/libs/vtools/visualization/line/operation/visoperation.h index e444ddba1..6fa325978 100644 --- a/src/libs/vtools/visualization/line/operation/visoperation.h +++ b/src/libs/vtools/visualization/line/operation/visoperation.h @@ -36,7 +36,7 @@ class VisOperation : public VisLine { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit VisOperation(const VContainer *data, QGraphicsItem *parent = nullptr); virtual ~VisOperation(); @@ -63,7 +63,7 @@ protected: void RefreshFlippedObjects(const QPointF &firstPoint, const QPointF &secondPoint); private: - Q_DISABLE_COPY(VisOperation) + Q_DISABLE_COPY_MOVE(VisOperation) // NOLINT }; //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/visualization/line/operation/vistoolflippingbyaxis.h b/src/libs/vtools/visualization/line/operation/vistoolflippingbyaxis.h index 80ff212c5..f52d0d2c8 100644 --- a/src/libs/vtools/visualization/line/operation/vistoolflippingbyaxis.h +++ b/src/libs/vtools/visualization/line/operation/vistoolflippingbyaxis.h @@ -36,7 +36,7 @@ class VisToolFlippingByAxis : public VisOperation { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit VisToolFlippingByAxis(const VContainer *data, QGraphicsItem *parent = nullptr); virtual ~VisToolFlippingByAxis() = default; @@ -49,7 +49,8 @@ public: virtual int type() const override {return Type;} enum { Type = UserType + static_cast(Vis::ToolFlippingByAxis)}; private: - Q_DISABLE_COPY(VisToolFlippingByAxis) + // cppcheck-suppress unknownMacro + Q_DISABLE_COPY_MOVE(VisToolFlippingByAxis) // NOLINT AxisType m_axisType; diff --git a/src/libs/vtools/visualization/line/operation/vistoolflippingbyline.h b/src/libs/vtools/visualization/line/operation/vistoolflippingbyline.h index e8714b500..95af24e8d 100644 --- a/src/libs/vtools/visualization/line/operation/vistoolflippingbyline.h +++ b/src/libs/vtools/visualization/line/operation/vistoolflippingbyline.h @@ -35,7 +35,7 @@ class VisToolFlippingByLine : public VisOperation { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit VisToolFlippingByLine(const VContainer *data, QGraphicsItem *parent = nullptr); virtual ~VisToolFlippingByLine() = default; @@ -48,7 +48,8 @@ public: virtual int type() const override {return Type;} enum { Type = UserType + static_cast(Vis::ToolFlippingByLine)}; private: - Q_DISABLE_COPY(VisToolFlippingByLine) + // cppcheck-suppress unknownMacro + Q_DISABLE_COPY_MOVE(VisToolFlippingByLine) // NOLINT quint32 object2Id; VScaledEllipse *point1; VScaledEllipse *point2; diff --git a/src/libs/vtools/visualization/line/operation/vistoolmove.h b/src/libs/vtools/visualization/line/operation/vistoolmove.h index 8eae23c12..092e208d1 100644 --- a/src/libs/vtools/visualization/line/operation/vistoolmove.h +++ b/src/libs/vtools/visualization/line/operation/vistoolmove.h @@ -45,7 +45,7 @@ class VisToolMove : public VisOperation { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit VisToolMove(const VContainer *data, QGraphicsItem *parent = nullptr); virtual ~VisToolMove() = default; @@ -67,7 +67,8 @@ public: virtual int type() const override {return Type;} enum { Type = UserType + static_cast(Vis::ToolMove)}; private: - Q_DISABLE_COPY(VisToolMove) + // cppcheck-suppress unknownMacro + Q_DISABLE_COPY_MOVE(VisToolMove) // NOLINT qreal angle; qreal rotationAngle; qreal length; diff --git a/src/libs/vtools/visualization/line/operation/vistoolrotation.h b/src/libs/vtools/visualization/line/operation/vistoolrotation.h index 4c6dedfc5..f06853212 100644 --- a/src/libs/vtools/visualization/line/operation/vistoolrotation.h +++ b/src/libs/vtools/visualization/line/operation/vistoolrotation.h @@ -45,7 +45,7 @@ class VisToolRotation : public VisOperation { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit VisToolRotation(const VContainer *data, QGraphicsItem *parent = nullptr); virtual ~VisToolRotation(); @@ -60,7 +60,8 @@ public: virtual int type() const override {return Type;} enum { Type = UserType + static_cast(Vis::ToolRotation)}; private: - Q_DISABLE_COPY(VisToolRotation) + // cppcheck-suppress unknownMacro + Q_DISABLE_COPY_MOVE(VisToolRotation) // NOLINT qreal angle; VScaledEllipse *point; VCurvePathItem *angleArc; diff --git a/src/libs/vtools/visualization/line/visline.h b/src/libs/vtools/visualization/line/visline.h index 31ef37e66..d1a39963c 100644 --- a/src/libs/vtools/visualization/line/visline.h +++ b/src/libs/vtools/visualization/line/visline.h @@ -47,7 +47,7 @@ class VisLine: public Visualization, public VScaledLine { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit VisLine(const VContainer *data, QGraphicsItem *parent = nullptr); virtual ~VisLine() = default; @@ -66,7 +66,7 @@ protected: void DrawRay(VScaledLine *lineItem, const QPointF &p, const QPointF &pTangent, const QColor &color, Qt::PenStyle style); private: - Q_DISABLE_COPY(VisLine) + Q_DISABLE_COPY_MOVE(VisLine) // NOLINT }; #endif // VISLINE_H diff --git a/src/libs/vtools/visualization/line/vistoolalongline.h b/src/libs/vtools/visualization/line/vistoolalongline.h index 7accf744a..8f3185a63 100644 --- a/src/libs/vtools/visualization/line/vistoolalongline.h +++ b/src/libs/vtools/visualization/line/vistoolalongline.h @@ -41,7 +41,7 @@ class VisToolAlongLine final :public VisLine { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit VisToolAlongLine(const VContainer *data, QGraphicsItem *parent = nullptr); virtual ~VisToolAlongLine() = default; @@ -53,7 +53,8 @@ public: virtual int type() const override {return Type;} enum { Type = UserType + static_cast(Vis::ToolAlongLine)}; private: - Q_DISABLE_COPY(VisToolAlongLine) + // cppcheck-suppress unknownMacro + Q_DISABLE_COPY_MOVE(VisToolAlongLine) // NOLINT quint32 object2Id; VScaledEllipse *point; VScaledEllipse *lineP1; diff --git a/src/libs/vtools/visualization/line/vistoolbisector.h b/src/libs/vtools/visualization/line/vistoolbisector.h index dd9e8eae0..61c08cc26 100644 --- a/src/libs/vtools/visualization/line/vistoolbisector.h +++ b/src/libs/vtools/visualization/line/vistoolbisector.h @@ -41,7 +41,7 @@ class VisToolBisector :public VisLine { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit VisToolBisector(const VContainer *data, QGraphicsItem *parent = nullptr); virtual ~VisToolBisector() = default; @@ -53,7 +53,8 @@ public: virtual int type() const override {return Type;} enum { Type = UserType + static_cast(Vis::ToolBisector)}; private: - Q_DISABLE_COPY(VisToolBisector) + // cppcheck-suppress unknownMacro + Q_DISABLE_COPY_MOVE(VisToolBisector) // NOLINT quint32 object2Id; quint32 object3Id; VScaledEllipse *point; diff --git a/src/libs/vtools/visualization/line/vistoolcurveintersectaxis.h b/src/libs/vtools/visualization/line/vistoolcurveintersectaxis.h index 3fe9f84b6..d1e7a3ca3 100644 --- a/src/libs/vtools/visualization/line/vistoolcurveintersectaxis.h +++ b/src/libs/vtools/visualization/line/vistoolcurveintersectaxis.h @@ -41,7 +41,7 @@ class VisToolCurveIntersectAxis final : public VisLine { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit VisToolCurveIntersectAxis(const VContainer *data, QGraphicsItem *parent = nullptr); virtual ~VisToolCurveIntersectAxis() = default; @@ -55,7 +55,8 @@ public: virtual int type() const override {return Type;} enum { Type = UserType + static_cast(Vis::ToolLineIntersectAxis)}; private: - Q_DISABLE_COPY(VisToolCurveIntersectAxis) + // cppcheck-suppress unknownMacro + Q_DISABLE_COPY_MOVE(VisToolCurveIntersectAxis) // NOLINT quint32 axisPointId; qreal angle; VScaledEllipse *point; diff --git a/src/libs/vtools/visualization/line/vistoolendline.h b/src/libs/vtools/visualization/line/vistoolendline.h index f29bfe9ec..d1d7890e9 100644 --- a/src/libs/vtools/visualization/line/vistoolendline.h +++ b/src/libs/vtools/visualization/line/vistoolendline.h @@ -41,7 +41,7 @@ class VisToolEndLine final : public VisLine { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit VisToolEndLine(const VContainer *data, QGraphicsItem *parent = nullptr); virtual ~VisToolEndLine() = default; @@ -57,7 +57,8 @@ public: virtual int type() const override {return Type;} enum { Type = UserType + static_cast(Vis::ToolEndLine)}; private: - Q_DISABLE_COPY(VisToolEndLine) + // cppcheck-suppress unknownMacro + Q_DISABLE_COPY_MOVE(VisToolEndLine) // NOLINT qreal length; qreal angle; VScaledEllipse *point; diff --git a/src/libs/vtools/visualization/line/vistoolheight.h b/src/libs/vtools/visualization/line/vistoolheight.h index 9c86b9b24..927fd0c73 100644 --- a/src/libs/vtools/visualization/line/vistoolheight.h +++ b/src/libs/vtools/visualization/line/vistoolheight.h @@ -42,7 +42,7 @@ class VisToolHeight final : public VisLine { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit VisToolHeight(const VContainer *data, QGraphicsItem *parent = nullptr); virtual ~VisToolHeight() = default; @@ -54,7 +54,8 @@ public: virtual int type() const override {return Type;} enum { Type = UserType + static_cast(Vis::ToolHeight)}; private: - Q_DISABLE_COPY(VisToolHeight) + // cppcheck-suppress unknownMacro + Q_DISABLE_COPY_MOVE(VisToolHeight) // NOLINT //base point in parent class quint32 lineP1Id{NULL_ID};//first point of line quint32 lineP2Id{NULL_ID};//second point of line diff --git a/src/libs/vtools/visualization/line/vistoolline.h b/src/libs/vtools/visualization/line/vistoolline.h index 86a0f8b11..7ac24a614 100644 --- a/src/libs/vtools/visualization/line/vistoolline.h +++ b/src/libs/vtools/visualization/line/vistoolline.h @@ -44,7 +44,7 @@ class VisToolLine : public VisLine { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit VisToolLine(const VContainer *data, QGraphicsItem *parent = nullptr); virtual ~VisToolLine() = default; @@ -57,7 +57,8 @@ protected: virtual void DrawLine(VScaledLine *lineItem, const QLineF &line, const QColor &color, Qt::PenStyle style = Qt::SolidLine) override; private: - Q_DISABLE_COPY(VisToolLine) + // cppcheck-suppress unknownMacro + Q_DISABLE_COPY_MOVE(VisToolLine) // NOLINT quint32 point2Id; }; diff --git a/src/libs/vtools/visualization/line/vistoollineintersect.h b/src/libs/vtools/visualization/line/vistoollineintersect.h index 599099c73..90d4cd0fe 100644 --- a/src/libs/vtools/visualization/line/vistoollineintersect.h +++ b/src/libs/vtools/visualization/line/vistoollineintersect.h @@ -41,7 +41,7 @@ class VisToolLineIntersect :public VisLine { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit VisToolLineIntersect(const VContainer *data, QGraphicsItem *parent = nullptr); virtual ~VisToolLineIntersect() = default; @@ -54,7 +54,8 @@ public: virtual int type() const override {return Type;} enum { Type = UserType + static_cast(Vis::ToolLineIntersect)}; private: - Q_DISABLE_COPY(VisToolLineIntersect) + // cppcheck-suppress unknownMacro + Q_DISABLE_COPY_MOVE(VisToolLineIntersect) // NOLINT quint32 line1P2Id; quint32 line2P1Id; quint32 line2P2Id; diff --git a/src/libs/vtools/visualization/line/vistoollineintersectaxis.h b/src/libs/vtools/visualization/line/vistoollineintersectaxis.h index 1b0c454c4..87144fab1 100644 --- a/src/libs/vtools/visualization/line/vistoollineintersectaxis.h +++ b/src/libs/vtools/visualization/line/vistoollineintersectaxis.h @@ -42,7 +42,7 @@ class VisToolLineIntersectAxis : public VisLine { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit VisToolLineIntersectAxis(const VContainer *data, QGraphicsItem *parent = nullptr); virtual ~VisToolLineIntersectAxis() = default; @@ -57,7 +57,8 @@ public: virtual int type() const override {return Type;} enum { Type = UserType + static_cast(Vis::ToolLineIntersectAxis)}; private: - Q_DISABLE_COPY(VisToolLineIntersectAxis) + // cppcheck-suppress unknownMacro + Q_DISABLE_COPY_MOVE(VisToolLineIntersectAxis) // NOLINT quint32 point2Id; quint32 axisPointId; qreal angle; diff --git a/src/libs/vtools/visualization/line/vistoolnormal.h b/src/libs/vtools/visualization/line/vistoolnormal.h index ec3303c49..ec1d1d74f 100644 --- a/src/libs/vtools/visualization/line/vistoolnormal.h +++ b/src/libs/vtools/visualization/line/vistoolnormal.h @@ -41,7 +41,7 @@ class VisToolNormal : public VisLine { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit VisToolNormal(const VContainer *data, QGraphicsItem *parent = nullptr); virtual ~VisToolNormal() = default; @@ -56,7 +56,8 @@ public: enum { Type = UserType + static_cast(Vis::ToolNormal)}; private: - Q_DISABLE_COPY(VisToolNormal) + // cppcheck-suppress unknownMacro + Q_DISABLE_COPY_MOVE(VisToolNormal) // NOLINT quint32 object2Id; VScaledEllipse *point; VScaledEllipse *lineP1; diff --git a/src/libs/vtools/visualization/line/vistoolpointfromarcandtangent.h b/src/libs/vtools/visualization/line/vistoolpointfromarcandtangent.h index 0040698f0..f22433a1d 100644 --- a/src/libs/vtools/visualization/line/vistoolpointfromarcandtangent.h +++ b/src/libs/vtools/visualization/line/vistoolpointfromarcandtangent.h @@ -45,7 +45,7 @@ class VArc; class VisToolPointFromArcAndTangent : public VisLine { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit VisToolPointFromArcAndTangent(const VContainer *data, QGraphicsItem *parent = nullptr); virtual ~VisToolPointFromArcAndTangent() = default; @@ -58,7 +58,8 @@ public: virtual int type() const override {return Type;} enum { Type = UserType + static_cast(Vis::ToolPointFromArcAndTangent)}; private: - Q_DISABLE_COPY(VisToolPointFromArcAndTangent) + // cppcheck-suppress unknownMacro + Q_DISABLE_COPY_MOVE(VisToolPointFromArcAndTangent) // NOLINT quint32 arcId; CrossCirclesPoint crossPoint; VScaledEllipse *point; diff --git a/src/libs/vtools/visualization/line/vistoolpointfromcircleandtangent.h b/src/libs/vtools/visualization/line/vistoolpointfromcircleandtangent.h index c9d698199..994b6c1c9 100644 --- a/src/libs/vtools/visualization/line/vistoolpointfromcircleandtangent.h +++ b/src/libs/vtools/visualization/line/vistoolpointfromcircleandtangent.h @@ -43,7 +43,7 @@ class VisToolPointFromCircleAndTangent : public VisLine { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit VisToolPointFromCircleAndTangent(const VContainer *data, QGraphicsItem *parent = nullptr); virtual ~VisToolPointFromCircleAndTangent() = default; @@ -57,7 +57,8 @@ public: virtual int type() const override {return Type;} enum { Type = UserType + static_cast(Vis::ToolPointFromCircleAndTangent)}; private: - Q_DISABLE_COPY(VisToolPointFromCircleAndTangent) + // cppcheck-suppress unknownMacro + Q_DISABLE_COPY_MOVE(VisToolPointFromCircleAndTangent) // NOLINT quint32 object2Id; qreal cRadius; CrossCirclesPoint crossPoint; diff --git a/src/libs/vtools/visualization/line/vistoolpointofcontact.h b/src/libs/vtools/visualization/line/vistoolpointofcontact.h index fdec291eb..436ca3a40 100644 --- a/src/libs/vtools/visualization/line/vistoolpointofcontact.h +++ b/src/libs/vtools/visualization/line/vistoolpointofcontact.h @@ -41,7 +41,7 @@ class VisToolPointOfContact : public VisLine { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit VisToolPointOfContact(const VContainer *data, QGraphicsItem *parent = nullptr); virtual ~VisToolPointOfContact() = default; @@ -53,7 +53,8 @@ public: virtual int type() const override {return Type;} enum { Type = UserType + static_cast(Vis::ToolPointOfContact)}; private: - Q_DISABLE_COPY(VisToolPointOfContact) + // cppcheck-suppress unknownMacro + Q_DISABLE_COPY_MOVE(VisToolPointOfContact) // NOLINT quint32 lineP2Id; quint32 radiusId; VScaledEllipse *point; diff --git a/src/libs/vtools/visualization/line/vistoolpointofintersection.h b/src/libs/vtools/visualization/line/vistoolpointofintersection.h index 9a46ea8f2..6a7f76b70 100644 --- a/src/libs/vtools/visualization/line/vistoolpointofintersection.h +++ b/src/libs/vtools/visualization/line/vistoolpointofintersection.h @@ -43,7 +43,7 @@ class VisToolPointOfIntersection : public VisLine { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit VisToolPointOfIntersection(const VContainer *data, QGraphicsItem *parent = nullptr); virtual ~VisToolPointOfIntersection() = default; @@ -54,7 +54,8 @@ public: virtual int type() const override {return Type;} enum { Type = UserType + static_cast(Vis::ToolPointOfIntersection)}; private: - Q_DISABLE_COPY(VisToolPointOfIntersection) + // cppcheck-suppress unknownMacro + Q_DISABLE_COPY_MOVE(VisToolPointOfIntersection) // NOLINT quint32 point2Id; VScaledEllipse *point; VScaledEllipse *axisP1;//axis1 is class themself diff --git a/src/libs/vtools/visualization/line/vistoolpointofintersectionarcs.h b/src/libs/vtools/visualization/line/vistoolpointofintersectionarcs.h index d39856cae..2a4dbde39 100644 --- a/src/libs/vtools/visualization/line/vistoolpointofintersectionarcs.h +++ b/src/libs/vtools/visualization/line/vistoolpointofintersectionarcs.h @@ -42,7 +42,7 @@ class VisToolPointOfIntersectionArcs : public VisLine { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit VisToolPointOfIntersectionArcs(const VContainer *data, QGraphicsItem *parent = nullptr); virtual ~VisToolPointOfIntersectionArcs() = default; @@ -57,7 +57,8 @@ public: virtual int type() const override {return Type;} enum { Type = UserType + static_cast(Vis::ToolPointOfIntersectionArcs)}; private: - Q_DISABLE_COPY(VisToolPointOfIntersectionArcs) + // cppcheck-suppress unknownMacro + Q_DISABLE_COPY_MOVE(VisToolPointOfIntersectionArcs) // NOLINT quint32 arc1Id; quint32 arc2Id; CrossCirclesPoint crossPoint; diff --git a/src/libs/vtools/visualization/line/vistoolpointofintersectioncircles.h b/src/libs/vtools/visualization/line/vistoolpointofintersectioncircles.h index 4b6d2f6ec..c03a7b41a 100644 --- a/src/libs/vtools/visualization/line/vistoolpointofintersectioncircles.h +++ b/src/libs/vtools/visualization/line/vistoolpointofintersectioncircles.h @@ -42,7 +42,7 @@ class VisToolPointOfIntersectionCircles : public VisLine { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit VisToolPointOfIntersectionCircles(const VContainer *data, QGraphicsItem *parent = nullptr); virtual ~VisToolPointOfIntersectionCircles() = default; @@ -58,7 +58,8 @@ public: virtual int type() const override {return Type;} enum { Type = UserType + static_cast(Vis::ToolPointOfIntersectionCircles)}; private: - Q_DISABLE_COPY(VisToolPointOfIntersectionCircles) + // cppcheck-suppress unknownMacro + Q_DISABLE_COPY_MOVE(VisToolPointOfIntersectionCircles) // NOLINT quint32 object2Id; qreal c1Radius; qreal c2Radius; diff --git a/src/libs/vtools/visualization/line/vistoolshoulderpoint.h b/src/libs/vtools/visualization/line/vistoolshoulderpoint.h index 56d582533..e8f711c15 100644 --- a/src/libs/vtools/visualization/line/vistoolshoulderpoint.h +++ b/src/libs/vtools/visualization/line/vistoolshoulderpoint.h @@ -41,7 +41,7 @@ class VisToolShoulderPoint : public VisLine { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit VisToolShoulderPoint(const VContainer *data, QGraphicsItem *parent = nullptr); virtual ~VisToolShoulderPoint() = default; @@ -53,7 +53,8 @@ public: virtual int type() const override {return Type;} enum { Type = UserType + static_cast(Vis::ToolShoulderPoint)}; private: - Q_DISABLE_COPY(VisToolShoulderPoint) + // cppcheck-suppress unknownMacro + Q_DISABLE_COPY_MOVE(VisToolShoulderPoint) // NOLINT quint32 lineP1Id; quint32 lineP2Id; VScaledEllipse *point; diff --git a/src/libs/vtools/visualization/line/vistoolspecialpoint.h b/src/libs/vtools/visualization/line/vistoolspecialpoint.h index 3b3b4ecd4..1df45a1a5 100644 --- a/src/libs/vtools/visualization/line/vistoolspecialpoint.h +++ b/src/libs/vtools/visualization/line/vistoolspecialpoint.h @@ -35,7 +35,7 @@ class VSimplePoint; class VisToolSpecialPoint : public VisLine { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit VisToolSpecialPoint(const VContainer *data, QGraphicsItem *parent = nullptr); virtual ~VisToolSpecialPoint(); @@ -44,7 +44,8 @@ public: virtual int type() const override {return Type;} enum { Type = UserType + static_cast(Vis::ToolSpecialPoint)}; private: - Q_DISABLE_COPY(VisToolSpecialPoint) + // cppcheck-suppress unknownMacro + Q_DISABLE_COPY_MOVE(VisToolSpecialPoint) // NOLINT QPointer m_point; }; diff --git a/src/libs/vtools/visualization/line/vistooltriangle.h b/src/libs/vtools/visualization/line/vistooltriangle.h index c4371bf68..5d890e45e 100644 --- a/src/libs/vtools/visualization/line/vistooltriangle.h +++ b/src/libs/vtools/visualization/line/vistooltriangle.h @@ -44,7 +44,7 @@ class VisToolTriangle : public VisLine { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit VisToolTriangle(const VContainer *data, QGraphicsItem *parent = nullptr); virtual ~VisToolTriangle() = default; @@ -58,7 +58,8 @@ public: virtual int type() const override {return Type;} enum { Type = UserType + static_cast(Vis::ToolTriangle)}; private: - Q_DISABLE_COPY(VisToolTriangle) + // cppcheck-suppress unknownMacro + Q_DISABLE_COPY_MOVE(VisToolTriangle) // NOLINT quint32 object2Id;//axis second point quint32 hypotenuseP1Id; quint32 hypotenuseP2Id; diff --git a/src/libs/vtools/visualization/line/vistooltruedarts.h b/src/libs/vtools/visualization/line/vistooltruedarts.h index 641b84b09..ffce3a1cd 100644 --- a/src/libs/vtools/visualization/line/vistooltruedarts.h +++ b/src/libs/vtools/visualization/line/vistooltruedarts.h @@ -41,7 +41,7 @@ class VisToolTrueDarts :public VisLine { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit VisToolTrueDarts(const VContainer *data, QGraphicsItem *parent = nullptr); virtual ~VisToolTrueDarts() = default; @@ -56,7 +56,8 @@ public: virtual int type() const override {return Type;} enum { Type = UserType + static_cast(Vis::ToolTrueDarts)}; private: - Q_DISABLE_COPY(VisToolTrueDarts) + // cppcheck-suppress unknownMacro + Q_DISABLE_COPY_MOVE(VisToolTrueDarts) // NOLINT quint32 baseLineP2Id; quint32 dartP1Id; quint32 dartP2Id; diff --git a/src/libs/vtools/visualization/path/vispath.h b/src/libs/vtools/visualization/path/vispath.h index 97a32c254..f4b93de66 100644 --- a/src/libs/vtools/visualization/path/vispath.h +++ b/src/libs/vtools/visualization/path/vispath.h @@ -44,7 +44,7 @@ class VSimplePoint; class VisPath : public Visualization, public VCurvePathItem { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit VisPath(const VContainer *data, QGraphicsItem *parent = nullptr); virtual ~VisPath() = default; @@ -61,7 +61,7 @@ protected: VSimplePoint *GetPoint(QVector &points, quint32 i, const QColor &color); private: - Q_DISABLE_COPY(VisPath) + Q_DISABLE_COPY_MOVE(VisPath) // NOLINT }; #endif // VISPATH_H diff --git a/src/libs/vtools/visualization/path/vispiecespecialpoints.h b/src/libs/vtools/visualization/path/vispiecespecialpoints.h index f3d4195a8..01ca3e082 100644 --- a/src/libs/vtools/visualization/path/vispiecespecialpoints.h +++ b/src/libs/vtools/visualization/path/vispiecespecialpoints.h @@ -35,7 +35,7 @@ class VSimplePoint; class VisPieceSpecialPoints : public VisPath { - Q_OBJECT + Q_OBJECT // NOLINT public: VisPieceSpecialPoints(const VContainer *data, QGraphicsItem *parent = nullptr); virtual ~VisPieceSpecialPoints() Q_DECL_EQ_DEFAULT; @@ -49,7 +49,7 @@ public: virtual int type() const override {return Type;} enum { Type = UserType + static_cast(Vis::PieceSpecialPoints)}; private: - Q_DISABLE_COPY(VisPieceSpecialPoints) + Q_DISABLE_COPY_MOVE(VisPieceSpecialPoints) // NOLINT QVector m_points; QVector m_spoints; bool m_showRect; diff --git a/src/libs/vtools/visualization/path/vistoolcubicbezier.h b/src/libs/vtools/visualization/path/vistoolcubicbezier.h index aaea5f3ab..d1c89ea07 100644 --- a/src/libs/vtools/visualization/path/vistoolcubicbezier.h +++ b/src/libs/vtools/visualization/path/vistoolcubicbezier.h @@ -41,7 +41,7 @@ class VisToolCubicBezier : public VisPath { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit VisToolCubicBezier(const VContainer *data, QGraphicsItem *parent = nullptr); virtual ~VisToolCubicBezier() Q_DECL_EQ_DEFAULT; @@ -55,7 +55,7 @@ public: virtual int type() const override {return Type;} enum { Type = UserType + static_cast(Vis::ToolCubicBezier)}; protected: - Q_DISABLE_COPY(VisToolCubicBezier) + Q_DISABLE_COPY_MOVE(VisToolCubicBezier) // NOLINT quint32 object2Id; quint32 object3Id; quint32 object4Id; diff --git a/src/libs/vtools/visualization/path/vistoolcubicbezierpath.h b/src/libs/vtools/visualization/path/vistoolcubicbezierpath.h index 7809e6484..8c93a281c 100644 --- a/src/libs/vtools/visualization/path/vistoolcubicbezierpath.h +++ b/src/libs/vtools/visualization/path/vistoolcubicbezierpath.h @@ -43,7 +43,7 @@ class VisToolCubicBezierPath : public VisPath { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit VisToolCubicBezierPath(const VContainer *data, QGraphicsItem *parent = nullptr); virtual ~VisToolCubicBezierPath(); @@ -56,7 +56,7 @@ public: virtual int type() const override {return Type;} enum { Type = UserType + static_cast(Vis::ToolCubicBezierPath)}; protected: - Q_DISABLE_COPY(VisToolCubicBezierPath) + Q_DISABLE_COPY_MOVE(VisToolCubicBezierPath) // NOLINT QVector mainPoints; QVector ctrlPoints; QVector lines; diff --git a/src/libs/vtools/visualization/path/vistoolcutarc.h b/src/libs/vtools/visualization/path/vistoolcutarc.h index c0b207b23..255d639ce 100644 --- a/src/libs/vtools/visualization/path/vistoolcutarc.h +++ b/src/libs/vtools/visualization/path/vistoolcutarc.h @@ -41,7 +41,7 @@ class VisToolCutArc final : public VisPath { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit VisToolCutArc(const VContainer *data, QGraphicsItem *parent = nullptr); virtual ~VisToolCutArc() Q_DECL_EQ_DEFAULT; @@ -51,7 +51,7 @@ public: virtual int type() const override {return Type;} enum { Type = UserType + static_cast(Vis::ToolCutArc)}; protected: - Q_DISABLE_COPY(VisToolCutArc) + Q_DISABLE_COPY_MOVE(VisToolCutArc) // NOLINT VScaledEllipse *point; VCurvePathItem *arc1; VCurvePathItem *arc2; diff --git a/src/libs/vtools/visualization/path/vistoolcutspline.h b/src/libs/vtools/visualization/path/vistoolcutspline.h index 1cb6574e2..6666c5aaf 100644 --- a/src/libs/vtools/visualization/path/vistoolcutspline.h +++ b/src/libs/vtools/visualization/path/vistoolcutspline.h @@ -41,7 +41,7 @@ class VisToolCutSpline final : public VisPath { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit VisToolCutSpline(const VContainer *data, QGraphicsItem *parent = nullptr); virtual ~VisToolCutSpline() Q_DECL_EQ_DEFAULT; @@ -51,7 +51,7 @@ public: virtual int type() const override {return Type;} enum { Type = UserType + static_cast(Vis::ToolCutSpline)}; protected: - Q_DISABLE_COPY(VisToolCutSpline) + Q_DISABLE_COPY_MOVE(VisToolCutSpline) // NOLINT VScaledEllipse *point; VCurvePathItem *spl1; VCurvePathItem *spl2; diff --git a/src/libs/vtools/visualization/path/vistoolcutsplinepath.h b/src/libs/vtools/visualization/path/vistoolcutsplinepath.h index e522c0e05..2a2f64545 100644 --- a/src/libs/vtools/visualization/path/vistoolcutsplinepath.h +++ b/src/libs/vtools/visualization/path/vistoolcutsplinepath.h @@ -41,7 +41,7 @@ class VisToolCutSplinePath final : public VisPath { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit VisToolCutSplinePath(const VContainer *data, QGraphicsItem *parent = nullptr); virtual ~VisToolCutSplinePath() Q_DECL_EQ_DEFAULT; @@ -51,7 +51,7 @@ public: virtual int type() const override {return Type;} enum { Type = UserType + static_cast(Vis::ToolCutSpline)}; protected: - Q_DISABLE_COPY(VisToolCutSplinePath) + Q_DISABLE_COPY_MOVE(VisToolCutSplinePath) // NOLINT VScaledEllipse *point; VCurvePathItem *splPath1; VCurvePathItem *splPath2; diff --git a/src/libs/vtools/visualization/path/vistoolduplicatedetail.h b/src/libs/vtools/visualization/path/vistoolduplicatedetail.h index 618a20f21..4080dc98f 100644 --- a/src/libs/vtools/visualization/path/vistoolduplicatedetail.h +++ b/src/libs/vtools/visualization/path/vistoolduplicatedetail.h @@ -33,7 +33,7 @@ class VisToolDuplicateDetail : public VisPath { - Q_OBJECT + Q_OBJECT // NOLINT public: VisToolDuplicateDetail(const VContainer *data, QGraphicsItem *parent = nullptr); virtual ~VisToolDuplicateDetail() = default; @@ -45,7 +45,7 @@ public: virtual int type() const override {return Type;} enum { Type = UserType + static_cast(Vis::ToolDuplicateDetail)}; private: - Q_DISABLE_COPY(VisToolDuplicateDetail) + Q_DISABLE_COPY_MOVE(VisToolDuplicateDetail) // NOLINT QPointF m_start; bool m_started; QPointF m_diff; diff --git a/src/libs/vtools/visualization/path/vistoolellipticalarc.h b/src/libs/vtools/visualization/path/vistoolellipticalarc.h index 5b200734e..4dafe3b9f 100644 --- a/src/libs/vtools/visualization/path/vistoolellipticalarc.h +++ b/src/libs/vtools/visualization/path/vistoolellipticalarc.h @@ -40,7 +40,7 @@ class VisToolEllipticalArc : public VisPath { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit VisToolEllipticalArc(const VContainer *data, QGraphicsItem *parent = nullptr); virtual ~VisToolEllipticalArc() Q_DECL_EQ_DEFAULT; @@ -55,7 +55,7 @@ public: virtual int type() const override {return Type;} enum { Type = UserType + static_cast(Vis::ToolEllipticalArc)}; private: - Q_DISABLE_COPY(VisToolEllipticalArc) + Q_DISABLE_COPY_MOVE(VisToolEllipticalArc) // NOLINT VScaledEllipse *arcCenter; qreal radius1; qreal radius2; diff --git a/src/libs/vtools/visualization/path/vistoolpiece.h b/src/libs/vtools/visualization/path/vistoolpiece.h index db5a65d01..d857aefe0 100644 --- a/src/libs/vtools/visualization/path/vistoolpiece.h +++ b/src/libs/vtools/visualization/path/vistoolpiece.h @@ -38,7 +38,7 @@ class VisToolPiece : public VisPath { - Q_OBJECT + Q_OBJECT // NOLINT public: VisToolPiece(const VContainer *data, QGraphicsItem *parent = nullptr); virtual ~VisToolPiece() Q_DECL_EQ_DEFAULT; @@ -48,7 +48,7 @@ public: virtual int type() const override {return Type;} enum { Type = UserType + static_cast(Vis::ToolPiece)}; private: - Q_DISABLE_COPY(VisToolPiece) + Q_DISABLE_COPY_MOVE(VisToolPiece) // NOLINT QVector m_points; QVector m_curves; diff --git a/src/libs/vtools/visualization/path/vistoolpiecepath.h b/src/libs/vtools/visualization/path/vistoolpiecepath.h index 444166acf..838a1a5b9 100644 --- a/src/libs/vtools/visualization/path/vistoolpiecepath.h +++ b/src/libs/vtools/visualization/path/vistoolpiecepath.h @@ -39,7 +39,7 @@ class VSimplePoint; class VisToolPiecePath : public VisPath { - Q_OBJECT + Q_OBJECT // NOLINT public: VisToolPiecePath(const VContainer *data, QGraphicsItem *parent = nullptr); virtual ~VisToolPiecePath() Q_DECL_EQ_DEFAULT; @@ -53,7 +53,7 @@ protected: virtual void mousePressEvent( QGraphicsSceneMouseEvent * event ) override; private: - Q_DISABLE_COPY(VisToolPiecePath) + Q_DISABLE_COPY_MOVE(VisToolPiecePath) // NOLINT QVector m_points; VScaledLine *m_line; diff --git a/src/libs/vtools/visualization/path/vistoolpointofintersectioncurves.h b/src/libs/vtools/visualization/path/vistoolpointofintersectioncurves.h index e1b5aacef..86a1d8ec7 100644 --- a/src/libs/vtools/visualization/path/vistoolpointofintersectioncurves.h +++ b/src/libs/vtools/visualization/path/vistoolpointofintersectioncurves.h @@ -42,7 +42,7 @@ class VisToolPointOfIntersectionCurves : public VisPath { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit VisToolPointOfIntersectionCurves(const VContainer *data, QGraphicsItem *parent = nullptr); virtual ~VisToolPointOfIntersectionCurves() Q_DECL_EQ_DEFAULT; @@ -57,7 +57,7 @@ public: virtual int type() const override {return Type;} enum { Type = UserType + static_cast(Vis::ToolPointOfIntersectionCurves)}; private: - Q_DISABLE_COPY(VisToolPointOfIntersectionCurves) + Q_DISABLE_COPY_MOVE(VisToolPointOfIntersectionCurves) // NOLINT quint32 object2Id; VCrossCurvesPoint vCrossPoint; HCrossCurvesPoint hCrossPoint; diff --git a/src/libs/vtools/visualization/visualization.cpp b/src/libs/vtools/visualization/visualization.cpp index a0826104d..23e94d978 100644 --- a/src/libs/vtools/visualization/visualization.cpp +++ b/src/libs/vtools/visualization/visualization.cpp @@ -47,8 +47,6 @@ #include "../vpatterndb/calculator.h" #include "../vpatterndb/vtranslatevars.h" #include "../qmuparser/qmuparsererror.h" -#include "../tools/drawTools/vdrawtool.h" -#include "../ifc/ifcdef.h" #include "../vmisc/vcommonsettings.h" #include "../vpatterndb/vcontainer.h" #include "../vwidgets/vmaingraphicsscene.h" @@ -57,7 +55,13 @@ template class QHash; -Q_LOGGING_CATEGORY(vVis, "v.visualization") +QT_WARNING_PUSH +QT_WARNING_DISABLE_CLANG("-Wmissing-prototypes") +QT_WARNING_DISABLE_INTEL(1418) + +Q_LOGGING_CATEGORY(vVis, "v.visualization") // NOLINT + +QT_WARNING_POP namespace { diff --git a/src/libs/vtools/visualization/visualization.h b/src/libs/vtools/visualization/visualization.h index 263825e35..5fa5d8f9c 100644 --- a/src/libs/vtools/visualization/visualization.h +++ b/src/libs/vtools/visualization/visualization.h @@ -57,7 +57,7 @@ QT_WARNING_DISABLE_GCC("-Wsuggest-final-methods") class Visualization : public QObject { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit Visualization(const VContainer *data); virtual ~Visualization() Q_DECL_EQ_DEFAULT; @@ -123,7 +123,7 @@ protected: static VCurvePathItem *GetCurveItem(QVector &curves, quint32 i, const QColor &color, QGraphicsItem *parent); private: - Q_DISABLE_COPY(Visualization) + Q_DISABLE_COPY_MOVE(Visualization) // NOLINT }; // cppcheck-suppress unknownMacro diff --git a/src/libs/vwidgets/fancytabbar/fancytab.h b/src/libs/vwidgets/fancytabbar/fancytab.h index 7baba42ff..59d853209 100644 --- a/src/libs/vwidgets/fancytabbar/fancytab.h +++ b/src/libs/vwidgets/fancytabbar/fancytab.h @@ -33,10 +33,12 @@ #include #include +#include "../vmisc/defglobal.h" + class FancyTab final : public QObject { friend class FancyTabBar; - Q_OBJECT + Q_OBJECT // NOLINT Q_PROPERTY(double fader READ fader WRITE setFader) public: @@ -49,7 +51,8 @@ public: void fadeOut(); private: - Q_DISABLE_COPY(FancyTab) + // cppcheck-suppress unknownMacro + Q_DISABLE_COPY_MOVE(FancyTab) // NOLINT QIcon m_icon; QString m_text; QString m_toolTip; diff --git a/src/libs/vwidgets/fancytabbar/fancytabbar.h b/src/libs/vwidgets/fancytabbar/fancytabbar.h index 8b3c4c81c..a7759a288 100644 --- a/src/libs/vwidgets/fancytabbar/fancytabbar.h +++ b/src/libs/vwidgets/fancytabbar/fancytabbar.h @@ -41,7 +41,7 @@ class QPainter; class FancyTabBar : public QWidget { - Q_OBJECT + Q_OBJECT // NOLINT public: enum TabBarPosition @@ -95,7 +95,7 @@ private slots: void EmitCurrentIndex(); private: - Q_DISABLE_COPY(FancyTabBar) + Q_DISABLE_COPY_MOVE(FancyTabBar) // NOLINT enum Corner { OutsideBeginning, OutsideEnd, InsideBeginning, InsideEnd }; diff --git a/src/libs/vwidgets/qtcolorpicker.cpp b/src/libs/vwidgets/qtcolorpicker.cpp index 8988219e6..c4d143ae0 100644 --- a/src/libs/vwidgets/qtcolorpicker.cpp +++ b/src/libs/vwidgets/qtcolorpicker.cpp @@ -140,7 +140,7 @@ */ class ColorPickerButton : public QFrame { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit ColorPickerButton(QWidget *parent); @@ -164,7 +164,7 @@ protected: */ class ColorPickerItem : public QFrame { - Q_OBJECT + Q_OBJECT // NOLINT public: ColorPickerItem(const QColor &color = Qt::white, const QString &text = QString(), @@ -200,7 +200,7 @@ private: */ class ColorPickerPopup : public QFrame { - Q_OBJECT + Q_OBJECT // NOLINT public: ColorPickerPopup(int width, bool withColorDialog, @@ -238,7 +238,7 @@ protected: void regenerateGrid(); private: - Q_DISABLE_COPY(ColorPickerPopup) + Q_DISABLE_COPY_MOVE(ColorPickerPopup) // NOLINT QMap > widgetAt{}; QList items{}; QGridLayout *grid{nullptr}; diff --git a/src/libs/vwidgets/qtcolorpicker.h b/src/libs/vwidgets/qtcolorpicker.h index 8782567a5..47fc2ac3f 100644 --- a/src/libs/vwidgets/qtcolorpicker.h +++ b/src/libs/vwidgets/qtcolorpicker.h @@ -54,13 +54,14 @@ #include #include +#include "../vmisc/defglobal.h" class ColorPickerPopup; class ColorPickerItem; class QtColorPicker : public QPushButton { - Q_OBJECT + Q_OBJECT // NOLINT Q_PROPERTY(bool colorDialog READ colorDialogEnabled WRITE setColorDialogEnabled) @@ -99,7 +100,8 @@ private Q_SLOTS: void popupClosed(); private: - Q_DISABLE_COPY(QtColorPicker) + // cppcheck-suppress unknownMacro + Q_DISABLE_COPY_MOVE(QtColorPicker) // NOLINT ColorPickerPopup *popup{nullptr}; QColor col{}; bool withColorDialog{false}; diff --git a/src/libs/vwidgets/scalesceneitems.h b/src/libs/vwidgets/scalesceneitems.h index 283ff4d3a..e2798a0b4 100644 --- a/src/libs/vwidgets/scalesceneitems.h +++ b/src/libs/vwidgets/scalesceneitems.h @@ -53,7 +53,7 @@ protected: bool m_isBoldLine; private: - Q_DISABLE_COPY(VScaledLine) + Q_DISABLE_COPY_MOVE(VScaledLine) // NOLINT }; class VScaledEllipse : public QGraphicsEllipseItem @@ -68,7 +68,7 @@ public: virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = nullptr) override; private: - Q_DISABLE_COPY(VScaledEllipse) + Q_DISABLE_COPY_MOVE(VScaledEllipse) // NOLINT }; #endif // SCALESCENEITEMS_H diff --git a/src/libs/vwidgets/vabstractmainwindow.cpp b/src/libs/vwidgets/vabstractmainwindow.cpp index 39bf2ed4d..99bd8292d 100644 --- a/src/libs/vwidgets/vabstractmainwindow.cpp +++ b/src/libs/vwidgets/vabstractmainwindow.cpp @@ -33,7 +33,6 @@ #include "../vmisc/def.h" #include "../vmisc/vsysexits.h" #include "dialogs/dialogexporttocsv.h" -#include "../vwidgets/vmaingraphicsview.h" #include #include @@ -56,7 +55,7 @@ QT_WARNING_PUSH QT_WARNING_DISABLE_CLANG("-Wmissing-prototypes") QT_WARNING_DISABLE_INTEL(1418) -Q_LOGGING_CATEGORY(abstactMainWindow, "abs.MainWindow") +Q_LOGGING_CATEGORY(abstactMainWindow, "abs.MainWindow") // NOLINT QT_WARNING_POP @@ -371,7 +370,7 @@ bool VAbstractMainWindow::IgnoreLocking(int error, const QString &path, bool gui break; } - qApp->exit(V_EX_NOINPUT); + QCoreApplication::exit(V_EX_NOINPUT); } return false; } diff --git a/src/libs/vwidgets/vabstractmainwindow.h b/src/libs/vwidgets/vabstractmainwindow.h index 25c650d23..3ca3254a9 100644 --- a/src/libs/vwidgets/vabstractmainwindow.h +++ b/src/libs/vwidgets/vabstractmainwindow.h @@ -35,6 +35,8 @@ #include #include +#include "../vmisc/defglobal.h" + struct VFinalMeasurement; QT_WARNING_PUSH @@ -43,7 +45,7 @@ QT_WARNING_DISABLE_GCC("-Wsuggest-final-methods") class VAbstractMainWindow : public QMainWindow { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit VAbstractMainWindow(QWidget *parent = nullptr); virtual ~VAbstractMainWindow() Q_DECL_EQ_DEFAULT; @@ -80,7 +82,7 @@ protected: bool IgnoreLocking(int error, const QString &path, bool guiMode); private: - Q_DISABLE_COPY(VAbstractMainWindow) + Q_DISABLE_COPY_MOVE(VAbstractMainWindow) // NOLINT }; QT_WARNING_POP diff --git a/src/libs/vwidgets/vabstractsimple.h b/src/libs/vwidgets/vabstractsimple.h index 7515b7041..5caa7602e 100644 --- a/src/libs/vwidgets/vabstractsimple.h +++ b/src/libs/vwidgets/vabstractsimple.h @@ -45,7 +45,7 @@ class QGraphicsSceneContextMenuEvent; class VAbstractSimple : public QObject { - Q_OBJECT + Q_OBJECT // NOLINT public: VAbstractSimple(quint32 id, QObject *parent = nullptr); virtual ~VAbstractSimple() = default; @@ -68,7 +68,7 @@ protected: GOType type; private: - Q_DISABLE_COPY(VAbstractSimple) + Q_DISABLE_COPY_MOVE(VAbstractSimple) // NOLINT }; #endif // VABSTRACTSIMPLE_H diff --git a/src/libs/vwidgets/vcomboboxdelegate.h b/src/libs/vwidgets/vcomboboxdelegate.h index 301a39918..611f52b45 100644 --- a/src/libs/vwidgets/vcomboboxdelegate.h +++ b/src/libs/vwidgets/vcomboboxdelegate.h @@ -30,9 +30,11 @@ #include +#include "../vmisc/defglobal.h" + class VComboBoxDelegate : public QItemDelegate { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit VComboBoxDelegate(const QStringList &items, QObject *parent = nullptr); @@ -45,7 +47,8 @@ public: virtual void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const override; private: - Q_DISABLE_COPY(VComboBoxDelegate) + // cppcheck-suppress unknownMacro + Q_DISABLE_COPY_MOVE(VComboBoxDelegate) // NOLINT QStringList m_items; }; diff --git a/src/libs/vwidgets/vcontrolpointspline.h b/src/libs/vwidgets/vcontrolpointspline.h index 5135c24eb..a8b669f0d 100644 --- a/src/libs/vwidgets/vcontrolpointspline.h +++ b/src/libs/vwidgets/vcontrolpointspline.h @@ -48,7 +48,7 @@ */ class VControlPointSpline : public QObject, public VScenePoint { - Q_OBJECT + Q_OBJECT // NOLINT public: VControlPointSpline(const qint32 &indexSpline, SplinePointPosition position, QGraphicsItem * parent = nullptr); VControlPointSpline(const qint32 &indexSpline, SplinePointPosition position, const QPointF &controlPoint, @@ -90,7 +90,7 @@ protected: virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event ) override; virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent *event ) override; private: - Q_DISABLE_COPY(VControlPointSpline) + Q_DISABLE_COPY_MOVE(VControlPointSpline) // NOLINT /** @brief indexSpline index spline in list.. */ qint32 indexSpline; diff --git a/src/libs/vwidgets/vcurvepathitem.h b/src/libs/vwidgets/vcurvepathitem.h index e9f9ff22a..cd82ae3f3 100644 --- a/src/libs/vwidgets/vcurvepathitem.h +++ b/src/libs/vwidgets/vcurvepathitem.h @@ -58,7 +58,7 @@ public: protected: virtual void ScalePenWidth(); private: - Q_DISABLE_COPY(VCurvePathItem) + Q_DISABLE_COPY_MOVE(VCurvePathItem) // NOLINT QVector> m_directionArrows; QVector m_points; diff --git a/src/libs/vwidgets/vdecorationaligningdelegate.h b/src/libs/vwidgets/vdecorationaligningdelegate.h index 2bfb424ac..ab8e78ea6 100644 --- a/src/libs/vwidgets/vdecorationaligningdelegate.h +++ b/src/libs/vwidgets/vdecorationaligningdelegate.h @@ -30,11 +30,11 @@ #include - +#include "../vmisc/defglobal.h" class VDecorationAligningDelegate : public QStyledItemDelegate { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit VDecorationAligningDelegate(Qt::Alignment alignment, QObject *parent = nullptr); @@ -44,7 +44,8 @@ public: void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const; private: - Q_DISABLE_COPY(VDecorationAligningDelegate) + // cppcheck-suppress unknownMacro + Q_DISABLE_COPY_MOVE(VDecorationAligningDelegate) // NOLINT Qt::Alignment const m_alignment; }; diff --git a/src/libs/vwidgets/velidedlabel.h b/src/libs/vwidgets/velidedlabel.h index 6a1906cc1..5c217b370 100644 --- a/src/libs/vwidgets/velidedlabel.h +++ b/src/libs/vwidgets/velidedlabel.h @@ -30,9 +30,11 @@ #include +#include "../vmisc/defglobal.h" + class VElidedLabel : public QFrame { - Q_OBJECT + Q_OBJECT // NOLINT Q_PROPERTY(QString text READ text WRITE setText) Q_PROPERTY(bool IsElided READ IsElided) Q_PROPERTY(bool showElided READ ShowElided WRITE SetShowElided) @@ -55,7 +57,8 @@ signals: void ElisionChanged(bool m_elided); private: - Q_DISABLE_COPY(VElidedLabel) + // cppcheck-suppress unknownMacro + Q_DISABLE_COPY_MOVE(VElidedLabel) // NOLINT bool m_elided{false}; bool m_showElided{true}; QString m_content{}; diff --git a/src/libs/vwidgets/vgrainlineitem.h b/src/libs/vwidgets/vgrainlineitem.h index d252fcbc7..cab63a255 100644 --- a/src/libs/vwidgets/vgrainlineitem.h +++ b/src/libs/vwidgets/vgrainlineitem.h @@ -35,7 +35,7 @@ class VGrainlineItem final : public VPieceItem { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit VGrainlineItem(QGraphicsItem* pParent = nullptr); virtual ~VGrainlineItem() Q_DECL_EQ_DEFAULT; @@ -71,7 +71,7 @@ protected: QPointF GetInsideCorner(int i, qreal dDist) const; private: - Q_DISABLE_COPY(VGrainlineItem) + Q_DISABLE_COPY_MOVE(VGrainlineItem) // NOLINT qreal m_dRotation; qreal m_dStartRotation; qreal m_dLength; diff --git a/src/libs/vwidgets/vgraphicssimpletextitem.h b/src/libs/vwidgets/vgraphicssimpletextitem.h index b38a1018d..1dc22fefb 100644 --- a/src/libs/vwidgets/vgraphicssimpletextitem.h +++ b/src/libs/vwidgets/vgraphicssimpletextitem.h @@ -46,7 +46,7 @@ */ class VGraphicsSimpleTextItem : public QObject, public QGraphicsSimpleTextItem { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit VGraphicsSimpleTextItem(QGraphicsItem *parent = nullptr); explicit VGraphicsSimpleTextItem( const QString & text, QGraphicsItem *parent = nullptr ); diff --git a/src/libs/vwidgets/vlineedit.cpp b/src/libs/vwidgets/vlineedit.cpp index e919a5456..9a85da69d 100644 --- a/src/libs/vwidgets/vlineedit.cpp +++ b/src/libs/vwidgets/vlineedit.cpp @@ -48,7 +48,7 @@ public: virtual QStringList splitPath(const QString& path) const override; private: - Q_DISABLE_COPY(MultiSelectCompleter) + Q_DISABLE_COPY_MOVE(MultiSelectCompleter) // NOLINT }; } diff --git a/src/libs/vwidgets/vlineedit.h b/src/libs/vwidgets/vlineedit.h index 939ee8815..ff9211eb9 100644 --- a/src/libs/vwidgets/vlineedit.h +++ b/src/libs/vwidgets/vlineedit.h @@ -31,11 +31,13 @@ #include +#include "../vmisc/defglobal.h" + class QStringListModel; class VLineEdit : public QLineEdit { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit VLineEdit(QWidget * parent = nullptr); explicit VLineEdit(const QString &contents, QWidget *parent = nullptr); @@ -45,7 +47,8 @@ protected: virtual void focusOutEvent(QFocusEvent *e) override; virtual void mousePressEvent(QMouseEvent *e) override; private: - Q_DISABLE_COPY(VLineEdit) + // cppcheck-suppress unknownMacro + Q_DISABLE_COPY_MOVE(VLineEdit) // NOLINT bool m_selectOnMousePress; }; @@ -56,7 +59,7 @@ private: */ class VCompleterLineEdit : public VLineEdit { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit VCompleterLineEdit(QWidget *parent = nullptr); @@ -72,7 +75,7 @@ private slots: void CompletionPopup(); private: - Q_DISABLE_COPY(VCompleterLineEdit) + Q_DISABLE_COPY_MOVE(VCompleterLineEdit) // NOLINT QStringListModel *m_model; }; diff --git a/src/libs/vwidgets/vmaingraphicsscene.h b/src/libs/vwidgets/vmaingraphicsscene.h index ede6ec022..ab9f94f4a 100644 --- a/src/libs/vwidgets/vmaingraphicsscene.h +++ b/src/libs/vwidgets/vmaingraphicsscene.h @@ -47,7 +47,7 @@ */ class VMainGraphicsScene : public QGraphicsScene { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit VMainGraphicsScene(QObject *parent = nullptr); explicit VMainGraphicsScene(const QRectF & sceneRect, QObject * parent = nullptr); @@ -156,7 +156,7 @@ signals: void LanguageChanged(); private: - Q_DISABLE_COPY(VMainGraphicsScene) + Q_DISABLE_COPY_MOVE(VMainGraphicsScene) // NOLINT /** @brief horScrollBar value horizontal scroll bar. */ qint32 horScrollBar; diff --git a/src/libs/vwidgets/vmaingraphicsview.h b/src/libs/vwidgets/vmaingraphicsview.h index d5155e2a2..9cbdbb698 100644 --- a/src/libs/vwidgets/vmaingraphicsview.h +++ b/src/libs/vwidgets/vmaingraphicsview.h @@ -40,6 +40,8 @@ #include #include +#include "../vmisc/defglobal.h" + /*! * This class adds ability to zoom QGraphicsView using mouse wheel. The point under cursor * remains motionless while it's possible. @@ -72,7 +74,7 @@ class QPinchGesture; class GraphicsViewZoom : public QObject { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit GraphicsViewZoom(QGraphicsView* view); void gentle_zoom(double factor); @@ -88,7 +90,8 @@ public slots: protected: virtual bool eventFilter(QObject* object, QEvent* event) override; private: - Q_DISABLE_COPY(GraphicsViewZoom) + // cppcheck-suppress unknownMacro + Q_DISABLE_COPY_MOVE(GraphicsViewZoom) // NOLINT QGraphicsView *_view; Qt::KeyboardModifiers _modifiers; double _zoom_factor_base; @@ -115,7 +118,7 @@ private: */ class VMainGraphicsView : public QGraphicsView { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit VMainGraphicsView(QWidget *parent = nullptr); void setShowToolOptions(bool value); @@ -166,7 +169,7 @@ protected: void dragMoveEvent(QDragMoveEvent *event) override; void dropEvent(QDropEvent *event) override; private: - Q_DISABLE_COPY(VMainGraphicsView) + Q_DISABLE_COPY_MOVE(VMainGraphicsView) // NOLINT GraphicsViewZoom* zoom; bool showToolOptions; bool isAllowRubberBand; diff --git a/src/libs/vwidgets/vnobrushscalepathitem.h b/src/libs/vwidgets/vnobrushscalepathitem.h index fb7620850..514916ec3 100644 --- a/src/libs/vwidgets/vnobrushscalepathitem.h +++ b/src/libs/vwidgets/vnobrushscalepathitem.h @@ -50,7 +50,7 @@ protected: enum { Type = UserType + static_cast(Vis::NoBrush)}; private: - Q_DISABLE_COPY(VNoBrushScalePathItem) + Q_DISABLE_COPY_MOVE(VNoBrushScalePathItem) // NOLINT qreal m_defaultWidth; }; diff --git a/src/libs/vwidgets/vpieceitem.h b/src/libs/vwidgets/vpieceitem.h index 93ca18d35..4d0bb30c1 100644 --- a/src/libs/vwidgets/vpieceitem.h +++ b/src/libs/vwidgets/vpieceitem.h @@ -36,7 +36,7 @@ class VPieceItem : public QGraphicsObject { - Q_OBJECT + Q_OBJECT // NOLINT public: enum MoveType { @@ -87,7 +87,7 @@ protected: virtual double GetAngle(const QPointF &pt) const; private: - Q_DISABLE_COPY(VPieceItem) + Q_DISABLE_COPY_MOVE(VPieceItem) // NOLINT }; Q_DECLARE_OPERATORS_FOR_FLAGS(VPieceItem::MoveTypes) diff --git a/src/libs/vwidgets/vplaintextedit.h b/src/libs/vwidgets/vplaintextedit.h index 41adc194c..428630faa 100644 --- a/src/libs/vwidgets/vplaintextedit.h +++ b/src/libs/vwidgets/vplaintextedit.h @@ -33,7 +33,7 @@ class VPlainTextEdit : public QPlainTextEdit { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit VPlainTextEdit(QWidget * parent = nullptr); explicit VPlainTextEdit(const QString & text, QWidget * parent = nullptr); diff --git a/src/libs/vwidgets/vscenepoint.h b/src/libs/vwidgets/vscenepoint.h index 21c672ac2..3142cf322 100644 --- a/src/libs/vwidgets/vscenepoint.h +++ b/src/libs/vwidgets/vscenepoint.h @@ -75,7 +75,7 @@ protected: void SetOnlyPoint(bool value); bool IsOnlyPoint() const; private: - Q_DISABLE_COPY(VScenePoint) + Q_DISABLE_COPY_MOVE(VScenePoint) // NOLINT void ScaleMainPenWidth(qreal scale); }; diff --git a/src/libs/vwidgets/vsimplecurve.h b/src/libs/vwidgets/vsimplecurve.h index db55ff8bc..e5dee6779 100644 --- a/src/libs/vwidgets/vsimplecurve.h +++ b/src/libs/vwidgets/vsimplecurve.h @@ -48,7 +48,7 @@ template class QSharedPointer; class VSimpleCurve : public VAbstractSimple, public VCurvePathItem { - Q_OBJECT + Q_OBJECT // NOLINT public: VSimpleCurve(quint32 id, const QSharedPointer &curve, QObject *parent = nullptr); virtual ~VSimpleCurve() Q_DECL_EQ_DEFAULT; @@ -80,7 +80,7 @@ protected: virtual void ScalePenWidth() override; private: - Q_DISABLE_COPY(VSimpleCurve) + Q_DISABLE_COPY_MOVE(VSimpleCurve) // NOLINT QSharedPointer m_curve; bool m_isHovered; diff --git a/src/libs/vwidgets/vsimplepoint.h b/src/libs/vwidgets/vsimplepoint.h index d9f5f99ba..7a02c5edb 100644 --- a/src/libs/vwidgets/vsimplepoint.h +++ b/src/libs/vwidgets/vsimplepoint.h @@ -48,7 +48,7 @@ class VPointF; class VSimplePoint : public VAbstractSimple, public VScenePoint { - Q_OBJECT + Q_OBJECT // NOLINT public: VSimplePoint(quint32 id, const QColor ¤tColor, QObject *parent = nullptr); virtual ~VSimplePoint() = default; @@ -94,7 +94,7 @@ protected: virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ) override; private: - Q_DISABLE_COPY(VSimplePoint) + Q_DISABLE_COPY_MOVE(VSimplePoint) // NOLINT bool m_visualizationMode; bool m_alwaysHovered; diff --git a/src/libs/vwidgets/vtextgraphicsitem.h b/src/libs/vwidgets/vtextgraphicsitem.h index 780ef3bf6..1bf5b8e7e 100644 --- a/src/libs/vwidgets/vtextgraphicsitem.h +++ b/src/libs/vwidgets/vtextgraphicsitem.h @@ -50,7 +50,7 @@ */ class VTextGraphicsItem final : public VPieceItem { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit VTextGraphicsItem(QGraphicsItem* pParent = nullptr); virtual ~VTextGraphicsItem() Q_DECL_EQ_DEFAULT; @@ -85,7 +85,7 @@ signals: void SignalShrink(); private: - Q_DISABLE_COPY(VTextGraphicsItem) + Q_DISABLE_COPY_MOVE(VTextGraphicsItem) // NOLINT QPointF m_ptStartPos; QPointF m_ptStart; QSizeF m_szStart; diff --git a/src/libs/vwidgets/vwidgetpopup.h b/src/libs/vwidgets/vwidgetpopup.h index 6d5a83034..34fbdfaef 100644 --- a/src/libs/vwidgets/vwidgetpopup.h +++ b/src/libs/vwidgets/vwidgetpopup.h @@ -35,6 +35,8 @@ #include #include +#include "../vmisc/defglobal.h" + /** \brief Class showing a widget as popup window. @@ -47,7 +49,7 @@ */ class VWidgetPopup : public QFrame { - Q_OBJECT + Q_OBJECT // NOLINT public: /** Constructor. @@ -78,7 +80,8 @@ public slots: void Show(QPoint coord); protected: - Q_DISABLE_COPY(VWidgetPopup) + // cppcheck-suppress unknownMacro + Q_DISABLE_COPY_MOVE(VWidgetPopup) // NOLINT QWidget *mWidget; bool mOwn; QWidget *mOldParent; diff --git a/src/test/CollectionTest/tst_tapecommandline.cpp b/src/test/CollectionTest/tst_tapecommandline.cpp index c53b93a32..88cd31048 100644 --- a/src/test/CollectionTest/tst_tapecommandline.cpp +++ b/src/test/CollectionTest/tst_tapecommandline.cpp @@ -34,7 +34,7 @@ namespace { -Q_GLOBAL_STATIC_WITH_ARGS(const QString, tmpTestFolder, (QLatin1String("tst_tape_tmp"))) +Q_GLOBAL_STATIC_WITH_ARGS(const QString, tmpTestFolder, (QLatin1String("tst_tape_tmp"))) // NOLINT } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/test/CollectionTest/tst_tapecommandline.h b/src/test/CollectionTest/tst_tapecommandline.h index 1ca600808..d0c8e387d 100644 --- a/src/test/CollectionTest/tst_tapecommandline.h +++ b/src/test/CollectionTest/tst_tapecommandline.h @@ -30,10 +30,11 @@ #define TST_TAPECOMMANDLINE_H #include "../vtest/abstracttest.h" +#include "../vmisc/defglobal.h" class TST_TapeCommandLine : public AbstractTest { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit TST_TapeCommandLine(QObject *parent = nullptr); @@ -44,7 +45,7 @@ private slots: void cleanupTestCase(); private: - Q_DISABLE_COPY(TST_TapeCommandLine) + Q_DISABLE_COPY_MOVE(TST_TapeCommandLine) // NOLINT }; diff --git a/src/test/CollectionTest/tst_valentinacommandline.cpp b/src/test/CollectionTest/tst_valentinacommandline.cpp index 7656149ee..96344fe7e 100644 --- a/src/test/CollectionTest/tst_valentinacommandline.cpp +++ b/src/test/CollectionTest/tst_valentinacommandline.cpp @@ -34,8 +34,8 @@ namespace { -Q_GLOBAL_STATIC_WITH_ARGS(const QString, tmpTestFolder, (QLatin1String("tst_valentina_tmp"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, tmpTestCollectionFolder, (QLatin1String("tst_valentina_collection_tmp"))) +Q_GLOBAL_STATIC_WITH_ARGS(const QString, tmpTestFolder, (QLatin1String("tst_valentina_tmp"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, tmpTestCollectionFolder, (QLatin1String("tst_valentina_collection_tmp"))) // NOLINT } TST_ValentinaCommandLine::TST_ValentinaCommandLine(QObject *parent) diff --git a/src/test/CollectionTest/tst_valentinacommandline.h b/src/test/CollectionTest/tst_valentinacommandline.h index 8ab3c4610..e2bdbe3cc 100644 --- a/src/test/CollectionTest/tst_valentinacommandline.h +++ b/src/test/CollectionTest/tst_valentinacommandline.h @@ -30,10 +30,11 @@ #define TST_VALENTINACOMMANDLINE_H #include "../vtest/abstracttest.h" +#include "../vmisc/defglobal.h" class TST_ValentinaCommandLine : public AbstractTest { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit TST_ValentinaCommandLine(QObject *parent = nullptr); @@ -50,7 +51,7 @@ private slots: void cleanupTestCase(); private: - Q_DISABLE_COPY(TST_ValentinaCommandLine) + Q_DISABLE_COPY_MOVE(TST_ValentinaCommandLine) // NOLINT }; #endif // TST_VALENTINACOMMANDLINE_H diff --git a/src/test/TranslationsTest/tst_abstractregexp.h b/src/test/TranslationsTest/tst_abstractregexp.h index 65542020f..9331f464e 100644 --- a/src/test/TranslationsTest/tst_abstractregexp.h +++ b/src/test/TranslationsTest/tst_abstractregexp.h @@ -30,6 +30,7 @@ #define TST_ABSTRACTREGEXP_H #include "../vtest/abstracttest.h" +#include "../vmisc/defglobal.h" #include @@ -38,7 +39,7 @@ class VTranslateVars; class TST_AbstractRegExp : public AbstractTest { - Q_OBJECT + Q_OBJECT // NOLINT public: TST_AbstractRegExp(const QString &locale, QObject *parent = nullptr); virtual ~TST_AbstractRegExp(); @@ -61,7 +62,7 @@ protected: void CallTestForValidCharacters(); private: - Q_DISABLE_COPY(TST_AbstractRegExp) + Q_DISABLE_COPY_MOVE(TST_AbstractRegExp) // NOLINT }; #endif // TST_ABSTRACTREGEXP_H diff --git a/src/test/TranslationsTest/tst_abstracttranslation.h b/src/test/TranslationsTest/tst_abstracttranslation.h index 4211bf0c7..f14fb03a1 100644 --- a/src/test/TranslationsTest/tst_abstracttranslation.h +++ b/src/test/TranslationsTest/tst_abstracttranslation.h @@ -34,9 +34,11 @@ #include #include +#include "../vmisc/defglobal.h" + class TST_AbstractTranslation : public QObject { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit TST_AbstractTranslation(QObject *parent = nullptr); @@ -54,7 +56,8 @@ protected: static const QString AttrValObsolete; private: - Q_DISABLE_COPY(TST_AbstractTranslation) + // cppcheck-suppress unknownMacro + Q_DISABLE_COPY_MOVE(TST_AbstractTranslation) // NOLINT QSharedPointer tsFile; QSharedPointer tsXML; diff --git a/src/test/TranslationsTest/tst_buitinregexp.h b/src/test/TranslationsTest/tst_buitinregexp.h index 8cef450ff..450596060 100644 --- a/src/test/TranslationsTest/tst_buitinregexp.h +++ b/src/test/TranslationsTest/tst_buitinregexp.h @@ -38,7 +38,7 @@ class VTranslateVars; class TST_BuitInRegExp : public TST_AbstractRegExp { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit TST_BuitInRegExp(const QString &locale, QObject *parent = nullptr); virtual ~TST_BuitInRegExp() Q_DECL_EQ_DEFAULT; @@ -66,7 +66,7 @@ private slots: void cleanupTestCase(); private: - Q_DISABLE_COPY(TST_BuitInRegExp) + Q_DISABLE_COPY_MOVE(TST_BuitInRegExp) // NOLINT }; #endif // TST_BUITINREGEXP_H diff --git a/src/test/TranslationsTest/tst_measurementregexp.h b/src/test/TranslationsTest/tst_measurementregexp.h index 1d4678e4b..0ed5c378c 100644 --- a/src/test/TranslationsTest/tst_measurementregexp.h +++ b/src/test/TranslationsTest/tst_measurementregexp.h @@ -30,6 +30,7 @@ #define TST_MEASUREMENTREGEXP_H #include "tst_abstractregexp.h" +#include "../vmisc/defglobal.h" #include @@ -38,7 +39,7 @@ class VTranslateVars; class TST_MeasurementRegExp : public TST_AbstractRegExp { - Q_OBJECT + Q_OBJECT // NOLINT public: TST_MeasurementRegExp(quint32 systemCode, const QString &locale, QObject *parent = nullptr); virtual ~TST_MeasurementRegExp(); @@ -64,7 +65,8 @@ private slots: void cleanupTestCase(); private: - Q_DISABLE_COPY(TST_MeasurementRegExp) + // cppcheck-suppress unknownMacro + Q_DISABLE_COPY_MOVE(TST_MeasurementRegExp) // NOLINT quint32 m_systemCode; QString m_system; diff --git a/src/test/TranslationsTest/tst_qmuparsererrormsg.h b/src/test/TranslationsTest/tst_qmuparsererrormsg.h index a99f29577..13426b2cc 100644 --- a/src/test/TranslationsTest/tst_qmuparsererrormsg.h +++ b/src/test/TranslationsTest/tst_qmuparsererrormsg.h @@ -37,7 +37,7 @@ class TST_QmuParserErrorMsg : public AbstractTest { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit TST_QmuParserErrorMsg(const QString &locale, QObject *parent = nullptr); virtual ~TST_QmuParserErrorMsg() override; @@ -49,7 +49,8 @@ private slots: void cleanupTestCase(); private: - Q_DISABLE_COPY(TST_QmuParserErrorMsg) + // cppcheck-suppress unknownMacro + Q_DISABLE_COPY_MOVE(TST_QmuParserErrorMsg) // NOLINT QString m_locale; QPointer appTranslator; diff --git a/src/test/TranslationsTest/tst_tslocaletranslation.h b/src/test/TranslationsTest/tst_tslocaletranslation.h index 58747f059..8534898dc 100644 --- a/src/test/TranslationsTest/tst_tslocaletranslation.h +++ b/src/test/TranslationsTest/tst_tslocaletranslation.h @@ -32,7 +32,7 @@ class TST_TSLocaleTranslation : public TST_AbstractTranslation { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit TST_TSLocaleTranslation(const QString &locale, QObject *parent = nullptr); @@ -45,7 +45,7 @@ private slots: void TestHTMLTags(); private: - Q_DISABLE_COPY(TST_TSLocaleTranslation) + Q_DISABLE_COPY_MOVE(TST_TSLocaleTranslation) // NOLINT QString m_locale; }; diff --git a/src/test/TranslationsTest/tst_tstranslation.h b/src/test/TranslationsTest/tst_tstranslation.h index 7ebe87971..f43717f74 100644 --- a/src/test/TranslationsTest/tst_tstranslation.h +++ b/src/test/TranslationsTest/tst_tstranslation.h @@ -33,7 +33,7 @@ class TST_TSTranslation : public TST_AbstractTranslation { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit TST_TSTranslation(QObject *parent = nullptr); @@ -48,7 +48,7 @@ private slots: void CheckInvalidCharacter(); private: - Q_DISABLE_COPY(TST_TSTranslation) + Q_DISABLE_COPY_MOVE(TST_TSTranslation) // NOLINT void PrepareOriginalStrings(); }; diff --git a/src/test/ValentinaTest/tst_dxf.h b/src/test/ValentinaTest/tst_dxf.h index 64569562c..6509f008f 100644 --- a/src/test/ValentinaTest/tst_dxf.h +++ b/src/test/ValentinaTest/tst_dxf.h @@ -30,10 +30,11 @@ #include +#include "../vmisc/defglobal.h" class TST_DXF :public QObject { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit TST_DXF(QObject *parent = nullptr); @@ -43,7 +44,7 @@ private slots: void TestCodecPage(); private: - Q_DISABLE_COPY(TST_DXF) + Q_DISABLE_COPY_MOVE(TST_DXF) // NOLINT }; #endif // TST_DXF_H diff --git a/src/test/ValentinaTest/tst_findpoint.h b/src/test/ValentinaTest/tst_findpoint.h index 471101f76..248b27ba5 100644 --- a/src/test/ValentinaTest/tst_findpoint.h +++ b/src/test/ValentinaTest/tst_findpoint.h @@ -33,7 +33,7 @@ class TST_FindPoint : public AbstractTest { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit TST_FindPoint(QObject *parent = nullptr); diff --git a/src/test/ValentinaTest/tst_misc.h b/src/test/ValentinaTest/tst_misc.h index 7a508bc33..da4f310d0 100644 --- a/src/test/ValentinaTest/tst_misc.h +++ b/src/test/ValentinaTest/tst_misc.h @@ -31,9 +31,11 @@ #include +#include "../vmisc/defglobal.h" + class TST_Misc :public QObject { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit TST_Misc(QObject *parent = nullptr); @@ -50,7 +52,7 @@ private slots: void TestIssue485(); private: - Q_DISABLE_COPY(TST_Misc) + Q_DISABLE_COPY_MOVE(TST_Misc) // NOLINT }; #endif // TST_MISC_H diff --git a/src/test/ValentinaTest/tst_nameregexp.h b/src/test/ValentinaTest/tst_nameregexp.h index 999b7b9a8..e239b31a8 100644 --- a/src/test/ValentinaTest/tst_nameregexp.h +++ b/src/test/ValentinaTest/tst_nameregexp.h @@ -33,7 +33,7 @@ class TST_NameRegExp : public QObject { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit TST_NameRegExp(QObject *parent = nullptr); diff --git a/src/test/ValentinaTest/tst_qmutokenparser.h b/src/test/ValentinaTest/tst_qmutokenparser.h index 2f8a87573..52bb583a0 100644 --- a/src/test/ValentinaTest/tst_qmutokenparser.h +++ b/src/test/ValentinaTest/tst_qmutokenparser.h @@ -32,9 +32,11 @@ #include #include +#include "../vmisc/defglobal.h" + class TST_QmuTokenParser : public QObject { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit TST_QmuTokenParser(QObject *parent = nullptr); private slots: @@ -44,7 +46,8 @@ private slots: void TokenFromUser(); void cleanupTestCase(); private: - Q_DISABLE_COPY(TST_QmuTokenParser) + // cppcheck-suppress unknownMacro + Q_DISABLE_COPY_MOVE(TST_QmuTokenParser) // NOLINT QLocale m_systemLocale; void PrepareVal(qreal val, const QLocale &locale); diff --git a/src/test/ValentinaTest/tst_readval.h b/src/test/ValentinaTest/tst_readval.h index e4cbda6f4..f80aef25b 100644 --- a/src/test/ValentinaTest/tst_readval.h +++ b/src/test/ValentinaTest/tst_readval.h @@ -34,9 +34,11 @@ #include #include +#include "../vmisc/defglobal.h" + class TST_ReadVal : public QObject { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit TST_ReadVal(QObject *parent = nullptr); private slots: @@ -46,7 +48,8 @@ private slots: void TestInvalidData(); void cleanupTestCase(); private: - Q_DISABLE_COPY(TST_ReadVal) + // cppcheck-suppress unknownMacro + Q_DISABLE_COPY_MOVE(TST_ReadVal) // NOLINT QLocale m_systemLocale; void PrepareVal(qreal val, const QLocale &locale); diff --git a/src/test/ValentinaTest/tst_vabstractcurve.h b/src/test/ValentinaTest/tst_vabstractcurve.h index 85ff865b8..0416ded80 100644 --- a/src/test/ValentinaTest/tst_vabstractcurve.h +++ b/src/test/ValentinaTest/tst_vabstractcurve.h @@ -33,7 +33,7 @@ class TST_VAbstractCurve : public AbstractTest { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit TST_VAbstractCurve(QObject *parent = nullptr); diff --git a/src/test/ValentinaTest/tst_vabstractpiece.h b/src/test/ValentinaTest/tst_vabstractpiece.h index fff210e94..78a8c822c 100644 --- a/src/test/ValentinaTest/tst_vabstractpiece.h +++ b/src/test/ValentinaTest/tst_vabstractpiece.h @@ -35,7 +35,7 @@ class VSAPoint; class TST_VAbstractPiece : public AbstractTest { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit TST_VAbstractPiece(QObject *parent = nullptr); diff --git a/src/test/ValentinaTest/tst_varc.h b/src/test/ValentinaTest/tst_varc.h index 0d7854bab..998924c45 100644 --- a/src/test/ValentinaTest/tst_varc.h +++ b/src/test/ValentinaTest/tst_varc.h @@ -33,7 +33,7 @@ class TST_VArc : public AbstractTest { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit TST_VArc(QObject *parent = nullptr); diff --git a/src/test/ValentinaTest/tst_vcommandline.h b/src/test/ValentinaTest/tst_vcommandline.h index 747d1eadd..191a9f81b 100644 --- a/src/test/ValentinaTest/tst_vcommandline.h +++ b/src/test/ValentinaTest/tst_vcommandline.h @@ -31,9 +31,11 @@ #include +#include "../vmisc/defglobal.h" + class TST_VCommandLine : public QObject { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit TST_VCommandLine(QObject *parent = nullptr); @@ -41,7 +43,7 @@ private slots: void UniqueKeys(); private: - Q_DISABLE_COPY(TST_VCommandLine) + Q_DISABLE_COPY_MOVE(TST_VCommandLine) // NOLINT }; #endif // TST_VCOMMANDLINE_H diff --git a/src/test/ValentinaTest/tst_vcubicbezierpath.h b/src/test/ValentinaTest/tst_vcubicbezierpath.h index ecde5092b..984358393 100644 --- a/src/test/ValentinaTest/tst_vcubicbezierpath.h +++ b/src/test/ValentinaTest/tst_vcubicbezierpath.h @@ -31,9 +31,11 @@ #include +#include "../vmisc/defglobal.h" + class TST_VCubicBezierPath : public QObject { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit TST_VCubicBezierPath(QObject *parent = nullptr); @@ -46,7 +48,7 @@ private slots: void TestSubSplPointsCount() const; private: - Q_DISABLE_COPY(TST_VCubicBezierPath) + Q_DISABLE_COPY_MOVE(TST_VCubicBezierPath) // NOLINT }; diff --git a/src/test/ValentinaTest/tst_vdomdocument.h b/src/test/ValentinaTest/tst_vdomdocument.h index 051f84ad5..75f25a6d6 100644 --- a/src/test/ValentinaTest/tst_vdomdocument.h +++ b/src/test/ValentinaTest/tst_vdomdocument.h @@ -30,9 +30,11 @@ #include +#include "../vmisc/defglobal.h" + class TST_VDomDocument :public QObject { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit TST_VDomDocument(QObject *parent = nullptr); @@ -40,7 +42,7 @@ private slots: void TestCompareDomElements_data(); void TestCompareDomElements(); private: - Q_DISABLE_COPY(TST_VDomDocument) + Q_DISABLE_COPY_MOVE(TST_VDomDocument) // NOLINT }; #endif // TST_VDOMDOCUMENT_H diff --git a/src/test/ValentinaTest/tst_vellipticalarc.h b/src/test/ValentinaTest/tst_vellipticalarc.h index 74730a43b..12289dc36 100644 --- a/src/test/ValentinaTest/tst_vellipticalarc.h +++ b/src/test/ValentinaTest/tst_vellipticalarc.h @@ -30,10 +30,11 @@ #define TST_VELLIPTICALARC_H #include "../vtest/abstracttest.h" +#include "../vmisc/defglobal.h" class TST_VEllipticalArc : public AbstractTest { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit TST_VEllipticalArc(QObject *parent = nullptr); @@ -59,7 +60,8 @@ private slots: void EmptyArc(); private: - Q_DISABLE_COPY(TST_VEllipticalArc) + // cppcheck-suppress unknownMacro + Q_DISABLE_COPY_MOVE(TST_VEllipticalArc) // NOLINT void TestData(); }; diff --git a/src/test/ValentinaTest/tst_vgobject.h b/src/test/ValentinaTest/tst_vgobject.h index 83d49a0e1..e9f911467 100644 --- a/src/test/ValentinaTest/tst_vgobject.h +++ b/src/test/ValentinaTest/tst_vgobject.h @@ -33,7 +33,7 @@ class TST_VGObject : public QObject { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit TST_VGObject(QObject *parent = nullptr); diff --git a/src/test/ValentinaTest/tst_vlayoutdetail.h b/src/test/ValentinaTest/tst_vlayoutdetail.h index 68675de1e..e7d1fd3cc 100644 --- a/src/test/ValentinaTest/tst_vlayoutdetail.h +++ b/src/test/ValentinaTest/tst_vlayoutdetail.h @@ -33,7 +33,7 @@ class TST_VLayoutDetail : public AbstractTest { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit TST_VLayoutDetail(QObject *parent = nullptr); diff --git a/src/test/ValentinaTest/tst_vlockguard.h b/src/test/ValentinaTest/tst_vlockguard.h index d7031ae98..1fcbd805c 100644 --- a/src/test/ValentinaTest/tst_vlockguard.h +++ b/src/test/ValentinaTest/tst_vlockguard.h @@ -33,7 +33,7 @@ class TST_VLockGuard : public QObject { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit TST_VLockGuard(QObject *parent = nullptr); diff --git a/src/test/ValentinaTest/tst_vmeasurements.h b/src/test/ValentinaTest/tst_vmeasurements.h index 56965b166..25a3728eb 100644 --- a/src/test/ValentinaTest/tst_vmeasurements.h +++ b/src/test/ValentinaTest/tst_vmeasurements.h @@ -33,7 +33,7 @@ class TST_VMeasurements : public QObject { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit TST_VMeasurements(QObject *parent = nullptr); diff --git a/src/test/ValentinaTest/tst_vpiece.h b/src/test/ValentinaTest/tst_vpiece.h index 773ad3e19..2f715a223 100644 --- a/src/test/ValentinaTest/tst_vpiece.h +++ b/src/test/ValentinaTest/tst_vpiece.h @@ -30,10 +30,11 @@ #define TST_VDETAIL_H #include "../vtest/abstracttest.h" +#include "../vmisc/defglobal.h" class TST_VPiece : public AbstractTest { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit TST_VPiece(QObject *parent = nullptr); @@ -43,7 +44,7 @@ private slots: void TestSAPassmark(); private: - Q_DISABLE_COPY(TST_VPiece) + Q_DISABLE_COPY_MOVE(TST_VPiece) // NOLINT }; #endif // TST_VDETAIL_H diff --git a/src/test/ValentinaTest/tst_vpointf.h b/src/test/ValentinaTest/tst_vpointf.h index 0790f9259..cf57369cb 100644 --- a/src/test/ValentinaTest/tst_vpointf.h +++ b/src/test/ValentinaTest/tst_vpointf.h @@ -32,16 +32,18 @@ #include #include +#include "../vmisc/defglobal.h" + class TST_VPointF : public QObject { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit TST_VPointF(QObject *parent = nullptr); private slots: void TestFlip_data(); void TestFlip(); private: - Q_DISABLE_COPY(TST_VPointF) + Q_DISABLE_COPY_MOVE(TST_VPointF) // NOLINT }; #endif // TST_VPOINTF_H diff --git a/src/test/ValentinaTest/tst_vposter.h b/src/test/ValentinaTest/tst_vposter.h index 2b5ea9596..d61f220a5 100644 --- a/src/test/ValentinaTest/tst_vposter.h +++ b/src/test/ValentinaTest/tst_vposter.h @@ -35,7 +35,7 @@ class QPrinter; class TST_VPoster : public QObject { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit TST_VPoster(QObject *parent = nullptr); diff --git a/src/test/ValentinaTest/tst_vspline.h b/src/test/ValentinaTest/tst_vspline.h index 38e39a47e..ade7901ec 100644 --- a/src/test/ValentinaTest/tst_vspline.h +++ b/src/test/ValentinaTest/tst_vspline.h @@ -30,12 +30,13 @@ #define TST_VSPLINE_H #include "../vtest/abstracttest.h" +#include "../vmisc/defglobal.h" class VSpline; class TST_VSpline : public AbstractTest { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit TST_VSpline(QObject *parent = nullptr); @@ -57,7 +58,8 @@ private slots: void TestFlip(); private: - Q_DISABLE_COPY(TST_VSpline) + // cppcheck-suppress unknownMacro + Q_DISABLE_COPY_MOVE(TST_VSpline) // NOLINT void CompareSplines(const VSpline &spl1, const VSpline &spl2) const; }; diff --git a/src/test/ValentinaTest/tst_vsplinepath.h b/src/test/ValentinaTest/tst_vsplinepath.h index adaafd48e..b2d6a1d4b 100644 --- a/src/test/ValentinaTest/tst_vsplinepath.h +++ b/src/test/ValentinaTest/tst_vsplinepath.h @@ -31,9 +31,11 @@ #include +#include "../vmisc/defglobal.h" + class TST_VSplinePath : public QObject { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit TST_VSplinePath(QObject *parent = nullptr); private slots: @@ -42,7 +44,7 @@ private slots: void TestFlip_data(); void TestFlip(); private: - Q_DISABLE_COPY(TST_VSplinePath) + Q_DISABLE_COPY_MOVE(TST_VSplinePath) // NOLINT }; #endif // TST_VSPLINEPATH_H diff --git a/src/test/ValentinaTest/tst_vtooluniondetails.h b/src/test/ValentinaTest/tst_vtooluniondetails.h index 937173817..4fa905168 100644 --- a/src/test/ValentinaTest/tst_vtooluniondetails.h +++ b/src/test/ValentinaTest/tst_vtooluniondetails.h @@ -31,16 +31,18 @@ #include +#include "../vmisc/defglobal.h" + class TST_VToolUnionDetails : public QObject { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit TST_VToolUnionDetails(QObject *parent = nullptr); private slots: void TestUnitingMainPaths_data(); void TestUnitingMainPaths(); private: - Q_DISABLE_COPY(TST_VToolUnionDetails) + Q_DISABLE_COPY_MOVE(TST_VToolUnionDetails) // NOLINT }; #endif // TST_VTOOLUNIONDETAILS_H diff --git a/src/test/ValentinaTest/tst_vtranslatevars.h b/src/test/ValentinaTest/tst_vtranslatevars.h index cb7e14950..032eae33a 100644 --- a/src/test/ValentinaTest/tst_vtranslatevars.h +++ b/src/test/ValentinaTest/tst_vtranslatevars.h @@ -33,11 +33,13 @@ #include #include +#include "../vmisc/defglobal.h" + class VTranslateVars; class TST_VTranslateVars : public QObject { - Q_OBJECT + Q_OBJECT // NOLINT public: explicit TST_VTranslateVars(QObject *parent = nullptr); private slots: @@ -48,7 +50,8 @@ private slots: void TestFormulaToUser(); void cleanupTestCase(); private: - Q_DISABLE_COPY(TST_VTranslateVars) + // cppcheck-suppress unknownMacro + Q_DISABLE_COPY_MOVE(TST_VTranslateVars) // NOLINT VTranslateVars *m_trMs; QLocale m_systemLocale;