From e9f42bda302172fa4f45763a36739df97e2a026e Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Sat, 7 Oct 2023 18:56:39 +0300 Subject: [PATCH] Start using string literal operators for Qt types. --- src/app/puzzle/carousel/vpcarrousel.cpp | 8 +- .../dialogs/dialogpuzzlepreferences.cpp | 8 +- .../puzzle/dialogs/dialogsavemanuallayout.cpp | 12 +- src/app/puzzle/dialogs/vpdialogabout.cpp | 8 +- src/app/puzzle/layout/layoutdef.cpp | 22 +- src/app/puzzle/layout/vplayout.cpp | 8 +- src/app/puzzle/vpapplication.cpp | 8 +- src/app/puzzle/vpmainwindow.cpp | 22 +- src/app/puzzle/vpsettings.cpp | 45 ++-- src/app/puzzle/vptilefactory.cpp | 16 +- src/app/puzzle/xml/vplayoutfilereader.cpp | 8 +- src/app/puzzle/xml/vplayoutliterals.cpp | 14 +- src/app/tape/dialogs/dialogmdatabase.cpp | 18 +- .../tape/dialogs/dialogrestrictdimension.cpp | 12 +- src/app/tape/mapplication.cpp | 26 ++- src/app/tape/tmainwindow.cpp | 49 ++-- src/app/tape/vtapesettings.cpp | 22 +- src/app/valentina/core/vapplication.cpp | 8 +- .../core/vtooloptionspropertybrowser.cpp | 14 +- .../dialogs/dialogfinalmeasurements.cpp | 10 +- src/app/valentina/dialogs/dialoghistory.cpp | 8 +- .../valentina/dialogs/dialogincrements.cpp | 8 +- .../dialogs/dialoglayoutsettings.cpp | 14 +- .../dialogs/dialogpatternproperties.cpp | 8 +- .../valentina/dialogs/dialogsavelayout.cpp | 16 +- src/app/valentina/mainwindow.cpp | 60 ++--- src/app/valentina/mainwindowsnogui.cpp | 4 +- src/app/valentina/xml/vpattern.cpp | 58 ++--- src/libs/fervor/fvupdater.cpp | 18 +- src/libs/ifc/exception/vexceptionbadid.cpp | 36 ++- .../exception/vexceptionconversionerror.cpp | 23 +- .../exception/vexceptionemptyparameter.cpp | 31 ++- .../ifc/exception/vexceptionobjecterror.cpp | 39 +++- src/libs/ifc/exception/vexceptionwrongid.cpp | 29 ++- src/libs/ifc/ifcdef.cpp | 10 +- src/libs/ifc/xml/vabstractconverter.cpp | 88 +++---- src/libs/ifc/xml/vabstractpattern.cpp | 14 +- src/libs/ifc/xml/vdomdocument.cpp | 20 +- src/libs/ifc/xml/vlayoutconverter.cpp | 52 +++-- src/libs/ifc/xml/vpatternconverter.cpp | 214 +++++++++--------- src/libs/ifc/xml/vvitconverter.cpp | 18 +- src/libs/ifc/xml/vvstconverter.cpp | 14 +- src/libs/vformat/vdimensions.h | 52 +++-- src/libs/vformat/vmeasurements.cpp | 14 +- src/libs/vformat/vpatternrecipe.cpp | 15 +- src/libs/vformat/vwatermark.cpp | 4 +- src/libs/vganalytics/vganalytics.cpp | 8 +- src/libs/vganalytics/vganalyticsworker.cpp | 10 +- .../vgeometry/vabstractcubicbezierpath.cpp | 74 +++--- src/libs/vgeometry/vgeometrydef.cpp | 15 +- src/libs/vgeometry/vlayoutplacelabel.cpp | 36 +-- src/libs/vgeometry/vpointf.cpp | 16 +- src/libs/vgeometry/vspline.cpp | 28 ++- src/libs/vgeometry/vsplinepath.cpp | 10 +- src/libs/vhpgl/vhpglengine.cpp | 24 +- .../vlayout/dialogs/vabstractlayoutdialog.cpp | 10 +- src/libs/vlayout/dialogs/watermarkwindow.cpp | 26 ++- src/libs/vlayout/vabstractpiece.cpp | 24 +- src/libs/vlayout/vabstractpiece_p.h | 4 +- src/libs/vlayout/vlayoutexporter.cpp | 18 +- src/libs/vlayout/vlayoutpiece.cpp | 4 +- src/libs/vlayout/vlayoutpiece_p.h | 4 +- src/libs/vlayout/vlayoutpiecepath_p.h | 4 +- src/libs/vlayout/vlayoutpoint.cpp | 16 +- src/libs/vlayout/vposter.cpp | 15 +- src/libs/vlayout/vrawlayout.cpp | 79 ++++--- src/libs/vlayout/vrawsapoint.cpp | 12 +- src/libs/vlayout/vtextmanager.cpp | 16 +- src/libs/vmisc/compatibility.h | 41 +++- src/libs/vmisc/def.cpp | 32 +-- src/libs/vmisc/dialogs/dialogexporttocsv.cpp | 32 +-- src/libs/vmisc/projectversion.cpp | 37 +-- src/libs/vmisc/qxtcsvmodel.cpp | 6 + src/libs/vmisc/svgfont/svgdef.cpp | 12 +- src/libs/vmisc/svgfont/vsvgfontdatabase.cpp | 8 +- src/libs/vmisc/svgfont/vsvgfontengine.cpp | 4 +- src/libs/vmisc/svgfont/vsvgfontreader.cpp | 72 +++--- src/libs/vmisc/svgfont/vsvgpathtokenizer.cpp | 6 +- src/libs/vmisc/testpath.cpp | 21 +- src/libs/vmisc/testpath.h | 29 ++- src/libs/vmisc/theme/vapplicationstyle.cpp | 8 +- src/libs/vmisc/theme/vmanuallayoutstyle.cpp | 38 ++-- src/libs/vmisc/theme/vpatternpiecestyle.cpp | 24 +- src/libs/vmisc/theme/vtoolstyle.cpp | 40 ++-- src/libs/vmisc/vabstractapplication.cpp | 27 +-- src/libs/vmisc/vabstractvalapplication.cpp | 8 +- src/libs/vmisc/vcommonsettings.cpp | 188 +++++++-------- src/libs/vmisc/vmisc.qbs | 2 +- src/libs/vmisc/vmodifierkey.cpp | 14 +- src/libs/vmisc/vvalentinasettings.cpp | 128 +++++------ src/libs/vobj/vobjengine.cpp | 10 +- src/libs/vpatterndb/pmsystems.cpp | 78 ++----- src/libs/vpatterndb/variables/vcurveangle.cpp | 30 ++- .../vpatterndb/variables/vcurveclength.cpp | 28 ++- .../vpatterndb/variables/vcurvelength.cpp | 26 ++- src/libs/vpatterndb/variables/vpiecearea.cpp | 8 +- src/libs/vpatterndb/vformula.cpp | 8 +- src/libs/vpatterndb/vpiece.cpp | 10 +- src/libs/vpatterndb/vpiecenode.cpp | 1 - src/libs/vpatterndb/vtranslatevars.cpp | 4 +- .../plugins/Vector3d/vvector3dproperty.cpp | 39 ++-- .../plugins/vlabelproperty.cpp | 36 +-- .../plugins/vnumberproperty.cpp | 20 +- src/libs/vtest/abstracttest.cpp | 14 +- src/libs/vtools/dialogs/dialogtoolbox.cpp | 28 ++- .../dialogs/support/dialogeditlabel.cpp | 22 +- .../vtools/dialogs/tools/dialogsplinepath.cpp | 10 +- src/libs/vtools/dialogs/tools/dialogtool.cpp | 9 +- .../operation/vabstractoperation.cpp | 17 +- .../drawTools/toolcurve/vabstractspline.cpp | 17 +- .../tools/drawTools/toolcurve/vtoolarc.cpp | 21 +- .../toolcurve/vtoolarcwithlength.cpp | 21 +- .../toolcurve/vtoolellipticalarc.cpp | 28 ++- .../tooldoublepoint/vtooldoublepoint.cpp | 15 +- .../toolsinglepoint/toolcut/vtoolcut.cpp | 34 +-- .../toolsinglepoint/toolcut/vtoolcutarc.cpp | 88 +++---- .../toolcut/vtoolcutspline.cpp | 78 ++++--- .../toolcut/vtoolcutsplinepath.cpp | 100 ++++---- .../toollinepoint/vtoolalongline.cpp | 75 +++--- .../toollinepoint/vtoolcurveintersectaxis.cpp | 95 ++++---- .../toollinepoint/vtoolheight.cpp | 62 ++--- .../toollinepoint/vtoollineintersectaxis.cpp | 75 +++--- .../toollinepoint/vtoollinepoint.cpp | 17 +- .../toollinepoint/vtoolshoulderpoint.cpp | 68 +++--- .../toolsinglepoint/vtoolbasepoint.cpp | 13 +- .../toolsinglepoint/vtoollineintersect.cpp | 75 +++--- .../toolsinglepoint/vtoolpointofcontact.cpp | 89 ++++---- .../vtoolpointofintersectioncurves.cpp | 20 +- src/libs/vtools/tools/drawTools/vtoolline.cpp | 15 +- src/libs/vtools/tools/vabstracttool.cpp | 91 ++++---- src/libs/vwidgets/fancytabbar/fancytabbar.cpp | 70 +++--- src/libs/vwidgets/vabstractmainwindow.cpp | 12 +- src/libs/vwidgets/velidedlabel.cpp | 10 +- src/libs/vwidgets/vlineedit.cpp | 8 +- src/libs/vwidgets/vpiecegrainline_p.h | 4 +- .../CollectionTest/tst_tapecommandline.cpp | 8 +- .../tst_valentinacommandline.cpp | 39 ++-- .../TranslationsTest/tst_abstractregexp.cpp | 31 +-- .../tst_abstracttranslation.cpp | 39 ++-- .../TranslationsTest/tst_buitinregexp.cpp | 28 ++- .../tst_measurementregexp.cpp | 45 ++-- .../tst_qmuparsererrormsg.cpp | 42 ++-- .../tst_tslocaletranslation.cpp | 68 +++--- .../TranslationsTest/tst_tstranslation.cpp | 19 +- src/test/ValentinaTest/tst_nameregexp.cpp | 82 +++---- src/test/ValentinaTest/tst_qmutokenparser.cpp | 20 +- src/test/ValentinaTest/tst_readval.cpp | 36 +-- src/test/ValentinaTest/tst_varc.cpp | 26 ++- src/test/ValentinaTest/tst_vcommandline.cpp | 8 +- src/test/ValentinaTest/tst_vellipticalarc.cpp | 44 ++-- src/test/ValentinaTest/tst_vmeasurements.cpp | 56 ++--- src/test/ValentinaTest/tst_vpointf.cpp | 15 +- src/test/ValentinaTest/tst_vsplinepath.cpp | 35 +-- .../ValentinaTest/tst_vtooluniondetails.cpp | 28 ++- src/test/ValentinaTest/tst_vtranslatevars.cpp | 26 ++- 155 files changed, 2712 insertions(+), 2017 deletions(-) diff --git a/src/app/puzzle/carousel/vpcarrousel.cpp b/src/app/puzzle/carousel/vpcarrousel.cpp index 42f3d8ffc..8b9317cdb 100644 --- a/src/app/puzzle/carousel/vpcarrousel.cpp +++ b/src/app/puzzle/carousel/vpcarrousel.cpp @@ -42,6 +42,12 @@ #include #include +#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) +#include "../vmisc/compatibility.h" +#endif + +using namespace Qt::Literals::StringLiterals; + QT_WARNING_PUSH QT_WARNING_DISABLE_CLANG("-Wmissing-prototypes") QT_WARNING_DISABLE_INTEL(1418) @@ -308,5 +314,5 @@ auto VPCarrousel::GetSheetName(const VPCarrouselSheet &sheet) -> QString return QStringLiteral("--> %1 %2 <--").arg(tr("Pieces of"), sheet.name); } - return tr("Pieces of") + ' ' + sheet.name; + return tr("Pieces of") + ' '_L1 + sheet.name; } diff --git a/src/app/puzzle/dialogs/dialogpuzzlepreferences.cpp b/src/app/puzzle/dialogs/dialogpuzzlepreferences.cpp index c434c7501..452c66d4c 100644 --- a/src/app/puzzle/dialogs/dialogpuzzlepreferences.cpp +++ b/src/app/puzzle/dialogs/dialogpuzzlepreferences.cpp @@ -37,6 +37,12 @@ #include #include +#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) +#include "../vmisc/compatibility.h" +#endif + +using namespace Qt::Literals::StringLiterals; + //--------------------------------------------------------------------------------------------------------------------- DialogPuzzlePreferences::DialogPuzzlePreferences(QWidget *parent) : QDialog(parent), @@ -155,7 +161,7 @@ void DialogPuzzlePreferences::Apply() { const QString text = tr("Followed %n option(s) require restart to take effect: %1.", "", static_cast(preferences.size())) - .arg(preferences.join(QStringLiteral(", "))); + .arg(preferences.join(", "_L1)); QMessageBox::information(this, QCoreApplication::applicationName(), text); } diff --git a/src/app/puzzle/dialogs/dialogsavemanuallayout.cpp b/src/app/puzzle/dialogs/dialogsavemanuallayout.cpp index 21deee301..bdd69e320 100644 --- a/src/app/puzzle/dialogs/dialogsavemanuallayout.cpp +++ b/src/app/puzzle/dialogs/dialogsavemanuallayout.cpp @@ -38,15 +38,21 @@ #include #include +#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) +#include "../vmisc/compatibility.h" +#endif + +using namespace Qt::Literals::StringLiterals; + namespace { QT_WARNING_PUSH QT_WARNING_DISABLE_CLANG("-Wunused-member-function") #ifndef Q_OS_WIN -Q_GLOBAL_STATIC_WITH_ARGS(const QString, baseFilenameRegExp, (QLatin1String("^[^\\/]+$"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, baseFilenameRegExp, ("^[^\\/]+$"_L1)) // NOLINT #else -Q_GLOBAL_STATIC_WITH_ARGS(const QString, baseFilenameRegExp, (QLatin1String("^[^\\:?\"*|\\/<>]+$"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, baseFilenameRegExp, ("^[^\\:?\"*|\\/<>]+$"_L1)) // NOLINT #endif QT_WARNING_POP @@ -475,7 +481,7 @@ void DialogSaveManualLayout::ShowExample() QString example; if (m_count > 1) { - example = tr("Example:") + FileName() + QLatin1Char('1') + VLayoutExporter::ExportFormatSuffix(currentFormat); + example = tr("Example:") + FileName() + '1'_L1 + VLayoutExporter::ExportFormatSuffix(currentFormat); } else { diff --git a/src/app/puzzle/dialogs/vpdialogabout.cpp b/src/app/puzzle/dialogs/vpdialogabout.cpp index 2f3f48bfa..b8db9ff14 100644 --- a/src/app/puzzle/dialogs/vpdialogabout.cpp +++ b/src/app/puzzle/dialogs/vpdialogabout.cpp @@ -44,6 +44,12 @@ #define BUILD_REVISION VCS_REPO_STATE_REVISION #endif +#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) +#include "../vmisc/compatibility.h" +#endif + +using namespace Qt::Literals::StringLiterals; + //--------------------------------------------------------------------------------------------------------------------- VPDialogAbout::VPDialogAbout(QWidget *parent) : QDialog(parent), @@ -136,7 +142,7 @@ void VPDialogAbout::RetranslateUi() ui->labelBuildRevision->setText(tr("Build revision: %1").arg(QStringLiteral(BUILD_REVISION))); ui->label_QT_Version->setText(buildCompatibilityString()); - const QDate date = QLocale::c().toDate(QStringLiteral(__DATE__).simplified(), QStringLiteral("MMM d yyyy")); + const QDate date = QLocale::c().toDate(QStringLiteral(__DATE__).simplified(), "MMM d yyyy"_L1); ui->label_Puzzle_Built->setText(tr("Built on %1 at %2").arg(date.toString(), QStringLiteral(__TIME__))); ui->label_Legal_Stuff->setText(QApplication::translate("InternalStrings", diff --git a/src/app/puzzle/layout/layoutdef.cpp b/src/app/puzzle/layout/layoutdef.cpp index f6cf16d5e..2312e64ad 100644 --- a/src/app/puzzle/layout/layoutdef.cpp +++ b/src/app/puzzle/layout/layoutdef.cpp @@ -31,6 +31,12 @@ #include #include +#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) +#include "../vmisc/compatibility.h" +#endif + +using namespace Qt::Literals::StringLiterals; + //--------------------------------------------------------------------------------------------------------------------- auto GrainlineTypeToStr(GrainlineType type) -> QString { @@ -38,14 +44,14 @@ auto GrainlineTypeToStr(GrainlineType type) -> QString switch (type) { case GrainlineType::Horizontal: - result = QStringLiteral("horizontal"); + result = "horizontal"_L1; break; case GrainlineType::Vertical: - result = QStringLiteral("vertical"); + result = "vertical"_L1; break; case GrainlineType::NotFixed: default: - result = QStringLiteral("notFixed"); + result = "notFixed"_L1; break; } return result; @@ -54,8 +60,7 @@ auto GrainlineTypeToStr(GrainlineType type) -> QString //--------------------------------------------------------------------------------------------------------------------- auto StrToGrainlineType(const QString &string) -> GrainlineType { - const QStringList types - { + const QStringList types{ QStringLiteral("horizontal"), // 0 QStringLiteral("vertical"), // 1 QStringLiteral("notFixed") // 2 @@ -64,13 +69,13 @@ auto StrToGrainlineType(const QString &string) -> GrainlineType GrainlineType type = GrainlineType::NotFixed; switch (types.indexOf(string)) { - case 0:// horizontal + case 0: // horizontal type = GrainlineType::Horizontal; break; - case 2:// vertical + case 2: // vertical type = GrainlineType::Vertical; break; - case 3:// notFixed + case 3: // notFixed default: type = GrainlineType::NotFixed; break; @@ -78,7 +83,6 @@ auto StrToGrainlineType(const QString &string) -> GrainlineType return type; } - //--------------------------------------------------------------------------------------------------------------------- auto VPTransformationOrigon::operator==(const VPTransformationOrigon &origin) const -> bool { diff --git a/src/app/puzzle/layout/vplayout.cpp b/src/app/puzzle/layout/vplayout.cpp index 027bc93e6..0c0034222 100644 --- a/src/app/puzzle/layout/vplayout.cpp +++ b/src/app/puzzle/layout/vplayout.cpp @@ -39,6 +39,12 @@ #include #include +#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) +#include "../vmisc/compatibility.h" +#endif + +using namespace Qt::Literals::StringLiterals; + QT_WARNING_PUSH QT_WARNING_DISABLE_CLANG("-Wmissing-prototypes") QT_WARNING_DISABLE_INTEL(1418) @@ -179,7 +185,7 @@ auto VPLayout::WatermarkData() const -> VWatermarkData data.invalidFile = true; data.opacity = 20; data.showImage = true; - data.path = QStringLiteral("fake.png"); + data.path = "fake.png"_L1; data.showText = false; return data; } diff --git a/src/app/puzzle/vpapplication.cpp b/src/app/puzzle/vpapplication.cpp index 727a831d2..a2534dca4 100644 --- a/src/app/puzzle/vpapplication.cpp +++ b/src/app/puzzle/vpapplication.cpp @@ -50,6 +50,12 @@ #include #include +#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) +#include "../vmisc/compatibility.h" +#endif + +using namespace Qt::Literals::StringLiterals; + QT_WARNING_PUSH QT_WARNING_DISABLE_CLANG("-Wmissing-prototypes") QT_WARNING_DISABLE_INTEL(1418) @@ -430,7 +436,7 @@ void VPApplication::InitOptions() []() { QString country = VGAnalytics::CountryCode(); - if (country == QLatin1String("ru") || country == QLatin1String("by")) + if (country == "ru"_L1 || country == "by"_L1) { qFatal("contry not detected"); } diff --git a/src/app/puzzle/vpmainwindow.cpp b/src/app/puzzle/vpmainwindow.cpp index b72a7876c..9bb160288 100644 --- a/src/app/puzzle/vpmainwindow.cpp +++ b/src/app/puzzle/vpmainwindow.cpp @@ -102,6 +102,12 @@ using namespace bpstd::literals::chrono_literals; #endif // __cplusplus >= 201402L #endif //(defined(Q_CC_GNU) && Q_CC_GNU < 409) && !defined(Q_CC_CLANG) +#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) +#include "../vmisc/compatibility.h" +#endif + +using namespace Qt::Literals::StringLiterals; + namespace { //--------------------------------------------------------------------------------------------------------------------- @@ -1649,18 +1655,18 @@ void VPMainWindow::UpdateWindowTitle() } } - showName += QLatin1String("[*]"); + showName += "[*]"_L1; if (IsLayoutReadOnly()) { - showName += QStringLiteral(" (") + tr("read only") + QChar(')'); + showName += " ("_L1 + tr("read only") + ')'_L1; } setWindowTitle(showName); setWindowFilePath(curFile); #if defined(Q_OS_MAC) - static QIcon fileIcon = QIcon(QCoreApplication::applicationDirPath() + QLatin1String("/../Resources/layout.icns")); + static QIcon fileIcon = QIcon(QCoreApplication::applicationDirPath() + "/../Resources/layout.icns"_L1); QIcon icon; if (not curFile.isEmpty()) { @@ -1783,10 +1789,10 @@ void VPMainWindow::CreateWindowMenu(QMenu *menu) VPMainWindow *window = windows.at(i); QString title = QStringLiteral("%1. %2").arg(i + 1).arg(window->windowTitle()); - const vsizetype index = title.lastIndexOf(QLatin1String("[*]")); + const vsizetype index = title.lastIndexOf("[*]"_L1); if (index != -1) { - window->isWindowModified() ? title.replace(index, 3, QChar('*')) : title.replace(index, 3, QString()); + window->isWindowModified() ? title.replace(index, 3, '*'_L1) : title.replace(index, 3, QString()); } QAction *action = menu->addAction(title, this, &VPMainWindow::ShowWindow); @@ -3510,7 +3516,7 @@ auto VPMainWindow::on_actionSaveAs_triggered() -> bool { QString filters = tr("Layout files") + QStringLiteral(" (*.vlt)"); QString suffix = QStringLiteral("vlt"); - QString fName = tr("layout") + QChar('.') + suffix; + QString fName = tr("layout") + '.'_L1 + suffix; QString dir; if (curFile.isEmpty()) @@ -3522,7 +3528,7 @@ auto VPMainWindow::on_actionSaveAs_triggered() -> bool dir = QFileInfo(curFile).absolutePath(); } - QString fileName = QFileDialog::getSaveFileName(this, tr("Save as"), dir + QChar('/') + fName, filters, nullptr, + QString fileName = QFileDialog::getSaveFileName(this, tr("Save as"), dir + '/'_L1 + fName, filters, nullptr, VAbstractApplication::VApp()->NativeFileDialog()); if (fileName.isEmpty()) @@ -3533,7 +3539,7 @@ auto VPMainWindow::on_actionSaveAs_triggered() -> bool QFileInfo f(fileName); if (f.suffix().isEmpty() && f.suffix() != suffix) { - fileName += QChar('.') + suffix; + fileName += '.'_L1 + suffix; } if (curFile.isEmpty()) diff --git a/src/app/puzzle/vpsettings.cpp b/src/app/puzzle/vpsettings.cpp index a6943233e..f5c23d8dd 100644 --- a/src/app/puzzle/vpsettings.cpp +++ b/src/app/puzzle/vpsettings.cpp @@ -30,46 +30,47 @@ #include +using namespace Qt::Literals::StringLiterals; + namespace { QT_WARNING_PUSH QT_WARNING_DISABLE_CLANG("-Wunused-member-function") // NOLINTNEXTLINE -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingDockWidgetPropertiesActive, (QLatin1String("dockWidget/properties"))) +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingDockWidgetPropertiesActive, ("dockWidget/properties"_L1)) // NOLINTNEXTLINE -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingDockPropertiesContentsActive, (QLatin1String("dockWidget/contents"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutUnit, (QLatin1String("layout/unit"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingDockPropertiesContentsActive, ("dockWidget/contents"_L1)) +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutUnit, ("layout/unit"_L1)) // NOLINT // NOLINTNEXTLINE -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutSheetPaperWidth, (QLatin1String("layout/sheetPaperWidth"))) +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutSheetPaperWidth, ("layout/sheetPaperWidth"_L1)) // NOLINTNEXTLINE -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutSheetPaperHeight, (QLatin1String("layout/sheetPaperHeight"))) +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutSheetPaperHeight, ("layout/sheetPaperHeight"_L1)) // NOLINTNEXTLINE -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutTilePaperWidth, (QLatin1String("layout/tilePaperWidth"))) +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutTilePaperWidth, ("layout/tilePaperWidth"_L1)) // NOLINTNEXTLINE -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutTilePaperHeight, (QLatin1String("layout/tilePaperHeight"))) -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, settingLayoutTilePaperHeight, ("layout/tilePaperHeight"_L1)) +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutSheetMargins, ("layout/sheetMargins"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutTileMargins, ("layout/tileMargins"_L1)) // NOLINT // NOLINTNEXTLINE -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutSheetIgnoreMargins, (QLatin1String("layout/sheetIgnoreMargins"))) +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutSheetIgnoreMargins, ("layout/sheetIgnoreMargins"_L1)) // NOLINTNEXTLINE -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutTileIgnoreMargins, (QLatin1String("layout/tileIgnoreMargins"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutTileShowTiles, (QLatin1String("layout/tileShowTiles"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutTileIgnoreMargins, ("layout/tileIgnoreMargins"_L1)) +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutTileShowTiles, ("layout/tileShowTiles"_L1)) // NOLINT // NOLINTNEXTLINE -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutTileShowWatermark, (QLatin1String("layout/tileShowWatermark"))) +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutTileShowWatermark, ("layout/tileShowWatermark"_L1)) // NOLINTNEXTLINE Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutWarningPiecesSuperposition, - (QLatin1String("layout/warningPiecesSuperposition"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutStickyEdges, (QLatin1String("layout/stickyEdges"))) // NOLINT + ("layout/warningPiecesSuperposition"_L1)) +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutStickyEdges, ("layout/stickyEdges"_L1)) // NOLINT // NOLINTNEXTLINE -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutWarningPiecesOutOfBound, - (QLatin1String("layout/warningPiecesOutOfBound"))) +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutWarningPiecesOutOfBound, ("layout/warningPiecesOutOfBound"_L1)) // NOLINTNEXTLINE -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutFollowGrainline, (QLatin1String("layout/followGrainline"))) -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 -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutShowGrainline, (QLatin1String("layout/showGrainline"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutFollowGrainline, ("layout/followGrainline"_L1)) +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutPieceGap, ("layout/pieceGap"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutExportFormat, ("layout/exportFormat"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutLineWidth, ("layout/lineWidth"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutShowGrainline, ("layout/showGrainline"_L1)) // NOLINT QT_WARNING_POP diff --git a/src/app/puzzle/vptilefactory.cpp b/src/app/puzzle/vptilefactory.cpp index 5aeaf5e81..49b4df117 100644 --- a/src/app/puzzle/vptilefactory.cpp +++ b/src/app/puzzle/vptilefactory.cpp @@ -12,6 +12,8 @@ #include "layout/vpsheet.h" #include "theme/vtheme.h" +using namespace Qt::Literals::StringLiterals; + namespace { QT_WARNING_PUSH @@ -610,12 +612,11 @@ void VPTileFactory::DrawTextInformation(QPainter *painter, int row, int col, int const QString tileColorStr = QStringLiteral("%1,%2,%3").arg(tileColor->red()).arg(tileColor->green()).arg(tileColor->blue()); - td.setHtml(QString("" - "" - "" - "" - "
%2
") - .arg(tileColorStr, grid)); + td.setHtml(u"" + "" + "" + "" + "
%2
"_s.arg(tileColorStr, grid)); painter->setPen(PenTileInfos()); painter->save(); painter->translate(QPointF(UnitConvertor(1, Unit::Cm, Unit::Px), m_drawingAreaHeight - tileStripeWidth / 1.3)); @@ -780,8 +781,7 @@ void VPTileFactory::PaintWatermarkImage(QPainter *painter, const QRectF &img, co } QPixmap watermark; - if (f.suffix() == QLatin1String("png") || f.suffix() == QLatin1String("jpg") || - f.suffix() == QLatin1String("jpeg") || f.suffix() == QLatin1String("bmp")) + if (f.suffix() == "png"_L1 || f.suffix() == "jpg"_L1 || f.suffix() == "jpeg"_L1 || f.suffix() == "bmp"_L1) { QString error; watermark = WatermarkImageFromCache(watermarkData, watermarkPath, xScale, yScale, error); diff --git a/src/app/puzzle/xml/vplayoutfilereader.cpp b/src/app/puzzle/xml/vplayoutfilereader.cpp index a3e63dec6..c2091f6d0 100644 --- a/src/app/puzzle/xml/vplayoutfilereader.cpp +++ b/src/app/puzzle/xml/vplayoutfilereader.cpp @@ -49,6 +49,8 @@ #include // and, not, or #endif +using namespace Qt::Literals::StringLiterals; + QT_WARNING_PUSH QT_WARNING_DISABLE_CLANG("-Wmissing-prototypes") QT_WARNING_DISABLE_INTEL(1418) @@ -1061,7 +1063,7 @@ auto VPLayoutFileReader::ReadAttributeDouble(const QXmlStreamAttributes &attribs try { QString parametr = ReadAttributeString(attribs, name, defValue); - param = parametr.replace(QChar(','), QChar('.')).toDouble(&ok); + param = parametr.replace(','_L1, '.'_L1).toDouble(&ok); if (not ok) { throw VExceptionConversionError(message, name); @@ -1087,7 +1089,7 @@ auto VPLayoutFileReader::ReadAttributeUInt(const QXmlStreamAttributes &attribs, try { QString parametr = ReadAttributeString(attribs, name, defValue); - param = parametr.replace(QChar(','), QChar('.')).toUInt(&ok); + param = parametr.replace(','_L1, '.'_L1).toUInt(&ok); if (not ok) { throw VExceptionConversionError(message, name); @@ -1113,7 +1115,7 @@ auto VPLayoutFileReader::ReadAttributeInt(const QXmlStreamAttributes &attribs, c try { QString parametr = ReadAttributeString(attribs, name, defValue); - param = parametr.replace(QChar(','), QChar('.')).toInt(&ok); + param = parametr.replace(','_L1, '.'_L1).toInt(&ok); if (not ok) { throw VExceptionConversionError(message, name); diff --git a/src/app/puzzle/xml/vplayoutliterals.cpp b/src/app/puzzle/xml/vplayoutliterals.cpp index 29e646f27..097f2d4c8 100644 --- a/src/app/puzzle/xml/vplayoutliterals.cpp +++ b/src/app/puzzle/xml/vplayoutliterals.cpp @@ -27,6 +27,12 @@ *************************************************************************/ #include "vplayoutliterals.h" +#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) +#include "../vmisc/compatibility.h" +#endif + +using namespace Qt::Literals::StringLiterals; + namespace ML // Manual layout { const QString TagLayout = QStringLiteral("layout"); // NOLINT(cert-err58-cpp) @@ -129,8 +135,8 @@ const QString threeWaysUpDownRightStr = QStringLiteral("threeWaysUpDownRight"); const QString threeWaysUpLeftRightStr = QStringLiteral("threeWaysUpLeftRight"); // NOLINT(cert-err58-cpp) const QString threeWaysDownLeftRightStr = QStringLiteral("threeWaysDownLeftRight"); // NOLINT(cert-err58-cpp) -const QChar groupSep = QLatin1Char(';'); -const QChar coordintatesSep = QLatin1Char(','); -const QChar pointsSep = QLatin1Char(' '); -const QChar itemsSep = QLatin1Char('*'); +const QChar groupSep = ';'_L1; +const QChar coordintatesSep = ','_L1; +const QChar pointsSep = ' '_L1; +const QChar itemsSep = '*'_L1; } // namespace ML diff --git a/src/app/tape/dialogs/dialogmdatabase.cpp b/src/app/tape/dialogs/dialogmdatabase.cpp index fcea308dc..0b9dfa31d 100644 --- a/src/app/tape/dialogs/dialogmdatabase.cpp +++ b/src/app/tape/dialogs/dialogmdatabase.cpp @@ -31,12 +31,17 @@ #include "../vpatterndb/measurements.h" #include "ui_dialogmdatabase.h" - #include #include #include #include +#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) +#include "../vmisc/compatibility.h" +#endif + +using namespace Qt::Literals::StringLiterals; + //--------------------------------------------------------------------------------------------------------------------- DialogMDataBase::DialogMDataBase(const QStringList &list, QWidget *parent) : QDialog(parent), @@ -513,12 +518,11 @@ auto DialogMDataBase::ItemFullDescription(QTreeWidgetItem *item, bool showImage) imgTag = ImgTag(number); } - const QString text = QString("

%1
%2. %3

" - "

%4

") - .arg(imgTag, number, VAbstractApplication::VApp()->TrVars()->GuiText(name), - VAbstractApplication::VApp()->TrVars()->Description(name)); + const QString text = u"

%1
%2. %3

" + "

%4

"_s.arg(imgTag, number, VAbstractApplication::VApp()->TrVars()->GuiText(name), + VAbstractApplication::VApp()->TrVars()->Description(name)); return text; } diff --git a/src/app/tape/dialogs/dialogrestrictdimension.cpp b/src/app/tape/dialogs/dialogrestrictdimension.cpp index 3eaa0b69f..bb9a9ad90 100644 --- a/src/app/tape/dialogs/dialogrestrictdimension.cpp +++ b/src/app/tape/dialogs/dialogrestrictdimension.cpp @@ -37,6 +37,12 @@ #include "../vmisc/backport/qoverload.h" #endif // QT_VERSION < QT_VERSION_CHECK(5, 7, 0) +#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) +#include "../vmisc/compatibility.h" +#endif + +using namespace Qt::Literals::StringLiterals; + namespace { //--------------------------------------------------------------------------------------------------------------------- @@ -187,7 +193,7 @@ void DialogRestrictDimension::changeEvent(QEvent *event) { MeasurementDimension_p dimension = m_dimensions.at(index); - name->setText(dimension->Name() + QChar(':')); + name->setText(dimension->Name() + ':'_L1); name->setToolTip(VAbstartMeasurementDimension::DimensionToolTip(dimension, m_fullCircumference)); InitDimensionGradation(dimension, control); @@ -366,7 +372,7 @@ void DialogRestrictDimension::CellContextMenu(QPoint pos) } columnValue = m_dimensions.at(0)->ValidBases().at(item->column()); - coordinates = QChar('0'); + coordinates = '0'_L1; } else if (m_restrictionType == RestrictDimension::Second) { @@ -451,7 +457,7 @@ void DialogRestrictDimension::InitDimensionsBaseValues() if (m_dimensions.size() > index) { MeasurementDimension_p dimension = m_dimensions.at(index); - name->setText(dimension->Name() + QChar(':')); + name->setText(dimension->Name() + ':'_L1); name->setToolTip(VAbstartMeasurementDimension::DimensionToolTip(dimension, m_fullCircumference)); InitDimensionGradation(dimension, control); diff --git a/src/app/tape/mapplication.cpp b/src/app/tape/mapplication.cpp index 45e43419d..59a4d5669 100644 --- a/src/app/tape/mapplication.cpp +++ b/src/app/tape/mapplication.cpp @@ -69,6 +69,12 @@ #include "../vmisc/appimage.h" #endif // defined(APPIMAGE) && defined(Q_OS_LINUX) +#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) +#include "../vmisc/compatibility.h" +#endif + +using namespace Qt::Literals::StringLiterals; + QT_WARNING_PUSH QT_WARNING_DISABLE_CLANG("-Wmissing-prototypes") QT_WARNING_DISABLE_INTEL(1418) @@ -82,19 +88,19 @@ namespace QT_WARNING_PUSH QT_WARNING_DISABLE_CLANG("-Wunused-member-function") -Q_GLOBAL_STATIC_WITH_ARGS(const QString, LONG_OPTION_DIMENSION_A, (QLatin1String("dimensionA"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, SINGLE_OPTION_DIMENSION_A, (QChar('a'))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, LONG_OPTION_DIMENSION_A, ("dimensionA"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, SINGLE_OPTION_DIMENSION_A, ('a'_L1)) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, LONG_OPTION_DIMENSION_B, (QLatin1String("dimensionB"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, SINGLE_OPTION_DIMENSION_B, (QChar('b'))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, LONG_OPTION_DIMENSION_B, ("dimensionB"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, SINGLE_OPTION_DIMENSION_B, ('b'_L1)) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, LONG_OPTION_DIMENSION_C, (QLatin1String("dimensionC"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, SINGLE_OPTION_DIMENSION_C, (QChar('c'))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, LONG_OPTION_DIMENSION_C, ("dimensionC"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, SINGLE_OPTION_DIMENSION_C, ('c'_L1)) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, LONG_OPTION_UNITS, (QLatin1String("units"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, SINGLE_OPTION_UNITS, (QChar('u'))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, LONG_OPTION_UNITS, ("units"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, SINGLE_OPTION_UNITS, ('u'_L1)) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, LONG_OPTION_TEST, (QLatin1String("test"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, LONG_OPTION_TEST, ("test"_L1)) // NOLINT QT_WARNING_POP } // namespace @@ -473,7 +479,7 @@ void MApplication::InitOptions() []() { QString country = VGAnalytics::CountryCode(); - if (country == QLatin1String("ru") || country == QLatin1String("by")) + if (country == "ru"_L1 || country == "by"_L1) { qFatal("contry not detected"); } diff --git a/src/app/tape/tmainwindow.cpp b/src/app/tape/tmainwindow.cpp index d76fff7c7..2c20390d2 100644 --- a/src/app/tape/tmainwindow.cpp +++ b/src/app/tape/tmainwindow.cpp @@ -102,6 +102,8 @@ using namespace bpstd::literals::chrono_literals; #include #endif // defined(Q_OS_MAC) +using namespace Qt::Literals::StringLiterals; + constexpr int DIALOG_MAX_FORMULA_HEIGHT = 64; QT_WARNING_PUSH @@ -1021,7 +1023,7 @@ auto TMainWindow::FileSaveAs() -> bool suffix = QStringLiteral("vst"); } - fName += QChar('.') + suffix; + fName += '.'_L1 + suffix; const QString dir = SaveDirPath(m_curFile, m_mType); @@ -1030,7 +1032,7 @@ auto TMainWindow::FileSaveAs() -> bool fName = StrippedName(m_curFile); } - QString fileName = QFileDialog::getSaveFileName(this, tr("Save as"), dir + QChar('/') + fName, filters, nullptr, + QString fileName = QFileDialog::getSaveFileName(this, tr("Save as"), dir + '/'_L1 + fName, filters, nullptr, VAbstractApplication::VApp()->NativeFileDialog()); if (fileName.isEmpty()) @@ -1041,7 +1043,7 @@ auto TMainWindow::FileSaveAs() -> bool QFileInfo f(fileName); if (f.suffix().isEmpty() && f.suffix() != suffix) { - fileName += QChar('.') + suffix; + fileName += '.'_L1 + suffix; } if (m_curFile.isEmpty()) @@ -1162,7 +1164,7 @@ void TMainWindow::ImportDataFromCSV() QFileInfo f(fileName); if (f.suffix().isEmpty() && f.suffix() != suffix) { - fileName += QChar('.') + suffix; + fileName += '.'_L1 + suffix; } DialogExportToCSV dialog(this); @@ -1973,9 +1975,9 @@ void TMainWindow::ShowMDiagram(const QString &name) } else { - ui->labelDiagram->setText(QString("

%1

" - "

%2. %3

") - .arg(DialogMDataBase::ImgTag(number), number, trv->GuiText(name))); + ui->labelDiagram->setText(u"

%1

" + "

%2. %3

"_s.arg( + DialogMDataBase::ImgTag(number), number, trv->GuiText(name))); } } @@ -2049,7 +2051,7 @@ void TMainWindow::SaveMName(const QString &text) QString name = newName; do { - name = name + QChar('_') + QString::number(num); + name = name + '_'_L1 + QString::number(num); num++; } while (not m_data->IsUnique(name)); newName = name; @@ -2418,7 +2420,7 @@ void TMainWindow::ExportToIndividual() QString filters = tr("Individual measurements") + QStringLiteral(" (*.vit)"); QString fName = tr("measurements.vit"); - QString fileName = QFileDialog::getSaveFileName(this, tr("Export to individual"), dir + QChar('/') + fName, filters, + QString fileName = QFileDialog::getSaveFileName(this, tr("Export to individual"), dir + '/'_L1 + fName, filters, nullptr, VAbstractApplication::VApp()->NativeFileDialog()); if (fileName.isEmpty()) @@ -2430,7 +2432,7 @@ void TMainWindow::ExportToIndividual() QFileInfo f(fileName); if (f.suffix().isEmpty() && f.suffix() != suffix) { - fileName += QChar('.') + suffix; + fileName += '.'_L1 + suffix; } if (m_curFile.isEmpty()) @@ -2834,7 +2836,7 @@ void TMainWindow::InitWindow() ui->comboBoxPMSystem->setEnabled(true); ui->comboBoxPMSystem->clear(); InitPMSystems(ui->comboBoxPMSystem); - const qint32 index = ui->comboBoxPMSystem->findData(QLatin1Char('p') + m_m->PMSystem()); + const qint32 index = ui->comboBoxPMSystem->findData('p'_L1 + m_m->PMSystem()); ui->comboBoxPMSystem->setCurrentIndex(index); connect(ui->comboBoxPMSystem, QOverload::of(&QComboBox::currentIndexChanged), this, &TMainWindow::SavePMSystem); @@ -2946,7 +2948,7 @@ void TMainWindow::InitDimensionsBaseValue() if (dimensions.size() > index) { const MeasurementDimension_p &dimension = dimensions.at(index); - name->setText(dimension->Name() + QChar(':')); + name->setText(dimension->Name() + ':'_L1); name->setToolTip(VAbstartMeasurementDimension::DimensionToolTip(dimension, m_m->IsFullCircumference())); DimesionLabels labels = dimension->Labels(); @@ -3057,11 +3059,11 @@ void TMainWindow::InitDimensionControls() if (name == nullptr) { - name = new QLabel(dimension->Name() + QChar(':')); + name = new QLabel(dimension->Name() + ':'_L1); } else { - name->setText(dimension->Name() + QChar(':')); + name->setText(dimension->Name() + ':'_L1); } name->setToolTip(VAbstartMeasurementDimension::DimensionToolTip(dimension, m_m->IsFullCircumference())); @@ -3148,7 +3150,7 @@ void TMainWindow::ShowHeaderUnits(QTableWidget *table, int column, const QString SCASSERT(table != nullptr) QString header = table->horizontalHeaderItem(column)->text(); - const auto index = header.indexOf(QLatin1String("(")); + const auto index = header.indexOf('('_L1); if (index != -1) { header.remove(index - 1, 100); @@ -3170,7 +3172,7 @@ void TMainWindow::SetCurrentFile(const QString &fileName) m_curFile = fileName; if (m_curFile.isEmpty()) { - ui->lineEditPathToFile->setText(QChar('<') + tr("Empty") + QChar('>')); + ui->lineEditPathToFile->setText('<'_L1 + tr("Empty") + '>'_L1); ui->lineEditPathToFile->setToolTip(tr("File was not saved yet.")); ui->lineEditPathToFile->setCursorPosition(0); ui->pushButtonShowInExplorer->setEnabled(false); @@ -3563,22 +3565,21 @@ void TMainWindow::UpdateWindowTitle() { showName = tr("untitled"); } - m_mType == MeasurementsType::Multisize ? showName += QLatin1String(".vst") : showName += QLatin1String(".vit"); + m_mType == MeasurementsType::Multisize ? showName += ".vst"_L1 : showName += ".vit"_L1; } - showName += QLatin1String("[*]"); + showName += "[*]"_L1; if (m_mIsReadOnly || not isFileWritable) { - showName += QStringLiteral(" (") + tr("read only") + QChar(')'); + showName += QStringLiteral(" (") + tr("read only") + ')'_L1; } setWindowTitle(showName); setWindowFilePath(m_curFile); #if defined(Q_OS_MAC) - static QIcon fileIcon = - QIcon(QCoreApplication::applicationDirPath() + QLatin1String("/../Resources/measurements.icns")); + static QIcon fileIcon = QIcon(QCoreApplication::applicationDirPath() + "/../Resources/measurements.icns"_L1); QIcon icon; if (not m_curFile.isEmpty()) { @@ -3910,10 +3911,10 @@ void TMainWindow::CreateWindowMenu(QMenu *menu) TMainWindow *window = windows.at(i); QString title = QStringLiteral("%1. %2").arg(i + 1).arg(window->windowTitle()); - const auto index = title.lastIndexOf(QLatin1String("[*]")); + const auto index = title.lastIndexOf("[*]"_L1); if (index != -1) { - window->isWindowModified() ? title.replace(index, 3, QChar('*')) : title.replace(index, 3, QString()); + window->isWindowModified() ? title.replace(index, 3, '*'_L1) : title.replace(index, 3, QString()); } QAction *action = menu->addAction(title, this, &TMainWindow::ShowWindow); @@ -4760,7 +4761,7 @@ void TMainWindow::UpdateSearchControlsTooltips() { auto UpdateToolTip = [](QAbstractButton *button) { - if (button->toolTip().contains(QLatin1String("%1"))) + if (button->toolTip().contains("%1"_L1)) { button->setToolTip(button->toolTip().arg(button->shortcut().toString(QKeySequence::NativeText))); } diff --git a/src/app/tape/vtapesettings.cpp b/src/app/tape/vtapesettings.cpp index d48421d94..2d1dc380a 100644 --- a/src/app/tape/vtapesettings.cpp +++ b/src/app/tape/vtapesettings.cpp @@ -32,27 +32,31 @@ #include #include +#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) +#include "../vmisc/compatibility.h" +#endif + +using namespace Qt::Literals::StringLiterals; + namespace { QT_WARNING_PUSH QT_WARNING_DISABLE_CLANG("-Wunused-member-function") -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPathsTemplates, (QLatin1String("paths/templates"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPathsTemplates, ("paths/templates"_L1)) // NOLINT -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, settingDataBaseGeometry, ("database/geometry"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchHistoryTape, ("searchHistory/tape"_L1)) // NOLINT // NOLINTNEXTLINE Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsTapeUseUnicodeProperties, - (QLatin1String("searchOptions/tapeUseUnicodeProperties"))) + ("searchOptions/tapeUseUnicodeProperties"_L1)) // NOLINTNEXTLINE -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsTapeWholeWord, - (QLatin1String("searchOptions/tapeWholeWord"))) +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsTapeWholeWord, ("searchOptions/tapeWholeWord"_L1)) // NOLINTNEXTLINE -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsTapeRegexp, (QLatin1String("searchOptions/tapeRegexp"))) +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsTapeRegexp, ("searchOptions/tapeRegexp"_L1)) // NOLINTNEXTLINE -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsTapeMatchCase, - (QLatin1String("searchOptions/tapeMatchCase"))) +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsTapeMatchCase, ("searchOptions/tapeMatchCase"_L1)) QT_WARNING_POP } // namespace diff --git a/src/app/valentina/core/vapplication.cpp b/src/app/valentina/core/vapplication.cpp index dd12339b6..812b16d65 100644 --- a/src/app/valentina/core/vapplication.cpp +++ b/src/app/valentina/core/vapplication.cpp @@ -77,6 +77,12 @@ #include #endif +#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) +#include "../vmisc/compatibility.h" +#endif + +using namespace Qt::Literals::StringLiterals; + QT_WARNING_PUSH QT_WARNING_DISABLE_CLANG("-Wmissing-prototypes") QT_WARNING_DISABLE_INTEL(1418) @@ -685,7 +691,7 @@ void VApplication::InitOptions() []() { QString country = VGAnalytics::CountryCode(); - if (country == QLatin1String("ru") || country == QLatin1String("by")) + if (country == "ru"_L1 || country == "by"_L1) { qFatal("contry not detected"); } diff --git a/src/app/valentina/core/vtooloptionspropertybrowser.cpp b/src/app/valentina/core/vtooloptionspropertybrowser.cpp index d25bf41c1..21814fdde 100644 --- a/src/app/valentina/core/vtooloptionspropertybrowser.cpp +++ b/src/app/valentina/core/vtooloptionspropertybrowser.cpp @@ -94,14 +94,20 @@ #include #include +#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) +#include "../vmisc/compatibility.h" +#endif + +using namespace Qt::Literals::StringLiterals; + namespace { QT_WARNING_PUSH QT_WARNING_DISABLE_CLANG("-Wunused-member-function") -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 +Q_GLOBAL_STATIC_WITH_ARGS(const QString, AttrHold, ("hold"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, AttrVisible, ("visible"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, AttrOpacity, ("opacity"_L1)) // NOLINT QT_WARNING_POP } // namespace @@ -4379,7 +4385,7 @@ auto VToolOptionsPropertyBrowser::PropertiesList() -> QStringList { static QStringList attr{ AttrName, /* 0 */ - QLatin1String("position"), /* 1 */ + "position"_L1, /* 1 */ AttrBasePoint, /* 2 */ AttrTypeLine, /* 3 */ AttrLength, /* 4 */ diff --git a/src/app/valentina/dialogs/dialogfinalmeasurements.cpp b/src/app/valentina/dialogs/dialogfinalmeasurements.cpp index 6f856bed5..82050e185 100644 --- a/src/app/valentina/dialogs/dialogfinalmeasurements.cpp +++ b/src/app/valentina/dialogs/dialogfinalmeasurements.cpp @@ -38,6 +38,12 @@ #include +#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) +#include "../vmisc/compatibility.h" +#endif + +using namespace Qt::Literals::StringLiterals; + constexpr int DIALOG_MAX_FORMULA_HEIGHT = 64; //--------------------------------------------------------------------------------------------------------------------- @@ -251,7 +257,7 @@ void DialogFinalMeasurements::Add() VFinalMeasurement m; m.name = tr("measurement"); - m.formula = QLatin1Char('0'); + m.formula = '0'_L1; m_measurements.append(m); @@ -902,7 +908,7 @@ void DialogFinalMeasurements::UpdateSearchControlsTooltips() { auto UpdateToolTip = [](QAbstractButton *button) { - if (button->toolTip().contains(QLatin1String("%1"))) + if (button->toolTip().contains("%1"_L1)) { button->setToolTip(button->toolTip().arg(button->shortcut().toString(QKeySequence::NativeText))); } diff --git a/src/app/valentina/dialogs/dialoghistory.cpp b/src/app/valentina/dialogs/dialoghistory.cpp index acd3a1182..f38bff851 100644 --- a/src/app/valentina/dialogs/dialoghistory.cpp +++ b/src/app/valentina/dialogs/dialoghistory.cpp @@ -45,6 +45,12 @@ #include #include +#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) +#include "../vmisc/compatibility.h" +#endif + +using namespace Qt::Literals::StringLiterals; + namespace { //--------------------------------------------------------------------------------------------------------------------- @@ -780,7 +786,7 @@ void DialogHistory::UpdateSearchControlsTooltips() { auto UpdateToolTip = [](QAbstractButton *button) { - if (button->toolTip().contains(QLatin1String("%1"))) + if (button->toolTip().contains("%1"_L1)) { button->setToolTip(button->toolTip().arg(button->shortcut().toString(QKeySequence::NativeText))); } diff --git a/src/app/valentina/dialogs/dialogincrements.cpp b/src/app/valentina/dialogs/dialogincrements.cpp index 483ad5cfd..ec80d16ab 100644 --- a/src/app/valentina/dialogs/dialogincrements.cpp +++ b/src/app/valentina/dialogs/dialogincrements.cpp @@ -56,6 +56,12 @@ #include #include +#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) +#include "../vmisc/compatibility.h" +#endif + +using namespace Qt::Literals::StringLiterals; + constexpr int DIALOG_MAX_FORMULA_HEIGHT = 64; namespace @@ -1191,7 +1197,7 @@ void DialogIncrements::UpdateSearchControlsTooltips() { auto UpdateToolTip = [](QAbstractButton *button) { - if (button->toolTip().contains(QLatin1String("%1"))) + if (button->toolTip().contains("%1"_L1)) { button->setToolTip(button->toolTip().arg(button->shortcut().toString(QKeySequence::NativeText))); } diff --git a/src/app/valentina/dialogs/dialoglayoutsettings.cpp b/src/app/valentina/dialogs/dialoglayoutsettings.cpp index a7f27d1a6..770f12dea 100644 --- a/src/app/valentina/dialogs/dialoglayoutsettings.cpp +++ b/src/app/valentina/dialogs/dialoglayoutsettings.cpp @@ -39,6 +39,12 @@ #include #include +#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) +#include "../vmisc/compatibility.h" +#endif + +using namespace Qt::Literals::StringLiterals; + //--------------------------------------------------------------------------------------------------------------------- DialogLayoutSettings::DialogLayoutSettings(VLayoutGenerator *generator, QWidget *parent, bool disableSettings) : VAbstractLayoutDialog(parent), @@ -821,11 +827,11 @@ auto DialogLayoutSettings::MakeHelpTemplateList() -> QString if (i < VAbstractLayoutDialog::PageFormatNames().size() - 2) { - out += QLatin1String(",\n"); + out += ",\n"_L1; } else { - out += QLatin1String(".\n"); + out += ".\n"_L1; } } } @@ -843,11 +849,11 @@ auto DialogLayoutSettings::MakeHelpTiledPdfTemplateList() -> QString if (i < static_cast(PaperSizeTemplate::Tabloid)) { - out += QLatin1String(",\n"); + out += ",\n"_L1; } else { - out += QLatin1String(".\n"); + out += ".\n"_L1; } } return out; diff --git a/src/app/valentina/dialogs/dialogpatternproperties.cpp b/src/app/valentina/dialogs/dialogpatternproperties.cpp index 95b62042b..e747aec4d 100644 --- a/src/app/valentina/dialogs/dialogpatternproperties.cpp +++ b/src/app/valentina/dialogs/dialogpatternproperties.cpp @@ -53,6 +53,12 @@ #include "../ifc/xml/vpatternimage.h" #include "../qmuparser/qmudef.h" +#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) +#include "../vmisc/compatibility.h" +#endif + +using namespace Qt::Literals::StringLiterals; + //--------------------------------------------------------------------------------------------------------------------- DialogPatternProperties::DialogPatternProperties(VPattern *doc, VContainer *pattern, QWidget *parent) : QDialog(parent), @@ -514,7 +520,7 @@ void DialogPatternProperties::BrowseLabelPath() path = settings->GetPathLabelTemplate(); } - QString filters(tr("Label template") + QLatin1String("(*.xml)")); + QString filters(tr("Label template") + "(*.xml)"_L1); const QString filePath = QFileDialog::getOpenFileName(this, tr("Label template"), path, filters, nullptr, VAbstractApplication::VApp()->NativeFileDialog()); diff --git a/src/app/valentina/dialogs/dialogsavelayout.cpp b/src/app/valentina/dialogs/dialogsavelayout.cpp index a26f54d67..966175686 100644 --- a/src/app/valentina/dialogs/dialogsavelayout.cpp +++ b/src/app/valentina/dialogs/dialogsavelayout.cpp @@ -45,15 +45,21 @@ #include #include +#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) +#include "../vmisc/compatibility.h" +#endif + +using namespace Qt::Literals::StringLiterals; + namespace { QT_WARNING_PUSH QT_WARNING_DISABLE_CLANG("-Wunused-member-function") #ifndef Q_OS_WIN -Q_GLOBAL_STATIC_WITH_ARGS(const QString, baseFilenameRegExp, (QLatin1String("^[^\\/]+$"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, baseFilenameRegExp, ("^[^\\/]+$"_L1)) // NOLINT #else -Q_GLOBAL_STATIC_WITH_ARGS(const QString, baseFilenameRegExp, (QLatin1String("^[^\\:?\"*|\\/<>]+$"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, baseFilenameRegExp, ("^[^\\:?\"*|\\/<>]+$"_L1)) // NOLINT #endif QT_WARNING_POP @@ -297,11 +303,11 @@ auto DialogSaveLayout::MakeHelpFormatList() -> QString if (i < formats.size() - 1) { - out += QLatin1String(",\n"); + out += ",\n"_L1; } else { - out += QLatin1String(".\n"); + out += ".\n"_L1; } } return out; @@ -424,7 +430,7 @@ void DialogSaveLayout::PathChanged(const QString &text) void DialogSaveLayout::ShowExample() { const LayoutExportFormats currentFormat = Format(); - ui->labelExample->setText(tr("Example:") + FileName() + QLatin1Char('1') + + ui->labelExample->setText(tr("Example:") + FileName() + '1'_L1 + VLayoutExporter::ExportFormatSuffix(currentFormat)); ui->groupBoxPaperFormat->setEnabled(false); diff --git a/src/app/valentina/mainwindow.cpp b/src/app/valentina/mainwindow.cpp index 7c91f6087..246f9ce7e 100644 --- a/src/app/valentina/mainwindow.cpp +++ b/src/app/valentina/mainwindow.cpp @@ -236,6 +236,12 @@ using namespace bpstd::literals::chrono_literals; #endif // __cplusplus >= 201402L #endif //(defined(Q_CC_GNU) && Q_CC_GNU < 409) && !defined(Q_CC_CLANG) +#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) +#include "../vmisc/compatibility.h" +#endif + +using namespace Qt::Literals::StringLiterals; + QT_WARNING_PUSH QT_WARNING_DISABLE_CLANG("-Wmissing-prototypes") QT_WARNING_DISABLE_INTEL(1418) @@ -249,7 +255,7 @@ namespace QT_WARNING_PUSH QT_WARNING_DISABLE_CLANG("-Wunused-member-function") -Q_GLOBAL_STATIC_WITH_ARGS(const QString, autosavePrefix, (QLatin1String(".autosave"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, autosavePrefix, (".autosave"_L1)) // NOLINT QT_WARNING_POP @@ -779,11 +785,11 @@ void MainWindow::ReadMeasurements(qreal baseA, qreal baseB, qreal baseC) if (name == nullptr) { - name = new QLabel(dimension->Name() + QChar(':')); + name = new QLabel(dimension->Name() + ':'_L1); } else { - name->setText(dimension->Name() + QChar(':')); + name->setText(dimension->Name() + ':'_L1); } name->setToolTip(VAbstartMeasurementDimension::DimensionToolTip(dimension, m_m->IsFullCircumference())); @@ -850,7 +856,7 @@ void MainWindow::SetToolButton(bool checked, Tool t, const QString &cursor, cons if (qApp->devicePixelRatio() >= 2) // NOLINT(cppcoreguidelines-pro-type-static-cast-downcast) { // Try to load HiDPI versions of the cursors if availible - auto hiDPICursor = QString(cursor).replace(QLatin1String(".png"), QLatin1String("@2x.png")); + auto hiDPICursor = QString(cursor).replace(".png"_L1, "@2x.png"_L1); auto cursorHiDPIResource = VTheme::GetResourceName(resource, hiDPICursor); if (QFileInfo::exists(cursorHiDPIResource)) { @@ -2324,7 +2330,7 @@ void MainWindow::StoreMultisizeMDimensions() { if (not m_dimensionALabel.isNull()) { - m_dimensionALabel->setText(dimensions.at(0)->Name() + QChar(':')); + m_dimensionALabel->setText(dimensions.at(0)->Name() + ':'_L1); } } @@ -2332,7 +2338,7 @@ void MainWindow::StoreMultisizeMDimensions() { if (not m_dimensionBLabel.isNull()) { - m_dimensionBLabel->setText(dimensions.at(1)->Name() + QChar(':')); + m_dimensionBLabel->setText(dimensions.at(1)->Name() + ':'_L1); } } @@ -2340,7 +2346,7 @@ void MainWindow::StoreMultisizeMDimensions() { if (not m_dimensionCLabel.isNull()) { - m_dimensionCLabel->setText(dimensions.at(2)->Name() + QChar(':')); + m_dimensionCLabel->setText(dimensions.at(2)->Name() + ':'_L1); } } @@ -4087,8 +4093,8 @@ auto MainWindow::on_actionSaveAs_triggered() -> bool } QString filters(tr("Pattern files") + QStringLiteral("(*.val)")); - QString fileName = QFileDialog::getSaveFileName(this, tr("Save as"), dir + QChar('/') + newFileName, filters, - nullptr, VAbstractApplication::VApp()->NativeFileDialog()); + QString fileName = QFileDialog::getSaveFileName(this, tr("Save as"), dir + '/'_L1 + newFileName, filters, nullptr, + VAbstractApplication::VApp()->NativeFileDialog()); if (fileName.isEmpty()) { @@ -4096,9 +4102,9 @@ auto MainWindow::on_actionSaveAs_triggered() -> bool } QFileInfo f(fileName); - if (f.suffix().isEmpty() && f.suffix() != QLatin1String("val")) + if (f.suffix().isEmpty() && f.suffix() != "val"_L1) { - fileName += QLatin1String(".val"); + fileName += ".val"_L1; } if (patternPath.isEmpty()) @@ -5240,11 +5246,11 @@ void MainWindow::InitDimensionControls() if (name.isNull()) { - name = new QLabel(dimension->Name() + QChar(':')); + name = new QLabel(dimension->Name() + ':'_L1); } else { - name->setText(dimension->Name() + QChar(':')); + name->setText(dimension->Name() + ':'_L1); } name->setToolTip(VAbstartMeasurementDimension::DimensionToolTip(dimension, m_m->IsFullCircumference())); @@ -5527,7 +5533,7 @@ auto MainWindow::SavePattern(const QString &fileName, QString &error) -> bool const bool result = doc->SaveDocument(fileName, error); if (result) { - if (tempInfo.suffix() != QLatin1String("autosave")) + if (tempInfo.suffix() != "autosave"_L1) { setCurrentFile(fileName); statusBar()->showMessage(tr("File saved"), 5000); @@ -6243,7 +6249,7 @@ auto MainWindow::LoadPattern(QString fileName, const QString &customMeasureFile) QFileInfo info(fileName); if (info.exists() && info.isRelative()) { - fileName = QFileInfo(QDir::currentPath() + QLatin1Char('/') + fileName).canonicalFilePath(); + fileName = QFileInfo(QDir::currentPath() + '/'_L1 + fileName).canonicalFilePath(); } } @@ -6646,7 +6652,7 @@ void MainWindow::CreateMeasurements() QStringList arguments; if (isNoScaling) { - arguments.append(QLatin1String("--") + LONG_OPTION_NO_HDPI_SCALING); + arguments.append("--"_L1 + LONG_OPTION_NO_HDPI_SCALING); } QProcess::startDetached(tape, arguments, workingDirectory); @@ -6659,7 +6665,7 @@ void MainWindow::ExportDrawAs() auto Uncheck = qScopeGuard([this] { ui->actionExportDraw->setChecked(false); }); QString filters(tr("Scalable Vector Graphics files") + QStringLiteral("(*.svg)")); - QString dir = QDir::homePath() + QChar('/') + FileName() + QStringLiteral(".svg"); + QString dir = QDir::homePath() + '/'_L1 + FileName() + QStringLiteral(".svg"); QString fileName = QFileDialog::getSaveFileName(this, tr("Save draw"), dir, filters, nullptr, VAbstractApplication::VApp()->NativeFileDialog()); @@ -6669,9 +6675,9 @@ void MainWindow::ExportDrawAs() } QFileInfo f(fileName); - if (f.suffix().isEmpty() || f.suffix() != QLatin1String("svg")) + if (f.suffix().isEmpty() || f.suffix() != "svg"_L1) { - fileName += QLatin1String(".svg"); + fileName += ".svg"_L1; } ExportDraw(fileName); @@ -6867,7 +6873,7 @@ auto MainWindow::CheckPathToMeasurements(const QString &patternPath, const QStri } MeasurementsType patternType; - if (table.suffix() == QLatin1String("vst")) + if (table.suffix() == "vst"_L1) { patternType = MeasurementsType::Multisize; } @@ -7194,7 +7200,7 @@ auto MainWindow::DoFMExport(const VCommandLinePtr &expParams) -> bool QFileInfo info(filePath); if (info.isRelative()) { - filePath = QDir::currentPath() + QLatin1Char('/') + filePath; + filePath = QDir::currentPath() + '/'_L1 + filePath; } const QString codecName = expParams->OptCSVCodecName(); @@ -7429,7 +7435,7 @@ auto MainWindow::GetPatternFileName() -> QString { shownName = StrippedName(VAbstractValApplication::VApp()->GetPatternPath()); } - shownName += QLatin1String("[*]"); + shownName += "[*]"_L1; return shownName; } @@ -7446,10 +7452,10 @@ auto MainWindow::GetMeasurementFileName() -> QString if (m_mChanges) { - shownName += QChar('*'); + shownName += '*'_L1; } - shownName += QChar(']'); + shownName += ']'_L1; return shownName; } @@ -7474,14 +7480,12 @@ void MainWindow::UpdateWindowTitle() } else { - setWindowTitle(GetPatternFileName() + GetMeasurementFileName() + QStringLiteral(" (") + tr("read only") + - QChar(')')); + setWindowTitle(GetPatternFileName() + GetMeasurementFileName() + " ("_L1 + tr("read only") + ')'_L1); } setWindowFilePath(VAbstractValApplication::VApp()->GetPatternPath()); #if defined(Q_OS_MAC) - static QIcon fileIcon = - QIcon(QCoreApplication::applicationDirPath() + QLatin1String("/../Resources/Valentina.icns")); + static QIcon fileIcon = QIcon(QCoreApplication::applicationDirPath() + "/../Resources/Valentina.icns"_L1); QIcon icon; if (not VAbstractValApplication::VApp()->GetPatternPath().isEmpty()) { diff --git a/src/app/valentina/mainwindowsnogui.cpp b/src/app/valentina/mainwindowsnogui.cpp index 575e4969a..977c50585 100644 --- a/src/app/valentina/mainwindowsnogui.cpp +++ b/src/app/valentina/mainwindowsnogui.cpp @@ -76,6 +76,8 @@ #include #endif +using namespace Qt::Literals::StringLiterals; + QT_WARNING_PUSH QT_WARNING_DISABLE_CLANG("-Wmissing-prototypes") QT_WARNING_DISABLE_INTEL(1418) @@ -555,7 +557,7 @@ void MainWindowsNoGUI::ExportFlatLayout(const QList &scenes, c if (format == LayoutExportFormats::PDFTiled && m_dialogSaveLayout->Mode() == Draw::Layout) { - const QString name = path + '/' + m_dialogSaveLayout->FileName() + QChar('1'); + const QString name = path + '/'_L1 + m_dialogSaveLayout->FileName() + '1'_L1; PdfTiledFile(name); } else diff --git a/src/app/valentina/xml/vpattern.cpp b/src/app/valentina/xml/vpattern.cpp index d770c910e..aad3be434 100644 --- a/src/app/valentina/xml/vpattern.cpp +++ b/src/app/valentina/xml/vpattern.cpp @@ -132,6 +132,8 @@ using namespace bpstd::literals::chrono_literals; #endif // __cplusplus >= 201402L #endif //(defined(Q_CC_GNU) && Q_CC_GNU < 409) && !defined(Q_CC_CLANG) +using namespace Qt::Literals::StringLiterals; + const QString VPattern::AttrReadOnly = QStringLiteral("readOnly"); // NOLINT(cert-err58-cpp) const QString VPattern::AttrLabelPrefix = QStringLiteral("labelPrefix"); // NOLINT(cert-err58-cpp) @@ -471,7 +473,7 @@ auto VPattern::SaveDocument(const QString &fileName, QString &error) -> bool } const bool saved = VAbstractPattern::SaveDocument(fileName, error); - if (saved && QFileInfo(fileName).suffix() != QLatin1String("autosave")) + if (saved && QFileInfo(fileName).suffix() != "autosave"_L1) { modified = false; } @@ -1500,52 +1502,52 @@ auto VPattern::GetLabelBase(quint32 index) const -> QString case 0: // de { const QString al = QStringLiteral("A,Ä,B,C,D,E,F,G,H,I,J,K,L,M,N,O,Ö,P,Q,R,S,ß,T,U,Ü,V,W,X,Y,Z"); - alphabet = al.split(QChar(',')); + alphabet = al.split(','_L1); break; } case 2: // fr { const QString al = QStringLiteral("A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z"); - alphabet = al.split(QChar(',')); + alphabet = al.split(','_L1); break; } case 3: // ru { const QString al = QStringLiteral("А,Б,В,Г,Д,Е,Ж,З,И,К,Л,М,Н,О,П,Р,С,Т,У,Ф,Х,Ц,Ч,Ш,Щ,Э,Ю,Я"); - alphabet = al.split(QChar(',')); + alphabet = al.split(','_L1); break; } case 4: // uk { const QString al = QStringLiteral("А,Б,В,Г,Д,Е,Ж,З,І,Ї,Й,К,Л,М,Н,О,П,Р,С,Т,У,Ф,Х,Ц,Ч,Ш,Щ,Є,Ю,Я"); - alphabet = al.split(QChar(',')); + alphabet = al.split(','_L1); break; } case 5: // hr case 7: // bs { const QString al = QStringLiteral("A,B,C,Č,Ć,D,Dž,Ð,E,F,G,H,I,J,K,L,Lj,M,N,Nj,O,P,R,S,Š,T,U,V,Z,Ž"); - alphabet = al.split(QChar(',')); + alphabet = al.split(','_L1); break; } case 6: // sr { const QString al = QStringLiteral("А,Б,В,Г,Д,Ђ,Е,Ж,З,И,Ј,К,Л,Љ,М,Н,Њ,О,П,Р,С,Т,Ћ,У,Ф,Х,Ц,Ч,Џ,Ш"); - alphabet = al.split(QChar(',')); + alphabet = al.split(','_L1); break; } case 8: // cs { const QString al = QStringLiteral("a,á,b,c,č,d,ď,e,é,ě,f,g,h,ch,i,í,j,k,l,m,n,ň,o,ó,p,q,r,ř,s,š,t,ť,u,ú,ů," "v,w,x,y,ý,z,ž"); - alphabet = al.split(QChar(',')); + alphabet = al.split(','_L1); break; } case 1: // en default: // en { const QString al = QStringLiteral("A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z"); - alphabet = al.split(QChar(',')); + alphabet = al.split(','_L1); break; } } @@ -1640,7 +1642,7 @@ void VPattern::ParseToolEndLine(VMainGraphicsScene *scene, QDomElement &domEleme catch (qmu::QmuParserError &e) { VExceptionObjectError excep(tr("Error creating or updating point of end line"), domElement); - excep.AddMoreInformation(QString("Message: " + e.GetMsg() + "\n" + "Expression: " + e.GetExpr())); + excep.AddMoreInformation("Message: "_L1 + e.GetMsg() + '\n'_L1 + "Expression: "_L1 + e.GetExpr()); throw excep; } } @@ -1690,7 +1692,7 @@ void VPattern::ParseToolAlongLine(VMainGraphicsScene *scene, QDomElement &domEle catch (qmu::QmuParserError &e) { VExceptionObjectError excep(tr("Error creating or updating point along line"), domElement); - excep.AddMoreInformation(QString("Message: " + e.GetMsg() + "\n" + "Expression: " + e.GetExpr())); + excep.AddMoreInformation("Message: "_L1 + e.GetMsg() + '\n'_L1 + "Expression: "_L1 + e.GetExpr()); throw excep; } } @@ -1735,7 +1737,7 @@ void VPattern::ParseToolShoulderPoint(VMainGraphicsScene *scene, QDomElement &do catch (qmu::QmuParserError &e) { VExceptionObjectError excep(tr("Error creating or updating point of shoulder"), domElement); - excep.AddMoreInformation(QString("Message: " + e.GetMsg() + "\n" + "Expression: " + e.GetExpr())); + excep.AddMoreInformation("Message: "_L1 + e.GetMsg() + '\n'_L1 + "Expression: "_L1 + e.GetExpr()); throw excep; } } @@ -1780,7 +1782,7 @@ void VPattern::ParseToolNormal(VMainGraphicsScene *scene, QDomElement &domElemen catch (qmu::QmuParserError &e) { VExceptionObjectError excep(tr("Error creating or updating point of normal"), domElement); - excep.AddMoreInformation(QString("Message: " + e.GetMsg() + "\n" + "Expression: " + e.GetExpr())); + excep.AddMoreInformation("Message: "_L1 + e.GetMsg() + '\n'_L1 + "Expression: "_L1 + e.GetExpr()); throw excep; } } @@ -1825,7 +1827,7 @@ void VPattern::ParseToolBisector(VMainGraphicsScene *scene, QDomElement &domElem catch (qmu::QmuParserError &e) { VExceptionObjectError excep(tr("Error creating or updating point of bisector"), domElement); - excep.AddMoreInformation(QString("Message: " + e.GetMsg() + "\n" + "Expression: " + e.GetExpr())); + excep.AddMoreInformation("Message: "_L1 + e.GetMsg() + '\n'_L1 + "Expression: "_L1 + e.GetExpr()); throw excep; } } @@ -1901,7 +1903,7 @@ void VPattern::ParseToolPointOfContact(VMainGraphicsScene *scene, QDomElement &d catch (qmu::QmuParserError &e) { VExceptionObjectError excep(tr("Error creating or updating point of contact"), domElement); - excep.AddMoreInformation(QString("Message: " + e.GetMsg() + "\n" + "Expression: " + e.GetExpr())); + excep.AddMoreInformation("Message: "_L1 + e.GetMsg() + '\n'_L1 + "Expression: "_L1 + e.GetExpr()); throw excep; } } @@ -2061,7 +2063,7 @@ void VPattern::ParsePlaceLabel(QDomElement &domElement, const Document &parse) catch (qmu::QmuParserError &e) { VExceptionObjectError excep(tr("Error creating or updating place label"), domElement); - excep.AddMoreInformation(QString("Message: " + e.GetMsg() + "\n" + "Expression: " + e.GetExpr())); + excep.AddMoreInformation("Message: "_L1 + e.GetMsg() + '\n'_L1 + "Expression: "_L1 + e.GetExpr()); throw excep; } } @@ -2197,7 +2199,7 @@ void VPattern::ParseToolCutSpline(VMainGraphicsScene *scene, QDomElement &domEle catch (qmu::QmuParserError &e) { VExceptionObjectError excep(tr("Error creating or updating cut spline point"), domElement); - excep.AddMoreInformation(QString("Message: " + e.GetMsg() + "\n" + "Expression: " + e.GetExpr())); + excep.AddMoreInformation("Message: "_L1 + e.GetMsg() + '\n'_L1 + "Expression: "_L1 + e.GetExpr()); throw excep; } } @@ -2242,7 +2244,7 @@ void VPattern::ParseToolCutSplinePath(VMainGraphicsScene *scene, QDomElement &do catch (qmu::QmuParserError &e) { VExceptionObjectError excep(tr("Error creating or updating cut spline path point"), domElement); - excep.AddMoreInformation(QString("Message: " + e.GetMsg() + "\n" + "Expression: " + e.GetExpr())); + excep.AddMoreInformation("Message: "_L1 + e.GetMsg() + '\n'_L1 + "Expression: "_L1 + e.GetExpr()); throw excep; } } @@ -2287,7 +2289,7 @@ void VPattern::ParseToolCutArc(VMainGraphicsScene *scene, QDomElement &domElemen catch (qmu::QmuParserError &e) { VExceptionObjectError excep(tr("Error creating or updating cut arc point"), domElement); - excep.AddMoreInformation(QString("Message: " + e.GetMsg() + "\n" + "Expression: " + e.GetExpr())); + excep.AddMoreInformation("Message: "_L1 + e.GetMsg() + '\n'_L1 + "Expression: "_L1 + e.GetExpr()); throw excep; } } @@ -2334,7 +2336,7 @@ void VPattern::ParseToolLineIntersectAxis(VMainGraphicsScene *scene, QDomElement catch (qmu::QmuParserError &e) { VExceptionObjectError excep(tr("Error creating or updating point of intersection line and axis"), domElement); - excep.AddMoreInformation(QString("Message: " + e.GetMsg() + "\n" + "Expression: " + e.GetExpr())); + excep.AddMoreInformation("Message: "_L1 + e.GetMsg() + '\n'_L1 + "Expression: "_L1 + e.GetExpr()); throw excep; } } @@ -2387,7 +2389,7 @@ void VPattern::ParseToolCurveIntersectAxis(VMainGraphicsScene *scene, QDomElemen catch (qmu::QmuParserError &e) { VExceptionObjectError excep(tr("Error creating or updating point of intersection curve and axis"), domElement); - excep.AddMoreInformation(QString("Message: " + e.GetMsg() + "\n" + "Expression: " + e.GetExpr())); + excep.AddMoreInformation("Message: "_L1 + e.GetMsg() + '\n'_L1 + "Expression: "_L1 + e.GetExpr()); throw excep; } } @@ -2746,7 +2748,7 @@ void VPattern::ParseToolSpline(VMainGraphicsScene *scene, QDomElement &domElemen catch (qmu::QmuParserError &e) { VExceptionObjectError excep(tr("Error creating or updating simple interactive spline"), domElement); - excep.AddMoreInformation(QString("Message: " + e.GetMsg() + "\n" + "Expression: " + e.GetExpr())); + excep.AddMoreInformation("Message: "_L1 + e.GetMsg() + '\n'_L1 + "Expression: "_L1 + e.GetExpr()); throw excep; } } @@ -2966,7 +2968,7 @@ void VPattern::ParseToolSplinePath(VMainGraphicsScene *scene, const QDomElement catch (qmu::QmuParserError &e) { VExceptionObjectError excep(tr("Error creating or updating interactive spline path"), domElement); - excep.AddMoreInformation(QString("Message: " + e.GetMsg() + "\n" + "Expression: " + e.GetExpr())); + excep.AddMoreInformation("Message: "_L1 + e.GetMsg() + '\n'_L1 + "Expression: "_L1 + e.GetExpr()); throw excep; } } @@ -3179,7 +3181,7 @@ void VPattern::ParseToolArc(VMainGraphicsScene *scene, QDomElement &domElement, catch (qmu::QmuParserError &e) { VExceptionObjectError excep(tr("Error creating or updating simple arc"), domElement); - excep.AddMoreInformation(QString("Message: " + e.GetMsg() + "\n" + "Expression: " + e.GetExpr())); + excep.AddMoreInformation("Message: "_L1 + e.GetMsg() + '\n'_L1 + "Expression: "_L1 + e.GetExpr()); throw excep; } } @@ -3239,7 +3241,7 @@ void VPattern::ParseToolEllipticalArc(VMainGraphicsScene *scene, QDomElement &do catch (qmu::QmuParserError &e) { VExceptionObjectError excep(tr("Error creating or updating simple elliptical arc"), domElement); - excep.AddMoreInformation(QString("Message: " + e.GetMsg() + "\n" + "Expression: " + e.GetExpr())); + excep.AddMoreInformation("Message: "_L1 + e.GetMsg() + '\n'_L1 + "Expression: "_L1 + e.GetExpr()); throw excep; } } @@ -3370,7 +3372,7 @@ void VPattern::ParseToolArcWithLength(VMainGraphicsScene *scene, QDomElement &do catch (qmu::QmuParserError &e) { VExceptionObjectError excep(tr("Error creating or updating simple arc"), domElement); - excep.AddMoreInformation(QString("Message: " + e.GetMsg() + "\n" + "Expression: " + e.GetExpr())); + excep.AddMoreInformation("Message: "_L1 + e.GetMsg() + '\n'_L1 + "Expression: "_L1 + e.GetExpr()); throw excep; } } @@ -3416,7 +3418,7 @@ void VPattern::ParseToolRotation(VMainGraphicsScene *scene, QDomElement &domElem catch (qmu::QmuParserError &e) { VExceptionObjectError excep(tr("Error creating or updating operation of rotation"), domElement); - excep.AddMoreInformation(QString("Message: " + e.GetMsg() + "\n" + "Expression: " + e.GetExpr())); + excep.AddMoreInformation("Message: "_L1 + e.GetMsg() + '\n'_L1 + "Expression: "_L1 + e.GetExpr()); throw excep; } } @@ -3532,7 +3534,7 @@ void VPattern::ParseToolMove(VMainGraphicsScene *scene, QDomElement &domElement, catch (qmu::QmuParserError &e) { VExceptionObjectError excep(tr("Error creating or updating operation of moving"), domElement); - excep.AddMoreInformation(QString("Message: " + e.GetMsg() + "\n" + "Expression: " + e.GetExpr())); + excep.AddMoreInformation("Message: "_L1 + e.GetMsg() + '\n'_L1 + "Expression: "_L1 + e.GetExpr()); throw excep; } } diff --git a/src/libs/fervor/fvupdater.cpp b/src/libs/fervor/fvupdater.cpp index fa4dcba4e..0b42d7fc2 100644 --- a/src/libs/fervor/fvupdater.cpp +++ b/src/libs/fervor/fvupdater.cpp @@ -49,17 +49,21 @@ #include "fvavailableupdate.h" #include "fvupdatewindow.h" +#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) +#include "../vmisc/compatibility.h" +#endif + +using namespace Qt::Literals::StringLiterals; + namespace { QT_WARNING_PUSH QT_WARNING_DISABLE_CLANG("-Wunused-member-function") // NOLINTNEXTLINE -Q_GLOBAL_STATIC_WITH_ARGS(const QString, defaultFeedURL, - (QLatin1String("https://valentinaproject.bitbucket.io/Appcast.xml"))) +Q_GLOBAL_STATIC_WITH_ARGS(const QString, defaultFeedURL, ("https://valentinaproject.bitbucket.io/Appcast.xml"_L1)) // NOLINTNEXTLINE -Q_GLOBAL_STATIC_WITH_ARGS(const QString, testFeedURL, - (QLatin1String("https://valentinaproject.bitbucket.io/Appcast_testing.xml"))) +Q_GLOBAL_STATIC_WITH_ARGS(const QString, testFeedURL, ("https://valentinaproject.bitbucket.io/Appcast_testing.xml"_L1)) QT_WARNING_POP } // namespace @@ -416,13 +420,13 @@ auto FvUpdater::xmlParseFeed() -> bool if (m_xml.isStartElement()) { - if (m_xml.name() == QLatin1String("item")) + if (m_xml.name() == "item"_L1) { xmlEnclosureUrl.clear(); xmlEnclosureVersion.clear(); xmlEnclosurePlatform.clear(); } - else if (m_xml.name() == QLatin1String("enclosure")) + else if (m_xml.name() == "enclosure"_L1) { const QXmlStreamAttributes attribs = m_xml.attributes(); const QString fervorPlatform = QStringLiteral("fervor:platform"); @@ -458,7 +462,7 @@ auto FvUpdater::xmlParseFeed() -> bool } else if (m_xml.isEndElement()) { - if (m_xml.name() == QLatin1String("item")) + if (m_xml.name() == "item"_L1) { // That's it - we have analyzed a single and we'll stop // here (because the topmost is the most recent one, and thus diff --git a/src/libs/ifc/exception/vexceptionbadid.cpp b/src/libs/ifc/exception/vexceptionbadid.cpp index 1e2f68846..beb12eaf9 100644 --- a/src/libs/ifc/exception/vexceptionbadid.cpp +++ b/src/libs/ifc/exception/vexceptionbadid.cpp @@ -30,14 +30,24 @@ #include "vexception.h" +#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) +#include "../vmisc/compatibility.h" +#endif + +using namespace Qt::Literals::StringLiterals; + //--------------------------------------------------------------------------------------------------------------------- /** * @brief VExceptionBadId exception bad id * @param error string with error * @param id id */ -VExceptionBadId::VExceptionBadId(const QString &error, const quint32 &id) V_NOEXCEPT_EXPR (true) - :VException(error), id(id), key(QString()){} +VExceptionBadId::VExceptionBadId(const QString &error, const quint32 &id) V_NOEXCEPT_EXPR(true) + : VException(error), + id(id), + key(QString()) +{ +} //--------------------------------------------------------------------------------------------------------------------- /** @@ -45,21 +55,29 @@ VExceptionBadId::VExceptionBadId(const QString &error, const quint32 &id) V_NOEX * @param error string with error * @param key string key */ -VExceptionBadId::VExceptionBadId(const QString &error, const QString &key) V_NOEXCEPT_EXPR (true) - :VException(error), id(NULL_ID), key(key){} +VExceptionBadId::VExceptionBadId(const QString &error, const QString &key) V_NOEXCEPT_EXPR(true) + : VException(error), + id(NULL_ID), + key(key) +{ +} //--------------------------------------------------------------------------------------------------------------------- /** * @brief VExceptionBadId copy constructor * @param e exception */ -VExceptionBadId::VExceptionBadId(const VExceptionBadId &e) V_NOEXCEPT_EXPR (true) - :VException(e), id(e.BadId()), key(e.BadKey()){} +VExceptionBadId::VExceptionBadId(const VExceptionBadId &e) V_NOEXCEPT_EXPR(true) + : VException(e), + id(e.BadId()), + key(e.BadKey()) +{ +} //--------------------------------------------------------------------------------------------------------------------- auto VExceptionBadId::operator=(const VExceptionBadId &e) V_NOEXCEPT_EXPR(true) -> VExceptionBadId & { - if ( &e == this ) + if (&e == this) { return *this; } @@ -79,11 +97,11 @@ auto VExceptionBadId::ErrorMessage() const -> QString QString error; if (key.isEmpty()) { - error = QString("ExceptionBadId: %1, id = %2").arg(this->error).arg(id); + error = u"ExceptionBadId: %1, id = %2"_s.arg(this->error).arg(id); } else { - error = QString("ExceptionBadId: %1, id = %2").arg(this->error, key); + error = u"ExceptionBadId: %1, id = %2"_s.arg(this->error, key); } return error; } diff --git a/src/libs/ifc/exception/vexceptionconversionerror.cpp b/src/libs/ifc/exception/vexceptionconversionerror.cpp index 29d6681ec..2d4263226 100644 --- a/src/libs/ifc/exception/vexceptionconversionerror.cpp +++ b/src/libs/ifc/exception/vexceptionconversionerror.cpp @@ -32,14 +32,21 @@ #include "vexception.h" +#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) +#include "../vmisc/compatibility.h" +#endif + +using namespace Qt::Literals::StringLiterals; + //--------------------------------------------------------------------------------------------------------------------- /** * @brief VExceptionConversionError exception conversion error * @param error string with error * @param str string, where happend error */ -VExceptionConversionError::VExceptionConversionError(const QString &error, const QString &str) V_NOEXCEPT_EXPR (true) - :VException(error), str(str) +VExceptionConversionError::VExceptionConversionError(const QString &error, const QString &str) V_NOEXCEPT_EXPR(true) + : VException(error), + str(str) { Q_ASSERT_X(not str.isEmpty(), Q_FUNC_INFO, "Error converting string is empty"); } @@ -49,15 +56,17 @@ VExceptionConversionError::VExceptionConversionError(const QString &error, const * @brief VExceptionConversionError copy constructor * @param e exception */ -VExceptionConversionError::VExceptionConversionError(const VExceptionConversionError &e) V_NOEXCEPT_EXPR (true) - :VException(e), str(e.String()) -{} +VExceptionConversionError::VExceptionConversionError(const VExceptionConversionError &e) V_NOEXCEPT_EXPR(true) + : VException(e), + str(e.String()) +{ +} //--------------------------------------------------------------------------------------------------------------------- auto VExceptionConversionError::operator=(const VExceptionConversionError &e) V_NOEXCEPT_EXPR(true) -> VExceptionConversionError & { - if ( &e == this ) + if (&e == this) { return *this; } @@ -73,5 +82,5 @@ auto VExceptionConversionError::operator=(const VExceptionConversionError &e) V_ */ auto VExceptionConversionError::ErrorMessage() const -> QString { - return QString("ExceptionConversionError: %1 \"%2\"").arg(error, str); + return u"ExceptionConversionError: %1 \"%2\""_s.arg(error, str); } diff --git a/src/libs/ifc/exception/vexceptionemptyparameter.cpp b/src/libs/ifc/exception/vexceptionemptyparameter.cpp index fcbd525a9..31f61ccd3 100644 --- a/src/libs/ifc/exception/vexceptionemptyparameter.cpp +++ b/src/libs/ifc/exception/vexceptionemptyparameter.cpp @@ -33,6 +33,12 @@ #include "vexception.h" +#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) +#include "../vmisc/compatibility.h" +#endif + +using namespace Qt::Literals::StringLiterals; + //--------------------------------------------------------------------------------------------------------------------- /** * @brief VExceptionEmptyParameter exception empty parameter @@ -41,8 +47,12 @@ * @param domElement dom element */ VExceptionEmptyParameter::VExceptionEmptyParameter(const QString &what, const QString &name, - const QDomElement &domElement) V_NOEXCEPT_EXPR (true) - : VException(what), name(name), tagText(QString()), tagName(QString()), lineNumber(-1) + const QDomElement &domElement) V_NOEXCEPT_EXPR(true) + : VException(what), + name(name), + tagText(QString()), + tagName(QString()), + lineNumber(-1) { Q_ASSERT_X(not domElement.isNull(), Q_FUNC_INFO, "domElement is null"); Q_ASSERT_X(not name.isEmpty(), Q_FUNC_INFO, "Parameter name is empty"); @@ -57,15 +67,20 @@ VExceptionEmptyParameter::VExceptionEmptyParameter(const QString &what, const QS * @brief VExceptionEmptyParameter copy constructor * @param e exception */ -VExceptionEmptyParameter::VExceptionEmptyParameter(const VExceptionEmptyParameter &e) V_NOEXCEPT_EXPR (true) - :VException(e), name(e.Name()), tagText(e.TagText()), tagName(e.TagName()), lineNumber(e.LineNumber()) -{} +VExceptionEmptyParameter::VExceptionEmptyParameter(const VExceptionEmptyParameter &e) V_NOEXCEPT_EXPR(true) + : VException(e), + name(e.Name()), + tagText(e.TagText()), + tagName(e.TagName()), + lineNumber(e.LineNumber()) +{ +} //--------------------------------------------------------------------------------------------------------------------- auto VExceptionEmptyParameter::operator=(const VExceptionEmptyParameter &e) V_NOEXCEPT_EXPR(true) -> VExceptionEmptyParameter & { - if ( &e == this ) + if (&e == this) { return *this; } @@ -84,7 +99,7 @@ auto VExceptionEmptyParameter::operator=(const VExceptionEmptyParameter &e) V_NO */ auto VExceptionEmptyParameter::ErrorMessage() const -> QString { - return QString("ExceptionEmptyParameter: %1 %2").arg(error, name); + return u"ExceptionEmptyParameter: %1 %2"_s.arg(error, name); } //--------------------------------------------------------------------------------------------------------------------- @@ -94,5 +109,5 @@ auto VExceptionEmptyParameter::ErrorMessage() const -> QString */ auto VExceptionEmptyParameter::DetailedInformation() const -> QString { - return MoreInfo(QString("tag: %1 in line %2\nFull tag:\n%3").arg(tagName).arg(lineNumber).arg(tagText)); + return MoreInfo(u"tag: %1 in line %2\nFull tag:\n%3"_s.arg(tagName).arg(lineNumber).arg(tagText)); } diff --git a/src/libs/ifc/exception/vexceptionobjecterror.cpp b/src/libs/ifc/exception/vexceptionobjecterror.cpp index 530164d7f..7c359b7ee 100644 --- a/src/libs/ifc/exception/vexceptionobjecterror.cpp +++ b/src/libs/ifc/exception/vexceptionobjecterror.cpp @@ -33,14 +33,23 @@ #include "vexception.h" +#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) +#include "../vmisc/compatibility.h" +#endif + +using namespace Qt::Literals::StringLiterals; + //--------------------------------------------------------------------------------------------------------------------- /** * @brief VExceptionObjectError exception object error * @param what string with error * @param domElement dom element */ -VExceptionObjectError::VExceptionObjectError(const QString &what, const QDomElement &domElement) V_NOEXCEPT_EXPR (true) - :VException(what), tagText(QString()), tagName(QString()), lineNumber(-1) +VExceptionObjectError::VExceptionObjectError(const QString &what, const QDomElement &domElement) V_NOEXCEPT_EXPR(true) + : VException(what), + tagText(QString()), + tagName(QString()), + lineNumber(-1) { Q_ASSERT_X(not domElement.isNull(), Q_FUNC_INFO, "domElement is null"); QTextStream stream(&tagText); @@ -50,23 +59,31 @@ VExceptionObjectError::VExceptionObjectError(const QString &what, const QDomElem } //--------------------------------------------------------------------------------------------------------------------- -VExceptionObjectError::VExceptionObjectError(const QString &what) V_NOEXCEPT_EXPR (true) - :VException(what), tagText(QString()), tagName(QString()), lineNumber(-1) -{} +VExceptionObjectError::VExceptionObjectError(const QString &what) V_NOEXCEPT_EXPR(true) + : VException(what), + tagText(QString()), + tagName(QString()), + lineNumber(-1) +{ +} //--------------------------------------------------------------------------------------------------------------------- /** * @brief VExceptionObjectError copy constructor * @param e exception */ -VExceptionObjectError::VExceptionObjectError(const VExceptionObjectError &e) V_NOEXCEPT_EXPR (true) - :VException(e), tagText(e.TagText()), tagName(e.TagName()), lineNumber(e.LineNumber()) -{} +VExceptionObjectError::VExceptionObjectError(const VExceptionObjectError &e) V_NOEXCEPT_EXPR(true) + : VException(e), + tagText(e.TagText()), + tagName(e.TagName()), + lineNumber(e.LineNumber()) +{ +} //--------------------------------------------------------------------------------------------------------------------- auto VExceptionObjectError::operator=(const VExceptionObjectError &e) V_NOEXCEPT_EXPR(true) -> VExceptionObjectError & { - if ( &e == this ) + if (&e == this) { return *this; } @@ -84,7 +101,7 @@ auto VExceptionObjectError::operator=(const VExceptionObjectError &e) V_NOEXCEPT */ auto VExceptionObjectError::ErrorMessage() const -> QString { - return QString("ExceptionObjectError: %1").arg(error); + return u"ExceptionObjectError: %1"_s.arg(error); } //--------------------------------------------------------------------------------------------------------------------- @@ -94,5 +111,5 @@ auto VExceptionObjectError::ErrorMessage() const -> QString */ auto VExceptionObjectError::DetailedInformation() const -> QString { - return MoreInfo(QString("tag: %1 in line %2\n%3").arg(tagName).arg(lineNumber).arg(tagText)); + return MoreInfo(u"tag: %1 in line %2\n%3"_s.arg(tagName).arg(lineNumber).arg(tagText)); } diff --git a/src/libs/ifc/exception/vexceptionwrongid.cpp b/src/libs/ifc/exception/vexceptionwrongid.cpp index 7ace9e57e..d3a60dfe6 100644 --- a/src/libs/ifc/exception/vexceptionwrongid.cpp +++ b/src/libs/ifc/exception/vexceptionwrongid.cpp @@ -33,14 +33,23 @@ #include "vexception.h" +#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) +#include "../vmisc/compatibility.h" +#endif + +using namespace Qt::Literals::StringLiterals; + //--------------------------------------------------------------------------------------------------------------------- /** * @brief VExceptionWrongId exception wrong parameter id * @param what string with error * @param domElement som element */ -VExceptionWrongId::VExceptionWrongId(const QString &what, const QDomElement &domElement) V_NOEXCEPT_EXPR (true) - :VException(what), tagText(QString()), tagName(QString()), lineNumber(-1) +VExceptionWrongId::VExceptionWrongId(const QString &what, const QDomElement &domElement) V_NOEXCEPT_EXPR(true) + : VException(what), + tagText(QString()), + tagName(QString()), + lineNumber(-1) { Q_ASSERT_X(not domElement.isNull(), Q_FUNC_INFO, "domElement is null"); QTextStream stream(&tagText); @@ -54,14 +63,18 @@ VExceptionWrongId::VExceptionWrongId(const QString &what, const QDomElement &dom * @brief VExceptionWrongId copy constructor * @param e exception */ -VExceptionWrongId::VExceptionWrongId(const VExceptionWrongId &e) V_NOEXCEPT_EXPR (true) - :VException(e), tagText(e.TagText()), tagName(e.TagName()), lineNumber(e.LineNumber()) -{} +VExceptionWrongId::VExceptionWrongId(const VExceptionWrongId &e) V_NOEXCEPT_EXPR(true) + : VException(e), + tagText(e.TagText()), + tagName(e.TagName()), + lineNumber(e.LineNumber()) +{ +} //--------------------------------------------------------------------------------------------------------------------- auto VExceptionWrongId::operator=(const VExceptionWrongId &e) V_NOEXCEPT_EXPR(true) -> VExceptionWrongId & { - if ( &e == this ) + if (&e == this) { return *this; } @@ -79,7 +92,7 @@ auto VExceptionWrongId::operator=(const VExceptionWrongId &e) V_NOEXCEPT_EXPR(tr */ auto VExceptionWrongId::ErrorMessage() const -> QString { - return QString("ExceptionWrongId: %1").arg(error); + return u"ExceptionWrongId: %1"_s.arg(error); } //--------------------------------------------------------------------------------------------------------------------- @@ -89,5 +102,5 @@ auto VExceptionWrongId::ErrorMessage() const -> QString */ auto VExceptionWrongId::DetailedInformation() const -> QString { - return MoreInfo(QString("tag: %1 in line %2\nFull tag:\n%3").arg(tagName).arg(lineNumber).arg(tagText)); + return MoreInfo(u"tag: %1 in line %2\nFull tag:\n%3"_s.arg(tagName).arg(lineNumber).arg(tagText)); } diff --git a/src/libs/ifc/ifcdef.cpp b/src/libs/ifc/ifcdef.cpp index cae46f034..96b9730ac 100644 --- a/src/libs/ifc/ifcdef.cpp +++ b/src/libs/ifc/ifcdef.cpp @@ -35,6 +35,12 @@ #include #include +#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) +#include "../vmisc/compatibility.h" +#endif + +using namespace Qt::Literals::StringLiterals; + const QString CustomMSign = QStringLiteral("@"); const QString CustomIncrSign = QStringLiteral("#"); @@ -282,8 +288,8 @@ const QString elarc_ = QStringLiteral(ELARC_); const QString splPath = QStringLiteral("SplPath"); const QString radius_V = QStringLiteral("Radius"); const QString radiusArc_ = radius_V + arc_; -const QString radius1ElArc_ = radius_V + QLatin1Char('1') + elarc_; -const QString radius2ElArc_ = radius_V + QLatin1Char('2') + elarc_; +const QString radius1ElArc_ = radius_V + '1'_L1 + elarc_; +const QString radius2ElArc_ = radius_V + '2'_L1 + elarc_; const QString angle1_V = QStringLiteral("Angle1"); const QString angle2_V = QStringLiteral("Angle2"); const QString c1Length_V = QStringLiteral("C1Length"); diff --git a/src/libs/ifc/xml/vabstractconverter.cpp b/src/libs/ifc/xml/vabstractconverter.cpp index 30b1e26e3..3d48eb310 100644 --- a/src/libs/ifc/xml/vabstractconverter.cpp +++ b/src/libs/ifc/xml/vabstractconverter.cpp @@ -30,8 +30,8 @@ #include "vparsererrorhandler.h" #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) -#include #include +#include #else #include #include @@ -54,13 +54,19 @@ #include "../exception/vexception.h" #include "vdomdocument.h" +#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) +#include "../vmisc/compatibility.h" +#endif + +using namespace Qt::Literals::StringLiterals; + //--------------------------------------------------------------------------------------------------------------------- VAbstractConverter::VAbstractConverter(const QString &fileName) - : m_ver(0x0), - m_originalFileName(fileName), - m_convertedFileName(fileName) + : m_ver(0x0), + m_originalFileName(fileName), + m_convertedFileName(fileName) { - setXMLContent(m_convertedFileName);// Throw an exception on error + setXMLContent(m_convertedFileName); // Throw an exception on error } //--------------------------------------------------------------------------------------------------------------------- @@ -99,21 +105,21 @@ auto VAbstractConverter::GetCurrentFormatVersion() const -> unsigned //--------------------------------------------------------------------------------------------------------------------- void VAbstractConverter::ReserveFile() const { - //It's not possible in all cases make conversion without lose data. - //For such cases we will store old version in a reserve file. + // It's not possible in all cases make conversion without lose data. + // For such cases we will store old version in a reserve file. QString error; QFileInfo info(m_convertedFileName); - const QString reserveFileName = QString("%1/%2(v%3).%4.bak") - .arg(info.absoluteDir().absolutePath(), info.baseName(), GetFormatVersionStr(), info.completeSuffix()); + const QString reserveFileName = u"%1/%2(v%3).%4.bak"_s.arg(info.absoluteDir().absolutePath(), info.baseName(), + GetFormatVersionStr(), info.completeSuffix()); if (not SafeCopy(m_convertedFileName, reserveFileName, error)) { -//#ifdef Q_OS_WIN32 -// qt_ntfs_permission_lookup++; // turn checking on -//#endif /*Q_OS_WIN32*/ + // #ifdef Q_OS_WIN32 + // qt_ntfs_permission_lookup++; // turn checking on + // #endif /*Q_OS_WIN32*/ const bool isFileWritable = info.isWritable(); -//#ifdef Q_OS_WIN32 -// qt_ntfs_permission_lookup--; // turn it off again -//#endif /*Q_OS_WIN32*/ + // #ifdef Q_OS_WIN32 + // qt_ntfs_permission_lookup--; // turn it off again + // #endif /*Q_OS_WIN32*/ if (not IsReadOnly() && isFileWritable) { const QString errorMsg(tr("Error creating a reserv copy: %1.").arg(error)); @@ -136,7 +142,7 @@ void VAbstractConverter::CorrectionsPositions(vsizetype position, vsizetype bias { if (bias == 0) { - return;// Nothing to correct; + return; // Nothing to correct; } BiasTokens(position, bias, tokens); @@ -149,13 +155,13 @@ void VAbstractConverter::BiasTokens(vsizetype position, vsizetype bias, QMap::const_iterator i = tokens.constBegin(); while (i != tokens.constEnd()) { - if (i.key()<= position) + if (i.key() <= position) { // Tokens before position "position" did not change his positions. newTokens.insert(i.key(), i.value()); } else { - newTokens.insert(i.key()-bias, i.value()); + newTokens.insert(i.key() - bias, i.value()); } ++i; } @@ -185,15 +191,12 @@ void VAbstractConverter::ValidateXML(const QString &schema) const domParser.setErrorHandler(&parserErrorHandler); QByteArray data = fileSchema.readAll(); - const char* schemaData = data.constData(); + const char *schemaData = data.constData(); - QScopedPointer grammarSource( - new XERCES_CPP_NAMESPACE::MemBufInputSource(reinterpret_cast(schemaData), - strlen(schemaData), "schema")); + QScopedPointer grammarSource(new XERCES_CPP_NAMESPACE::MemBufInputSource( + reinterpret_cast(schemaData), strlen(schemaData), "schema")); - if (domParser.loadGrammar( - *grammarSource, - XERCES_CPP_NAMESPACE::Grammar::SchemaGrammarType, true) == nullptr) + if (domParser.loadGrammar(*grammarSource, XERCES_CPP_NAMESPACE::Grammar::SchemaGrammarType, true) == nullptr) { VException e(parserErrorHandler.StatusMessage()); e.AddMoreInformation(tr("Could not load schema file '%1'.").arg(fileSchema.fileName())); @@ -205,8 +208,10 @@ void VAbstractConverter::ValidateXML(const QString &schema) const if (parserErrorHandler.HasError()) { VException e(parserErrorHandler.StatusMessage()); - e.AddMoreInformation(tr("Schema file %3 invalid in line %1 column %2").arg(parserErrorHandler.Line()) - .arg(parserErrorHandler.Column()).arg(fileSchema.fileName())); + e.AddMoreInformation(tr("Schema file %3 invalid in line %1 column %2") + .arg(parserErrorHandler.Line()) + .arg(parserErrorHandler.Column()) + .arg(fileSchema.fileName())); throw e; } @@ -225,19 +230,20 @@ void VAbstractConverter::ValidateXML(const QString &schema) const } QByteArray patternFileData = pattern.readAll(); - const char* patternData = patternFileData.constData(); + const char *patternData = patternFileData.constData(); - QScopedPointer patternSource( - new XERCES_CPP_NAMESPACE::MemBufInputSource(reinterpret_cast(patternData), - strlen(patternData), "pattern")); + QScopedPointer patternSource(new XERCES_CPP_NAMESPACE::MemBufInputSource( + reinterpret_cast(patternData), strlen(patternData), "pattern")); domParser.parse(*patternSource); if (domParser.getErrorCount() > 0) { VException e(parserErrorHandler.StatusMessage()); - e.AddMoreInformation(tr("Validation error file %3 in line %1 column %2").arg(parserErrorHandler.Line()) - .arg(parserErrorHandler.Column()).arg(m_originalFileName)); + e.AddMoreInformation(tr("Validation error file %3 in line %1 column %2") + .arg(parserErrorHandler.Line()) + .arg(parserErrorHandler.Column()) + .arg(m_originalFileName)); throw e; } #else @@ -250,7 +256,7 @@ void VAbstractConverter::ValidateXML(const QString &schema) const QXmlSchema sch; sch.setMessageHandler(&parserErrorHandler); - if (sch.load(&fileSchema, QUrl::fromLocalFile(fileSchema.fileName()))==false) + if (sch.load(&fileSchema, QUrl::fromLocalFile(fileSchema.fileName())) == false) { VException e(parserErrorHandler.StatusMessage()); e.AddMoreInformation(tr("Could not load schema file '%1'.").arg(fileSchema.fileName())); @@ -275,8 +281,10 @@ void VAbstractConverter::ValidateXML(const QString &schema) const if (errorOccurred) { VException e(parserErrorHandler.StatusMessage()); - e.AddMoreInformation(tr("Validation error file %3 in line %1 column %2").arg(parserErrorHandler.Line()) - .arg(parserErrorHandler.Column()).arg(m_originalFileName)); + e.AddMoreInformation(tr("Validation error file %3 in line %1 column %2") + .arg(parserErrorHandler.Line()) + .arg(parserErrorHandler.Column()) + .arg(m_originalFileName)); throw e; } #endif // QT_VERSION < QT_VERSION_CHECK(6, 0, 0) @@ -309,7 +317,7 @@ void VAbstractConverter::ValidateInputFile(const QString ¤tSchema) const { schema = XSDSchema(m_ver); } - catch(const VException &e) + catch (const VException &e) { if (m_ver < MinVer()) { // Version less than minimally supported version. Can't do anything. @@ -322,7 +330,7 @@ void VAbstractConverter::ValidateInputFile(const QString ¤tSchema) const { // Try to open like the current version. ValidateXML(currentSchema); } - catch(const VException &exp) + catch (const VException &exp) { // Nope, we can't. Q_UNUSED(exp) throw e; @@ -342,7 +350,7 @@ void VAbstractConverter::ValidateInputFile(const QString ¤tSchema) const //--------------------------------------------------------------------------------------------------------------------- void VAbstractConverter::Save() { - m_tmpFile.resize(0);//clear previous content + m_tmpFile.resize(0); // clear previous content const int indent = 4; QTextStream out(&m_tmpFile); #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) @@ -371,7 +379,7 @@ void VAbstractConverter::SetVersion(const QString &version) //--------------------------------------------------------------------------------------------------------------------- auto VAbstractConverter::XSDSchema(unsigned int ver) const -> QString { - const QHash schemas = Schemas(); + const QHash schemas = Schemas(); if (schemas.contains(ver)) { return schemas.value(ver); diff --git a/src/libs/ifc/xml/vabstractpattern.cpp b/src/libs/ifc/xml/vabstractpattern.cpp index 60bd68687..64dd79d64 100644 --- a/src/libs/ifc/xml/vabstractpattern.cpp +++ b/src/libs/ifc/xml/vabstractpattern.cpp @@ -59,6 +59,8 @@ #include "vtoolrecord.h" #include "vvalentinasettings.h" +using namespace Qt::Literals::StringLiterals; + class QDomElement; const QString VAbstractPattern::TagPattern = QStringLiteral("pattern"); @@ -176,7 +178,7 @@ namespace QT_WARNING_PUSH QT_WARNING_DISABLE_CLANG("-Wunused-member-function") -Q_GLOBAL_STATIC_WITH_ARGS(const QString, dimensionDefValue, (QLatin1String("-1"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, dimensionDefValue, ("-1"_L1)) // NOLINT QT_WARNING_POP @@ -256,13 +258,13 @@ auto PrepareGroupTags(QStringList tags) -> QString tag = tag.simplified(); } - return ConvertToStringList(ConvertToSet(tags)).join(','); + return ConvertToStringList(ConvertToSet(tags)).join(','_L1); } //--------------------------------------------------------------------------------------------------------------------- auto StringToTransfrom(const QString &matrix) -> QTransform { - QStringList elements = matrix.split(QChar(';')); + QStringList elements = matrix.split(';'_L1); if (elements.count() == 9) { qreal m11 = elements.at(0).toDouble(); @@ -293,7 +295,7 @@ auto TransformToString(const QTransform &m) -> QString QStringList matrix{NumberToString(m.m11()), NumberToString(m.m12()), NumberToString(m.m13()), NumberToString(m.m21()), NumberToString(m.m22()), NumberToString(m.m23()), NumberToString(m.m31()), NumberToString(m.m32()), NumberToString(m.m33())}; - return matrix.join(QChar(';')); + return matrix.join(';'_L1); } } // namespace @@ -334,7 +336,7 @@ auto VAbstractPattern::ListMeasurements() const -> QStringList for (const auto &token : tokens) { - if (token == QChar('-') || measurements.contains(token) || others.contains(token)) + if (token == '-'_L1 || measurements.contains(token) || others.contains(token)) { continue; } @@ -342,7 +344,7 @@ auto VAbstractPattern::ListMeasurements() const -> QStringList IsVariable(token) || IsFunction(token) ? others.insert(token) : measurements.insert(token); } - return QStringList(measurements.values()); + return {measurements.values()}; } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/ifc/xml/vdomdocument.cpp b/src/libs/ifc/xml/vdomdocument.cpp index 9d66d7d03..5c04bab7f 100644 --- a/src/libs/ifc/xml/vdomdocument.cpp +++ b/src/libs/ifc/xml/vdomdocument.cpp @@ -70,6 +70,12 @@ #include #endif +#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) +#include "../vmisc/compatibility.h" +#endif + +using namespace Qt::Literals::StringLiterals; + namespace { //--------------------------------------------------------------------------------------------------------------------- @@ -606,7 +612,7 @@ auto VDomDocument::GetParametrDouble(const QDomElement &domElement, const QStrin try { QString parametr = GetParametrString(domElement, name, defValue); - param = parametr.replace(QChar(','), QChar('.')).toDouble(&ok); + param = parametr.replace(','_L1, '.'_L1).toDouble(&ok); if (ok == false) { throw VExceptionConversionError(QObject::tr("Can't convert toDouble parameter"), name); @@ -827,7 +833,7 @@ auto VDomDocument::SaveDocument(const QString &fileName, QString &error) -> bool auto VDomDocument::Major() const -> QString { QString version = UniqueTagText(TagVersion, "0.0.0"); - QStringList v = version.split(QChar('.')); + QStringList v = version.split('.'_L1); return v.at(0); } @@ -836,7 +842,7 @@ auto VDomDocument::Major() const -> QString auto VDomDocument::Minor() const -> QString { QString version = UniqueTagText(TagVersion, "0.0.0"); - QStringList v = version.split(QChar('.')); + QStringList v = version.split('.'_L1); return v.at(1); } @@ -845,7 +851,7 @@ auto VDomDocument::Minor() const -> QString auto VDomDocument::Patch() const -> QString { QString version = UniqueTagText(TagVersion, "0.0.0"); - QStringList v = version.split(QChar('.')); + QStringList v = version.split('.'_L1); return v.at(2); } @@ -882,7 +888,7 @@ auto VDomDocument::GetFormatVersion(const QString &version) -> unsigned { ValidateVersion(version); - const QStringList ver = version.split(QChar('.')); + const QStringList ver = version.split('.'_L1); bool ok = false; const unsigned major = ver.at(0).toUInt(&ok); @@ -1029,7 +1035,7 @@ auto VDomDocument::SafeCopy(const QString &source, const QString &destination, Q // qt_ntfs_permission_lookup++; // turn checking on // #endif /*Q_OS_WIN32*/ - QTemporaryFile destFile(destination + QLatin1String(".XXXXXX")); + QTemporaryFile destFile(destination + ".XXXXXX"_L1); destFile.setAutoRemove(false); // Will be renamed to be destination file if (not destFile.open()) { @@ -1151,7 +1157,7 @@ void VDomDocument::ValidateVersion(const QString &version) throw VException(errorMsg); } - if (version == QLatin1String("0.0.0")) + if (version == "0.0.0"_L1) { const QString errorMsg(tr("Version \"0.0.0\" invalid.")); throw VException(errorMsg); diff --git a/src/libs/ifc/xml/vlayoutconverter.cpp b/src/libs/ifc/xml/vlayoutconverter.cpp index e9c29515b..662cb081a 100644 --- a/src/libs/ifc/xml/vlayoutconverter.cpp +++ b/src/libs/ifc/xml/vlayoutconverter.cpp @@ -30,6 +30,12 @@ #include "../ifcdef.h" #include "../vlayout/vlayoutpoint.h" +#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) +#include "../vmisc/compatibility.h" +#endif + +using namespace Qt::Literals::StringLiterals; + /* * Version rules: * 1. Version have three parts "major.minor.patch"; @@ -52,28 +58,28 @@ QT_WARNING_DISABLE_CLANG("-Wunused-member-function") // 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, strSeamLineTag, (QLatin1String("seamLine"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strSeamAllowanceTag, (QLatin1String("seamAllowance"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strInternalPathTag, (QLatin1String("internalPath"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strMarkerTag, (QLatin1String("marker"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strPointTag, (QLatin1String("point"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strPieceTag, (QLatin1String("piece"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strGrainlineTag, (QLatin1String("grainline"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strAttrX, (QLatin1String("x"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strAttrY, (QLatin1String("y"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strAttrTurnPoint, (QLatin1String("turnPoint"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strAttrCurvePoint, (QLatin1String("curvePoint"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strAttrId, (QLatin1String("id"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strAttrUId, (QLatin1String("uid"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strAttrAngle, (QLatin1String("angle"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strAttrArrowDirection, (QLatin1String("arrowDirection"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strSeamLineTag, ("seamLine"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strSeamAllowanceTag, ("seamAllowance"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strInternalPathTag, ("internalPath"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strMarkerTag, ("marker"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strPointTag, ("point"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strPieceTag, ("piece"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strGrainlineTag, ("grainline"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strAttrX, ("x"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strAttrY, ("y"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strAttrTurnPoint, ("turnPoint"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strAttrCurvePoint, ("curvePoint"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strAttrId, ("id"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strAttrUId, ("uid"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strAttrAngle, ("angle"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strAttrArrowDirection, ("arrowDirection"_L1)) // NOLINT QT_WARNING_POP -const QChar groupSep = QLatin1Char(';'); -const QChar coordintatesSep = QLatin1Char(','); -const QChar pointsSep = QLatin1Char(' '); -// const QChar itemsSep = QLatin1Char('*'); +const QChar groupSep = ';'_L1; +const QChar coordintatesSep = ','_L1; +const QChar pointsSep = ' '_L1; +// const QChar itemsSep = '*'_L1; //--------------------------------------------------------------------------------------------------------------------- auto StringV0_1_2ToPoint(const QString &point) -> QPointF @@ -307,17 +313,17 @@ void VLayoutConverter::ConvertPiecesToV0_1_5() switch (arrows.indexOf(arrowDirection)) { case 0: // at front - SetAttribute(node, *strAttrArrowDirection, QLatin1String("oneWayUp")); + SetAttribute(node, *strAttrArrowDirection, "oneWayUp"_L1); break; case 1: // at rear - SetAttribute(node, *strAttrArrowDirection, QLatin1String("oneWayDown")); + SetAttribute(node, *strAttrArrowDirection, "oneWayDown"_L1); break; case 2: // at four way - SetAttribute(node, *strAttrArrowDirection, QLatin1String("fourWays")); + SetAttribute(node, *strAttrArrowDirection, "fourWays"_L1); break; case 3: // at both default: - SetAttribute(node, *strAttrArrowDirection, QLatin1String("twoWaysUpDown")); + SetAttribute(node, *strAttrArrowDirection, "twoWaysUpDown"_L1); break; } } diff --git a/src/libs/ifc/xml/vpatternconverter.cpp b/src/libs/ifc/xml/vpatternconverter.cpp index 8042c1855..9b712c551 100644 --- a/src/libs/ifc/xml/vpatternconverter.cpp +++ b/src/libs/ifc/xml/vpatternconverter.cpp @@ -46,6 +46,12 @@ #include "../qmuparser/qmutokenparser.h" #include "../vmisc/def.h" +#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) +#include "../vmisc/compatibility.h" +#endif + +using namespace Qt::Literals::StringLiterals; + class QDomElement; /* @@ -70,111 +76,111 @@ QT_WARNING_DISABLE_CLANG("-Wunused-member-function") // 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"))) // 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, strUnit, ("unit"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strVersion, ("version"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strName, ("name"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strBase, ("base"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strFormula, ("formula"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strId, ("id"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strKGrowth, ("kgrowth"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strKSize, ("ksize"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strPoint, ("point"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strLength, ("length"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strAngle, ("angle"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strC1Radius, ("c1Radius"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strC2Radius, ("c2Radius"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strCRadius, ("cRadius"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strArc, ("arc"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strAngle1, ("angle1"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strAngle2, ("angle2"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strRadius, ("radius"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strPathPoint, ("pathPoint"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strKAsm1, ("kAsm1"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strKAsm2, ("kAsm2"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strPath, ("path"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strType, ("type"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strCutArc, ("cutArc"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strSpline, ("spline"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strSplinePath, ("splinePath"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strCutSpline, ("cutSpline"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strCutSplinePath, ("cutSplinePath"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strColor, ("color"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strMeasurements, ("measurements"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strIncrement, ("increment"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strIncrements, ("increments"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strPreviewCalculations, ("previewCalculations"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strModeling, ("modeling"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strTools, ("tools"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strIdTool, ("idTool"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strIdObject, ("idObject"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strChildren, ("children"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strChild, ("child"_L1)) // NOLINT // NOLINTNEXTLINE -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strPointOfIntersectionCurves, (QLatin1String("pointOfIntersectionCurves"))) -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, strPointOfIntersectionCurves, ("pointOfIntersectionCurves"_L1)) +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strCurveIntersectAxis, ("curveIntersectAxis"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strCurve, ("curve"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strCurve1, ("curve1"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strCurve2, ("curve2"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strModelingPath, ("modelingPath"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strModelingSpline, ("modelingSpline"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strPointFromArcAndTangent, ("pointFromArcAndTangent"_L1)) // NOLINT // NOLINTNEXTLINE -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strPointOfIntersectionArcs, (QLatin1String("pointOfIntersectionArcs"))) -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 -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strFirstToCountour, (QLatin1String("firstToCountour"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strFirstToContour, (QLatin1String("firstToContour"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strLastToCountour, (QLatin1String("lastToCountour"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strLastToContour, (QLatin1String("lastToContour"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strPointOfIntersectionArcs, ("pointOfIntersectionArcs"_L1)) +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strFirstArc, ("firstArc"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strSecondArc, ("secondArc"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strDetail, ("detail"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strSupplement, ("supplement"_L1)) // NOLINT +// Q_GLOBAL_STATIC_WITH_ARGS(const QString, strClosed, ("closed"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strWidth, ("width"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strHeight, ("height"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strNode, ("node"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strNodes, ("nodes"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strData, ("data"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strPatternInfo, ("patternInfo"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strGrainline, ("grainline"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strReverse, ("reverse"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strMx, ("mx"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strMy, ("my"_L1)) // NOLINT +// Q_GLOBAL_STATIC_WITH_ARGS(const QString, strForbidFlipping, ("forbidFlipping"_L1)) // NOLINT +// Q_GLOBAL_STATIC_WITH_ARGS(const QString, strInLayout, ("inLayout"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strSeamAllowance, ("seamAllowance"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strUUID, ("uuid"_L1)) // NOLINT +// Q_GLOBAL_STATIC_WITH_ARGS(const QString, strNodeType, ("nodeType"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strDet, ("det"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strTypeObject, ("typeObject"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strReadOnly, ("readOnly"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strPatternLabel, ("patternLabel"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strImage, ("image"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strAuthor, ("author"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strDescription, ("description"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strNotes, ("notes"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strGradation, ("gradation"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strPatternName, ("patternName"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strPatternNum, ("patternNumber"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strCompanyName, ("company"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strCustomerName, ("customer"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strLine, ("line"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strText, ("text"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strBold, ("bold"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strItalic, ("italic"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strAlignment, ("alignment"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strFSIncrement, ("sfIncrement"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strShowDate, ("showDate"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strShowMeasurements, ("showMeasurements"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strSize, ("size"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strMCP, ("mcp"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strLetter, ("letter"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strMaterial, ("material"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strUserDefined, ("userDef"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strPlacement, ("placement"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strCutNumber, ("cutNumber"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strQuantity, ("quantity"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strExtension, ("extension"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strContentType, ("contentType"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strFirstToCountour, ("firstToCountour"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strFirstToContour, ("firstToContour"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strLastToCountour, ("lastToCountour"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strLastToContour, ("lastToContour"_L1)) // NOLINT QT_WARNING_POP } // anonymous namespace @@ -629,7 +635,7 @@ auto VPatternConverter::FixIncrementsToV0_2_0() -> QSet { const QString name = GetParametrString(domElement, *strName); names.insert(name); - domElement.setAttribute(*strName, QLatin1String("#") + name); + domElement.setAttribute(*strName, '#'_L1 + name); const QString base = GetParametrString(domElement, *strBase); domElement.setAttribute(*strFormula, base); diff --git a/src/libs/ifc/xml/vvitconverter.cpp b/src/libs/ifc/xml/vvitconverter.cpp index 32d076fac..dee9de3de 100644 --- a/src/libs/ifc/xml/vvitconverter.cpp +++ b/src/libs/ifc/xml/vvitconverter.cpp @@ -40,6 +40,12 @@ #include "vabstractmconverter.h" +#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) +#include "../vmisc/compatibility.h" +#endif + +using namespace Qt::Literals::StringLiterals; + /* * Version rules: * 1. Version have three parts "major.minor.patch"; @@ -62,11 +68,11 @@ QT_WARNING_DISABLE_CLANG("-Wunused-member-function") // 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"))) // 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 +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strTagRead_Only, ("read-only"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strGivenName, ("given-name"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strFamilyName, ("family-name"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strCustomer, ("customer"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strPersonal, ("personal"_L1)) // NOLINT QT_WARNING_POP } // namespace @@ -330,7 +336,7 @@ void VVITConverter::ConverCustomerNameToV0_4_0() QString customerName; if (not givenName.isEmpty() && not familyName.isEmpty()) { - customerName = givenName + QLatin1Char(' ') + familyName; + customerName = givenName + ' '_L1 + familyName; } else if (not givenName.isEmpty() && familyName.isEmpty()) { diff --git a/src/libs/ifc/xml/vvstconverter.cpp b/src/libs/ifc/xml/vvstconverter.cpp index 5e8189cb0..92da2b3f3 100644 --- a/src/libs/ifc/xml/vvstconverter.cpp +++ b/src/libs/ifc/xml/vvstconverter.cpp @@ -41,6 +41,12 @@ #include "../vmisc/def.h" #include "vabstractmconverter.h" +#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) +#include "../vmisc/compatibility.h" +#endif + +using namespace Qt::Literals::StringLiterals; + /* * Version rules: * 1. Version have three parts "major.minor.patch"; @@ -61,10 +67,10 @@ namespace QT_WARNING_PUSH QT_WARNING_DISABLE_CLANG("-Wunused-member-function") -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 +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strTagRead_Only, ("read-only"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strAttrCircumference, ("circumference"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strAttrMeasurement, ("measurement"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strTagDimension, ("dimension"_L1)) // NOLINT QT_WARNING_POP } // namespace diff --git a/src/libs/vformat/vdimensions.h b/src/libs/vformat/vdimensions.h index f37f523e2..825f1559d 100644 --- a/src/libs/vformat/vdimensions.h +++ b/src/libs/vformat/vdimensions.h @@ -39,7 +39,7 @@ #include "../vmisc/defglobal.h" #endif // QT_VERSION < QT_VERSION_CHECK(5, 13, 0) -enum class MeasurementDimension: qint8 +enum class MeasurementDimension : qint8 { X = 0, // height Y = 1, // size (chest half circumference) @@ -112,13 +112,14 @@ template inline auto VFuzzyValue(const QMap &c, qreal val class VAbstartMeasurementDimension { Q_DECLARE_TR_FUNCTIONS(VAbstartMeasurementDimension) // NOLINT + public: - VAbstartMeasurementDimension() =default; + VAbstartMeasurementDimension() = default; explicit VAbstartMeasurementDimension(Unit units); VAbstartMeasurementDimension(Unit units, qreal min, qreal max, qreal step); - virtual ~VAbstartMeasurementDimension() =default; + virtual ~VAbstartMeasurementDimension() = default; - virtual auto Type() const -> MeasurementDimension =0; + virtual auto Type() const -> MeasurementDimension = 0; auto IsValid() -> bool; @@ -144,7 +145,7 @@ public: auto RangeMin() const -> int; auto RangeMax() const -> int; - virtual auto Axis() const -> QChar =0; + virtual auto Axis() const -> QChar = 0; auto Name() const -> QString; @@ -171,15 +172,15 @@ protected: private: Q_DISABLE_COPY_MOVE(VAbstartMeasurementDimension) // NOLINT - Unit m_units{Unit::Cm}; - qreal m_minValue{0}; - qreal m_maxValue{0}; - qreal m_step{-1}; - qreal m_baseValue{0}; + Unit m_units{Unit::Cm}; + qreal m_minValue{0}; + qreal m_maxValue{0}; + qreal m_step{-1}; + qreal m_baseValue{0}; mutable QString m_error{}; - DimesionLabels m_labels{}; - bool m_measurement{true}; - QString m_customName{}; + DimesionLabels m_labels{}; + bool m_measurement{true}; + QString m_customName{}; }; //--------------------------------------------------------------------------------------------------------------------- @@ -283,10 +284,10 @@ inline void VAbstartMeasurementDimension::SetCustomName(const QString &newCustom class VXMeasurementDimension : public VAbstartMeasurementDimension { public: - VXMeasurementDimension() =default; + VXMeasurementDimension() = default; explicit VXMeasurementDimension(Unit units); VXMeasurementDimension(Unit units, qreal min, qreal max, qreal step); - ~VXMeasurementDimension() override =default; + ~VXMeasurementDimension() override = default; auto Type() const -> MeasurementDimension override; @@ -305,7 +306,7 @@ inline auto VXMeasurementDimension::Type() const -> MeasurementDimension //--------------------------------------------------------------------------------------------------------------------- inline auto VXMeasurementDimension::Axis() const -> QChar { - return QChar('X'); + return QLatin1Char('X'); } // VYMeasurementDimension @@ -313,10 +314,10 @@ inline auto VXMeasurementDimension::Axis() const -> QChar class VYMeasurementDimension : public VAbstartMeasurementDimension { public: - VYMeasurementDimension() =default; + VYMeasurementDimension() = default; explicit VYMeasurementDimension(Unit units); VYMeasurementDimension(Unit units, qreal min, qreal max, qreal step); - ~VYMeasurementDimension() override =default; + ~VYMeasurementDimension() override = default; auto Type() const -> MeasurementDimension override; @@ -335,7 +336,7 @@ inline auto VYMeasurementDimension::Type() const -> MeasurementDimension //--------------------------------------------------------------------------------------------------------------------- inline auto VYMeasurementDimension::Axis() const -> QChar { - return QChar('Y'); + return QLatin1Char('Y'); } // VWMeasurementDimension @@ -343,10 +344,10 @@ inline auto VYMeasurementDimension::Axis() const -> QChar class VWMeasurementDimension : public VAbstartMeasurementDimension { public: - VWMeasurementDimension() =default; + VWMeasurementDimension() = default; explicit VWMeasurementDimension(Unit units); VWMeasurementDimension(Unit units, qreal min, qreal max, qreal step); - ~VWMeasurementDimension() override =default; + ~VWMeasurementDimension() override = default; auto Type() const -> MeasurementDimension override; @@ -365,7 +366,7 @@ inline auto VWMeasurementDimension::Type() const -> MeasurementDimension //--------------------------------------------------------------------------------------------------------------------- inline auto VWMeasurementDimension::Axis() const -> QChar { - return QChar('W'); + return QLatin1Char('W'); } // VZMeasurementDimension @@ -373,10 +374,10 @@ inline auto VWMeasurementDimension::Axis() const -> QChar class VZMeasurementDimension : public VAbstartMeasurementDimension { public: - VZMeasurementDimension() =default; + VZMeasurementDimension() = default; explicit VZMeasurementDimension(Unit units); VZMeasurementDimension(Unit units, qreal min, qreal max, qreal step); - ~VZMeasurementDimension() override =default; + ~VZMeasurementDimension() override = default; auto Type() const -> MeasurementDimension override; @@ -395,7 +396,7 @@ inline auto VZMeasurementDimension::Type() const -> MeasurementDimension //--------------------------------------------------------------------------------------------------------------------- inline auto VZMeasurementDimension::Axis() const -> QChar { - return QChar('Z'); + return QLatin1Char('Z'); } class VDimensionRestriction @@ -415,6 +416,7 @@ public: void SetExcludeValues(const QSet &exclude); auto GetExcludeValues() const -> QSet; + private: qreal m_min{0}; qreal m_max{0}; diff --git a/src/libs/vformat/vmeasurements.cpp b/src/libs/vformat/vmeasurements.cpp index c42e08074..b8029c557 100644 --- a/src/libs/vformat/vmeasurements.cpp +++ b/src/libs/vformat/vmeasurements.cpp @@ -54,6 +54,12 @@ #include "../vpatterndb/vcontainer.h" #include "def.h" +#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) +#include "../vmisc/compatibility.h" +#endif + +using namespace Qt::Literals::StringLiterals; + const QString VMeasurements::TagVST = QStringLiteral("vst"); const QString VMeasurements::TagVIT = QStringLiteral("vit"); const QString VMeasurements::TagBodyMeasurements = QStringLiteral("body-measurements"); @@ -111,14 +117,14 @@ namespace QT_WARNING_PUSH QT_WARNING_DISABLE_CLANG("-Wunused-member-function") -Q_GLOBAL_STATIC_WITH_ARGS(const QString, defBirthDate, (QLatin1String("1800-01-01"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, defBirthDate, ("1800-01-01"_L1)) // NOLINT QT_WARNING_POP //--------------------------------------------------------------------------------------------------------------------- auto FileComment() -> QString { - return QString("Measurements created with Valentina v%1 (https://smart-pattern.com.ua/).").arg(AppVersionStr()); + return u"Measurements created with Valentina v%1 (https://smart-pattern.com.ua/)."_s.arg(AppVersionStr()); } } // namespace @@ -1295,7 +1301,7 @@ auto VMeasurements::UniqueTagAttr(const QString &tag, const QString &attr, qreal const QDomElement domElement = domNode.toElement(); if (domElement.isNull() == false) { - return GetParametrDouble(domElement, attr, QString("%1").arg(defVal)); + return GetParametrDouble(domElement, attr, u"%1"_s.arg(defVal)); } } } @@ -1476,7 +1482,7 @@ auto VMeasurements::EvalFormula(VContainer *data, const QString &formula, bool * auto VMeasurements::ClearPMCode(const QString &code) const -> QString { QString clear = code; - const vsizetype index = clear.indexOf(QLatin1Char('p')); + const vsizetype index = clear.indexOf('p'_L1); if (index == 0) { clear.remove(0, 1); diff --git a/src/libs/vformat/vpatternrecipe.cpp b/src/libs/vformat/vpatternrecipe.cpp index 635caec19..c1b826435 100644 --- a/src/libs/vformat/vpatternrecipe.cpp +++ b/src/libs/vformat/vpatternrecipe.cpp @@ -75,6 +75,12 @@ #include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/vtooltriangle.h" #include "../vtools/tools/drawTools/vtoolline.h" +#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) +#include "../vmisc/compatibility.h" +#endif + +using namespace Qt::Literals::StringLiterals; + namespace { #define TagStep QStringLiteral("step") @@ -496,11 +502,10 @@ auto VPatternRecipe::FinalMeasurement(const VFinalMeasurement &fm, const VContai const qreal result = cal->EvalFormula(data.DataVariables(), fm.formula); if (qIsInf(result) || qIsNaN(result)) { - const QString errorMsg = QString("%1\n\n%1") - .arg(tr("Reading final measurements error."), - tr("Value for final measurtement '%1' is infinite or NaN. " - "Please, check your calculations.") - .arg(fm.name)); + const QString errorMsg = u"%1\n\n%1"_s.arg(tr("Reading final measurements error."), + tr("Value for final measurtement '%1' is infinite or NaN. " + "Please, check your calculations.") + .arg(fm.name)); VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) : qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; diff --git a/src/libs/vformat/vwatermark.cpp b/src/libs/vformat/vwatermark.cpp index 8cd0c5119..3b4f28dd1 100644 --- a/src/libs/vformat/vwatermark.cpp +++ b/src/libs/vformat/vwatermark.cpp @@ -31,6 +31,8 @@ #include "../vmisc/compatibility.h" #include "../vmisc/projectversion.h" +using namespace Qt::Literals::StringLiterals; + const QString VWatermark::TagWatermark = QStringLiteral("watermark"); const QString VWatermark::TagText = QStringLiteral("text"); const QString VWatermark::TagImage = QStringLiteral("image"); @@ -47,7 +49,7 @@ namespace //--------------------------------------------------------------------------------------------------------------------- auto FileComment() -> QString { - return QString("Watermark created with Valentina v%1 (https://smart-pattern.com.ua/).").arg(AppVersionStr()); + return u"Watermark created with Valentina v%1 (https://smart-pattern.com.ua/)."_s.arg(AppVersionStr()); } } // namespace diff --git a/src/libs/vganalytics/vganalytics.cpp b/src/libs/vganalytics/vganalytics.cpp index ae7c87bb1..e43bd1b63 100644 --- a/src/libs/vganalytics/vganalytics.cpp +++ b/src/libs/vganalytics/vganalytics.cpp @@ -68,6 +68,12 @@ using namespace bpstd::literals::chrono_literals; #endif // __cplusplus >= 201402L #endif //(defined(Q_CC_GNU) && Q_CC_GNU < 409) && !defined(Q_CC_CLANG) +#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) +#include "../vmisc/compatibility.h" +#endif + +using namespace Qt::Literals::StringLiterals; + namespace { @@ -179,7 +185,7 @@ auto VGAnalytics::RepoRevision() const -> QString //--------------------------------------------------------------------------------------------------------------------- void VGAnalytics::SetGUILanguage(const QString &language) { - d->m_guiLanguage = language.toLower().replace(QChar('_'), QChar('-')); + d->m_guiLanguage = language.toLower().replace('_'_L1, '-'_L1); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vganalytics/vganalyticsworker.cpp b/src/libs/vganalytics/vganalyticsworker.cpp index 1d327212d..bd2c7157e 100644 --- a/src/libs/vganalytics/vganalyticsworker.cpp +++ b/src/libs/vganalytics/vganalyticsworker.cpp @@ -39,6 +39,12 @@ #include #include +#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) +#include "../vmisc/compatibility.h" +#endif + +using namespace Qt::Literals::StringLiterals; + const QLatin1String VGAnalyticsWorker::dateTimeFormat("yyyy,MM,dd-hh:mm::ss:zzz"); namespace @@ -56,7 +62,7 @@ VGAnalyticsWorker::VGAnalyticsWorker(QObject *parent) m_request.setHeader(QNetworkRequest::ContentTypeHeader, "application/json; charset=utf-8"); m_request.setHeader(QNetworkRequest::UserAgentHeader, GetUserAgent()); - m_guiLanguage = QLocale::system().name().toLower().replace(QChar('_'), QChar('-')); + m_guiLanguage = QLocale::system().name().toLower().replace('_'_L1, '-'_L1); m_screensNumber = QString::number(QGuiApplication::screens().size()); @@ -212,7 +218,7 @@ auto VGAnalyticsWorker::PostMessage() -> QNetworkReply * QString connection = QStringLiteral("close"); if (m_messageQueue.count() > 1) { - connection = QLatin1String("keep-alive"); + connection = "keep-alive"_L1; } QueryBuffer buffer = m_messageQueue.head(); diff --git a/src/libs/vgeometry/vabstractcubicbezierpath.cpp b/src/libs/vgeometry/vabstractcubicbezierpath.cpp index a1b16691a..083f48690 100644 --- a/src/libs/vgeometry/vabstractcubicbezierpath.cpp +++ b/src/libs/vgeometry/vabstractcubicbezierpath.cpp @@ -32,23 +32,29 @@ #include #include -#include "../vmisc/def.h" -#include "../ifc/ifcdef.h" #include "../ifc/exception/vexception.h" +#include "../ifc/ifcdef.h" +#include "../vmisc/def.h" +#include "vabstractapplication.h" #include "vpointf.h" #include "vspline.h" -#include "vabstractapplication.h" + +#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) +#include "../vmisc/compatibility.h" +#endif + +using namespace Qt::Literals::StringLiterals; //--------------------------------------------------------------------------------------------------------------------- VAbstractCubicBezierPath::VAbstractCubicBezierPath(const GOType &type, const quint32 &idObject, const Draw &mode) - : VAbstractBezier(type, idObject, mode) + : VAbstractBezier(type, idObject, mode) { } //--------------------------------------------------------------------------------------------------------------------- auto VAbstractCubicBezierPath::operator=(const VAbstractCubicBezierPath &curve) -> VAbstractCubicBezierPath & { - if ( &curve == this ) + if (&curve == this) { return *this; } @@ -162,15 +168,15 @@ auto VAbstractCubicBezierPath::Segment(const QPointF &p) const -> int * @return cutting point. */ auto VAbstractCubicBezierPath::CutSplinePath(qreal length, qint32 &p1, qint32 &p2, QPointF &spl1p2, QPointF &spl1p3, - QPointF &spl2p2, QPointF &spl2p3, - const QString &pointName) const -> QPointF + QPointF &spl2p2, QPointF &spl2p3, const QString &pointName) const + -> QPointF { if (CountSubSpl() < 1) { throw VException(tr("Can't cut this spline")); } - //Always need return two spline paths, so we must correct wrong length. + // Always need return two spline paths, so we must correct wrong length. qreal fullLength = GetLength(); if (fullLength <= minLength) @@ -179,8 +185,9 @@ auto VAbstractCubicBezierPath::CutSplinePath(qreal length, qint32 &p1, qint32 &p spl1p2 = spl1p3 = spl2p2 = spl2p3 = QPointF(); const QString errorMsg = tr("Unable to cut curve '%1'. The curve is too short.").arg(name()); - VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) : - qWarning() << VAbstractApplication::warningMessageSignature + errorMsg; + VAbstractApplication::VApp()->IsPedantic() + ? throw VException(errorMsg) + : qWarning() << VAbstractApplication::warningMessageSignature + errorMsg; return {}; } @@ -195,15 +202,16 @@ auto VAbstractCubicBezierPath::CutSplinePath(qreal length, qint32 &p1, qint32 &p if (not pointName.isEmpty()) { errorMsg = tr("Curve '%1'. Length of a cut segment (%2) is too small. Optimize it to minimal value.") - .arg(name(), pointName); + .arg(name(), pointName); } else { - errorMsg = tr("Curve '%1'. Length of a cut segment is too small. Optimize it to minimal value.") - .arg(name()); + errorMsg = + tr("Curve '%1'. Length of a cut segment is too small. Optimize it to minimal value.").arg(name()); } - VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) : - qWarning() << VAbstractApplication::warningMessageSignature + errorMsg; + VAbstractApplication::VApp()->IsPedantic() + ? throw VException(errorMsg) + : qWarning() << VAbstractApplication::warningMessageSignature + errorMsg; } else if (length > maxLength) { @@ -213,15 +221,15 @@ auto VAbstractCubicBezierPath::CutSplinePath(qreal length, qint32 &p1, qint32 &p if (not pointName.isEmpty()) { errorMsg = tr("Curve '%1'. Length of a cut segment (%2) is too big. Optimize it to maximal value.") - .arg(name(), pointName); + .arg(name(), pointName); } else { - errorMsg = tr("Curve '%1'. Length of a cut segment is too big. Optimize it to maximal value.") - .arg(name()); + errorMsg = tr("Curve '%1'. Length of a cut segment is too big. Optimize it to maximal value.").arg(name()); } - VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) : - qWarning() << VAbstractApplication::warningMessageSignature + errorMsg; + VAbstractApplication::VApp()->IsPedantic() + ? throw VException(errorMsg) + : qWarning() << VAbstractApplication::warningMessageSignature + errorMsg; } fullLength = 0; @@ -232,10 +240,10 @@ auto VAbstractCubicBezierPath::CutSplinePath(qreal length, qint32 &p1, qint32 &p fullLength += splLength; if (fullLength > length) { - p1 = i-1; + p1 = i - 1; p2 = i; - const QPointF point = spl.CutSpline(length - (fullLength - splLength), spl1p2, spl1p3, spl2p2, spl2p3, - pointName); + const QPointF point = + spl.CutSpline(length - (fullLength - splLength), spl1p2, spl1p3, spl2p2, spl2p3, pointName); const QVector points = GetSplinePath(); @@ -248,7 +256,7 @@ auto VAbstractCubicBezierPath::CutSplinePath(qreal length, qint32 &p1, qint32 &p spl1p2.rx() += ToPixel(0.1, Unit::Mm); QLineF line(splP1.P().toQPointF(), spl1p2); line.setLength(ToPixel(0.1, Unit::Mm)); - line.setAngle(splP1.Angle1()+180); + line.setAngle(splP1.Angle1() + 180); spl1p2 = line.p2(); } } @@ -261,7 +269,7 @@ auto VAbstractCubicBezierPath::CutSplinePath(qreal length, qint32 &p1, qint32 &p { spl2p3.rx() += ToPixel(0.1, Unit::Mm); QLineF line(splP2.P().toQPointF(), spl2p3); - line.setAngle(splP2.Angle2()+180); + line.setAngle(splP2.Angle2() + 180); spl2p3 = line.p2(); } } @@ -285,15 +293,15 @@ auto VAbstractCubicBezierPath::NameForHistory(const QString &toolName) const -> QString name = toolName; if (CountPoints() > 0) { - name += QString(" %1").arg(FirstPoint().name()); + name += u" %1"_s.arg(FirstPoint().name()); if (CountSubSpl() >= 1) { - name += QString("_%1").arg(LastPoint().name()); + name += u"_%1"_s.arg(LastPoint().name()); } if (GetDuplicate() > 0) { - name += QString("_%1").arg(GetDuplicate()); + name += u"_%1"_s.arg(GetDuplicate()); } } @@ -301,10 +309,10 @@ auto VAbstractCubicBezierPath::NameForHistory(const QString &toolName) const -> if (not GetAliasSuffix().isEmpty()) { - alias = QString("%1 %2").arg(toolName, GetAliasSuffix()); + alias = u"%1 %2"_s.arg(toolName, GetAliasSuffix()); } - return not alias.isEmpty() ? QString("%1 (%2)").arg(alias, name) : name; + return not alias.isEmpty() ? u"%1 (%2)"_s.arg(alias, name) : name; } //--------------------------------------------------------------------------------------------------------------------- @@ -314,14 +322,14 @@ void VAbstractCubicBezierPath::CreateName() if (CountPoints() > 0) { name = splPath; - name.append(QString("_%1").arg(FirstPoint().name())); + name.append(u"_%1"_s.arg(FirstPoint().name())); if (CountSubSpl() >= 1) { - name.append(QString("_%1").arg(LastPoint().name())); + name.append(u"_%1"_s.arg(LastPoint().name())); if (GetDuplicate() > 0) { - name += QString("_%1").arg(GetDuplicate()); + name += u"_%1"_s.arg(GetDuplicate()); } } } diff --git a/src/libs/vgeometry/vgeometrydef.cpp b/src/libs/vgeometry/vgeometrydef.cpp index 205ac96f9..cb0959889 100644 --- a/src/libs/vgeometry/vgeometrydef.cpp +++ b/src/libs/vgeometry/vgeometrydef.cpp @@ -29,13 +29,19 @@ #include "vgeometrydef.h" #if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) -# include "../vmisc/vdatastreamenum.h" +#include "../vmisc/vdatastreamenum.h" #endif #include "../ifc/exception/vexception.h" #include +#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) +#include "../vmisc/compatibility.h" +#endif + +using namespace Qt::Literals::StringLiterals; + const quint32 VLayoutPassmark::streamHeader = 0x943E2759; // CRC-32Q string "VLayoutPassmark" const quint16 VLayoutPassmark::classVersion = 2; @@ -59,8 +65,8 @@ auto operator>>(QDataStream &dataStream, VLayoutPassmark &data) -> QDataStream & { QString message = QCoreApplication::tr("VLayoutPassmark prefix mismatch error: actualStreamHeader = 0x%1 and " "streamHeader = 0x%2") - .arg(actualStreamHeader, 8, 0x10, QChar('0')) - .arg(VLayoutPassmark::streamHeader, 8, 0x10, QChar('0')); + .arg(actualStreamHeader, 8, 0x10, '0'_L1) + .arg(VLayoutPassmark::streamHeader, 8, 0x10, '0'_L1); throw VException(message); } @@ -71,7 +77,8 @@ auto operator>>(QDataStream &dataStream, VLayoutPassmark &data) -> QDataStream & { QString message = QCoreApplication::tr("VLayoutPassmark compatibility error: actualClassVersion = %1 and " "classVersion = %2") - .arg(actualClassVersion).arg(VLayoutPassmark::classVersion); + .arg(actualClassVersion) + .arg(VLayoutPassmark::classVersion); throw VException(message); } diff --git a/src/libs/vgeometry/vlayoutplacelabel.cpp b/src/libs/vgeometry/vlayoutplacelabel.cpp index 8c87ace34..7fde679c5 100644 --- a/src/libs/vgeometry/vlayoutplacelabel.cpp +++ b/src/libs/vgeometry/vlayoutplacelabel.cpp @@ -28,28 +28,35 @@ #include "vlayoutplacelabel.h" #if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) -# include "../vmisc/vdatastreamenum.h" +#include "../vmisc/vdatastreamenum.h" #endif #include "../ifc/exception/vexception.h" +#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) +#include "../vmisc/compatibility.h" +#endif + +using namespace Qt::Literals::StringLiterals; + // See https://stackoverflow.com/a/46719572/3045403 -#if __cplusplus < 201703L // C++17 -constexpr quint32 VLayoutPlaceLabel::streamHeader; // NOLINT(readability-redundant-declaration) -constexpr quint16 VLayoutPlaceLabel::classVersion; // NOLINT(readability-redundant-declaration) +#if __cplusplus < 201703L // C++17 +constexpr quint32 VLayoutPlaceLabel::streamHeader; // NOLINT(readability-redundant-declaration) +constexpr quint16 VLayoutPlaceLabel::classVersion; // NOLINT(readability-redundant-declaration) #endif //--------------------------------------------------------------------------------------------------------------------- VLayoutPlaceLabel::VLayoutPlaceLabel(const VPlaceLabelItem &item) - : m_center(item.toQPointF()), - m_type(item.GetLabelType()), - m_rotationMatrix(item.RotationMatrix()), - m_box(item.Box()) -{} + : m_center(item.toQPointF()), + m_type(item.GetLabelType()), + m_rotationMatrix(item.RotationMatrix()), + m_box(item.Box()) +{ +} // Friend functions //--------------------------------------------------------------------------------------------------------------------- -auto operator<<(QDataStream &dataStream, const VLayoutPlaceLabel &data) -> QDataStream& +auto operator<<(QDataStream &dataStream, const VLayoutPlaceLabel &data) -> QDataStream & { dataStream << VLayoutPlaceLabel::streamHeader << VLayoutPlaceLabel::classVersion; @@ -65,7 +72,7 @@ auto operator<<(QDataStream &dataStream, const VLayoutPlaceLabel &data) -> QData } //--------------------------------------------------------------------------------------------------------------------- -auto operator>>(QDataStream &dataStream, VLayoutPlaceLabel &data) -> QDataStream& +auto operator>>(QDataStream &dataStream, VLayoutPlaceLabel &data) -> QDataStream & { quint32 actualStreamHeader = 0; dataStream >> actualStreamHeader; @@ -74,8 +81,8 @@ auto operator>>(QDataStream &dataStream, VLayoutPlaceLabel &data) -> QDataStream { QString message = QCoreApplication::tr("VLayoutPlaceLabel prefix mismatch error: actualStreamHeader = 0x%1 and " "streamHeader = 0x%2") - .arg(actualStreamHeader, 8, 0x10, QChar('0')) - .arg(VLayoutPlaceLabel::streamHeader, 8, 0x10, QChar('0')); + .arg(actualStreamHeader, 8, 0x10, '0'_L1) + .arg(VLayoutPlaceLabel::streamHeader, 8, 0x10, '0'_L1); throw VException(message); } @@ -86,7 +93,8 @@ auto operator>>(QDataStream &dataStream, VLayoutPlaceLabel &data) -> QDataStream { QString message = QCoreApplication::tr("VLayoutPlaceLabel compatibility error: actualClassVersion = %1 and " "classVersion = %2") - .arg(actualClassVersion).arg(VLayoutPlaceLabel::classVersion); + .arg(actualClassVersion) + .arg(VLayoutPlaceLabel::classVersion); throw VException(message); } diff --git a/src/libs/vgeometry/vpointf.cpp b/src/libs/vgeometry/vpointf.cpp index 069179c7b..0cb8ab5f6 100644 --- a/src/libs/vgeometry/vpointf.cpp +++ b/src/libs/vgeometry/vpointf.cpp @@ -34,6 +34,12 @@ #include #include +#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) +#include "../vmisc/compatibility.h" +#endif + +using namespace Qt::Literals::StringLiterals; + //--------------------------------------------------------------------------------------------------------------------- /** * @brief VPointF creat empty point @@ -258,11 +264,11 @@ void VPointF::SetShowLabel(bool hide) auto VPointF::ToJson() const -> QJsonObject { QJsonObject object = VGObject::ToJson(); - object[QLatin1String("x")] = x(); - object[QLatin1String("y")] = y(); - object[QLatin1String("name")] = name(); - object[QLatin1String("mx")] = mx(); - object[QLatin1String("my")] = my(); + object["x"_L1] = x(); + object["y"_L1] = y(); + object["name"_L1] = name(); + object["mx"_L1] = mx(); + object["my"_L1] = my(); return object; } diff --git a/src/libs/vgeometry/vspline.cpp b/src/libs/vgeometry/vspline.cpp index 587ee9f70..d1c5a1b11 100644 --- a/src/libs/vgeometry/vspline.cpp +++ b/src/libs/vgeometry/vspline.cpp @@ -35,6 +35,12 @@ #include "vabstractcurve.h" #include "vspline_p.h" +#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) +#include "../vmisc/compatibility.h" +#endif + +using namespace Qt::Literals::StringLiterals; + //--------------------------------------------------------------------------------------------------------------------- /** * @brief VSpline default constructor @@ -585,17 +591,17 @@ auto VSpline::ParamT(const QPointF &pBt) const -> qreal auto VSpline::ToJson() const -> QJsonObject { QJsonObject object = VAbstractCubicBezier::ToJson(); - object[QLatin1String("aScale")] = GetApproximationScale(); - object[QLatin1String("p1")] = GetP1().ToJson(); - object[QLatin1String("p4")] = GetP4().ToJson(); - object[QLatin1String("angle1")] = GetStartAngle(); - object[QLatin1String("angle1Formula")] = GetStartAngleFormula(); - object[QLatin1String("angle2")] = GetEndAngle(); - object[QLatin1String("angle2Formula")] = GetEndAngleFormula(); - object[QLatin1String("c1Length")] = GetC1Length(); - object[QLatin1String("c1LengthFormula")] = GetC1LengthFormula(); - object[QLatin1String("c2Length")] = GetC2Length(); - object[QLatin1String("c2LengthFormula")] = GetC2LengthFormula(); + object["aScale"_L1] = GetApproximationScale(); + object["p1"_L1] = GetP1().ToJson(); + object["p4"_L1] = GetP4().ToJson(); + object["angle1"_L1] = GetStartAngle(); + object["angle1Formula"_L1] = GetStartAngleFormula(); + object["angle2"_L1] = GetEndAngle(); + object["angle2Formula"_L1] = GetEndAngleFormula(); + object["c1Length"_L1] = GetC1Length(); + object["c1LengthFormula"_L1] = GetC1LengthFormula(); + object["c2Length"_L1] = GetC2Length(); + object["c2LengthFormula"_L1] = GetC2LengthFormula(); return object; } diff --git a/src/libs/vgeometry/vsplinepath.cpp b/src/libs/vgeometry/vsplinepath.cpp index 76f1feeb7..5489ad1d7 100644 --- a/src/libs/vgeometry/vsplinepath.cpp +++ b/src/libs/vgeometry/vsplinepath.cpp @@ -36,6 +36,12 @@ #include "vabstractcurve.h" #include "vsplinepath_p.h" +#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) +#include "../vmisc/compatibility.h" +#endif + +using namespace Qt::Literals::StringLiterals; + //--------------------------------------------------------------------------------------------------------------------- /** * @brief VSplinePath constructor. @@ -349,14 +355,14 @@ auto VSplinePath::at(vsizetype indx) const -> const VSplinePoint & auto VSplinePath::ToJson() const -> QJsonObject { QJsonObject object = VAbstractCubicBezierPath::ToJson(); - object[QLatin1String("aScale")] = GetApproximationScale(); + object["aScale"_L1] = GetApproximationScale(); QJsonArray nodesArray; for (const auto &node : d->path) { nodesArray.append(node.ToJson()); } - object[QLatin1String("nodes")] = nodesArray; + object["nodes"_L1] = nodesArray; return object; } diff --git a/src/libs/vhpgl/vhpglengine.cpp b/src/libs/vhpgl/vhpglengine.cpp index 775d01ab6..c8192b792 100644 --- a/src/libs/vhpgl/vhpglengine.cpp +++ b/src/libs/vhpgl/vhpglengine.cpp @@ -49,6 +49,12 @@ #include #include +#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) +#include "../vmisc/compatibility.h" +#endif + +using namespace Qt::Literals::StringLiterals; + namespace { const qreal accuracyPointOnLine{0.99}; @@ -57,15 +63,15 @@ QT_WARNING_PUSH QT_WARNING_DISABLE_CLANG("-Wunused-member-function") // mnemonics -Q_GLOBAL_STATIC_WITH_ARGS(const QString, mIN, (QLatin1String("IN"))) // NOLINT initialize set instruction -Q_GLOBAL_STATIC_WITH_ARGS(const QString, mPU, (QLatin1String("PU"))) // NOLINT pen up -Q_GLOBAL_STATIC_WITH_ARGS(const QString, mPD, (QLatin1String("PD"))) // NOLINT pen down -Q_GLOBAL_STATIC_WITH_ARGS(const QString, mLT, (QLatin1String("LT"))) // NOLINT line type -Q_GLOBAL_STATIC_WITH_ARGS(const QString, mSP, (QLatin1String("SP"))) // NOLINT select pen -Q_GLOBAL_STATIC_WITH_ARGS(const QString, mPG, (QLatin1String("PG"))) // NOLINT page feed -Q_GLOBAL_STATIC_WITH_ARGS(const QString, mPA, (QLatin1String("PA"))) // NOLINT plot absolute -Q_GLOBAL_STATIC_WITH_ARGS(const QString, mPW, (QLatin1String("PW"))) // NOLINT pen width -Q_GLOBAL_STATIC_WITH_ARGS(const QString, mLA, (QLatin1String("LA"))) // NOLINT line attributes +Q_GLOBAL_STATIC_WITH_ARGS(const QString, mIN, ("IN"_L1)) // NOLINT initialize set instruction +Q_GLOBAL_STATIC_WITH_ARGS(const QString, mPU, ("PU"_L1)) // NOLINT pen up +Q_GLOBAL_STATIC_WITH_ARGS(const QString, mPD, ("PD"_L1)) // NOLINT pen down +Q_GLOBAL_STATIC_WITH_ARGS(const QString, mLT, ("LT"_L1)) // NOLINT line type +Q_GLOBAL_STATIC_WITH_ARGS(const QString, mSP, ("SP"_L1)) // NOLINT select pen +Q_GLOBAL_STATIC_WITH_ARGS(const QString, mPG, ("PG"_L1)) // NOLINT page feed +Q_GLOBAL_STATIC_WITH_ARGS(const QString, mPA, ("PA"_L1)) // NOLINT plot absolute +Q_GLOBAL_STATIC_WITH_ARGS(const QString, mPW, ("PW"_L1)) // NOLINT pen width +Q_GLOBAL_STATIC_WITH_ARGS(const QString, mLA, ("LA"_L1)) // NOLINT line attributes QT_WARNING_POP diff --git a/src/libs/vlayout/dialogs/vabstractlayoutdialog.cpp b/src/libs/vlayout/dialogs/vabstractlayoutdialog.cpp index df23af027..180e313d8 100644 --- a/src/libs/vlayout/dialogs/vabstractlayoutdialog.cpp +++ b/src/libs/vlayout/dialogs/vabstractlayoutdialog.cpp @@ -32,6 +32,12 @@ #include +#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) +#include "../vmisc/compatibility.h" +#endif + +using namespace Qt::Literals::StringLiterals; + //--------------------------------------------------------------------------------------------------------------------- VAbstractLayoutDialog::VAbstractLayoutDialog(QWidget *parent) : QDialog(parent) @@ -42,8 +48,8 @@ VAbstractLayoutDialog::VAbstractLayoutDialog(QWidget *parent) void VAbstractLayoutDialog::InitTemplates(QComboBox *comboBoxTemplates) { SCASSERT(comboBoxTemplates != nullptr) - const QIcon icoPaper(QLatin1String("://icon/16x16/template.png")); - const QIcon icoRoll(QLatin1String("://icon/16x16/roll.png")); + const QIcon icoPaper("://icon/16x16/template.png"_L1); + const QIcon icoRoll("://icon/16x16/roll.png"_L1); const QString pdi = QStringLiteral("(%1ppi)").arg(PrintDPI); auto cntr = static_cast(PaperSizeTemplate::A0); diff --git a/src/libs/vlayout/dialogs/watermarkwindow.cpp b/src/libs/vlayout/dialogs/watermarkwindow.cpp index d00e9bad1..aa757137d 100644 --- a/src/libs/vlayout/dialogs/watermarkwindow.cpp +++ b/src/libs/vlayout/dialogs/watermarkwindow.cpp @@ -49,6 +49,12 @@ #include "../vmisc/vabstractapplication.h" #include "../vpropertyexplorer/checkablemessagebox.h" +#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) +#include "../vmisc/compatibility.h" +#endif + +using namespace Qt::Literals::StringLiterals; + //--------------------------------------------------------------------------------------------------------------------- WatermarkWindow::WatermarkWindow(const QString &patternPath, QWidget *parent) : QMainWindow(parent), @@ -97,7 +103,7 @@ WatermarkWindow::WatermarkWindow(const QString &patternPath, QWidget *parent) connect(ui->pushButtonBrowse, &QPushButton::clicked, this, [this]() { - const QString filter = tr("Images") + QLatin1String(" (*.png *.jpg *.jpeg *.bmp)"); + const QString filter = tr("Images") + " (*.png *.jpg *.jpeg *.bmp)"_L1; const QString fileName = QFileDialog::getOpenFileName(this, tr("Watermark image"), QString(), filter, nullptr, VAbstractApplication::VApp()->NativeFileDialog()); @@ -305,7 +311,7 @@ void WatermarkWindow::on_actionNew_triggered() //--------------------------------------------------------------------------------------------------------------------- auto WatermarkWindow::on_actionSaveAs_triggered() -> bool { - QString filters(tr("Watermark files") + QLatin1String("(*.vwm)")); + QString filters(tr("Watermark files") + "(*.vwm)"_L1); QString dir; if (m_curFile.isEmpty()) { @@ -316,8 +322,7 @@ auto WatermarkWindow::on_actionSaveAs_triggered() -> bool dir = QFileInfo(m_curFile).absolutePath(); } - QString fileName = QFileDialog::getSaveFileName(this, tr("Save as"), - dir + QLatin1String("/") + tr("watermark") + QLatin1String(".vwm"), + QString fileName = QFileDialog::getSaveFileName(this, tr("Save as"), dir + '/'_L1 + tr("watermark") + ".vwm"_L1, filters, nullptr, VAbstractApplication::VApp()->NativeFileDialog()); if (fileName.isEmpty()) @@ -326,9 +331,9 @@ auto WatermarkWindow::on_actionSaveAs_triggered() -> bool } QFileInfo f(fileName); - if (f.suffix().isEmpty() && f.suffix() != QLatin1String("vwm")) + if (f.suffix().isEmpty() && f.suffix() != "vwm"_L1) { - fileName += QLatin1String(".vwm"); + fileName += ".vwm"_L1; } if (f.exists() && m_curFile != fileName) @@ -461,7 +466,7 @@ auto WatermarkWindow::on_actionSave_triggered() -> bool void WatermarkWindow::on_actionOpen_triggered() { qDebug("Openning new watermark file."); - const QString filter(tr("Watermark files") + QLatin1String(" (*.vwm)")); + const QString filter(tr("Watermark files") + " (*.vwm)"_L1); QString dir = QDir::homePath(); qDebug("Run QFileDialog::getOpenFileName: dir = %s.", qUtf8Printable(dir)); const QString filePath = QFileDialog::getOpenFileName(this, tr("Open file"), dir, filter, nullptr, @@ -540,13 +545,12 @@ void WatermarkWindow::UpdateWindowTitle() } else { - setWindowTitle(GetWatermarkFileName() + QLatin1String(" (") + tr("read only") + QLatin1String(")")); + setWindowTitle(GetWatermarkFileName() + " ("_L1 + tr("read only") + ')'_L1); } setWindowFilePath(m_curFile); #if defined(Q_OS_MAC) - static QIcon fileIcon = - QIcon(QCoreApplication::applicationDirPath() + QLatin1String("/../Resources/Valentina.icns")); + static QIcon fileIcon = QIcon(QCoreApplication::applicationDirPath() + "/../Resources/Valentina.icns"_L1); QIcon icon; if (not m_curFile.isEmpty()) { @@ -577,7 +581,7 @@ auto WatermarkWindow::GetWatermarkFileName() -> QString { shownName = StrippedName(m_curFile); } - shownName += QLatin1String("[*]"); + shownName += "[*]"_L1; return shownName; } diff --git a/src/libs/vlayout/vabstractpiece.cpp b/src/libs/vlayout/vabstractpiece.cpp index 18ebaf872..b3e750993 100644 --- a/src/libs/vlayout/vabstractpiece.cpp +++ b/src/libs/vlayout/vabstractpiece.cpp @@ -52,6 +52,8 @@ #include #include +using namespace Qt::Literals::StringLiterals; + const qreal maxL = 3.5; namespace @@ -1536,43 +1538,43 @@ auto VAbstractPiece::GetUniqueID() const -> QString auto VSAPoint::toJson() const -> QJsonObject { QJsonObject pointObject = VLayoutPoint::toJson(); - pointObject[QLatin1String("type")] = "VSAPoint"; + pointObject["type"_L1] = "VSAPoint"; if (not VFuzzyComparePossibleNulls(m_before, -1)) { - pointObject[QLatin1String("saBefore")] = m_before; + pointObject["saBefore"_L1] = m_before; } if (not VFuzzyComparePossibleNulls(m_after, -1)) { - pointObject[QLatin1String("saAfter")] = m_after; + pointObject["saAfter"_L1] = m_after; } if (m_angle != PieceNodeAngle::ByLength) { - pointObject[QLatin1String("angle")] = static_cast(m_angle); + pointObject["angle"_L1] = static_cast(m_angle); } if (m_manualPassmarkLength) { - pointObject[QLatin1String("manualPassmarkLength")] = m_manualPassmarkLength; - pointObject[QLatin1String("passmarkLength")] = m_passmarkLength; + pointObject["manualPassmarkLength"_L1] = m_manualPassmarkLength; + pointObject["passmarkLength"_L1] = m_passmarkLength; } if (m_manualPassmarkWidth) { - pointObject[QLatin1String("manualPassmarkWidth")] = m_manualPassmarkWidth; - pointObject[QLatin1String("passmarkWidth")] = m_passmarkWidth; + pointObject["manualPassmarkWidth"_L1] = m_manualPassmarkWidth; + pointObject["passmarkWidth"_L1] = m_passmarkWidth; } else { - pointObject[QLatin1String("passmarkClockwiseOpening")] = m_passmarkClockwiseOpening; + pointObject["passmarkClockwiseOpening"_L1] = m_passmarkClockwiseOpening; } if (m_manualPassmarkAngle) { - pointObject[QLatin1String("manualPassmarkAngle")] = m_manualPassmarkAngle; - pointObject[QLatin1String("passmarkAngle")] = m_passmarkAngle; + pointObject["manualPassmarkAngle"_L1] = m_manualPassmarkAngle; + pointObject["passmarkAngle"_L1] = m_passmarkAngle; } return pointObject; diff --git a/src/libs/vlayout/vabstractpiece_p.h b/src/libs/vlayout/vabstractpiece_p.h index 9a0e9f966..2bdc841e1 100644 --- a/src/libs/vlayout/vabstractpiece_p.h +++ b/src/libs/vlayout/vabstractpiece_p.h @@ -125,8 +125,8 @@ inline auto operator>>(QDataStream &dataStream, VAbstractPieceData &piece) -> QD { QString message = QCoreApplication::tr("VAbstractPieceData prefix mismatch error: actualStreamHeader = 0x%1 " "and streamHeader = 0x%2") - .arg(actualStreamHeader, 8, 0x10, QChar('0')) - .arg(VAbstractPieceData::streamHeader, 8, 0x10, QChar('0')); + .arg(actualStreamHeader, 8, 0x10, QLatin1Char('0')) + .arg(VAbstractPieceData::streamHeader, 8, 0x10, QLatin1Char('0')); throw VException(message); } diff --git a/src/libs/vlayout/vlayoutexporter.cpp b/src/libs/vlayout/vlayoutexporter.cpp index fd4b2edb5..168e4f8d7 100644 --- a/src/libs/vlayout/vlayoutexporter.cpp +++ b/src/libs/vlayout/vlayoutexporter.cpp @@ -52,15 +52,21 @@ #include "vprintlayout.h" #include "vrawlayout.h" +#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) +#include "../vmisc/compatibility.h" +#endif + +using namespace Qt::Literals::StringLiterals; + namespace { QT_WARNING_PUSH QT_WARNING_DISABLE_CLANG("-Wunused-member-function") #ifdef Q_OS_WIN -Q_GLOBAL_STATIC_WITH_ARGS(const QString, PDFTOPS, (QLatin1String("pdftops.exe"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, PDFTOPS, ("pdftops.exe"_L1)) // NOLINT #else -Q_GLOBAL_STATIC_WITH_ARGS(const QString, PDFTOPS, (QLatin1String("pdftops"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, PDFTOPS, ("pdftops"_L1)) // NOLINT #endif QT_WARNING_POP @@ -425,14 +431,14 @@ auto VLayoutExporter::SupportPDFConversion() -> bool #if defined(Q_OS_OSX) // Seek pdftops in app bundle - bool found = Test(qApp->applicationDirPath() + QLatin1String("/") + *PDFTOPS); + bool found = Test(qApp->applicationDirPath() + '/'_L1 + *PDFTOPS); if (not found) { found = Test(*PDFTOPS); } return found; #elif defined(Q_OS_WIN) - return Test(qApp->applicationDirPath() + QLatin1String("/") + *PDFTOPS); + return Test(qApp->applicationDirPath() + '/'_L1 + *PDFTOPS); #else return Test(*PDFTOPS); #endif @@ -452,9 +458,9 @@ void VLayoutExporter::PdfToPs(const QStringList ¶ms) QProcess proc; #if defined(Q_OS_MAC) - if (QFileInfo::exists(qApp->applicationDirPath() + QLatin1String("/") + *PDFTOPS)) + if (QFileInfo::exists(qApp->applicationDirPath() + '/'_L1 + *PDFTOPS)) { - proc.start(qApp->applicationDirPath() + QLatin1String("/") + *PDFTOPS, params); + proc.start(qApp->applicationDirPath() + '/'_L1 + *PDFTOPS, params); } else { diff --git a/src/libs/vlayout/vlayoutpiece.cpp b/src/libs/vlayout/vlayoutpiece.cpp index b0f2dfb29..084e9ee40 100644 --- a/src/libs/vlayout/vlayoutpiece.cpp +++ b/src/libs/vlayout/vlayoutpiece.cpp @@ -69,6 +69,8 @@ #include "vlayoutpiece_p.h" #include "vtextmanager.h" +using namespace Qt::Literals::StringLiterals; + namespace { //--------------------------------------------------------------------------------------------------------------------- @@ -509,7 +511,7 @@ auto ReplacePlaceholders(const QMap &placeholders, QString lin auto TestDimension = [per, placeholders, line](const QString &placeholder, const QString &errorMsg) { - if (line.contains(per + placeholder + per) && placeholders.value(placeholder) == QChar('0')) + if (line.contains(per + placeholder + per) && placeholders.value(placeholder) == '0'_L1) { VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) diff --git a/src/libs/vlayout/vlayoutpiece_p.h b/src/libs/vlayout/vlayoutpiece_p.h index 54f3753c9..55e4937d6 100644 --- a/src/libs/vlayout/vlayoutpiece_p.h +++ b/src/libs/vlayout/vlayoutpiece_p.h @@ -169,8 +169,8 @@ inline auto operator>>(QDataStream &dataStream, VLayoutPieceData &piece) -> QDat { QString message = QCoreApplication::tr("VLayoutPieceData prefix mismatch error: actualStreamHeader = 0x%1 and " "streamHeader = 0x%2") - .arg(actualStreamHeader, 8, 0x10, QChar('0')) - .arg(VLayoutPieceData::streamHeader, 8, 0x10, QChar('0')); + .arg(actualStreamHeader, 8, 0x10, QLatin1Char('0')) + .arg(VLayoutPieceData::streamHeader, 8, 0x10, QLatin1Char('0')); throw VException(message); } diff --git a/src/libs/vlayout/vlayoutpiecepath_p.h b/src/libs/vlayout/vlayoutpiecepath_p.h index 0aa1a0df9..f8dc545c7 100644 --- a/src/libs/vlayout/vlayoutpiecepath_p.h +++ b/src/libs/vlayout/vlayoutpiecepath_p.h @@ -111,8 +111,8 @@ auto operator>>(QDataStream &dataStream, VLayoutPiecePathData &path) -> QDataStr { QString message = QCoreApplication::tr("VLayoutPiecePathData prefix mismatch error: actualStreamHeader = 0x%1 " "and streamHeader = 0x%2") - .arg(actualStreamHeader, 8, 0x10, QChar('0')) - .arg(VLayoutPiecePathData::streamHeader, 8, 0x10, QChar('0')); + .arg(actualStreamHeader, 8, 0x10, QLatin1Char('0')) + .arg(VLayoutPiecePathData::streamHeader, 8, 0x10, QLatin1Char('0')); throw VException(message); } diff --git a/src/libs/vlayout/vlayoutpoint.cpp b/src/libs/vlayout/vlayoutpoint.cpp index 53dafc888..9a3f482db 100644 --- a/src/libs/vlayout/vlayoutpoint.cpp +++ b/src/libs/vlayout/vlayoutpoint.cpp @@ -30,22 +30,28 @@ #include +#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) +#include "../vmisc/compatibility.h" +#endif + +using namespace Qt::Literals::StringLiterals; + //--------------------------------------------------------------------------------------------------------------------- auto VLayoutPoint::toJson() const -> QJsonObject { QJsonObject pointObject; - pointObject[QLatin1String("type")] = "VLayoutPoint"; - pointObject[QLatin1String("x")] = x(); - pointObject[QLatin1String("y")] = y(); + pointObject["type"_L1] = "VLayoutPoint"; + pointObject["x"_L1] = x(); + pointObject["y"_L1] = y(); if (m_turnPoint) { - pointObject[QLatin1String("turnPoint")] = m_turnPoint; + pointObject["turnPoint"_L1] = m_turnPoint; } if (m_curvePoint) { - pointObject[QLatin1String("curvePoint")] = m_curvePoint; + pointObject["curvePoint"_L1] = m_curvePoint; } return pointObject; diff --git a/src/libs/vlayout/vposter.cpp b/src/libs/vlayout/vposter.cpp index 0984de937..b461d867b 100644 --- a/src/libs/vlayout/vposter.cpp +++ b/src/libs/vlayout/vposter.cpp @@ -50,6 +50,8 @@ #include "../vmisc/def.h" #include "../vmisc/vabstractvalapplication.h" +using namespace Qt::Literals::StringLiterals; + namespace { //--------------------------------------------------------------------------------------------------------------------- @@ -254,12 +256,11 @@ auto VPoster::Borders(QGraphicsItem *parent, const PosterData &img, vsizetype sh sheet = QCoreApplication::translate("VPoster", "Sheet %1 of %2").arg(img.index + 1).arg(sheets); } - labels->setHtml(QString("" - "" - "" - "" - "
%1%2%3
") - .arg(grid, page, sheet)); + labels->setHtml(u"" + "" + "" + "" + "
%1%2%3
"_s.arg(grid, page, sheet)); data.append(labels); @@ -317,7 +318,7 @@ auto VPoster::ImageWatermark(QGraphicsItem *parent, const PosterData &img, const if (watermark.isNull()) { const QString errorMsg = - QCoreApplication::translate("VPoster", "Cannot open the watermark image.") + QChar(' ') + error; + QCoreApplication::translate("VPoster", "Cannot open the watermark image.") + ' '_L1 + error; VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) : qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; diff --git a/src/libs/vlayout/vrawlayout.cpp b/src/libs/vlayout/vrawlayout.cpp index 729d28846..0e786fc09 100644 --- a/src/libs/vlayout/vrawlayout.cpp +++ b/src/libs/vlayout/vrawlayout.cpp @@ -28,9 +28,9 @@ #include "vrawlayout.h" #include -#include #include #include +#include #if QT_VERSION < QT_VERSION_CHECK(5, 12, 0) #include "../vmisc/backport/qscopeguard.h" @@ -38,10 +38,16 @@ #include #endif -#include "../vmisc/def.h" #include "../ifc/exception/vexception.h" +#include "../vmisc/def.h" -const QByteArray VRawLayout::fileHeaderByteArray = QByteArray("RLD!..."); +#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) +#include "../vmisc/compatibility.h" +#endif + +using namespace Qt::Literals::StringLiterals; + +const QByteArray VRawLayout::fileHeaderByteArray = "RLD!..."_ba; const quint16 VRawLayout::fileVersion = 1; const quint32 VRawLayoutData::streamHeader = 0x8B0E8A27; // CRC-32Q string "VRawLayoutData" @@ -70,8 +76,8 @@ auto operator>>(QDataStream &dataStream, VRawLayoutData &data) -> QDataStream & { QString message = QCoreApplication::tr("VRawLayoutData prefix mismatch error: actualStreamHeader = 0x%1 and " "streamHeader = 0x%2") - .arg(actualStreamHeader, 8, 0x10, QChar('0')) - .arg(VRawLayoutData::streamHeader, 8, 0x10, QChar('0')); + .arg(actualStreamHeader, 8, 0x10, '0'_L1) + .arg(VRawLayoutData::streamHeader, 8, 0x10, '0'_L1); throw VException(message); } @@ -82,23 +88,25 @@ auto operator>>(QDataStream &dataStream, VRawLayoutData &data) -> QDataStream & { QString message = QCoreApplication::tr("VRawLayoutData compatibility error: actualClassVersion = %1 and " "classVersion = %2") - .arg( actualClassVersion ).arg(VRawLayoutData::classVersion); + .arg(actualClassVersion) + .arg(VRawLayoutData::classVersion); throw VException(message); } dataStream >> data.pieces; -// if (actualClassVersion >= 2) -// { -// // read value in version 2 -// } + // if (actualClassVersion >= 2) + // { + // // read value in version 2 + // } return dataStream; } //--------------------------------------------------------------------------------------------------------------------- VRawLayout::VRawLayout() -{} +{ +} //--------------------------------------------------------------------------------------------------------------------- auto VRawLayout::WriteFile(QIODevice *ioDevice, const VRawLayoutData &data) -> bool @@ -141,13 +149,14 @@ auto VRawLayout::ReadFile(QIODevice *ioDevice, VRawLayoutData &data) -> bool if (wasOpen || ioDevice->open(QIODevice::ReadOnly)) { - auto CloseFile = qScopeGuard([wasOpen, ioDevice]() - { - if (not wasOpen) // Only close this if it was opened by this function. - { - ioDevice->close(); - } - }); + auto CloseFile = qScopeGuard( + [wasOpen, ioDevice]() + { + if (not wasOpen) // Only close this if it was opened by this function. + { + ioDevice->close(); + } + }); QDataStream dataStream(ioDevice); dataStream.setVersion(QDataStream::Qt_5_4); @@ -157,8 +166,8 @@ auto VRawLayout::ReadFile(QIODevice *ioDevice, VRawLayoutData &data) -> bool // a large amount of memory if the wrong file type was read. Instead, we'll just read the // same number of bytes that are in the array we are comparing it to. No size was written. const int len = static_cast(fileHeaderByteArray.size()); - QByteArray actualFileHeaderByteArray( len, '\0' ); - dataStream.readRawData( actualFileHeaderByteArray.data(), len ); + QByteArray actualFileHeaderByteArray(len, '\0'); + dataStream.readRawData(actualFileHeaderByteArray.data(), len); if (actualFileHeaderByteArray != fileHeaderByteArray) { @@ -174,8 +183,9 @@ auto VRawLayout::ReadFile(QIODevice *ioDevice, VRawLayoutData &data) -> bool { // file is from a future version that we don't know how to load m_errorString = tr("VRawLayout::ReadFile() failed.\n" - "Raw layout format compatibility error: actualFileVersion = %1 and fileVersion = %2" ) - .arg(actualFileVersion).arg(fileVersion); + "Raw layout format compatibility error: actualFileVersion = %1 and fileVersion = %2") + .arg(actualFileVersion) + .arg(fileVersion); return false; } @@ -185,7 +195,7 @@ auto VRawLayout::ReadFile(QIODevice *ioDevice, VRawLayoutData &data) -> bool // For example, if this file is from a future version of this code. dataStream >> data; } - catch (const VException& e) + catch (const VException &e) { qCritical() << e.ErrorMessage(); @@ -208,11 +218,12 @@ auto VRawLayout::WriteFile(const QString &filePath, const VRawLayoutData &data) QFile file(filePath); if (file.open(QIODevice::WriteOnly | QIODevice::Truncate)) { - auto CloseFile = qScopeGuard([&file]() - { - file.flush(); - file.close(); - }); + auto CloseFile = qScopeGuard( + [&file]() + { + file.flush(); + file.close(); + }); return WriteFile(&file, data); } @@ -226,15 +237,15 @@ auto VRawLayout::ReadFile(const QString &filePath, VRawLayoutData &data) -> bool QFile file(filePath); if (file.open(QIODevice::ReadOnly)) { - auto CloseFile = qScopeGuard([&file]() - { - file.flush(); - file.close(); - }); + auto CloseFile = qScopeGuard( + [&file]() + { + file.flush(); + file.close(); + }); return ReadFile(&file, data); } m_errorString = file.errorString(); return false; - } diff --git a/src/libs/vlayout/vrawsapoint.cpp b/src/libs/vlayout/vrawsapoint.cpp index f615680fc..d4952d00b 100644 --- a/src/libs/vlayout/vrawsapoint.cpp +++ b/src/libs/vlayout/vrawsapoint.cpp @@ -30,14 +30,20 @@ #include +#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) +#include "../vmisc/compatibility.h" +#endif + +using namespace Qt::Literals::StringLiterals; + //--------------------------------------------------------------------------------------------------------------------- auto VRawSAPoint::toJson() const -> QJsonObject { QJsonObject pointObject = VLayoutPoint::toJson(); - pointObject[QLatin1String("type")] = "VRawSAPoint"; - pointObject[QLatin1String("loopPoint")] = m_loopPoint; - pointObject[QLatin1String("primary")] = m_primary; + pointObject["type"_L1] = "VRawSAPoint"; + pointObject["loopPoint"_L1] = m_loopPoint; + pointObject["primary"_L1] = m_primary; return pointObject; } diff --git a/src/libs/vlayout/vtextmanager.cpp b/src/libs/vlayout/vtextmanager.cpp index 4ef60c91b..750d18df9 100644 --- a/src/libs/vlayout/vtextmanager.cpp +++ b/src/libs/vlayout/vtextmanager.cpp @@ -55,6 +55,8 @@ #include "../vpatterndb/vcontainer.h" #include "vtextmanager.h" +using namespace Qt::Literals::StringLiterals; + namespace { QT_WARNING_PUSH @@ -179,8 +181,8 @@ auto operator>>(QDataStream &dataStream, TextLine &data) -> QDataStream & { QString message = QCoreApplication::tr("TextLine prefix mismatch error: actualStreamHeader = 0x%1 and " "streamHeader = 0x%2") - .arg(actualStreamHeader, 8, 0x10, QChar('0')) - .arg(TextLine::streamHeader, 8, 0x10, QChar('0')); + .arg(actualStreamHeader, 8, 0x10, '0'_L1) + .arg(TextLine::streamHeader, 8, 0x10, '0'_L1); throw VException(message); } @@ -240,8 +242,8 @@ auto operator>>(QDataStream &dataStream, VTextManager &data) -> QDataStream & { QString message = QCoreApplication::tr("VTextManager prefix mismatch error: actualStreamHeader = 0x%1 and " "streamHeader = 0x%2") - .arg(actualStreamHeader, 8, 0x10, QChar('0')) - .arg(VTextManager::streamHeader, 8, 0x10, QChar('0')); + .arg(actualStreamHeader, 8, 0x10, '0'_L1) + .arg(VTextManager::streamHeader, 8, 0x10, '0'_L1); throw VException(message); } @@ -495,7 +497,7 @@ auto ReplacePlaceholders(const QMap &placeholders, QString lin auto TestDimension = [per, placeholders, line](const QString &placeholder, const QString &errorMsg) { - if (line.contains(per + placeholder + per) && placeholders.value(placeholder) == QChar('0')) + if (line.contains(per + placeholder + per) && placeholders.value(placeholder) == '0'_L1) { VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) @@ -866,7 +868,7 @@ auto VTextManager::BreakTextIntoLines(const QString &text, const QFont &font, in { if (!currentLine.isEmpty()) { - currentLine += QChar(' '); + currentLine += ' '_L1; } currentLine += word; currentLineWidth = totalWidth; @@ -966,7 +968,7 @@ auto VTextManager::BreakTextIntoLines(const QString &text, const VSvgFont &font, { if (!currentLine.isEmpty()) { - currentLine += QChar(' '); + currentLine += ' '_L1; } currentLine += word; currentLineWidth = totalWidth; diff --git a/src/libs/vmisc/compatibility.h b/src/libs/vmisc/compatibility.h index aa553e2c5..89a597269 100644 --- a/src/libs/vmisc/compatibility.h +++ b/src/libs/vmisc/compatibility.h @@ -54,6 +54,43 @@ class QPointF; +#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) +namespace Qt +{ +inline namespace Literals +{ +inline namespace StringLiterals +{ + +//--------------------------------------------------------------------------------------------------------------------- +constexpr inline auto operator"" _L1(char ch) noexcept -> QLatin1Char +{ + return QLatin1Char(ch); +} + +//--------------------------------------------------------------------------------------------------------------------- +constexpr inline auto operator"" _L1(const char *str, size_t size) noexcept -> QLatin1String +{ + return QLatin1String(str, static_cast(size)); +} + +//--------------------------------------------------------------------------------------------------------------------- +inline auto operator"" _ba(const char *str, size_t size) noexcept -> QByteArray +{ + return {str, static_cast(size)}; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline auto operator"" _s(const char16_t *str, size_t size) noexcept -> QString +{ + return QString::fromUtf16(str, static_cast(size)); +} + +} // namespace StringLiterals +} // namespace Literals +} // namespace Qt +#endif + // Contains helpful methods to hide version dependent code. It can be deprecation of method or change in API //--------------------------------------------------------------------------------------------------------------------- template @@ -328,6 +365,8 @@ inline auto Front(const QString &str) -> QChar //--------------------------------------------------------------------------------------------------------------------- inline auto FontFromString(const QString &descrip) -> QFont { + using namespace Qt::Literals::StringLiterals; + QFont font; if (!descrip.isEmpty()) @@ -337,7 +376,7 @@ inline auto FontFromString(const QString &descrip) -> QFont // Qt 5's QFont::fromString expects a value with 11 fields, e.g. // Ubuntu,10,-1,5,50,0,0,0,0,0 #if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) - const auto l = descrip.split(QLatin1Char(',')); + const auto l = descrip.split(','_L1); // Qt5's QFont::fromString() isn't compatible with Qt6's QFont::toString(). // If we were built with Qt5, don't try to process a font preference that // was created by Qt6. diff --git a/src/libs/vmisc/def.cpp b/src/libs/vmisc/def.cpp index a13aa9413..b32a784bd 100644 --- a/src/libs/vmisc/def.cpp +++ b/src/libs/vmisc/def.cpp @@ -61,6 +61,12 @@ #include "../ifc/exception/vexception.h" #include "literals.h" +#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) +#include "compatibility.h" +#endif + +using namespace Qt::Literals::StringLiterals; + namespace { //--------------------------------------------------------------------------------------------------------------------- @@ -100,7 +106,7 @@ void InitLanguageList(QComboBox *combobox) locale.truncate(locale.lastIndexOf('.')); // "valentina_de_De" locale.remove(0, locale.indexOf('_') + 1); // "de_De" - if (locale.startsWith(QLatin1String("ru"))) + if (locale.startsWith("ru"_L1)) { continue; } @@ -114,11 +120,11 @@ void InitLanguageList(QComboBox *combobox) QString lang = loc.nativeLanguageName(); // Since Qt 5.12 country names have spaces QString country = QLocale::countryToString(loc.country()).remove(' '); - if (country == QLatin1String("Czechia")) + if (country == "Czechia"_L1) { - country = QLatin1String("CzechRepublic"); + country = "CzechRepublic"_L1; } - QIcon ico(QString("://flags/%1.png").arg(country)); + QIcon ico(u"://flags/%1.png"_s.arg(country)); combobox->addItem(ico, lang, locale); } @@ -127,7 +133,7 @@ void InitLanguageList(QComboBox *combobox) { // English language is internal and doens't have own *.qm file. // Since Qt 5.12 country names have spaces - QIcon ico(QString("://flags/%1.png").arg(QLocale::countryToString(QLocale::UnitedStates).remove(' '))); + QIcon ico(u"://flags/%1.png"_s.arg(QLocale::countryToString(QLocale::UnitedStates).remove(' '))); QString lang = QLocale(en_US).nativeLanguageName(); combobox->addItem(ico, lang, en_US); } @@ -332,12 +338,12 @@ void MacosEnableLayerBacking() QT_WARNING_PUSH QT_WARNING_DISABLE_CLANG("-Wunused-member-function") -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 -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strCheckMark, (QLatin1String("checkMark"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strTMark, ("tMark"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strVMark, ("vMark"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strVMark2, ("vMark2"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strUMark, ("uMark"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strBoxMark, ("boxMark"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strCheckMark, ("checkMark"_L1)) // NOLINT QT_WARNING_POP @@ -567,8 +573,8 @@ auto operator>>(QDataStream &in, CustomSARecord &record) -> QDataStream & { QString message = QCoreApplication::tr("CustomSARecord prefix mismatch error: actualStreamHeader = 0x%1 " "and streamHeader = 0x%2") - .arg(actualStreamHeader, 8, 0x10, QChar('0')) - .arg(CustomSARecord::streamHeader, 8, 0x10, QChar('0')); + .arg(actualStreamHeader, 8, 0x10, '0'_L1) + .arg(CustomSARecord::streamHeader, 8, 0x10, '0'_L1); throw VException(message); } diff --git a/src/libs/vmisc/dialogs/dialogexporttocsv.cpp b/src/libs/vmisc/dialogs/dialogexporttocsv.cpp index 1b07076f9..42c361243 100644 --- a/src/libs/vmisc/dialogs/dialogexporttocsv.cpp +++ b/src/libs/vmisc/dialogs/dialogexporttocsv.cpp @@ -47,6 +47,12 @@ #include "../vmisc/backport/qoverload.h" #endif // QT_VERSION < QT_VERSION_CHECK(5, 7, 0) +#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) +#include "../compatibility.h" +#endif + +using namespace Qt::Literals::StringLiterals; + //--------------------------------------------------------------------------------------------------------------------- DialogExportToCSV::DialogExportToCSV(QWidget *parent) : QDialog(parent), @@ -149,20 +155,20 @@ auto DialogExportToCSV::GetSeparator() const -> QChar { if (ui->radioButtonTab->isChecked()) { - return QChar('\t'); + return '\t'_L1; } + if (ui->radioButtonSemicolon->isChecked()) { - return QChar(';'); + return ';'_L1; } + else if (ui->radioButtonSpace->isChecked()) { - return QChar(' '); - } - else - { - return VCommonSettings::GetDefCSVSeparator(); + return ' '_L1; } + + return VCommonSettings::GetDefCSVSeparator(); } //--------------------------------------------------------------------------------------------------------------------- @@ -295,7 +301,7 @@ auto DialogExportToCSV::MakeHelpCodecsList() -> QString if (VTextCodec *codec = VTextCodec::codecForMib(list.at(i))) { out += QStringLiteral("\t* ") + codec->name(); - out += i < list.size() - 1 ? QLatin1String(",\n") : QLatin1String(".\n"); + out += i < list.size() - 1 ? ",\n"_L1 : ".\n"_L1; } else { @@ -308,10 +314,10 @@ auto DialogExportToCSV::MakeHelpCodecsList() -> QString //--------------------------------------------------------------------------------------------------------------------- auto DialogExportToCSV::MakeHelpSeparatorList() -> QString { - QString out = QStringLiteral("\n"); - out += QLatin1String("\t* 'Tab',\n"); - out += QLatin1String("\t* ';',\n"); - out += QLatin1String("\t* 'Space',\n"); - out += QLatin1String("\t* ','.\n"); + QString out = "\n"_L1; + out += "\t* 'Tab',\n"_L1; + out += "\t* ';',\n"_L1; + out += "\t* 'Space',\n"_L1; + out += "\t* ','.\n"_L1; return out; } diff --git a/src/libs/vmisc/projectversion.cpp b/src/libs/vmisc/projectversion.cpp index 54d3d0e58..ae89de2d1 100644 --- a/src/libs/vmisc/projectversion.cpp +++ b/src/libs/vmisc/projectversion.cpp @@ -41,6 +41,12 @@ #define LATEST_TAG_DISTANCE VCS_REPO_STATE_DISTANCE #endif +#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) +#include "compatibility.h" +#endif + +using namespace Qt::Literals::StringLiterals; + //--------------------------------------------------------------------------------------------------------------------- auto AppVersionStr() -> const QString & { @@ -55,13 +61,13 @@ auto compilerString() -> QString #if defined(Q_CC_INTEL) // must be before GNU, Clang and MSVC because ICC/ICL claim to be them QString iccCompact; #ifdef __INTEL_CLANG_COMPILER - iccCompact = QLatin1String("Clang"); + iccCompact = "Clang"_L1; #elif defined(__INTEL_MS_COMPAT_LEVEL) - iccCompact = QLatin1String("Microsoft"); + iccCompact = "Microsoft"_L1; #elif defined(__GNUC__) - iccCompact = QLatin1String("GCC"); + iccCompact = Q "GCC"_L1; #else - iccCompact = QLatin1String("no"); + iccCompact = "no"_L1; #endif QString iccVersion; if (__INTEL_COMPILER >= 1300) @@ -73,34 +79,31 @@ auto compilerString() -> QString iccVersion = QLatin1String(__INTEL_COMPILER); } #ifdef __INTEL_COMPILER_UPDATE - return QLatin1String("Intel(R) C++ ") + iccVersion + QChar('.') + QLatin1String(__INTEL_COMPILER_UPDATE) + - QLatin1String(" build ") + QLatin1String(__INTEL_COMPILER_BUILD_DATE) + QLatin1String(" [") + - QLatin1String(iccCompact) + QLatin1String(" compatibility]"); + return "Intel(R) C++ "_L1 + iccVersion + '.'_L1 + QLatin1String(__INTEL_COMPILER_UPDATE) + " build "_L1 + + QLatin1String(__INTEL_COMPILER_BUILD_DATE) + " ["_L1 + QLatin1String(iccCompact) + " compatibility]"_L1; #else - return QLatin1String("Intel(R) C++ ") + iccVersion + QLatin1String(" build ") + - QLatin1String(__INTEL_COMPILER_BUILD_DATE) + QLatin1String(" [") + iccCompact + - QLatin1String(" compatibility]"); + return "Intel(R) C++ "_L1 + iccVersion + " build "_L1 + QLatin1String(__INTEL_COMPILER_BUILD_DATE) + " ["_L1 + + iccCompact + " compatibility]"_L1; #endif #elif defined(Q_CC_CLANG) // must be before GNU, because clang claims to be GNU too // cppcheck-suppress unassignedVariable QString isAppleString; #if defined(__apple_build_version__) // Apple clang has other version numbers - isAppleString = QLatin1String(" (Apple)"); + isAppleString = " (Apple)"_L1; #endif - return QLatin1String("Clang ") + QString::number(__clang_major__) + QLatin1Char('.') + - QString::number(__clang_minor__) + isAppleString; + return "Clang "_L1 + QString::number(__clang_major__) + '.'_L1 + QString::number(__clang_minor__) + isAppleString; #elif defined(Q_CC_GNU) - return QLatin1String("GCC ") + QLatin1String(__VERSION__); + return "GCC "_L1 + QLatin1String(__VERSION__); #elif defined(Q_CC_MSVC) if (_MSC_VER >= 1800) // 1800: MSVC 2013 (yearly release cycle) { - return QLatin1String("MSVC ") + QString::number(2008 + ((_MSC_VER / 100) - 13)); + return "MSVC "_L1 + QString::number(2008 + ((_MSC_VER / 100) - 13)); } if (_MSC_VER >= 1500) // 1500: MSVC 2008, 1600: MSVC 2010, ... (2-year release cycle) { - return QLatin1String("MSVC ") + QString::number(2008 + 2 * ((_MSC_VER / 100) - 15)); + return "MSVC "_L1 + QString::number(2008 + 2 * ((_MSC_VER / 100) - 15)); } - return QLatin1String("MSVC "); + return "MSVC "_L1; #else return QStringLiteral(""); #endif diff --git a/src/libs/vmisc/qxtcsvmodel.cpp b/src/libs/vmisc/qxtcsvmodel.cpp index 675eb44e1..e804eeb68 100644 --- a/src/libs/vmisc/qxtcsvmodel.cpp +++ b/src/libs/vmisc/qxtcsvmodel.cpp @@ -50,6 +50,12 @@ #include "backport/text.h" #endif +#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) +#include "compatibility.h" +#endif + +using namespace Qt::Literals::StringLiterals; + class QxtCsvModelPrivate : public QxtPrivate { public: diff --git a/src/libs/vmisc/svgfont/svgdef.cpp b/src/libs/vmisc/svgfont/svgdef.cpp index 5b89bcf24..f78a7d2a4 100644 --- a/src/libs/vmisc/svgfont/svgdef.cpp +++ b/src/libs/vmisc/svgfont/svgdef.cpp @@ -31,6 +31,12 @@ #include #include +#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) +#include "../compatibility.h" +#endif + +using namespace Qt::Literals::StringLiterals; + //--------------------------------------------------------------------------------------------------------------------- auto LatinWritingSystem(QChar c) -> bool { @@ -1569,13 +1575,13 @@ auto WritingSystemSample(SVGFontWritingSystem writingSystem) -> QString { case SVGFontWritingSystem::Any: case SVGFontWritingSystem::Symbol: - sample += QLatin1String("AaBbzZ"); + sample += "AaBbzZ"_L1; break; case SVGFontWritingSystem::Latin: - sample = QLatin1String("Aa"); + sample = "Aa"_L1; sample += QChar(0x00C3); sample += QChar(0x00E1); - sample += QLatin1String("Zz"); + sample += "Zz"_L1; break; case SVGFontWritingSystem::Greek: sample += QChar(0x0393); diff --git a/src/libs/vmisc/svgfont/vsvgfontdatabase.cpp b/src/libs/vmisc/svgfont/vsvgfontdatabase.cpp index 2b4f5ffcc..d0a095c7e 100644 --- a/src/libs/vmisc/svgfont/vsvgfontdatabase.cpp +++ b/src/libs/vmisc/svgfont/vsvgfontdatabase.cpp @@ -38,6 +38,12 @@ #include "vsvgfontengine.h" #include "vsvgfontreader.h" +#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) +#include "../compatibility.h" +#endif + +using namespace Qt::Literals::StringLiterals; + namespace { QT_WARNING_PUSH @@ -199,7 +205,7 @@ auto VSvgFontDatabase::SystemSVGFontPath() -> QString #ifdef Q_OS_WIN return QCoreApplication::applicationDirPath() + fontPath; #elif defined(Q_OS_MAC) - QDir dirBundle(QCoreApplication::applicationDirPath() + QLatin1String("/../Resources") + fontPath); + QDir dirBundle(QCoreApplication::applicationDirPath() + "/../Resources"_L1 + fontPath); if (dirBundle.exists()) { return dirBundle.absolutePath(); diff --git a/src/libs/vmisc/svgfont/vsvgfontengine.cpp b/src/libs/vmisc/svgfont/vsvgfontengine.cpp index cd61e5adf..ce16f1516 100644 --- a/src/libs/vmisc/svgfont/vsvgfontengine.cpp +++ b/src/libs/vmisc/svgfont/vsvgfontengine.cpp @@ -40,6 +40,8 @@ #include #include +using namespace Qt::Literals::StringLiterals; + //--------------------------------------------------------------------------------------------------------------------- VSvgFontEngine::VSvgFontEngine() : d(new VSvgFontEngineData()) @@ -388,7 +390,7 @@ auto VSvgFontEngine::ElidedText(const QString &text, SVGTextElideMode mode, int } else { - ellipsis = QLatin1String("..."); + ellipsis = "..."_L1; } } diff --git a/src/libs/vmisc/svgfont/vsvgfontreader.cpp b/src/libs/vmisc/svgfont/vsvgfontreader.cpp index db155d238..e18f7b8ad 100644 --- a/src/libs/vmisc/svgfont/vsvgfontreader.cpp +++ b/src/libs/vmisc/svgfont/vsvgfontreader.cpp @@ -38,22 +38,28 @@ #include #include +#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) +#include "../compatibility.h" +#endif + +using namespace Qt::Literals::StringLiterals; + namespace { //--------------------------------------------------------------------------------------------------------------------- auto ParseFontStyle(const QString &fontStyle) -> SVGFontStyle { - if (fontStyle == QLatin1String("normal")) + if (fontStyle == "normal"_L1) { return SVGFontStyle::Normal; } - if (fontStyle == QLatin1String("italic")) + if (fontStyle == "italic"_L1) { return SVGFontStyle::Italic; } - if (fontStyle == QLatin1String("oblique")) + if (fontStyle == "oblique"_L1) { return SVGFontStyle::Oblique; } @@ -99,12 +105,12 @@ auto ParseFontWeight(const QString &fontWeight) -> SVGFontWeight else { QString fontWeightLower = fontWeight.toLower(); - if (fontWeightLower == QLatin1String("normal")) + if (fontWeightLower == "normal"_L1) { return SVGFontWeight::Normal; } - if (fontWeightLower == QLatin1String("bold")) + if (fontWeightLower == "bold"_L1) { return SVGFontWeight::Bold; } @@ -115,13 +121,13 @@ auto ParseFontWeight(const QString &fontWeight) -> SVGFontWeight //--------------------------------------------------------------------------------------------------------------------- auto InitFont(const QXmlStreamAttributes &fontAttr) -> VSvgFont { - const auto hax = fontAttr.value(QLatin1String("horiz-adv-x")); + const auto hax = fontAttr.value("horiz-adv-x"_L1); qreal horizAdvX = hax.toDouble(); - QString id = fontAttr.value(QLatin1String("id")).toString(); + QString id = fontAttr.value("id"_L1).toString(); if (id.isEmpty()) { - id = fontAttr.value(QLatin1String("xml:id")).toString(); + id = fontAttr.value("xml:id"_L1).toString(); } VSvgFont font(horizAdvX); @@ -141,11 +147,11 @@ auto VSvgFontReader::ReadSvgFontHeader(QFile *file) -> VSvgFont { if (readNextStartElement()) { - if (name() == QLatin1String("svg")) + if (name() == "svg"_L1) { while (readNextStartElement()) { - if (name() == QLatin1String("defs")) + if (name() == "defs"_L1) { return ReadFontHeader(); } @@ -185,11 +191,11 @@ auto VSvgFontReader::ReadSvgFont(QFile *file) -> VSvgFontEngine { if (readNextStartElement()) { - if (name() == QLatin1String("svg")) + if (name() == "svg"_L1) { while (readNextStartElement()) { - if (name() == QLatin1String("defs")) + if (name() == "defs"_L1) { return ReadFontData(); } @@ -221,11 +227,11 @@ auto VSvgFontReader::ReadSvgFont(QFile *file) -> VSvgFontEngine //--------------------------------------------------------------------------------------------------------------------- auto VSvgFontReader::ReadFontHeader() -> VSvgFont { - AssertRootTag(QLatin1String("defs")); + AssertRootTag("defs"_L1); while (readNextStartElement()) { - if (name() == QLatin1String("font")) + if (name() == "font"_L1) { return ReadFontFace(); } @@ -238,13 +244,13 @@ auto VSvgFontReader::ReadFontHeader() -> VSvgFont //--------------------------------------------------------------------------------------------------------------------- auto VSvgFontReader::ReadFontFace() -> VSvgFont { - AssertRootTag(QLatin1String("font")); + AssertRootTag("font"_L1); VSvgFont font = InitFont(attributes()); while (readNextStartElement()) { - if (name() == QLatin1String("font-face")) + if (name() == "font-face"_L1) { SetFontFace(&font); return font; @@ -259,11 +265,11 @@ auto VSvgFontReader::ReadFontFace() -> VSvgFont //--------------------------------------------------------------------------------------------------------------------- auto VSvgFontReader::ReadFontData() -> VSvgFontEngine { - AssertRootTag(QLatin1String("defs")); + AssertRootTag("defs"_L1); while (readNextStartElement()) { - if (name() == QLatin1String("font")) + if (name() == "font"_L1) { return ReadFont(); } @@ -279,7 +285,7 @@ auto VSvgFontReader::ReadFontData() -> VSvgFontEngine //--------------------------------------------------------------------------------------------------------------------- auto VSvgFontReader::ReadFont() -> VSvgFontEngine { - AssertRootTag(QLatin1String("font")); + AssertRootTag("font"_L1); VSvgFont font = InitFont(attributes()); @@ -287,7 +293,7 @@ auto VSvgFontReader::ReadFont() -> VSvgFontEngine while (readNextStartElement()) { - if (name() == QLatin1String("font-face")) + if (name() == "font-face"_L1) { SetFontFace(&font); engine = VSvgFontEngine(font); @@ -300,7 +306,7 @@ auto VSvgFontReader::ReadFont() -> VSvgFontEngine while (readNextStartElement()) { - if (name() == QLatin1String("missing-glyph") || name() == QLatin1String("glyph")) + if (name() == "missing-glyph"_L1 || name() == "glyph"_L1) { ParseSvgGlyph(&engine, attributes()); } @@ -331,8 +337,8 @@ void VSvgFontReader::AssertRootTag(const QString &tag) const void VSvgFontReader::SetFontFace(VSvgFont *font) { QXmlStreamAttributes fontFaceAttr = attributes(); - QString fontFamily = fontFaceAttr.value(QLatin1String("font-family")).toString(); - const auto unitsPerEmStr = fontFaceAttr.value(QLatin1String("units-per-em")); + QString fontFamily = fontFaceAttr.value("font-family"_L1).toString(); + const auto unitsPerEmStr = fontFaceAttr.value("units-per-em"_L1); qreal unitsPerEm = unitsPerEmStr.toDouble(); if (qFuzzyIsNull(unitsPerEm)) @@ -340,33 +346,33 @@ void VSvgFontReader::SetFontFace(VSvgFont *font) unitsPerEm = 1000; } - const auto ascentStr = fontFaceAttr.value(QLatin1String("ascent")); + const auto ascentStr = fontFaceAttr.value("ascent"_L1); qreal ascent = ascentStr.toDouble(); if (qFuzzyIsNull(ascent)) { ascent = 800; } - const auto descentStr = fontFaceAttr.value(QLatin1String("descent")); + const auto descentStr = fontFaceAttr.value("descent"_L1); qreal descent = descentStr.toDouble(); if (qFuzzyIsNull(descent)) { descent = -200; } - QString fontStyle = fontFaceAttr.value(QLatin1String("font-style")).toString(); - QString fontWeight = fontFaceAttr.value(QLatin1String("font-weight")).toString(); + QString fontStyle = fontFaceAttr.value("font-style"_L1).toString(); + QString fontWeight = fontFaceAttr.value("font-weight"_L1).toString(); QString fontName; while (readNextStartElement()) { - if (name() == QLatin1String("font-face-src")) + if (name() == "font-face-src"_L1) { while (readNextStartElement()) { - if (name() == QLatin1String("font-face-name")) + if (name() == "font-face-name"_L1) { - fontName = attributes().value(QLatin1String("name")).toString(); + fontName = attributes().value("name"_L1).toString(); } else { @@ -392,9 +398,9 @@ void VSvgFontReader::SetFontFace(VSvgFont *font) //--------------------------------------------------------------------------------------------------------------------- void VSvgFontReader::ParseSvgGlyph(VSvgFontEngine *engine, const QXmlStreamAttributes &glyphAttr) { - auto uncStr = glyphAttr.value(QLatin1String("unicode")); - auto havStr = glyphAttr.value(QLatin1String("horiz-adv-x")); - auto pathStr = glyphAttr.value(QLatin1String("d")); + auto uncStr = glyphAttr.value("unicode"_L1); + auto havStr = glyphAttr.value("horiz-adv-x"_L1); + auto pathStr = glyphAttr.value("d"_L1); QChar unicode = (uncStr.isEmpty()) ? u'\0' : uncStr.at(0); qreal havx = (havStr.isEmpty()) ? -1 : havStr.toDouble(); diff --git a/src/libs/vmisc/svgfont/vsvgpathtokenizer.cpp b/src/libs/vmisc/svgfont/vsvgpathtokenizer.cpp index eb4e79a71..226f6be34 100644 --- a/src/libs/vmisc/svgfont/vsvgpathtokenizer.cpp +++ b/src/libs/vmisc/svgfont/vsvgpathtokenizer.cpp @@ -34,6 +34,8 @@ #include "../compatibility.h" +using namespace Qt::Literals::StringLiterals; + namespace { QT_WARNING_PUSH @@ -410,7 +412,7 @@ void VSVGPathTokenizer::Command_m(QPainterPath &path) const // As per 1.2 spec 8.3.2 The "moveto" commands // If a 'moveto' is followed by multiple pairs of coordinates without explicit commands, // the subsequent pairs shall be treated as implicit 'lineto' commands. - m_pathElem = QLatin1Char('l'); + m_pathElem = 'l'_L1; } //--------------------------------------------------------------------------------------------------------------------- @@ -430,7 +432,7 @@ void VSVGPathTokenizer::Command_M(QPainterPath &path) const // As per 1.2 spec 8.3.2 The "moveto" commands // If a 'moveto' is followed by multiple pairs of coordinates without explicit commands, // the subsequent pairs shall be treated as implicit 'lineto' commands. - m_pathElem = QLatin1Char('L'); + m_pathElem = 'L'_L1; } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vmisc/testpath.cpp b/src/libs/vmisc/testpath.cpp index 4d9ef4aca..2acc5e16e 100644 --- a/src/libs/vmisc/testpath.cpp +++ b/src/libs/vmisc/testpath.cpp @@ -27,20 +27,25 @@ *************************************************************************/ #include "testpath.h" -#include -#include -#include -#include #include +#include #include +#include +#include +#include + +#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) +#include "compatibility.h" +#endif + +using namespace Qt::Literals::StringLiterals; //--------------------------------------------------------------------------------------------------------------------- #if !defined(V_NO_ASSERT) // Use for writing tests auto PointToJson(const QPointF &point) -> QJsonObject { - QJsonObject pointObject - { + QJsonObject pointObject{ {"type", "QPointF"}, {"x", point.x()}, {"y", point.y()}, @@ -52,11 +57,11 @@ auto PointToJson(const QPointF &point) -> QJsonObject void VectorToJson(const QVector &points, QJsonObject &json) { QJsonArray pointsArray; - for (auto point: points) + for (auto point : points) { pointsArray.append(PointToJson(point)); } - json[QLatin1String("vector")] = pointsArray; + json["vector"_L1] = pointsArray; } #endif // !defined(V_NO_ASSERT) diff --git a/src/libs/vmisc/testpath.h b/src/libs/vmisc/testpath.h index 8c0a4d855..9bcac2067 100644 --- a/src/libs/vmisc/testpath.h +++ b/src/libs/vmisc/testpath.h @@ -29,8 +29,8 @@ #define TESTPATH_H #include -#include #include +#include #include #include #include @@ -45,14 +45,12 @@ class VRawSAPoint; auto PointToJson(const QPointF &point) -> QJsonObject; void VectorToJson(const QVector &points, QJsonObject &json); -template -void VectorToJson(const QVector &points, QJsonObject &json); +template void VectorToJson(const QVector &points, QJsonObject &json); //--------------------------------------------------------------------------------------------------------------------- -template -void DumpVector(const QVector &points, const QString &templateName=QString()) +template void DumpVector(const QVector &points, const QString &templateName = QString()) { - QTemporaryFile temp; // Go to tmp folder to find dump + QTemporaryFile temp; // Go to tmp folder to find dump temp.setAutoRemove(false); // Remove dump manually if (not templateName.isEmpty()) @@ -63,14 +61,14 @@ void DumpVector(const QVector &points, const QString &templateName=QString()) if (temp.open()) { #if defined(Q_OS_LINUX) - #if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0) -// On Linux, QTemporaryFile will attempt to create unnamed temporary -// files. If that succeeds, open() will return true but exists() will be -// false. If you call fileName() or any function that calls it, -// QTemporaryFile will give the file a name, so most applications will -// not see a difference. +#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0) + // On Linux, QTemporaryFile will attempt to create unnamed temporary + // files. If that succeeds, open() will return true but exists() will be + // false. If you call fileName() or any function that calls it, + // QTemporaryFile will give the file a name, so most applications will + // not see a difference. temp.fileName(); // call to create a file on disk - #endif +#endif #endif QJsonObject vectorObject; VectorToJson(points, vectorObject); @@ -83,11 +81,10 @@ void DumpVector(const QVector &points, const QString &templateName=QString()) } //--------------------------------------------------------------------------------------------------------------------- -template -void VectorToJson(const QVector &points, QJsonObject &json) +template void VectorToJson(const QVector &points, QJsonObject &json) { QJsonArray pointsArray; - for (auto point: points) + for (auto point : points) { pointsArray.append(point.toJson()); } diff --git a/src/libs/vmisc/theme/vapplicationstyle.cpp b/src/libs/vmisc/theme/vapplicationstyle.cpp index cf3ccb6a4..be267198e 100644 --- a/src/libs/vmisc/theme/vapplicationstyle.cpp +++ b/src/libs/vmisc/theme/vapplicationstyle.cpp @@ -34,6 +34,12 @@ #include "vtheme.h" +#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) +#include "../compatibility.h" +#endif + +using namespace Qt::Literals::StringLiterals; + namespace { auto StandardIconPaths() -> QHash @@ -239,7 +245,7 @@ auto VApplicationStyle::layoutSpacing(QSizePolicy::ControlType control1, QSizePo auto VApplicationStyle::StyleIcon(StandardPixmap standardIcon, const QStyleOption *option, const QWidget *widget) const -> QIcon { - if (VTheme::ThemeStylesheet() == QLatin1String("native")) + if (VTheme::ThemeStylesheet() == "native"_L1) { return m_style->standardIcon(standardIcon, option, widget); } diff --git a/src/libs/vmisc/theme/vmanuallayoutstyle.cpp b/src/libs/vmisc/theme/vmanuallayoutstyle.cpp index 74c3fb5d2..7d5dd8cb7 100644 --- a/src/libs/vmisc/theme/vmanuallayoutstyle.cpp +++ b/src/libs/vmisc/theme/vmanuallayoutstyle.cpp @@ -30,31 +30,35 @@ #include #include +#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) +#include "../compatibility.h" +#endif + +using namespace Qt::Literals::StringLiterals; + namespace { QT_WARNING_PUSH QT_WARNING_DISABLE_CLANG("-Wunused-member-function") -Q_GLOBAL_STATIC_WITH_ARGS(const QString, ManualLayoutStyleNodeVar, (QLatin1String("ManualLayoutStyle"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, SheetBorderColorVar, (QLatin1String("SheetBorderColor"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, SheetMarginColorVar, (QLatin1String("SheetMarginColor"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, SheetGridColorVar, (QLatin1String("SheetGridColor"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, SheetTileGridColorVar, (QLatin1String("SheetTileGridColor"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, SheetTileNumberColorVar, (QLatin1String("SheetTileNumberColor"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, PieceOkColorVar, (QLatin1String("PieceOkColor"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, PieceErrorColorVar, (QLatin1String("PieceErrorColor"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, PieceHoverColorVar, (QLatin1String("PieceHoverColor"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, PieceHandleColorVar, (QLatin1String("PieceHandleColor"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, PieceHandleHoverColorVar, (QLatin1String("PieceHandleHoverColor"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, CarrouselPieceColorVar, (QLatin1String("CarrouselPieceColor"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, ManualLayoutStyleNodeVar, ("ManualLayoutStyle"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, SheetBorderColorVar, ("SheetBorderColor"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, SheetMarginColorVar, ("SheetMarginColor"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, SheetGridColorVar, ("SheetGridColor"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, SheetTileGridColorVar, ("SheetTileGridColor"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, SheetTileNumberColorVar, ("SheetTileNumberColor"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, PieceOkColorVar, ("PieceOkColor"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, PieceErrorColorVar, ("PieceErrorColor"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, PieceHoverColorVar, ("PieceHoverColor"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, PieceHandleColorVar, ("PieceHandleColor"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, PieceHandleHoverColorVar, ("PieceHandleHoverColor"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, CarrouselPieceColorVar, ("CarrouselPieceColor"_L1)) // NOLINT // NOLINTNEXTLINE -Q_GLOBAL_STATIC_WITH_ARGS(const QString, CarrouselPieceSelectedColorVar, (QLatin1String("CarrouselPieceSelectedColor"))) +Q_GLOBAL_STATIC_WITH_ARGS(const QString, CarrouselPieceSelectedColorVar, ("CarrouselPieceSelectedColor"_L1)) // NOLINTNEXTLINE -Q_GLOBAL_STATIC_WITH_ARGS(const QString, CarrouselPieceBackgroundColorVar, - (QLatin1String("CarrouselPieceBackgroundColor"))) +Q_GLOBAL_STATIC_WITH_ARGS(const QString, CarrouselPieceBackgroundColorVar, ("CarrouselPieceBackgroundColor"_L1)) // NOLINTNEXTLINE -Q_GLOBAL_STATIC_WITH_ARGS(const QString, CarrouselPieceForegroundColorVar, - (QLatin1String("CarrouselPieceForegroundColor"))) +Q_GLOBAL_STATIC_WITH_ARGS(const QString, CarrouselPieceForegroundColorVar, ("CarrouselPieceForegroundColor"_L1)) QT_WARNING_POP } // namespace diff --git a/src/libs/vmisc/theme/vpatternpiecestyle.cpp b/src/libs/vmisc/theme/vpatternpiecestyle.cpp index 497ae725f..9980aa2de 100644 --- a/src/libs/vmisc/theme/vpatternpiecestyle.cpp +++ b/src/libs/vmisc/theme/vpatternpiecestyle.cpp @@ -29,20 +29,26 @@ #include +#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) +#include "../compatibility.h" +#endif + +using namespace Qt::Literals::StringLiterals; + namespace { QT_WARNING_PUSH QT_WARNING_DISABLE_CLANG("-Wunused-member-function") -Q_GLOBAL_STATIC_WITH_ARGS(const QString, PatternPieceStyleNodeVar, (QLatin1String("PatternPieceStyle"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, PieceColorVar, (QLatin1String("PieceColor"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, PointColorVar, (QLatin1String("PointColor"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, NodeLabelColorVar, (QLatin1String("NodeLabelColor"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, NodeLabelHoverColorVar, (QLatin1String("NodeLabelHoverColor"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, NodeLabelLineColorVar, (QLatin1String("NodeLabelLineColor"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, LabelBackgroundColorVar, (QLatin1String("LabelBackgroundColor"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, LabelTextColorVar, (QLatin1String("LabelTextColor"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, LabelModeColorVar, (QLatin1String("LabelModeColor"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, PatternPieceStyleNodeVar, ("PatternPieceStyle"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, PieceColorVar, ("PieceColor"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, PointColorVar, ("PointColor"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, NodeLabelColorVar, ("NodeLabelColor"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, NodeLabelHoverColorVar, ("NodeLabelHoverColor"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, NodeLabelLineColorVar, ("NodeLabelLineColor"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, LabelBackgroundColorVar, ("LabelBackgroundColor"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, LabelTextColorVar, ("LabelTextColor"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, LabelModeColorVar, ("LabelModeColor"_L1)) // NOLINT QT_WARNING_POP } // namespace diff --git a/src/libs/vmisc/theme/vtoolstyle.cpp b/src/libs/vmisc/theme/vtoolstyle.cpp index 4e4337730..58f5b2dda 100644 --- a/src/libs/vmisc/theme/vtoolstyle.cpp +++ b/src/libs/vmisc/theme/vtoolstyle.cpp @@ -33,28 +33,34 @@ #include #include +#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) +#include "../compatibility.h" +#endif + +using namespace Qt::Literals::StringLiterals; + namespace { QT_WARNING_PUSH QT_WARNING_DISABLE_CLANG("-Wunused-member-function") -Q_GLOBAL_STATIC_WITH_ARGS(const QString, ToolStyleNodeVar, (QLatin1String("ToolStyle"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, PatternColorVar, (QLatin1String("PatternColor"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, DisabledColorVar, (QLatin1String("DisabledColor"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, ColorAdjustmentsVar, (QLatin1String("ColorAdjustments"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, PointColorVar, (QLatin1String("PointColor"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, LabelColorVar, (QLatin1String("LabelColor"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, LabelHoverColorVar, (QLatin1String("LabelHoverColor"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, LabelLineColorVar, (QLatin1String("LabelLineColor"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, AccuracyRadiusColorVar, (QLatin1String("AccuracyRadiusColor"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, ControlLineColorVar, (QLatin1String("ControlLineColor"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, ControlPointColorVar, (QLatin1String("ControlPointColor"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, VisMainColorVar, (QLatin1String("VisMainColor"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, VisSupportColorVar, (QLatin1String("VisSupportColor"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, VisSupportColor2Var, (QLatin1String("VisSupportColor2"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, VisSupportColor3Var, (QLatin1String("VisSupportColor3"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, VisSupportColor4Var, (QLatin1String("VisSupportColor4"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, BasePointColorVar, (QLatin1String("BasePointColor"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, ToolStyleNodeVar, ("ToolStyle"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, PatternColorVar, ("PatternColor"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, DisabledColorVar, ("DisabledColor"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, ColorAdjustmentsVar, ("ColorAdjustments"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, PointColorVar, ("PointColor"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, LabelColorVar, ("LabelColor"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, LabelHoverColorVar, ("LabelHoverColor"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, LabelLineColorVar, ("LabelLineColor"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, AccuracyRadiusColorVar, ("AccuracyRadiusColor"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, ControlLineColorVar, ("ControlLineColor"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, ControlPointColorVar, ("ControlPointColor"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, VisMainColorVar, ("VisMainColor"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, VisSupportColorVar, ("VisSupportColor"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, VisSupportColor2Var, ("VisSupportColor2"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, VisSupportColor3Var, ("VisSupportColor3"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, VisSupportColor4Var, ("VisSupportColor4"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, BasePointColorVar, ("BasePointColor"_L1)) // NOLINT QT_WARNING_POP diff --git a/src/libs/vmisc/vabstractapplication.cpp b/src/libs/vmisc/vabstractapplication.cpp index 35a39aab4..4b3f6e4ad 100644 --- a/src/libs/vmisc/vabstractapplication.cpp +++ b/src/libs/vmisc/vabstractapplication.cpp @@ -62,6 +62,8 @@ #include "appimage.h" #endif // defined(APPIMAGE) && defined(Q_OS_LINUX) +using namespace Qt::Literals::StringLiterals; + namespace { auto FilterLocales(const QStringList &locales) -> QStringList @@ -69,7 +71,7 @@ auto FilterLocales(const QStringList &locales) -> QStringList QStringList filtered; for (const auto &locale : locales) { - if (not locale.startsWith(QLatin1String("ru"))) + if (not locale.startsWith("ru"_L1)) { filtered.append(locale); } @@ -118,17 +120,17 @@ VAbstractApplication::VAbstractApplication(int &argc, char **argv) #if defined(V_NO_ASSERT) // Ignore SSL-related warnings // See issue #528: Error: QSslSocket: cannot resolve SSLv2_client_method. - rules += QLatin1String("qt.network.ssl.warning=false\n"); + rules += "qt.network.ssl.warning=false\n"_L1; // See issue #568: Certificate checking on Mac OS X. - rules += QLatin1String("qt.network.ssl.critical=false\n" - "qt.network.ssl.fatal=false\n"); + rules += "qt.network.ssl.critical=false\n" + "qt.network.ssl.fatal=false\n"_L1; #endif // defined(V_NO_ASSERT) #if defined(V_NO_ASSERT) // See issue #992: QXcbConnection: XCB Error. - rules += QLatin1String("qt.qpa*=false\n"); - rules += QLatin1String("kf5.kio.core*=false\n"); - rules += QLatin1String("qt.gui.icc.warning=false\n"); + rules += "qt.qpa*=false\n"_L1; + rules += "kf5.kio.core*=false\n"_L1; + rules += "qt.gui.icc.warning=false\n"_L1; #endif if (not rules.isEmpty()) @@ -189,12 +191,11 @@ auto VAbstractApplication::translationsPath(const QString &locale) -> QString QString mainPath; if (locale.isEmpty()) { - mainPath = QCoreApplication::applicationDirPath() + QLatin1String("/../Resources") + trPath; + mainPath = QCoreApplication::applicationDirPath() + "/../Resources"_L1 + trPath; } else { - mainPath = QCoreApplication::applicationDirPath() + QLatin1String("/../Resources") + trPath + - QLatin1String("/") + locale + QLatin1String(".lproj"); + mainPath = QCoreApplication::applicationDirPath() + "/../Resources"_L1 + trPath + '/'_L1 + locale + ".lproj"_L1; } QDir dirBundle(mainPath); if (dirBundle.exists()) @@ -285,7 +286,7 @@ void VAbstractApplication::WinAttachConsole() //--------------------------------------------------------------------------------------------------------------------- void VAbstractApplication::LoadTranslation(QString locale) { - if (locale.startsWith(QLatin1String("ru"))) + if (locale.startsWith("ru"_L1)) { locale = QString(); } @@ -468,7 +469,7 @@ void VAbstractApplication::CacheTextCodec(QStringConverter::Encoding encoding, V void VAbstractApplication::CheckSystemLocale() { const QString defLocale = QLocale::system().name(); - if (defLocale.startsWith(QLatin1String("ru"))) + if (defLocale.startsWith("ru"_L1)) { qFatal("Incompatible locale \"%s\"", qPrintable(defLocale)); } @@ -537,7 +538,7 @@ void VAbstractApplication::InitHighDpiScaling(int argc, char *argv[]) { #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) /* For more info see: http://doc.qt.io/qt-5/highdpi.html */ - if (IsOptionSet(argc, argv, qPrintable(QLatin1String("--") + LONG_OPTION_NO_HDPI_SCALING))) + if (IsOptionSet(argc, argv, qPrintable("--"_L1 + LONG_OPTION_NO_HDPI_SCALING))) { QCoreApplication::setAttribute(Qt::AA_DisableHighDpiScaling); } diff --git a/src/libs/vmisc/vabstractvalapplication.cpp b/src/libs/vmisc/vabstractvalapplication.cpp index eceee924b..2468b40a3 100644 --- a/src/libs/vmisc/vabstractvalapplication.cpp +++ b/src/libs/vmisc/vabstractvalapplication.cpp @@ -32,6 +32,12 @@ #include #include +#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) +#include "compatibility.h" +#endif + +using namespace Qt::Literals::StringLiterals; + //--------------------------------------------------------------------------------------------------------------------- VAbstractValApplication::VAbstractValApplication(int &argc, char **argv) : VAbstractApplication(argc, argv) @@ -95,7 +101,7 @@ auto VAbstractValApplication::GetPlaceholderTranslator() -> QSharedPointerGetLocale(); } - if (pieceLabelLocale.startsWith(QLatin1String("ru"))) + if (pieceLabelLocale.startsWith("ru"_L1)) { return QSharedPointer(new QTranslator); } diff --git a/src/libs/vmisc/vcommonsettings.cpp b/src/libs/vmisc/vcommonsettings.cpp index ed54f2ac4..a61a2c1b9 100644 --- a/src/libs/vmisc/vcommonsettings.cpp +++ b/src/libs/vmisc/vcommonsettings.cpp @@ -53,6 +53,8 @@ #include "defglobal.h" #include "literals.h" +using namespace Qt::Literals::StringLiterals; + const int VCommonSettings::defaultScrollingDuration = 300; const int VCommonSettings::scrollingDurationMin = 100; const int VCommonSettings::scrollingDurationMax = 1000; @@ -85,158 +87,142 @@ QT_WARNING_DISABLE_CLANG("-Wunused-member-function") namespace { // NOLINTNEXTLINE -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPathsIndividualMeasurements, - (QLatin1String("paths/individual_measurements"))) +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPathsIndividualMeasurements, ("paths/individual_measurements"_L1)) // NOLINTNEXTLINE -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPathsMultisizeMeasurements, - (QLatin1String("paths/standard_measurements"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPathsPattern, (QLatin1String("paths/pattern"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPathsManualLayouts, (QLatin1String("paths/manualLayouts"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPathsSVGFonts, (QLatin1String("paths/svgFonts"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPathsMultisizeMeasurements, ("paths/standard_measurements"_L1)) +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPathsPattern, ("paths/pattern"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPathsManualLayouts, ("paths/manualLayouts"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPathsSVGFonts, ("paths/svgFonts"_L1)) // NOLINT // NOLINTNEXTLINE -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPathsFontCorrections, (QLatin1String("paths/fontCorrections"))) +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPathsFontCorrections, ("paths/fontCorrections"_L1)) // NOLINTNEXTLINE -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationOsSeparator, (QLatin1String("configuration/osSeparator"))) +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationOsSeparator, ("configuration/osSeparator"_L1)) // NOLINTNEXTLINE -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationAutosaveState, - (QLatin1String("configuration/autosave/state"))) +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationAutosaveState, ("configuration/autosave/state"_L1)) // NOLINTNEXTLINE -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationAutosaveTime, - (QLatin1String("configuration/autosave/time"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationLocale, (QLatin1String("configuration/locale"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationAutosaveTime, ("configuration/autosave/time"_L1)) +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationLocale, ("configuration/locale"_L1)) // NOLINT // NOLINTNEXTLINE -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationPieceLabelLocale, - (QLatin1String("configuration/pieceLabelLocale"))) -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, settingConfigurationPieceLabelLocale, ("configuration/pieceLabelLocale"_L1)) +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPMSystemCode, ("configuration/pmscode"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationUnit, ("configuration/unit"_L1)) // NOLINT // NOLINTNEXTLINE Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationConfirmItemDeletion, - (QLatin1String("configuration/confirm_item_deletion"))) + ("configuration/confirm_item_deletion"_L1)) // NOLINTNEXTLINE Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationConfirmFormatRewriting, - (QLatin1String("configuration/confirm_format_rewriting"))) + ("configuration/confirm_format_rewriting"_L1)) // NOLINTNEXTLINE Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationAskContinueIfLayoutStale, - (QLatin1String("configuration/askContinueIfLayoutStale"))) + ("configuration/askContinueIfLayoutStale"_L1)) // NOLINTNEXTLINE -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationToolBarStyle, - (QLatin1String("configuration/tool_bar_style"))) +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationToolBarStyle, ("configuration/tool_bar_style"_L1)) // NOLINTNEXTLINE Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationToolboxIconSizeSmall, - (QLatin1String("configuration/toolboxIconSizeSmall"))) + ("configuration/toolboxIconSizeSmall"_L1)) // NOLINTNEXTLINE -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationFreeCurveMode, - (QLatin1String("configuration/freeCurveMode"))) +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationFreeCurveMode, ("configuration/freeCurveMode"_L1)) // NOLINTNEXTLINE Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationDoubleClickZoomFitBestCurrentPP, - (QLatin1String("configuration/doubleClickZoomFitBestCurrentPP"))) + ("configuration/doubleClickZoomFitBestCurrentPP"_L1)) // NOLINTNEXTLINE -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationInteractiveTools, - (QLatin1String("configuration/interactiveTools"))) +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationInteractiveTools, ("configuration/interactiveTools"_L1)) // NOLINTNEXTLINE Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationDontUseNativeDialog, - (QLatin1String("configuration/dontUseNativeDialog"))) + ("configuration/dontUseNativeDialog"_L1)) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternUndo, (QLatin1String("pattern/undo"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternUndo, ("pattern/undo"_L1)) // NOLINT // NOLINTNEXTLINE -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternForbidFlipping, (QLatin1String("pattern/forbidFlipping"))) +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternForbidFlipping, ("pattern/forbidFlipping"_L1)) // NOLINTNEXTLINE -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternForceFlipping, (QLatin1String("pattern/forceFlipping"))) +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternForceFlipping, ("pattern/forceFlipping"_L1)) // NOLINTNEXTLINE -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternSewLineOnDrawing, (QLatin1String("pattern/sewLineOnDrawing"))) -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, settingPatternSewLineOnDrawing, ("pattern/sewLineOnDrawing"_L1)) +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternHideMainPath, ("pattern/hideMainPath"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingDoublePassmark, ("pattern/doublePassmark"_L1)) // NOLINT // NOLINTNEXTLINE -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternDefaultSeamAllowance, - (QLatin1String("pattern/defaultSeamAllowance"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternLabelFont, (QLatin1String("pattern/labelFont"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternLabelSVGFont, (QLatin1String("pattern/labelSVGFont"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternDefaultSeamAllowance, ("pattern/defaultSeamAllowance"_L1)) +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternLabelFont, ("pattern/labelFont"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternLabelSVGFont, ("pattern/labelSVGFont"_L1)) // NOLINT // NOLINTNEXTLINE -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPieceLabelFontPointSize, - (QLatin1String("pattern/pieceLabelFontPointSize"))) +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPieceLabelFontPointSize, ("pattern/pieceLabelFontPointSize"_L1)) // NOLINTNEXTLINE -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternSingleStrokeOutlineFont, - (QLatin1String("pattern/singleStrokeOutlineFont"))) +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternSingleStrokeOutlineFont, ("pattern/singleStrokeOutlineFont"_L1)) // NOLINTNEXTLINE -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternSingleLineFonts, (QLatin1String("pattern/singleLineFonts"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternLineWidth, (QLatin1String("pattern/lineWidth"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternSingleLineFonts, ("pattern/singleLineFonts"_L1)) +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternLineWidth, ("pattern/lineWidth"_L1)) // NOLINT // NOLINTNEXTLINE -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternCurveApproximationScale, - (QLatin1String("pattern/curveApproximationScale"))) +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternCurveApproximationScale, ("pattern/curveApproximationScale"_L1)) // NOLINTNEXTLINE -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternShowCurveDetails, (QLatin1String("pattern/showCurveDetails"))) +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternShowCurveDetails, ("pattern/showCurveDetails"_L1)) // NOLINTNEXTLINE -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternPieceShowMainPath, (QLatin1String("pattern/pieceShowMainPath"))) +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternPieceShowMainPath, ("pattern/pieceShowMainPath"_L1)) // NOLINTNEXTLINE -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternLabelFontSize, (QLatin1String("pattern/labelFontSize"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternHideLabels, (QLatin1String("pattern/hideLabels"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternLabelFontSize, ("pattern/labelFontSize"_L1)) +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternHideLabels, ("pattern/hideLabels"_L1)) // NOLINT // NOLINTNEXTLINE -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternShowAccuracyRadius, - (QLatin1String("pattern/showAccuracyRadius"))) +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternShowAccuracyRadius, ("pattern/showAccuracyRadius"_L1)) // NOLINTNEXTLINE -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternUseOpenGLRender, (QLatin1String("pattern/useOpenGLRender"))) +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternUseOpenGLRender, ("pattern/useOpenGLRender"_L1)) // NOLINTNEXTLINE -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternGraphicalOutput, (QLatin1String("pattern/graphicalOutput"))) +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternGraphicalOutput, ("pattern/graphicalOutput"_L1)) // NOLINTNEXTLINE -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingsPatternTranslateFormula, (QLatin1String("pattern/translateFormula"))) -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, settingGeneralToolbarsState, (QLatin1String("toolbarsState"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingsPatternTranslateFormula, ("pattern/translateFormula"_L1)) +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingGeneralRecentFileList, ("recentFileList"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingGeneralRestoreFileList, ("restoreFileList"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingGeneralGeometry, ("geometry"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingGeneralToolbarsState, ("toolbarsState"_L1)) // NOLINT // NOLINTNEXTLINE -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationThemeMode, (QLatin1String("configuration/themeMode"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPreferenceDialogSize, (QLatin1String("preferenceDialogSize"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationThemeMode, ("configuration/themeMode"_L1)) +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPreferenceDialogSize, ("preferenceDialogSize"_L1)) // NOLINT // NOLINTNEXTLINE -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingToolSeamAllowanceDialogSize, - (QLatin1String("toolSeamAllowanceDialogSize"))) +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingToolSeamAllowanceDialogSize, ("toolSeamAllowanceDialogSize"_L1)) // NOLINTNEXTLINE -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingIncrementsDialogSize, (QLatin1String("toolIncrementsDialogSize"))) +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingIncrementsDialogSize, ("toolIncrementsDialogSize"_L1)) // NOLINTNEXTLINE -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingFormulaWizardDialogSize, (QLatin1String("formulaWizardDialogSize"))) +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingFormulaWizardDialogSize, ("formulaWizardDialogSize"_L1)) // NOLINTNEXTLINE -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingFinalMeasurementsDialogSize, - (QLatin1String("finalMeasurementsDialogSize"))) +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingFinalMeasurementsDialogSize, ("finalMeasurementsDialogSize"_L1)) // NOLINTNEXTLINE -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutSettingsDialogSize, (QLatin1String("layoutSettingsDialogSize"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingDialogSplinePathSize, (QLatin1String("splinePathDialogSize"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutSettingsDialogSize, ("layoutSettingsDialogSize"_L1)) +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingDialogSplinePathSize, ("splinePathDialogSize"_L1)) // NOLINT // NOLINTNEXTLINE -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingAutomaticallyCheckUpdates, (QLatin1String("automaticallyCheckUpdates"))) +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingAutomaticallyCheckUpdates, ("automaticallyCheckUpdates"_L1)) // NOLINTNEXTLINE -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLatestSkippedVersion, (QLatin1String("lastestSkippedVersion"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingDateOfLastRemind, (QLatin1String("dateOfLastRemind"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLatestSkippedVersion, ("lastestSkippedVersion"_L1)) +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingDateOfLastRemind, ("dateOfLastRemind"_L1)) // NOLINT -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, settingCSVWithHeader, ("csv/withHeader"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingCSVCodec, ("csv/withCodec"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingCSVSeparator, ("csv/withSeparator"_L1)) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLabelDateFormat, (QLatin1String("label/dateFormat"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLabelDateFormat, ("label/dateFormat"_L1)) // NOLINT // NOLINTNEXTLINE -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLabelUserDateFormats, (QLatin1String("label/userDateFormats"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLabelTimeFormat, (QLatin1String("label/timeFormat"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLabelUserDateFormats, ("label/userDateFormats"_L1)) +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLabelTimeFormat, ("label/timeFormat"_L1)) // NOLINT // NOLINTNEXTLINE -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLabelUserTimeFormats, (QLatin1String("label/userTimeFormats"))) +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLabelUserTimeFormats, ("label/userTimeFormats"_L1)) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingScrollingDuration, (QLatin1String("scrolling/duration"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingScrollingDuration, ("scrolling/duration"_L1)) // NOLINT // NOLINTNEXTLINE -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingScrollingUpdateInterval, (QLatin1String("scrolling/updateInterval"))) +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingScrollingUpdateInterval, ("scrolling/updateInterval"_L1)) // NOLINTNEXTLINE -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingScrollingSensorMouseScale, - (QLatin1String("scrolling/sensorMouseScale"))) +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingScrollingSensorMouseScale, ("scrolling/sensorMouseScale"_L1)) // NOLINTNEXTLINE -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingScrollingWheelMouseScale, (QLatin1String("scrolling/wheelMouseScale"))) +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingScrollingWheelMouseScale, ("scrolling/wheelMouseScale"_L1)) // NOLINTNEXTLINE -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingScrollingAcceleration, (QLatin1String("scrolling/acceleration"))) +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingScrollingAcceleration, ("scrolling/acceleration"_L1)) -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, settingTiledPDFMargins, ("tiledPDF/margins"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingTiledPDFOrientation, ("tiledPDF/orientation"_L1)) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingWatermarkEditorSize, (QLatin1String("watermarkEditorSize"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingWatermarkEditorSize, ("watermarkEditorSize"_L1)) // NOLINT // NOLINTNEXTLINE -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingWatermarkCustomColors, (QLatin1String("watermarkCustomColors"))) +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingWatermarkCustomColors, ("watermarkCustomColors"_L1)) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingsStatistictAskCollect, (QLatin1String("askCollect"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingsStatistictCollect, (QLatin1String("collect"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingsStatistictClientID, (QLatin1String("clientID"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingsStatistictAskCollect, ("askCollect"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingsStatistictCollect, ("collect"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingsStatistictClientID, ("clientID"_L1)) // NOLINT // Reading settings file is very expensive, cache curve approximation to speed up getting value qreal curveApproximationCached = -1; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables) @@ -261,7 +247,7 @@ auto ClearFormats(const QStringList &predefinedFormats, QStringList formats) -> } } // namespace -Q_GLOBAL_STATIC_WITH_ARGS(const QString, commonIniFilename, (QLatin1String("common"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, commonIniFilename, ("common"_L1)) // NOLINT #if !defined(Q_OS_WIN) const QString VCommonSettings::unixStandardSharePath = QStringLiteral(PKGDATADIR); // NOLINT(cert-err58-cpp) @@ -977,20 +963,20 @@ auto VCommonSettings::GetCSVSeparator() const -> QChar switch (separator) { case 0: - return QChar('\t'); // NOLINT(modernize-return-braced-init-list) + return '\t'_L1; case 1: - return QChar(';'); // NOLINT(modernize-return-braced-init-list) + return ';'_L1; case 2: - return QChar(' '); // NOLINT(modernize-return-braced-init-list) + return ' '_L1; default: - return QChar(','); // NOLINT(modernize-return-braced-init-list) + return ','_L1; } } //--------------------------------------------------------------------------------------------------------------------- auto VCommonSettings::GetDefCSVSeparator() -> QChar { - return QChar(','); // NOLINT(modernize-return-braced-init-list) + return ','_L1; } //--------------------------------------------------------------------------------------------------------------------- @@ -1029,7 +1015,7 @@ auto VCommonSettings::GetDefaultSeamAllowance() -> double if (not ok) { qDebug() << "Could not convert value" << value(*settingPatternDefaultSeamAllowance, 0) - << "to real. Return default value for default seam allowance is " << defaultValue << QChar('.'); + << "to real. Return default value for default seam allowance is " << defaultValue << '.'_L1; val = defaultValue; } diff --git a/src/libs/vmisc/vmisc.qbs b/src/libs/vmisc/vmisc.qbs index 43b72726a..8be127c9a 100644 --- a/src/libs/vmisc/vmisc.qbs +++ b/src/libs/vmisc/vmisc.qbs @@ -1,7 +1,7 @@ import qbs.Utilities VLib { - Depends { name: "Qt"; submodules: ["core", "printsupport"] } + Depends { name: "Qt"; submodules: ["core", "printsupport", "gui"] } name: "VMiscLib" files: { diff --git a/src/libs/vmisc/vmodifierkey.cpp b/src/libs/vmisc/vmodifierkey.cpp index d8dc7d557..780768edd 100644 --- a/src/libs/vmisc/vmodifierkey.cpp +++ b/src/libs/vmisc/vmodifierkey.cpp @@ -29,11 +29,17 @@ #include +#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) +#include "compatibility.h" +#endif + +using namespace Qt::Literals::StringLiterals; + //--------------------------------------------------------------------------------------------------------------------- VModifierKey::VModifierKey(int key) - : m_nativeText(QKeySequence(static_cast(key)).toString(QKeySequence::NativeText)) + : m_nativeText(QKeySequence(static_cast(key)).toString(QKeySequence::NativeText)) { - if (m_nativeText.endsWith(QLatin1Char('+'))) + if (m_nativeText.endsWith('+'_L1)) { m_nativeText.chop(1); } @@ -41,14 +47,14 @@ VModifierKey::VModifierKey(int key) //--------------------------------------------------------------------------------------------------------------------- VModifierKey::VModifierKey(Qt::KeyboardModifiers keys) - : VModifierKey(static_cast(keys)) + : VModifierKey(static_cast(keys)) { // nothing else } //--------------------------------------------------------------------------------------------------------------------- VModifierKey::VModifierKey(Qt::Key key) - : VModifierKey(static_cast(key)) + : VModifierKey(static_cast(key)) { // nothing else } diff --git a/src/libs/vmisc/vvalentinasettings.cpp b/src/libs/vmisc/vvalentinasettings.cpp index a4250d269..902d59754 100644 --- a/src/libs/vmisc/vvalentinasettings.cpp +++ b/src/libs/vmisc/vvalentinasettings.cpp @@ -43,6 +43,8 @@ #include "def.h" #include "qglobal.h" +using namespace Qt::Literals::StringLiterals; + #ifndef QPRINTENGINE_H Q_DECLARE_METATYPE(QMarginsF) // NOLINT #endif @@ -53,138 +55,128 @@ QT_WARNING_PUSH QT_WARNING_DISABLE_CLANG("-Wunused-member-function") // NOLINTNEXTLINE -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationLabelLanguage, - (QLatin1String("configuration/label_language"))) +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationLabelLanguage, ("configuration/label_language"_L1)) // NOLINTNEXTLINE -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationToolPointerMode, - (QLatin1String("configuration/toolPointerMode"))) +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationToolPointerMode, ("configuration/toolPointerMode"_L1)) // NOLINTNEXTLINE -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationUseToolGroups, - (QLatin1String("configuration/useToolGroups"))) +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationUseToolGroups, ("configuration/useToolGroups"_L1)) // NOLINTNEXTLINE Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingAutoRefreshPatternMessage, - (QLatin1String("configuration/autoRefreshPatternMessage"))) + ("configuration/autoRefreshPatternMessage"_L1)) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPathsLayout, (QLatin1String("paths/layout"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPathsLabelTemplate, (QLatin1String("paths/labels"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPathsLayout, ("paths/layout"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPathsLabelTemplate, ("paths/labels"_L1)) // NOLINT // NOLINTNEXTLINE -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternKnownMaterials, (QLatin1String("pattern/knownMaterials"))) +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternKnownMaterials, ("pattern/knownMaterials"_L1)) // NOLINTNEXTLINE -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternRememberMaterials, (QLatin1String("pattern/rememberMaterials"))) +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternRememberMaterials, ("pattern/rememberMaterials"_L1)) // NOLINTNEXTLINE Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternBackgroundImageDefOpacity, - (QLatin1String("pattern/backgroundImageDefOpacity"))) + ("pattern/backgroundImageDefOpacity"_L1)) -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, settingLayoutWidth, ("layout/width"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutSorting, ("layout/sorting"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutPaperHeight, ("layout/paperHeight"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutPaperWidth, ("layout/paperWidth"_L1)) // NOLINT // NOLINTNEXTLINE -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutFollowGrainline, (QLatin1String("layout/followGrainline"))) +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutFollowGrainline, ("layout/followGrainline"_L1)) // NOLINTNEXTLINE -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutManualPriority, (QLatin1String("layout/manualPriority"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutNestQuantity, (QLatin1String("layout/nestQuantity"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutManualPriority, ("layout/manualPriority"_L1)) +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutNestQuantity, ("layout/nestQuantity"_L1)) // NOLINT // NOLINTNEXTLINE -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutAutoCropLength, (QLatin1String("layout/autoCropLength"))) -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, settingLayoutAutoCropLength, ("layout/autoCropLength"_L1)) +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutAutoCropWidth, ("layout/autoCropWidth"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutSaveLength, ("layout/saveLength"_L1)) // NOLINT // NOLINTNEXTLINE -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutPreferOneSheetSolution, - (QLatin1String("layout/preferOneSheetSolution"))) -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutUnitePages, (QLatin1String("layout/unitePages"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutShowGrainline, (QLatin1String("layout/showGrainline"))) // 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, settingLayoutPreferOneSheetSolution, ("layout/preferOneSheetSolution"_L1)) +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutUnitePages, ("layout/unitePages"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutShowGrainline, ("layout/showGrainline"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingFields, ("layout/fields"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingIgnoreFields, ("layout/ignoreFields"_L1)) // NOLINT // NOLINTNEXTLINE -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingStripOptimization, (QLatin1String("layout/stripOptimization"))) -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, settingStripOptimization, ("layout/stripOptimization"_L1)) +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingMultiplier, ("layout/multiplier"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingTextAsPaths, ("layout/textAsPaths"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingNestingTime, ("layout/time"_L1)) // NOLINT // NOLINTNEXTLINE -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingEfficiencyCoefficient, (QLatin1String("layout/efficiencyCoefficient"))) -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, settingEfficiencyCoefficient, ("layout/efficiencyCoefficient"_L1)) +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutExportFormat, ("layout/exportFormat"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingDetailExportFormat, ("detail/exportFormat"_L1)) // NOLINT -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, settingTiledPDFPaperHeight, ("tiledPDF/paperHeight"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingTiledPDFPaperWidth, ("tiledPDF/paperWidth"_L1)) // NOLINT // NOLINTNEXTLINE -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingdockWidgetGroupsActive, (QLatin1String("dockWidget/groupsActive"))) +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingdockWidgetGroupsActive, ("dockWidget/groupsActive"_L1)) // NOLINTNEXTLINE -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingDockWidgetToolOptionsActive, - (QLatin1String("dockWidget/toolOptionsActive"))) +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingDockWidgetToolOptionsActive, ("dockWidget/toolOptionsActive"_L1)) // NOLINTNEXTLINE Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingDockWidgetPatternMessagesActive, - (QLatin1String("dockWidget/patternMessagesActive"))) + ("dockWidget/patternMessagesActive"_L1)) // NOLINTNEXTLINE Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingDockWidgetBackgroundImagesActive, - (QLatin1String("dockWidget/backgroundImagesActive"))) + ("dockWidget/backgroundImagesActive"_L1)) // NOLINTNEXTLINE -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternMessagesFontSize, (QLatin1String("font/patternMessagesSize"))) +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternMessagesFontSize, ("font/patternMessagesSize"_L1)) // NOLINTNEXTLINE -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchHistoryHistory, (QLatin1String("searchHistory/history"))) +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchHistoryHistory, ("searchHistory/history"_L1)) // NOLINTNEXTLINE -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchHistoryIncrements, (QLatin1String("searchHistory/increments"))) +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchHistoryIncrements, ("searchHistory/increments"_L1)) // NOLINTNEXTLINE Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchHistoryPreviewCalculations, - (QLatin1String("searchHistory/previewCalculations"))) + ("searchHistory/previewCalculations"_L1)) // NOLINTNEXTLINE -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchHistoryFinalMeasurements, - (QLatin1String("searchHistory/finalMeasurements"))) +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchHistoryFinalMeasurements, ("searchHistory/finalMeasurements"_L1)) // NOLINTNEXTLINE Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsHistoryUseUnicodeProperties, - (QLatin1String("searchOptions/historyUseUnicodeProperties"))) + ("searchOptions/historyUseUnicodeProperties"_L1)) // NOLINTNEXTLINE -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsHistoryWholeWord, - (QLatin1String("searchOptions/historyWholeWord"))) +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsHistoryWholeWord, ("searchOptions/historyWholeWord"_L1)) // NOLINTNEXTLINE -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsHistoryRegexp, - (QLatin1String("searchOptions/historyRegexp"))) +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsHistoryRegexp, ("searchOptions/historyRegexp"_L1)) // NOLINTNEXTLINE -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsHistoryMatchCase, - (QLatin1String("searchOptions/historyMatchCase"))) +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsHistoryMatchCase, ("searchOptions/historyMatchCase"_L1)) // NOLINTNEXTLINE Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsIncrementsUseUnicodeProperties, - (QLatin1String("searchOptions/incrementsUseUnicodeProperties"))) + ("searchOptions/incrementsUseUnicodeProperties"_L1)) // NOLINTNEXTLINE Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsIncrementsWholeWord, - (QLatin1String("searchOptions/incrementsWholeWord"))) + ("searchOptions/incrementsWholeWord"_L1)) // NOLINTNEXTLINE -Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsIncrementsRegexp, - (QLatin1String("searchOptions/incrementsRegexp"))) +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsIncrementsRegexp, ("searchOptions/incrementsRegexp"_L1)) // NOLINTNEXTLINE Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsIncrementsMatchCase, - (QLatin1String("searchOptions/incrementsMatchCase"))) + ("searchOptions/incrementsMatchCase"_L1)) // NOLINTNEXTLINE Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsPreviewCalculationsUseUnicodeProperties, - (QLatin1String("searchOptions/previewCalculationsUseUnicodeProperties"))) + ("searchOptions/previewCalculationsUseUnicodeProperties"_L1)) // NOLINTNEXTLINE Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsPreviewCalculationsWholeWord, - (QLatin1String("searchOptions/previewCalculationsWholeWord"))) + ("searchOptions/previewCalculationsWholeWord"_L1)) // NOLINTNEXTLINE Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsPreviewCalculationsRegexp, - (QLatin1String("searchOptions/previewCalculationsRegexp"))) + ("searchOptions/previewCalculationsRegexp"_L1)) // NOLINTNEXTLINE Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsPreviewCalculationsMatchCase, - (QLatin1String("searchOptions/previewCalculationsMatchCase"))) + ("searchOptions/previewCalculationsMatchCase"_L1)) // NOLINTNEXTLINE Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsFinalMeasurementsUseUnicodeProperties, - (QLatin1String("searchOptions/finalMeasurementsUseUnicodeProperties"))) + ("searchOptions/finalMeasurementsUseUnicodeProperties"_L1)) // NOLINTNEXTLINE Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsFinalMeasurementsWholeWord, - (QLatin1String("searchOptions/finalMeasurementsWholeWord"))) + ("searchOptions/finalMeasurementsWholeWord"_L1)) // NOLINTNEXTLINE Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsFinalMeasurementsRegexp, - (QLatin1String("searchOptions/finalMeasurementsRegexp"))) + ("searchOptions/finalMeasurementsRegexp"_L1)) // NOLINTNEXTLINE Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsFinalMeasurementsMatchCase, - (QLatin1String("searchOptions/finalMeasurementsMatchCase"))) + ("searchOptions/finalMeasurementsMatchCase"_L1)) QT_WARNING_POP } // namespace diff --git a/src/libs/vobj/vobjengine.cpp b/src/libs/vobj/vobjengine.cpp index df8c6f63d..bc470229e 100644 --- a/src/libs/vobj/vobjengine.cpp +++ b/src/libs/vobj/vobjengine.cpp @@ -54,6 +54,12 @@ #include // and, not, or #endif +#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) +#include "../vmisc/compatibility.h" +#endif + +using namespace Qt::Literals::StringLiterals; + class QPaintDevice; class QPixmap; class QPoint; @@ -170,7 +176,7 @@ void VObjEngine::drawPath(const QPainterPath &path) qint64 sq = Square(polygon); ++planeCount; - *stream << "o Plane." << QString("%1").arg(planeCount, 3, 10, QLatin1Char('0')) << Qt::endl; + *stream << "o Plane." << u"%1"_s.arg(planeCount, 3, 10, '0'_L1) << Qt::endl; quint32 num_points = 0; @@ -239,7 +245,7 @@ void VObjEngine::drawPolygon(const QPointF *points, int pointCount, PolygonDrawM for (int i = 0; i < pointCount; ++i) { - *stream << QString(" %1").arg(static_cast(globalPointsCount) - pointCount + i + 1); + *stream << u" %1"_s.arg(static_cast(globalPointsCount) - pointCount + i + 1); } *stream << Qt::endl; } diff --git a/src/libs/vpatterndb/pmsystems.cpp b/src/libs/vpatterndb/pmsystems.cpp index 1ffe5b25f..78d559084 100644 --- a/src/libs/vpatterndb/pmsystems.cpp +++ b/src/libs/vpatterndb/pmsystems.cpp @@ -32,6 +32,12 @@ #include +#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) +#include "../vmisc/compatibility.h" +#endif + +using namespace Qt::Literals::StringLiterals; + // pattern making systems codes const QString p0_S = QStringLiteral("p0"); const QString p1_S = QStringLiteral("p1"); @@ -94,62 +100,11 @@ const QString p998_S = QStringLiteral("p998"); auto ListPMSystems() -> QStringList { QStringList list; - list << p0_S - << p1_S - << p2_S - << p3_S - << p4_S - << p5_S - << p6_S - << p7_S - << p8_S - << p9_S - << p10_S - << p11_S - << p12_S - << p13_S - << p14_S - << p15_S - << p16_S - << p17_S - << p18_S - << p19_S - << p20_S - << p21_S - << p22_S - << p23_S - << p24_S - << p25_S - << p26_S - << p27_S - << p28_S - << p29_S - << p30_S - << p31_S - << p32_S - << p33_S - << p34_S - << p35_S - << p36_S - << p37_S - << p38_S - << p39_S - << p40_S - << p41_S - << p42_S - << p43_S - << p44_S - << p45_S - << p46_S - << p47_S - << p48_S - << p49_S - << p50_S - << p51_S - << p52_S - << p53_S - << p54_S - << p998_S; + list << p0_S << p1_S << p2_S << p3_S << p4_S << p5_S << p6_S << p7_S << p8_S << p9_S << p10_S << p11_S << p12_S + << p13_S << p14_S << p15_S << p16_S << p17_S << p18_S << p19_S << p20_S << p21_S << p22_S << p23_S << p24_S + << p25_S << p26_S << p27_S << p28_S << p29_S << p30_S << p31_S << p32_S << p33_S << p34_S << p35_S << p36_S + << p37_S << p38_S << p39_S << p40_S << p41_S << p42_S << p43_S << p44_S << p45_S << p46_S << p47_S << p48_S + << p49_S << p50_S << p51_S << p52_S << p53_S << p54_S << p998_S; return list; } @@ -161,16 +116,15 @@ void InitPMSystems(QComboBox *systemCombo) QMap systems; for (const auto &sys : listSystems) { - systems.insert(VAbstractApplication::VApp()->TrVars()->PMSystemName(sys) + QLatin1String(" (") + sys + - QLatin1String(")"), sys); + systems.insert(VAbstractApplication::VApp()->TrVars()->PMSystemName(sys) + " ("_L1 + sys + ')'_L1, sys); } -// * The default option (blank field or 'None') should appear at the top of the list. -// * The list should be sorted alphabetically so users can find their system easily. + // * The default option (blank field or 'None') should appear at the top of the list. + // * The list should be sorted alphabetically so users can find their system easily. SCASSERT(systemCombo != nullptr) - systemCombo->addItem(VAbstractApplication::VApp()->TrVars()->PMSystemName(listSystems.at(listSystems.size()-1)), - listSystems.at(listSystems.size()-1)); + systemCombo->addItem(VAbstractApplication::VApp()->TrVars()->PMSystemName(listSystems.at(listSystems.size() - 1)), + listSystems.at(listSystems.size() - 1)); QMap::const_iterator i = systems.constBegin(); while (i != systems.constEnd()) diff --git a/src/libs/vpatterndb/variables/vcurveangle.cpp b/src/libs/vpatterndb/variables/vcurveangle.cpp index 104f30d6b..a0863e5e3 100644 --- a/src/libs/vpatterndb/variables/vcurveangle.cpp +++ b/src/libs/vpatterndb/variables/vcurveangle.cpp @@ -31,30 +31,36 @@ #include #include -#include "../vmisc/def.h" #include "../ifc/ifcdef.h" #include "../vgeometry/vabstractcurve.h" -#include "../vgeometry/vspline.h" #include "../vgeometry/vellipticalarc.h" +#include "../vgeometry/vspline.h" +#include "../vmisc/def.h" #include "vcurvevariable.h" +#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) +#include "../vmisc/compatibility.h" +#endif + +using namespace Qt::Literals::StringLiterals; + //--------------------------------------------------------------------------------------------------------------------- VCurveAngle::VCurveAngle() - :VCurveVariable() + : VCurveVariable() { SetType(VarType::CurveAngle); } //--------------------------------------------------------------------------------------------------------------------- VCurveAngle::VCurveAngle(const quint32 &id, const quint32 &parentId) - :VCurveVariable(id, parentId) + : VCurveVariable(id, parentId) { SetType(VarType::CurveAngle); } //--------------------------------------------------------------------------------------------------------------------- VCurveAngle::VCurveAngle(const quint32 &id, const quint32 &parentId, const VAbstractCurve *curve, CurveAngle angle) - :VCurveVariable(id, parentId) + : VCurveVariable(id, parentId) { SetType(VarType::CurveAngle); SCASSERT(curve != nullptr) @@ -83,7 +89,7 @@ VCurveAngle::VCurveAngle(const quint32 &id, const quint32 &parentId, const VAbst //--------------------------------------------------------------------------------------------------------------------- VCurveAngle::VCurveAngle(const quint32 &id, const quint32 &parentId, const VAbstractCurve *baseCurve, const VSpline &spl, CurveAngle angle, qint32 segment) - :VCurveVariable(id, parentId) + : VCurveVariable(id, parentId) { // cppcheck-suppress unknownMacro SCASSERT(baseCurve != nullptr) @@ -92,35 +98,35 @@ VCurveAngle::VCurveAngle(const quint32 &id, const quint32 &parentId, const VAbst if (angle == CurveAngle::StartAngle) { SetValue(spl.GetStartAngle()); - SetName(angle1_V + baseCurve->name() + QLatin1String("_") + seg_ + QString().setNum(segment)); + SetName(angle1_V + baseCurve->name() + '_'_L1 + seg_ + QString().setNum(segment)); if (not baseCurve->GetAlias().isEmpty()) { - SetAlias(angle1_V + baseCurve->GetAlias() + QLatin1String("_") + seg_ + QString().setNum(segment)); + SetAlias(angle1_V + baseCurve->GetAlias() + '_'_L1 + seg_ + QString().setNum(segment)); } } else { SetValue(spl.GetEndAngle()); - SetName(angle2_V + baseCurve->name() + QLatin1String("_") + seg_ + QString().setNum(segment)); + SetName(angle2_V + baseCurve->name() + '_'_L1 + seg_ + QString().setNum(segment)); if (not baseCurve->GetAlias().isEmpty()) { - SetAlias(angle2_V + baseCurve->GetAlias() + QLatin1String("_") + seg_ + QString().setNum(segment)); + SetAlias(angle2_V + baseCurve->GetAlias() + '_'_L1 + seg_ + QString().setNum(segment)); } } } //--------------------------------------------------------------------------------------------------------------------- VEllipticalArcRotation::VEllipticalArcRotation() - : VCurveAngle() + : VCurveAngle() { SetType(VarType::CurveAngle); } //--------------------------------------------------------------------------------------------------------------------- VEllipticalArcRotation::VEllipticalArcRotation(const quint32 &id, const quint32 &parentId, const VEllipticalArc *elArc) - : VCurveAngle(id, parentId) + : VCurveAngle(id, parentId) { SetType(VarType::CurveAngle); SCASSERT(elArc != nullptr) diff --git a/src/libs/vpatterndb/variables/vcurveclength.cpp b/src/libs/vpatterndb/variables/vcurveclength.cpp index e21757065..ed332d55c 100644 --- a/src/libs/vpatterndb/variables/vcurveclength.cpp +++ b/src/libs/vpatterndb/variables/vcurveclength.cpp @@ -31,15 +31,20 @@ #include #include -#include "../vmisc/def.h" #include "../ifc/ifcdef.h" -#include "../vgeometry/vabstractcurve.h" #include "../vgeometry/vspline.h" +#include "../vmisc/def.h" #include "vcurvevariable.h" +#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) +#include "../vmisc/compatibility.h" +#endif + +using namespace Qt::Literals::StringLiterals; + //--------------------------------------------------------------------------------------------------------------------- VCurveCLength::VCurveCLength() - : VCurveVariable() + : VCurveVariable() { SetType(VarType::CurveCLength); } @@ -47,7 +52,7 @@ VCurveCLength::VCurveCLength() //--------------------------------------------------------------------------------------------------------------------- VCurveCLength::VCurveCLength(const quint32 &id, const quint32 &parentId, const VAbstractBezier *curve, CurveCLength cType, Unit patternUnit) - : VCurveVariable(id, parentId) + : VCurveVariable(id, parentId) { SetType(VarType::CurveCLength); SCASSERT(curve != nullptr) @@ -76,7 +81,7 @@ VCurveCLength::VCurveCLength(const quint32 &id, const quint32 &parentId, const V //--------------------------------------------------------------------------------------------------------------------- VCurveCLength::VCurveCLength(const quint32 &id, const quint32 &parentId, const VAbstractBezier *baseCurve, const VSpline &spl, CurveCLength cType, Unit patternUnit, qint32 segment) - : VCurveVariable(id, parentId) + : VCurveVariable(id, parentId) { // cppcheck-suppress unknownMacro SCASSERT(baseCurve != nullptr) @@ -85,35 +90,35 @@ VCurveCLength::VCurveCLength(const quint32 &id, const quint32 &parentId, const V if (cType == CurveCLength::C1) { SetValue(FromPixel(spl.GetC1Length(), patternUnit)); - SetName(c1Length_V + baseCurve->name() + QLatin1String("_") + seg_ + QString().setNum(segment)); + SetName(c1Length_V + baseCurve->name() + '_'_L1 + seg_ + QString().setNum(segment)); if (not baseCurve->GetAlias().isEmpty()) { - SetAlias(c1Length_V + baseCurve->GetAlias() + QLatin1String("_") + seg_ + QString().setNum(segment)); + SetAlias(c1Length_V + baseCurve->GetAlias() + '_'_L1 + seg_ + QString().setNum(segment)); } } else { SetValue(FromPixel(spl.GetC2Length(), patternUnit)); - SetName(c2Length_V + baseCurve->name() + QLatin1String("_") + seg_ + QString().setNum(segment)); + SetName(c2Length_V + baseCurve->name() + '_'_L1 + seg_ + QString().setNum(segment)); if (not baseCurve->GetAlias().isEmpty()) { - SetAlias(c2Length_V + baseCurve->GetAlias() + QLatin1String("_") + seg_ + QString().setNum(segment)); + SetAlias(c2Length_V + baseCurve->GetAlias() + '_'_L1 + seg_ + QString().setNum(segment)); } } } //--------------------------------------------------------------------------------------------------------------------- VCurveCLength::VCurveCLength(const VCurveCLength &var) - : VCurveVariable(var) + : VCurveVariable(var) { } //--------------------------------------------------------------------------------------------------------------------- auto VCurveCLength::operator=(const VCurveCLength &var) -> VCurveCLength & { - if ( &var == this ) + if (&var == this) { return *this; } @@ -125,4 +130,3 @@ auto VCurveCLength::operator=(const VCurveCLength &var) -> VCurveCLength & VCurveCLength::~VCurveCLength() { } - diff --git a/src/libs/vpatterndb/variables/vcurvelength.cpp b/src/libs/vpatterndb/variables/vcurvelength.cpp index f09bae093..f2d0174df 100644 --- a/src/libs/vpatterndb/variables/vcurvelength.cpp +++ b/src/libs/vpatterndb/variables/vcurvelength.cpp @@ -36,16 +36,22 @@ #include "../vgeometry/vspline.h" #include "vcurvevariable.h" +#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) +#include "../vmisc/compatibility.h" +#endif + +using namespace Qt::Literals::StringLiterals; + //--------------------------------------------------------------------------------------------------------------------- VCurveLength::VCurveLength() - :VCurveVariable() + : VCurveVariable() { SetType(VarType::CurveLength); } //--------------------------------------------------------------------------------------------------------------------- VCurveLength::VCurveLength(const quint32 &id, const quint32 &parentId, const VAbstractCurve *curve, Unit patternUnit) - :VCurveVariable(id, parentId) + : VCurveVariable(id, parentId) { SetType(VarType::CurveLength); // cppcheck-suppress unknownMacro @@ -63,16 +69,16 @@ VCurveLength::VCurveLength(const quint32 &id, const quint32 &parentId, const VAb //--------------------------------------------------------------------------------------------------------------------- VCurveLength::VCurveLength(const quint32 &id, const quint32 &parentId, const VAbstractCurve *baseCurve, const VSpline &spl, Unit patternUnit, qint32 segment) - :VCurveVariable(id, parentId) + : VCurveVariable(id, parentId) { SCASSERT(baseCurve != nullptr) SetType(VarType::CurveLength); - SetName(baseCurve->name() + QLatin1String("_") + seg_ + QString().setNum(segment)); + SetName(baseCurve->name() + '_'_L1 + seg_ + QString().setNum(segment)); if (not baseCurve->GetAlias().isEmpty()) { - SetAlias(baseCurve->GetAlias() + QLatin1String("_") + seg_ + QString().setNum(segment)); + SetAlias(baseCurve->GetAlias() + '_'_L1 + seg_ + QString().setNum(segment)); } SetValue(FromPixel(spl.GetLength(), patternUnit)); @@ -80,13 +86,14 @@ VCurveLength::VCurveLength(const quint32 &id, const quint32 &parentId, const VAb //--------------------------------------------------------------------------------------------------------------------- VCurveLength::VCurveLength(const VCurveLength &var) - :VCurveVariable(var) -{} + : VCurveVariable(var) +{ +} //--------------------------------------------------------------------------------------------------------------------- auto VCurveLength::operator=(const VCurveLength &var) -> VCurveLength & { - if ( &var == this ) + if (&var == this) { return *this; } @@ -96,4 +103,5 @@ auto VCurveLength::operator=(const VCurveLength &var) -> VCurveLength & //--------------------------------------------------------------------------------------------------------------------- VCurveLength::~VCurveLength() -{} +{ +} diff --git a/src/libs/vpatterndb/variables/vpiecearea.cpp b/src/libs/vpatterndb/variables/vpiecearea.cpp index 6ba02bd19..953d25dca 100644 --- a/src/libs/vpatterndb/variables/vpiecearea.cpp +++ b/src/libs/vpatterndb/variables/vpiecearea.cpp @@ -33,6 +33,12 @@ #include +#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) +#include "../vmisc/compatibility.h" +#endif + +using namespace Qt::Literals::StringLiterals; + //--------------------------------------------------------------------------------------------------------------------- VPieceArea::VPieceArea() : d(new VPieceAreaData) @@ -123,7 +129,7 @@ auto VPieceArea::PieceShortName(const VPiece &piece) -> QString QString shortName = piece.GetShortName(); if (shortName.isEmpty()) { - shortName = piece.GetName().replace(QChar(QChar::Space), '_').left(25); + shortName = piece.GetName().replace(QChar(QChar::Space), '_'_L1).left(25); if (shortName.isEmpty() || not QRegularExpression(VPiece::ShortNameRegExp()).match(shortName).hasMatch()) { shortName = QObject::tr("Unknown", "piece area"); diff --git a/src/libs/vpatterndb/vformula.cpp b/src/libs/vpatterndb/vformula.cpp index a3095de73..a4dd6bcba 100644 --- a/src/libs/vpatterndb/vformula.cpp +++ b/src/libs/vpatterndb/vformula.cpp @@ -42,6 +42,12 @@ #include "vcontainer.h" #include "vtranslatevars.h" +#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) +#include "../vmisc/compatibility.h" +#endif + +using namespace Qt::Literals::StringLiterals; + // VFormula //--------------------------------------------------------------------------------------------------------------------- VFormula::VFormula() @@ -259,7 +265,7 @@ void VFormula::Eval() } else { - d->strValue = VAbstractApplication::VApp()->LocaleToString(result) + QLatin1Char(' ') + d->postfix; + d->strValue = VAbstractApplication::VApp()->LocaleToString(result) + ' '_L1 + d->postfix; d->error = false; } } diff --git a/src/libs/vpatterndb/vpiece.cpp b/src/libs/vpatterndb/vpiece.cpp index 23a27953b..e030a2059 100644 --- a/src/libs/vpatterndb/vpiece.cpp +++ b/src/libs/vpatterndb/vpiece.cpp @@ -51,6 +51,8 @@ #include #include +using namespace Qt::Literals::StringLiterals; + namespace { auto PieceMissingNodes(const QVector &d1Nodes, const QVector &d2Nodes) -> QVector @@ -417,7 +419,7 @@ void VPiece::SetFormulaSAWidth(const QString &formula, qreal value) { SetSAWidth(value); const qreal width = GetSAWidth(); - width >= 0 ? d->m_formulaWidth = formula : d->m_formulaWidth = QLatin1Char('0'); + width >= 0 ? d->m_formulaWidth = formula : d->m_formulaWidth = '0'_L1; } //--------------------------------------------------------------------------------------------------------------------- @@ -1254,7 +1256,7 @@ auto VPiece::MainPathToJson() const -> QJsonObject nodesArray.append(nodeObject); } - pieceObject[QLatin1String("nodes")] = nodesArray; + pieceObject["nodes"_L1] = nodesArray; return pieceObject; } @@ -1500,8 +1502,8 @@ auto VPiece::ShortNameRegExp() -> QString } } - negativeSigns.replace('-', QLatin1String("\\-")); - groupSeparators.remove('\''); + negativeSigns.replace('-'_L1, "\\-"_L1); + groupSeparators.remove('\''_L1); // Same regexp in pattern.xsd shema file. Don't forget to synchronize. // \p{Zs} - \p{Space_Separator} diff --git a/src/libs/vpatterndb/vpiecenode.cpp b/src/libs/vpatterndb/vpiecenode.cpp index 9ff1fe427..c316561a3 100644 --- a/src/libs/vpatterndb/vpiecenode.cpp +++ b/src/libs/vpatterndb/vpiecenode.cpp @@ -28,7 +28,6 @@ #include "vpiecenode.h" #include "../vmisc/vabstractvalapplication.h" -#include "calculator.h" #include "vcontainer.h" #include "vformula.h" #include "vpiecenode_p.h" diff --git a/src/libs/vpatterndb/vtranslatevars.cpp b/src/libs/vpatterndb/vtranslatevars.cpp index 85204bd54..dbf043459 100644 --- a/src/libs/vpatterndb/vtranslatevars.cpp +++ b/src/libs/vpatterndb/vtranslatevars.cpp @@ -48,6 +48,8 @@ #include "pmsystems.h" #include "vtranslatemeasurements.h" +using namespace Qt::Literals::StringLiterals; + //--------------------------------------------------------------------------------------------------------------------- VTranslateVars::VTranslateVars() { @@ -789,7 +791,7 @@ void VTranslateVars::TranslateVarsToUser(QString &newFormula, QMap= QT_VERSION_CHECK(6, 0, 0) - QMetaType::QString) // todo: QVariant::Vector3D?? + QMetaType::QString) // todo: QVariant::Vector3D?? #else - QVariant::String) // todo: QVariant::Vector3D?? + QVariant::String) // todo: QVariant::Vector3D?? #endif { QVariant tmpFloat(0); @@ -41,22 +47,26 @@ VPE::QVector3DProperty::QVector3DProperty(const QString& name) #else tmpFloat.convert(QVariant::Double); #endif - auto* tmpX = new VDoubleProperty("X"); addChild(tmpX); tmpX->setUpdateBehaviour(true, false); - auto* tmpY = new VDoubleProperty("Y"); addChild(tmpY); tmpY->setUpdateBehaviour(true, false); - auto* tmpZ = new VDoubleProperty("Z"); addChild(tmpZ); tmpZ->setUpdateBehaviour(true, false); + auto *tmpX = new VDoubleProperty("X"); + addChild(tmpX); + tmpX->setUpdateBehaviour(true, false); + auto *tmpY = new VDoubleProperty("Y"); + addChild(tmpY); + tmpY->setUpdateBehaviour(true, false); + auto *tmpZ = new VDoubleProperty("Z"); + addChild(tmpZ); + tmpZ->setUpdateBehaviour(true, false); VPE::QVector3DProperty::setVector(Vector3D()); } - //! Get the data how it should be displayed auto VPE::QVector3DProperty::data(int column, int role) const -> QVariant { if (column == DPC_Data && Qt::DisplayRole == role) { Vector3D tmpVect = getVector(); - return QString("(%1, %2, %3)").arg(QString::number(tmpVect.X), - QString::number(tmpVect.Y), - QString::number(tmpVect.Z)); + return u"(%1, %2, %3)"_s.arg(QString::number(tmpVect.X), QString::number(tmpVect.Y), + QString::number(tmpVect.Z)); } return VProperty::data(column, role); } @@ -132,7 +142,7 @@ auto VPE::QVector3DProperty::clone(bool include_children, VProperty *container) if (!include_children) { - const QList &tmpChildren = container->getChildren(); + const QList &tmpChildren = container->getChildren(); for (auto *tmpChild : tmpChildren) { container->removeChild(tmpChild); @@ -141,7 +151,7 @@ auto VPE::QVector3DProperty::clone(bool include_children, VProperty *container) } } - return VProperty::clone(false, container); // Child + return VProperty::clone(false, container); // Child } void VPE::QVector3DProperty::setValue(const QVariant &value) @@ -151,11 +161,10 @@ void VPE::QVector3DProperty::setValue(const QVariant &value) { setVector(tmpStrings[0].toDouble(), tmpStrings[1].toDouble(), tmpStrings[2].toDouble()); } - } auto VPE::QVector3DProperty::getValue() const -> QVariant { Vector3D tmpVect = getVector(); - return QString("%1,%2,%3").arg(QString::number(tmpVect.X), QString::number(tmpVect.Y), QString::number(tmpVect.Z)); + return u"%1,%2,%3"_s.arg(QString::number(tmpVect.X), QString::number(tmpVect.Y), QString::number(tmpVect.Z)); } diff --git a/src/libs/vpropertyexplorer/plugins/vlabelproperty.cpp b/src/libs/vpropertyexplorer/plugins/vlabelproperty.cpp index b093a0c99..e1bfaee84 100644 --- a/src/libs/vpropertyexplorer/plugins/vlabelproperty.cpp +++ b/src/libs/vpropertyexplorer/plugins/vlabelproperty.cpp @@ -29,20 +29,26 @@ #include "vlabelproperty.h" #include -#include #include +#include #include #include "../vproperty_p.h" -VPE::VLabelProperty::VLabelProperty(const QString &name, const QMap &settings) - : VProperty(name, -#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) - QMetaType::QString), -#else - QVariant::String), +#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) +#include "../vmisc/compatibility.h" #endif - typeForParent(0) + +using namespace Qt::Literals::StringLiterals; + +VPE::VLabelProperty::VLabelProperty(const QString &name, const QMap &settings) + : VProperty(name, +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + QMetaType::QString), +#else + QVariant::String), +#endif + typeForParent(0) { VProperty::setSettings(settings); d_ptr->VariantValue.setValue(QString()); @@ -54,8 +60,8 @@ VPE::VLabelProperty::VLabelProperty(const QString &name, const QMapVariantValue.setValue(QString()); #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) @@ -71,7 +77,7 @@ auto VPE::VLabelProperty::createEditor(QWidget *parent, const QStyleOptionViewIt Q_UNUSED(options) Q_UNUSED(delegate) - QLabel* tmpEditor = new QLabel(parent); + QLabel *tmpEditor = new QLabel(parent); tmpEditor->setLocale(parent->locale()); tmpEditor->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); tmpEditor->setText(d_ptr->VariantValue.toString()); @@ -82,7 +88,7 @@ auto VPE::VLabelProperty::createEditor(QWidget *parent, const QStyleOptionViewIt auto VPE::VLabelProperty::setEditorData(QWidget *editor) -> bool { - if (QLabel* tmpWidget = qobject_cast(editor)) + if (QLabel *tmpWidget = qobject_cast(editor)) { tmpWidget->setText(d_ptr->VariantValue.toString()); return true; @@ -93,7 +99,7 @@ auto VPE::VLabelProperty::setEditorData(QWidget *editor) -> bool auto VPE::VLabelProperty::getEditorData(const QWidget *editor) const -> QVariant { - const QLabel* tmpEditor = qobject_cast(editor); + const QLabel *tmpEditor = qobject_cast(editor); if (tmpEditor) { return tmpEditor->text(); @@ -104,7 +110,7 @@ auto VPE::VLabelProperty::getEditorData(const QWidget *editor) const -> QVariant void VPE::VLabelProperty::setSetting(const QString &key, const QVariant &value) { - if (key == QLatin1String("TypeForParent")) + if (key == "TypeForParent"_L1) { setTypeForParent(value.toInt()); } @@ -112,7 +118,7 @@ void VPE::VLabelProperty::setSetting(const QString &key, const QVariant &value) auto VPE::VLabelProperty::getSetting(const QString &key) const -> QVariant { - if (key == QLatin1String("TypeForParent")) + if (key == "TypeForParent"_L1) { return typeForParent; } diff --git a/src/libs/vpropertyexplorer/plugins/vnumberproperty.cpp b/src/libs/vpropertyexplorer/plugins/vnumberproperty.cpp index bbb1a9d2b..4d119d1a9 100644 --- a/src/libs/vpropertyexplorer/plugins/vnumberproperty.cpp +++ b/src/libs/vpropertyexplorer/plugins/vnumberproperty.cpp @@ -30,15 +30,21 @@ #include "../vproperty_p.h" +#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) +#include "../vmisc/compatibility.h" +#endif + +using namespace Qt::Literals::StringLiterals; + namespace { -Q_GLOBAL_STATIC_WITH_ARGS(const QString, StrMin, (QLatin1String("Min"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, StrMax, (QLatin1String("Max"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, StrInteger, (QLatin1String("integer"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, StrStep, (QLatin1String("Step"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, StrSuffix, (QLatin1String("Suffix"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, StrPrecision, (QLatin1String("Precision"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, StrDouble, (QLatin1String("double"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, StrMin, ("Min"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, StrMax, ("Max"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, StrInteger, ("integer"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, StrStep, ("Step"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, StrSuffix, ("Suffix"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, StrPrecision, ("Precision"_L1)) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, StrDouble, ("double"_L1)) // NOLINT } // namespace const int VPE::VIntegerProperty::StandardMin = -1000000; diff --git a/src/libs/vtest/abstracttest.cpp b/src/libs/vtest/abstracttest.cpp index 63a7c894a..857aff9b5 100644 --- a/src/libs/vtest/abstracttest.cpp +++ b/src/libs/vtest/abstracttest.cpp @@ -56,6 +56,12 @@ #include "../vpatterndb/vpiece.h" #include "../vpatterndb/vpiecenode.h" +#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) +#include "../vmisc/compatibility.h" +#endif + +using namespace Qt::Literals::StringLiterals; + namespace { auto FillPath(const QVector &path, qreal accuracy) -> QVector @@ -234,7 +240,7 @@ void AbstractTest::PassmarkShapeFromJson(const QString &json, QVector &s QString type; AbstractTest::ReadStringValue(lineObject, typeKey, type); - if (type != QLatin1String("QLineF")) + if (type != "QLineF"_L1) { const QString error = QStringLiteral("Invalid json file '%1'. Unexpected class '%2'.") .arg(json, lineObject[typeKey].toString()); @@ -337,7 +343,7 @@ auto AbstractTest::PuzzlePath() const -> QString #else const QString path = QStringLiteral("/../../../app/puzzle/bin/puzzle"); #ifdef Q_OS_WIN - return QCoreApplication::applicationDirPath() + path + QLatin1String(".exe"); + return QCoreApplication::applicationDirPath() + path + ".exe"_L1; #else return QCoreApplication::applicationDirPath() + path; #endif @@ -352,7 +358,7 @@ auto AbstractTest::ValentinaPath() const -> QString #else const QString path = QStringLiteral("/../../../app/valentina/bin/valentina"); #ifdef Q_OS_WIN - return QCoreApplication::applicationDirPath() + path + QLatin1String(".exe"); + return QCoreApplication::applicationDirPath() + path + ".exe"_L1; #else return QCoreApplication::applicationDirPath() + path; #endif @@ -367,7 +373,7 @@ auto AbstractTest::TapePath() const -> QString #else const QString path = QStringLiteral("/../../../app/tape/bin/tape"); #ifdef Q_OS_WIN - return QCoreApplication::applicationDirPath() + path + QLatin1String(".exe"); + return QCoreApplication::applicationDirPath() + path + ".exe"_L1; #else return QCoreApplication::applicationDirPath() + path; #endif diff --git a/src/libs/vtools/dialogs/dialogtoolbox.cpp b/src/libs/vtools/dialogs/dialogtoolbox.cpp index 6bb40499f..afda6e70a 100644 --- a/src/libs/vtools/dialogs/dialogtoolbox.cpp +++ b/src/libs/vtools/dialogs/dialogtoolbox.cpp @@ -59,6 +59,12 @@ #include #include +#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) +#include "../vmisc/compatibility.h" +#endif + +using namespace Qt::Literals::StringLiterals; + const QColor errorColor = Qt::red; namespace @@ -640,31 +646,31 @@ auto GetNodeName(const VContainer *data, const VPieceNode &node, bool showPassma switch (node.GetPassmarkLineType()) { case PassmarkLineType::OneLine: - name += QLatin1Char('|'); + name += '|'_L1; break; case PassmarkLineType::TwoLines: - name += QLatin1String("||"); + name += "||"_L1; break; case PassmarkLineType::ThreeLines: - name += QLatin1String("|||"); + name += "|||"_L1; break; case PassmarkLineType::TMark: - name += QStringLiteral("┴"); + name += "┴"_L1; break; case PassmarkLineType::ExternalVMark: - name += QStringLiteral("⊼"); + name += "⊼"_L1; break; case PassmarkLineType::InternalVMark: - name += QStringLiteral("⊽"); + name += "⊽"_L1; break; case PassmarkLineType::UMark: - name += QStringLiteral("⋃"); + name += "⋃"_L1; break; case PassmarkLineType::BoxMark: - name += QStringLiteral("⎕"); + name += "⎕"_L1; break; case PassmarkLineType::CheckMark: - name += QStringLiteral("✓"); + name += "✓"_L1; break; default: break; @@ -673,12 +679,12 @@ auto GetNodeName(const VContainer *data, const VPieceNode &node, bool showPassma if (not node.IsCheckUniqueness()) { - name = QLatin1Char('[') + name + QLatin1Char(']'); + name = '['_L1 + name + ']'_L1; } if (not node.IsTurnPoint()) { - name += QStringLiteral(" ⦿"); + name += " ⦿"_L1; } } diff --git a/src/libs/vtools/dialogs/support/dialogeditlabel.cpp b/src/libs/vtools/dialogs/support/dialogeditlabel.cpp index fdc98dd86..255ff7202 100644 --- a/src/libs/vtools/dialogs/support/dialogeditlabel.cpp +++ b/src/libs/vtools/dialogs/support/dialogeditlabel.cpp @@ -52,6 +52,12 @@ #include #include +#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) +#include "../vmisc/compatibility.h" +#endif + +using namespace Qt::Literals::StringLiterals; + //--------------------------------------------------------------------------------------------------------------------- DialogEditLabel::DialogEditLabel(const VAbstractPattern *doc, const VContainer *data, QWidget *parent) : QDialog(parent), @@ -304,12 +310,12 @@ void DialogEditLabel::ExportTemplate() { VValentinaSettings *settings = VAbstractValApplication::VApp()->ValentinaSettings(); - QString filters(tr("Label template") + QLatin1String("(*.xml)")); + QString filters(tr("Label template") + "(*.xml)"_L1); const QString path = settings->GetPathLabelTemplate(); - QString fileName = QFileDialog::getSaveFileName(this, tr("Export label template"), - path + QLatin1String("/") + tr("template") + QLatin1String(".xml"), - filters, nullptr, VAbstractApplication::VApp()->NativeFileDialog()); + QString fileName = + QFileDialog::getSaveFileName(this, tr("Export label template"), path + '/'_L1 + tr("template") + ".xml"_L1, + filters, nullptr, VAbstractApplication::VApp()->NativeFileDialog()); if (fileName.isEmpty()) { @@ -317,9 +323,9 @@ void DialogEditLabel::ExportTemplate() } QFileInfo f(fileName); - if (f.suffix().isEmpty() && f.suffix() != QLatin1String("xml")) + if (f.suffix().isEmpty() && f.suffix() != "xml"_L1) { - fileName += QLatin1String(".xml"); + fileName += ".xml"_L1; } settings->SetPathLabelTemplate(QFileInfo(fileName).absolutePath()); @@ -358,7 +364,7 @@ void DialogEditLabel::ImportTemplate() } } - QString filter(tr("Label template") + QLatin1String(" (*.xml)")); + QString filter(tr("Label template") + " (*.xml)"_L1); // Use standard path to label templates const QString path = VAbstractValApplication::VApp()->ValentinaSettings()->GetPathLabelTemplate(); const QString fileName = QFileDialog::getOpenFileName(this, tr("Import template"), path, filter, nullptr, @@ -702,7 +708,7 @@ auto DialogEditLabel::ReplacePlaceholders(QString line) const -> QString auto TestDimension = [per, this, line](const QString &placeholder, const QString &errorMsg) { - if (line.contains(per + placeholder + per) && m_placeholders.value(placeholder).second == QChar('0')) + if (line.contains(per + placeholder + per) && m_placeholders.value(placeholder).second == '0'_L1) { VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) diff --git a/src/libs/vtools/dialogs/tools/dialogsplinepath.cpp b/src/libs/vtools/dialogs/tools/dialogsplinepath.cpp index 8722dc15e..c4f672e60 100644 --- a/src/libs/vtools/dialogs/tools/dialogsplinepath.cpp +++ b/src/libs/vtools/dialogs/tools/dialogsplinepath.cpp @@ -66,6 +66,12 @@ #include "../vmisc/backport/qoverload.h" #endif // QT_VERSION < QT_VERSION_CHECK(5, 7, 0) +#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) +#include "../vmisc/compatibility.h" +#endif + +using namespace Qt::Literals::StringLiterals; + //--------------------------------------------------------------------------------------------------------------------- /** * @brief DialogSplinePath create dialog @@ -816,7 +822,7 @@ void DialogSplinePath::DataPoint(const VSplinePoint &p) int row = ui->listWidget->currentRow(); const QString field = tr("Not used"); - const QString emptyRes = QString("_"); + const QString emptyRes = QChar('_'); if (row == 0) { @@ -993,7 +999,7 @@ void DialogSplinePath::ShowPointIssue(const QString &pName) } else { - item->setText(pName + QLatin1String("(!)")); + item->setText(pName + "(!)"_L1); } } diff --git a/src/libs/vtools/dialogs/tools/dialogtool.cpp b/src/libs/vtools/dialogs/tools/dialogtool.cpp index ba3e8f644..5aa250a38 100644 --- a/src/libs/vtools/dialogs/tools/dialogtool.cpp +++ b/src/libs/vtools/dialogs/tools/dialogtool.cpp @@ -61,13 +61,18 @@ #include "../../tools/vabstracttool.h" #include "../ifc/xml/vabstractpattern.h" -#include "../ifc/xml/vdomdocument.h" #include "../vgeometry/vabstractcurve.h" #include "../vgeometry/vgobject.h" #include "../vgeometry/vpointf.h" #include "../vpatterndb/vcontainer.h" #include "../vpatterndb/vpiecenode.h" +#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) +#include "../vmisc/compatibility.h" +#endif + +using namespace Qt::Literals::StringLiterals; + template class QSharedPointer; QT_WARNING_PUSH @@ -385,7 +390,7 @@ auto DialogTool::DNumber(const QString &baseName) const -> quint32 do { ++num; - name = baseName + QString("_%1").arg(num); + name = baseName + u"_%1"_s.arg(num); } while (not data->IsUnique(name)); return num; diff --git a/src/libs/vtools/tools/drawTools/operation/vabstractoperation.cpp b/src/libs/vtools/tools/drawTools/operation/vabstractoperation.cpp index aa6ef1374..d30f34bf3 100644 --- a/src/libs/vtools/tools/drawTools/operation/vabstractoperation.cpp +++ b/src/libs/vtools/tools/drawTools/operation/vabstractoperation.cpp @@ -34,6 +34,12 @@ #include "../../../undocommands/undogroup.h" #include "../vgeometry/vpointf.h" +#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) +#include "../vmisc/compatibility.h" +#endif + +using namespace Qt::Literals::StringLiterals; + const QString VAbstractOperation::TagItem = QStringLiteral("item"); const QString VAbstractOperation::TagSource = QStringLiteral("source"); const QString VAbstractOperation::TagDestination = QStringLiteral("destination"); @@ -939,12 +945,11 @@ auto VAbstractOperation::ComplexCurveToolTip(quint32 itemId) const -> QString { const QSharedPointer curve = VAbstractTool::data.GeometricObject(itemId); - const QString toolTip = QString("" - "" - "" - "%6" - "
%1: %2
%3: %4 %5
") - .arg(tr("Label"), curve->ObjectName(), tr("Length")) + const QString toolTip = u"" + "" + "" + "%6" + "
%1: %2
%3: %4 %5
"_s.arg(tr("Label"), curve->ObjectName(), tr("Length")) .arg(VAbstractValApplication::VApp()->fromPixel(curve->GetLength())) .arg(UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true), MakeToolTip()); return toolTip; diff --git a/src/libs/vtools/tools/drawTools/toolcurve/vabstractspline.cpp b/src/libs/vtools/tools/drawTools/toolcurve/vabstractspline.cpp index 9b48f68c3..6339b3381 100644 --- a/src/libs/vtools/tools/drawTools/toolcurve/vabstractspline.cpp +++ b/src/libs/vtools/tools/drawTools/toolcurve/vabstractspline.cpp @@ -53,6 +53,12 @@ #include "../vpatterndb/vcontainer.h" #include "../vwidgets/global.h" +#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) +#include "../vmisc/compatibility.h" +#endif + +using namespace Qt::Literals::StringLiterals; + //--------------------------------------------------------------------------------------------------------------------- VAbstractSpline::VAbstractSpline(VAbstractPattern *doc, VContainer *data, quint32 id, const QString ¬es, QGraphicsItem *parent) @@ -181,11 +187,10 @@ auto VAbstractSpline::MakeToolTip() const -> QString const QSharedPointer curve = VAbstractTool::data.GeometricObject(m_id); const QString toolTip = - QString("" - "" - "" - "
%4: %5
%1: %2 %3
") - .arg(tr("Length")) + u"" + "" + "" + "
%4: %5
%1: %2 %3
"_s.arg(tr("Length")) .arg(VAbstractValApplication::VApp()->fromPixel(curve->GetLength())) .arg(UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true), tr("Label"), curve->ObjectName()); return toolTip; @@ -468,7 +473,7 @@ void VAbstractSpline::SetAliasSuffix(QString alias) QSharedPointer curve = VAbstractTool::data.GeometricObject(m_id); const QString oldAliasSuffix = curve->GetAliasSuffix(); - alias = alias.simplified().replace(QChar(QChar::Space), QChar('_')); + alias = alias.simplified().replace(QChar(QChar::Space), '_'_L1); curve->SetAliasSuffix(alias); QRegularExpression rx(NameRegExp()); diff --git a/src/libs/vtools/tools/drawTools/toolcurve/vtoolarc.cpp b/src/libs/vtools/tools/drawTools/toolcurve/vtoolarc.cpp index 5a9356838..788687cd4 100644 --- a/src/libs/vtools/tools/drawTools/toolcurve/vtoolarc.cpp +++ b/src/libs/vtools/tools/drawTools/toolcurve/vtoolarc.cpp @@ -51,6 +51,12 @@ #include "../vwidgets/vmaingraphicsscene.h" #include "vabstractspline.h" +#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) +#include "../vmisc/compatibility.h" +#endif + +using namespace Qt::Literals::StringLiterals; + const QString VToolArc::ToolType = QStringLiteral("simple"); // NOLINT //--------------------------------------------------------------------------------------------------------------------- @@ -385,14 +391,13 @@ auto VToolArc::MakeToolTip() const -> QString { const QSharedPointer arc = VAbstractTool::data.GeometricObject(m_id); - const QString toolTip = QString("" - "" - "" - "" - "" - "" - "
%10: %11
%1: %2 %3
%4: %5 %3
%6: %7°
%8: %9°
") - .arg(tr("Length")) + const QString toolTip = u"" + "" + "" + "" + "" + "" + "
%10: %11
%1: %2 %3
%4: %5 %3
%6: %7°
%8: %9°
"_s.arg(tr("Length")) .arg(VAbstractValApplication::VApp()->fromPixel(arc->GetLength())) .arg(UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true), tr("Radius")) .arg(VAbstractValApplication::VApp()->fromPixel(arc->GetRadius())) diff --git a/src/libs/vtools/tools/drawTools/toolcurve/vtoolarcwithlength.cpp b/src/libs/vtools/tools/drawTools/toolcurve/vtoolarcwithlength.cpp index f231501da..07cbf2710 100644 --- a/src/libs/vtools/tools/drawTools/toolcurve/vtoolarcwithlength.cpp +++ b/src/libs/vtools/tools/drawTools/toolcurve/vtoolarcwithlength.cpp @@ -52,6 +52,12 @@ #include "../vwidgets/vmaingraphicsscene.h" #include "vabstractspline.h" +#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) +#include "../vmisc/compatibility.h" +#endif + +using namespace Qt::Literals::StringLiterals; + const QString VToolArcWithLength::ToolType = QStringLiteral("arcWithLength"); //--------------------------------------------------------------------------------------------------------------------- @@ -365,14 +371,13 @@ auto VToolArcWithLength::MakeToolTip() const -> QString { const QSharedPointer arc = VAbstractTool::data.GeometricObject(m_id); - const QString toolTip = QString("" - "" - "" - "" - "" - "" - "
%10: %11
%1: %2 %3
%4: %5 %3
%6: %7°
%8: %9°
") - .arg(tr("Length")) + const QString toolTip = u"" + "" + "" + "" + "" + "" + "
%10: %11
%1: %2 %3
%4: %5 %3
%6: %7°
%8: %9°
"_s.arg(tr("Length")) .arg(VAbstractValApplication::VApp()->fromPixel(arc->GetLength())) .arg(UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true), tr("Radius")) .arg(VAbstractValApplication::VApp()->fromPixel(arc->GetRadius())) diff --git a/src/libs/vtools/tools/drawTools/toolcurve/vtoolellipticalarc.cpp b/src/libs/vtools/tools/drawTools/toolcurve/vtoolellipticalarc.cpp index 11206e134..885376af8 100644 --- a/src/libs/vtools/tools/drawTools/toolcurve/vtoolellipticalarc.cpp +++ b/src/libs/vtools/tools/drawTools/toolcurve/vtoolellipticalarc.cpp @@ -52,6 +52,12 @@ #include "../vwidgets/vmaingraphicsscene.h" #include "vabstractspline.h" +#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) +#include "../vmisc/compatibility.h" +#endif + +using namespace Qt::Literals::StringLiterals; + const QString VToolEllipticalArc::ToolType = QStringLiteral("simple"); //--------------------------------------------------------------------------------------------------------------------- @@ -456,21 +462,21 @@ auto VToolEllipticalArc::MakeToolTip() const -> QString { const QSharedPointer elArc = VAbstractTool::data.GeometricObject(m_id); - const QString toolTip = QString("" - "" - "" - "" - "" - "" - "" - "" - "
%12: %13
%1: %2 %3
%4: %5 %3
%6: %7 %3
%8: %9°
%10: %11°
%14: %15°
") + const QString toolTip = u"" + "" + "" + "" + "" + "" + "" + "" + "
%12: %13
%1: %2 %3
%4: %5 %3
%6: %7 %3
%8: %9°
%10: %11°
%14: %15°
"_s .arg(tr("Length")) // 1 .arg(VAbstractValApplication::VApp()->fromPixel(elArc->GetLength())) // 2 .arg(UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true), // 3 - tr("Radius") + QLatin1Char('1')) // 4 + tr("Radius") + '1'_L1) // 4 .arg(VAbstractValApplication::VApp()->fromPixel(elArc->GetRadius1())) // 5 - .arg(tr("Radius") + QLatin1Char('2')) // 6 + .arg(tr("Radius") + '2'_L1) // 6 .arg(VAbstractValApplication::VApp()->fromPixel(elArc->GetRadius2())) // 7 .arg(tr("Start angle")) // 8 .arg(elArc->GetStartAngle()) // 9 diff --git a/src/libs/vtools/tools/drawTools/toolpoint/tooldoublepoint/vtooldoublepoint.cpp b/src/libs/vtools/tools/drawTools/toolpoint/tooldoublepoint/vtooldoublepoint.cpp index a6799b046..c9e241545 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/tooldoublepoint/vtooldoublepoint.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/tooldoublepoint/vtooldoublepoint.cpp @@ -52,6 +52,12 @@ #include "../vwidgets/../ifc/ifcdef.h" #include "../vwidgets/vsimplepoint.h" +#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) +#include "../vmisc/compatibility.h" +#endif + +using namespace Qt::Literals::StringLiterals; + //--------------------------------------------------------------------------------------------------------------------- VToolDoublePoint::VToolDoublePoint(VAbstractPattern *doc, VContainer *data, quint32 id, quint32 p1id, quint32 p2id, const QString ¬es, QGraphicsItem *parent) @@ -445,10 +451,9 @@ auto VToolDoublePoint::ComplexToolTip(quint32 itemId) const -> QString { const QSharedPointer point = VAbstractTool::data.GeometricObject(itemId); - const QString toolTip = QString("" - "" - "%3" - "
%1: %2
") - .arg(tr("Label"), point->name(), MakeToolTip()); + const QString toolTip = u"" + "" + "%3" + "
%1: %2
"_s.arg(tr("Label"), point->name(), MakeToolTip()); return toolTip; } diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcut.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcut.cpp index bc4581c10..caaab9484 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcut.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcut.cpp @@ -32,26 +32,32 @@ #include #include -#include "../ifc/xml/vdomdocument.h" +#include "../../../../vabstracttool.h" +#include "../../../vdrawtool.h" #include "../ifc/ifcdef.h" +#include "../ifc/xml/vdomdocument.h" +#include "../qmuparser/qmudef.h" #include "../vgeometry/vgobject.h" #include "../vgeometry/vpointf.h" #include "../vmisc/vabstractapplication.h" #include "../vpatterndb/vcontainer.h" #include "../vpatterndb/vformula.h" -#include "../../../../vabstracttool.h" -#include "../../../vdrawtool.h" #include "../vtoolsinglepoint.h" -#include "../qmuparser/qmudef.h" + +#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) +#include "../vmisc/compatibility.h" +#endif + +using namespace Qt::Literals::StringLiterals; //--------------------------------------------------------------------------------------------------------------------- VToolCut::VToolCut(const VToolCutInitData &initData, QGraphicsItem *parent) - : VToolSinglePoint(initData.doc, initData.data, initData.id, initData.notes, parent), - formula(initData.formula), - baseCurveId(initData.baseCurveId), - detailsMode(VAbstractApplication::VApp()->Settings()->IsShowCurveDetails()), - m_aliasSuffix1(initData.aliasSuffix1), - m_aliasSuffix2(initData.aliasSuffix2) + : VToolSinglePoint(initData.doc, initData.data, initData.id, initData.notes, parent), + formula(initData.formula), + baseCurveId(initData.baseCurveId), + detailsMode(VAbstractApplication::VApp()->Settings()->IsShowCurveDetails()), + m_aliasSuffix1(initData.aliasSuffix1), + m_aliasSuffix2(initData.aliasSuffix2) { Q_ASSERT_X(initData.baseCurveId != 0, Q_FUNC_INFO, "curveCutId == 0"); //-V654 //-V712 } @@ -114,7 +120,7 @@ void VToolCut::SetAliasSuffix1(QString alias) QSharedPointer curve = VAbstractTool::data.GeometricObject(baseCurveId); const QString oldAliasSuffix = curve->GetAliasSuffix(); - alias = alias.simplified().replace(QChar(QChar::Space), QChar('_')); + alias = alias.simplified().replace(QChar(QChar::Space), '_'_L1); curve->SetAliasSuffix(alias); QRegularExpression rx(NameRegExp()); @@ -143,7 +149,7 @@ void VToolCut::SetAliasSuffix2(QString alias) QSharedPointer curve = VAbstractTool::data.GeometricObject(baseCurveId); const QString oldAliasSuffix = curve->GetAliasSuffix(); - alias = alias.simplified().replace(QChar(QChar::Space), QChar('_')); + alias = alias.simplified().replace(QChar(QChar::Space), '_'_L1); curve->SetAliasSuffix(alias); QRegularExpression rx(NameRegExp()); @@ -192,9 +198,9 @@ void VToolCut::SaveOptions(QDomElement &tag, QSharedPointer &obj) VToolSinglePoint::SaveOptions(tag, obj); doc->SetAttributeOrRemoveIf(tag, AttrAlias1, m_aliasSuffix1, - [](const QString &suffix) noexcept {return suffix.isEmpty();}); + [](const QString &suffix) noexcept { return suffix.isEmpty(); }); doc->SetAttributeOrRemoveIf(tag, AttrAlias2, m_aliasSuffix2, - [](const QString &suffix) noexcept {return suffix.isEmpty();}); + [](const QString &suffix) noexcept { return suffix.isEmpty(); }); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutarc.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutarc.cpp index 1db8f5b4e..43f3519b0 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutarc.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutarc.cpp @@ -34,22 +34,28 @@ #include "../../../../../dialogs/tools/dialogcutarc.h" #include "../../../../../dialogs/tools/dialogtool.h" -#include "../../../../../visualization/visualization.h" #include "../../../../../visualization/path/vistoolcutarc.h" +#include "../../../../../visualization/visualization.h" +#include "../../../../vabstracttool.h" +#include "../../../vdrawtool.h" #include "../ifc/exception/vexception.h" #include "../ifc/ifcdef.h" #include "../vgeometry/varc.h" #include "../vgeometry/vpointf.h" #include "../vmisc/vabstractapplication.h" #include "../vmisc/vcommonsettings.h" +#include "../vpatterndb/variables/vcurvelength.h" #include "../vpatterndb/vcontainer.h" #include "../vpatterndb/vtranslatevars.h" -#include "../vpatterndb/variables/vcurvelength.h" #include "../vwidgets/vmaingraphicsscene.h" -#include "../../../../vabstracttool.h" -#include "../../../vdrawtool.h" #include "vtoolcut.h" +#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) +#include "../vmisc/compatibility.h" +#endif + +using namespace Qt::Literals::StringLiterals; + template class QSharedPointer; const QString VToolCutArc::ToolType = QStringLiteral("cutArc"); @@ -60,8 +66,8 @@ const QString VToolCutArc::ToolType = QStringLiteral("cutArc"); * @param initData init data. * @param parent parent object. */ -VToolCutArc::VToolCutArc(const VToolCutInitData &initData, QGraphicsItem * parent) - :VToolCut(initData, parent) +VToolCutArc::VToolCutArc(const VToolCutInitData &initData, QGraphicsItem *parent) + : VToolCut(initData, parent) { ToolCreation(initData.typeCreation); } @@ -112,7 +118,7 @@ auto VToolCutArc::Create(const QPointer &dialog, VMainGraphicsScene initData.aliasSuffix1 = dialogTool->GetAliasSuffix1(); initData.aliasSuffix2 = dialogTool->GetAliasSuffix2(); - VToolCutArc* point = Create(initData); + VToolCutArc *point = Create(initData); if (point != nullptr) { point->m_dialog = dialog; @@ -125,13 +131,13 @@ auto VToolCutArc::Create(const QPointer &dialog, VMainGraphicsScene * @brief Create help create tool. * @param initData init data. */ -auto VToolCutArc::Create(VToolCutInitData &initData) -> VToolCutArc* +auto VToolCutArc::Create(VToolCutInitData &initData) -> VToolCutArc * { const QSharedPointer arc = initData.data->GeometricObject(initData.baseCurveId); - //Declare special variable "CurrentLength" - auto *length = new VCurveLength(initData.baseCurveId, initData.baseCurveId, arc.data(), - *initData.data->GetPatternUnit()); + // Declare special variable "CurrentLength" + auto *length = + new VCurveLength(initData.baseCurveId, initData.baseCurveId, arc.data(), *initData.data->GetPatternUnit()); length->SetName(currentLength); initData.data->AddVariable(length); @@ -189,7 +195,7 @@ auto VToolCutArc::Create(VToolCutInitData &initData) -> VToolCutArc* VAbstractPattern::AddTool(initData.id, tool); initData.doc->IncrementReferens(arc->getIdTool()); } - //Very important to delete it. Only this tool need this special variable. + // Very important to delete it. Only this tool need this special variable. initData.data->RemoveVariable(currentLength); return tool; } @@ -207,10 +213,10 @@ void VToolCutArc::ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 { ContextMenu(event, id); } - catch(const VExceptionToolWasDeleted &e) + catch (const VExceptionToolWasDeleted &e) { Q_UNUSED(e) - return;//Leave this method immediately!!! + return; // Leave this method immediately!!! } } @@ -218,8 +224,7 @@ void VToolCutArc::ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 /** * @brief SaveDialog save options into file after change in dialog. */ -void VToolCutArc::SaveDialog(QDomElement &domElement, QList &oldDependencies, - QList &newDependencies) +void VToolCutArc::SaveDialog(QDomElement &domElement, QList &oldDependencies, QList &newDependencies) { SCASSERT(not m_dialog.isNull()) const QPointer dialogTool = qobject_cast(m_dialog); @@ -232,13 +237,13 @@ void VToolCutArc::SaveDialog(QDomElement &domElement, QList &oldDepende doc->SetAttribute(domElement, AttrLength, dialogTool->GetFormula()); doc->SetAttribute(domElement, AttrArc, QString().setNum(dialogTool->getArcId())); doc->SetAttributeOrRemoveIf(domElement, AttrAlias1, dialogTool->GetAliasSuffix1(), - [](const QString &suffix) noexcept {return suffix.isEmpty();}); + [](const QString &suffix) noexcept { return suffix.isEmpty(); }); doc->SetAttributeOrRemoveIf(domElement, AttrAlias2, dialogTool->GetAliasSuffix2(), - [](const QString &suffix) noexcept {return suffix.isEmpty();}); + [](const QString &suffix) noexcept { return suffix.isEmpty(); }); const QString notes = dialogTool->GetNotes(); doc->SetAttributeOrRemoveIf(domElement, AttrNotes, notes, - [](const QString ¬es) noexcept {return notes.isEmpty();}); + [](const QString ¬es) noexcept { return notes.isEmpty(); }); } //--------------------------------------------------------------------------------------------------------------------- @@ -269,8 +274,8 @@ void VToolCutArc::SetVisualization() SCASSERT(visual != nullptr) visual->SetArcId(baseCurveId); - visual->SetLength(VAbstractApplication::VApp()->TrVars() - ->FormulaToUser(formula, VAbstractApplication::VApp()->Settings()->GetOsSeparator())); + visual->SetLength(VAbstractApplication::VApp()->TrVars()->FormulaToUser( + formula, VAbstractApplication::VApp()->Settings()->GetOsSeparator())); const QSharedPointer curve = VAbstractTool::data.GeometricObject(baseCurveId); visual->SetLineStyle(LineStyleToPenStyle(curve->GetPenStyle())); @@ -284,8 +289,8 @@ auto VToolCutArc::MakeToolTip() const -> QString { const QSharedPointer arc = VAbstractTool::data.GeometricObject(baseCurveId); - const QString expression = VAbstractApplication::VApp()->TrVars() - ->FormulaToUser(formula, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); + const QString expression = VAbstractApplication::VApp()->TrVars()->FormulaToUser( + formula, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); const qreal length = Visualization::FindValFromUser(expression, VAbstractTool::data.DataVariables()); const QString arcStr = QCoreApplication::translate("VToolCutArc", "Arc"); @@ -307,28 +312,27 @@ auto VToolCutArc::MakeToolTip() const -> QString ar2.SetAliasSuffix(m_aliasSuffix2); auto ArcToolTip = [arcStr, lengthStr, startAngleStr, endAngleStr, radiusStr](QString toolTip, const VArc &arc, - const QString &arcNumber) + const QString &arcNumber) { - toolTip += QString(" %10: %11 " - " %1: %2 %3 " - " %4: %5 %3 " - " %6: %7° " - " %8: %9° ") - .arg(arcStr + arcNumber + QChar(QChar::Space) + lengthStr) - .arg(VAbstractValApplication::VApp()->fromPixel(arc.GetLength())) - .arg(UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true), - arcStr + arcNumber + QChar(QChar::Space) + radiusStr) - .arg(VAbstractValApplication::VApp()->fromPixel(arc.GetRadius())) - .arg(arcStr + arcNumber + QChar(QChar::Space) + startAngleStr) - .arg(arc.GetStartAngle()) - .arg(arcStr + arcNumber + QChar(QChar::Space) + endAngleStr) - .arg(arc.GetEndAngle()) - .arg(arcStr + arcNumber + - QChar(QChar::Space) + QCoreApplication::translate("VToolCutArc", "label"), - arc.ObjectName()); + toolTip += + u" %10: %11 " + " %1: %2 %3 " + " %4: %5 %3 " + " %6: %7° " + " %8: %9° "_s.arg(arcStr + arcNumber + QChar(QChar::Space) + lengthStr) + .arg(VAbstractValApplication::VApp()->fromPixel(arc.GetLength())) + .arg(UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true), + arcStr + arcNumber + QChar(QChar::Space) + radiusStr) + .arg(VAbstractValApplication::VApp()->fromPixel(arc.GetRadius())) + .arg(arcStr + arcNumber + QChar(QChar::Space) + startAngleStr) + .arg(arc.GetStartAngle()) + .arg(arcStr + arcNumber + QChar(QChar::Space) + endAngleStr) + .arg(arc.GetEndAngle()) + .arg(arcStr + arcNumber + QChar(QChar::Space) + QCoreApplication::translate("VToolCutArc", "label"), + arc.ObjectName()); return toolTip; }; return ArcToolTip(ArcToolTip(QStringLiteral(""), ar1, QChar('1')), ar2, QChar('2')) + - QStringLiteral("
"); + QStringLiteral(""); } diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutspline.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutspline.cpp index c049619fd..faa0c0f24 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutspline.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutspline.cpp @@ -34,8 +34,10 @@ #include "../../../../../dialogs/tools/dialogcutspline.h" #include "../../../../../dialogs/tools/dialogtool.h" -#include "../../../../../visualization/visualization.h" #include "../../../../../visualization/path/vistoolcutspline.h" +#include "../../../../../visualization/visualization.h" +#include "../../../../vabstracttool.h" +#include "../../../vdrawtool.h" #include "../ifc/exception/vexception.h" #include "../ifc/ifcdef.h" #include "../vgeometry/vabstractcubicbezier.h" @@ -44,18 +46,22 @@ #include "../vgeometry/vspline.h" #include "../vmisc/vabstractapplication.h" #include "../vmisc/vcommonsettings.h" +#include "../vpatterndb/variables/vcurvelength.h" #include "../vpatterndb/vcontainer.h" #include "../vpatterndb/vtranslatevars.h" -#include "../vpatterndb/variables/vcurvelength.h" #include "../vwidgets/vmaingraphicsscene.h" -#include "../../../../vabstracttool.h" -#include "../../../vdrawtool.h" #include "vtoolcut.h" +#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) +#include "../vmisc/compatibility.h" +#endif + +using namespace Qt::Literals::StringLiterals; + template class QSharedPointer; -const QString VToolCutSpline::ToolType = QStringLiteral("cutSpline"); // NOLINT(cert-err58-cpp) -const QString VToolCutSpline::AttrSpline = QStringLiteral("spline"); // NOLINT(cert-err58-cpp) +const QString VToolCutSpline::ToolType = QStringLiteral("cutSpline"); // NOLINT(cert-err58-cpp) +const QString VToolCutSpline::AttrSpline = QStringLiteral("spline"); // NOLINT(cert-err58-cpp) //--------------------------------------------------------------------------------------------------------------------- /** @@ -64,7 +70,7 @@ const QString VToolCutSpline::AttrSpline = QStringLiteral("spline"); // NOLINT(c * @param parent parent object. */ VToolCutSpline::VToolCutSpline(const VToolCutInitData &initData, QGraphicsItem *parent) - :VToolCut(initData, parent) + : VToolCut(initData, parent) { ToolCreation(initData.typeCreation); } @@ -96,7 +102,7 @@ void VToolCutSpline::SetDialog() * @param data container with variables. */ auto VToolCutSpline::Create(const QPointer &dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, - VContainer *data) -> VToolCutSpline* + VContainer *data) -> VToolCutSpline * { SCASSERT(not dialog.isNull()) const QPointer dialogTool = qobject_cast(dialog); @@ -115,7 +121,7 @@ auto VToolCutSpline::Create(const QPointer &dialog, VMainGraphicsSce initData.aliasSuffix1 = dialogTool->GetAliasSuffix1(); initData.aliasSuffix2 = dialogTool->GetAliasSuffix2(); - VToolCutSpline* point = Create(initData); + VToolCutSpline *point = Create(initData); if (point != nullptr) { point->m_dialog = dialog; @@ -128,21 +134,21 @@ auto VToolCutSpline::Create(const QPointer &dialog, VMainGraphicsSce * @brief Create help create tool. * @param initData init data. */ -auto VToolCutSpline::Create(VToolCutInitData &initData) -> VToolCutSpline* +auto VToolCutSpline::Create(VToolCutInitData &initData) -> VToolCutSpline * { const auto spl = initData.data->GeometricObject(initData.baseCurveId); - //Declare special variable "CurrentLength" - auto *length = new VCurveLength(initData.baseCurveId, initData.baseCurveId, spl.data(), - *initData.data->GetPatternUnit()); + // Declare special variable "CurrentLength" + auto *length = + new VCurveLength(initData.baseCurveId, initData.baseCurveId, spl.data(), *initData.data->GetPatternUnit()); length->SetName(currentLength); initData.data->AddVariable(length); const qreal result = CheckFormula(initData.id, initData.formula, initData.data); QPointF spl1p2, spl1p3, spl2p2, spl2p3; - QPointF point = spl->CutSpline(VAbstractValApplication::VApp()->toPixel(result), spl1p2, spl1p3, spl2p2, spl2p3, - initData.name); + QPointF point = + spl->CutSpline(VAbstractValApplication::VApp()->toPixel(result), spl1p2, spl1p3, spl2p2, spl2p3, initData.name); auto *p = new VPointF(point, initData.name, initData.mx, initData.my); p->SetShowLabel(initData.showLabel); @@ -190,7 +196,7 @@ auto VToolCutSpline::Create(VToolCutInitData &initData) -> VToolCutSpline* VAbstractPattern::AddTool(initData.id, tool); initData.doc->IncrementReferens(spl->getIdTool()); } - //Very important to delete it. Only this tool need this special variable. + // Very important to delete it. Only this tool need this special variable. initData.data->RemoveVariable(currentLength); return tool; } @@ -208,10 +214,10 @@ void VToolCutSpline::ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quin { ContextMenu(event, id); } - catch(const VExceptionToolWasDeleted &e) + catch (const VExceptionToolWasDeleted &e) { Q_UNUSED(e) - return;//Leave this method immediately!!! + return; // Leave this method immediately!!! } } @@ -233,11 +239,11 @@ void VToolCutSpline::SaveDialog(QDomElement &domElement, QList &oldDepe doc->SetAttribute(domElement, AttrLength, dialogTool->GetFormula()); doc->SetAttribute(domElement, AttrSpline, QString().setNum(dialogTool->getSplineId())); doc->SetAttributeOrRemoveIf(domElement, AttrAlias1, dialogTool->GetAliasSuffix1(), - [](const QString &suffix) noexcept {return suffix.isEmpty();}); + [](const QString &suffix) noexcept { return suffix.isEmpty(); }); doc->SetAttributeOrRemoveIf(domElement, AttrAlias2, dialogTool->GetAliasSuffix2(), - [](const QString &suffix) noexcept {return suffix.isEmpty();}); + [](const QString &suffix) noexcept { return suffix.isEmpty(); }); doc->SetAttributeOrRemoveIf(domElement, AttrNotes, dialogTool->GetNotes(), - [](const QString ¬es) noexcept {return notes.isEmpty();}); + [](const QString ¬es) noexcept { return notes.isEmpty(); }); } //--------------------------------------------------------------------------------------------------------------------- @@ -268,8 +274,8 @@ void VToolCutSpline::SetVisualization() SCASSERT(visual != nullptr) visual->SetSplineId(baseCurveId); - visual->SetLength(VAbstractApplication::VApp()->TrVars() - ->FormulaToUser(formula, VAbstractApplication::VApp()->Settings()->GetOsSeparator())); + visual->SetLength(VAbstractApplication::VApp()->TrVars()->FormulaToUser( + formula, VAbstractApplication::VApp()->Settings()->GetOsSeparator())); const QSharedPointer curve = VAbstractTool::data.GeometricObject(baseCurveId); visual->SetLineStyle(LineStyleToPenStyle(curve->GetPenStyle())); @@ -283,15 +289,15 @@ auto VToolCutSpline::MakeToolTip() const -> QString { const auto spl = VAbstractTool::data.GeometricObject(baseCurveId); - const QString expression = VAbstractApplication::VApp()->TrVars() - ->FormulaToUser(formula, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); + const QString expression = VAbstractApplication::VApp()->TrVars()->FormulaToUser( + formula, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); const qreal length = Visualization::FindValFromUser(expression, VAbstractTool::data.DataVariables()); const QSharedPointer p = VAbstractTool::data.GeometricObject(m_id); QPointF spl1p2, spl1p3, spl2p2, spl2p3; - QPointF point = spl->CutSpline(VAbstractValApplication::VApp()->toPixel(length), spl1p2, spl1p3, spl2p2, spl2p3, - p->name()); + QPointF point = + spl->CutSpline(VAbstractValApplication::VApp()->toPixel(length), spl1p2, spl1p3, spl2p2, spl2p3, p->name()); VSpline spline1 = VSpline(spl->GetP1(), spl1p2, spl1p3, VPointF(point)); spline1.SetAliasSuffix(m_aliasSuffix1); @@ -302,21 +308,21 @@ auto VToolCutSpline::MakeToolTip() const -> QString const QString curveStr = QCoreApplication::translate("VToolCutSpline", "Curve"); const QString lengthStr = QCoreApplication::translate("VToolCutSpline", "length"); - const QString toolTip = QString("" - "" - "" - "" - "" - "
%6: %7
%1: %2 %3
%8: %9
%4: %5 %3
") - .arg(curveStr + QStringLiteral("1 ") + lengthStr) + const QString toolTip = + u"" + "" + "" + "" + "" + "
%6: %7
%1: %2 %3
%8: %9
%4: %5 %3
"_s.arg(curveStr + QStringLiteral("1 ") + lengthStr) .arg(VAbstractValApplication::VApp()->fromPixel(spline1.GetLength())) .arg(UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true), curveStr + QStringLiteral("2 ") + lengthStr) .arg(VAbstractValApplication::VApp()->fromPixel(spline2.GetLength())) .arg(curveStr + QStringLiteral(" 1") + QCoreApplication::translate("VToolCutSpline", "label"), - spline1.ObjectName(), + spline1.ObjectName(), curveStr + QStringLiteral(" 2") + QCoreApplication::translate("VToolCutSpline", "label"), - spline2.ObjectName()); + spline2.ObjectName()); return toolTip; } diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutsplinepath.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutsplinepath.cpp index 8e9407322..1eeef417b 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutsplinepath.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutsplinepath.cpp @@ -35,8 +35,10 @@ #include "../../../../../dialogs/tools/dialogcutsplinepath.h" #include "../../../../../dialogs/tools/dialogtool.h" -#include "../../../../../visualization/visualization.h" #include "../../../../../visualization/path/vistoolcutsplinepath.h" +#include "../../../../../visualization/visualization.h" +#include "../../../../vabstracttool.h" +#include "../../../vdrawtool.h" #include "../ifc/exception/vexception.h" #include "../ifc/ifcdef.h" #include "../vgeometry/vabstractcubicbezierpath.h" @@ -47,17 +49,21 @@ #include "../vgeometry/vsplinepoint.h" #include "../vmisc/vabstractapplication.h" #include "../vmisc/vcommonsettings.h" +#include "../vpatterndb/variables/vcurvelength.h" #include "../vpatterndb/vcontainer.h" #include "../vpatterndb/vtranslatevars.h" -#include "../vpatterndb/variables/vcurvelength.h" #include "../vwidgets/vmaingraphicsscene.h" -#include "../../../../vabstracttool.h" -#include "../../../vdrawtool.h" #include "vtoolcut.h" +#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) +#include "../vmisc/compatibility.h" +#endif + +using namespace Qt::Literals::StringLiterals; + template class QSharedPointer; -const QString VToolCutSplinePath::ToolType = QStringLiteral("cutSplinePath"); +const QString VToolCutSplinePath::ToolType = QStringLiteral("cutSplinePath"); const QString VToolCutSplinePath::AttrSplinePath = QStringLiteral("splinePath"); //--------------------------------------------------------------------------------------------------------------------- @@ -67,7 +73,7 @@ const QString VToolCutSplinePath::AttrSplinePath = QStringLiteral("splinePath"); * @param parent parent object. */ VToolCutSplinePath::VToolCutSplinePath(const VToolCutInitData &initData, QGraphicsItem *parent) - :VToolCut(initData, parent) + : VToolCut(initData, parent) { ToolCreation(initData.typeCreation); } @@ -118,7 +124,7 @@ auto VToolCutSplinePath::Create(const QPointer &dialog, VMainGraphic initData.aliasSuffix1 = dialogTool->GetAliasSuffix1(); initData.aliasSuffix2 = dialogTool->GetAliasSuffix2(); - VToolCutSplinePath* point = Create(initData); + VToolCutSplinePath *point = Create(initData); if (point != nullptr) { point->m_dialog = dialog; @@ -136,9 +142,9 @@ auto VToolCutSplinePath::Create(VToolCutInitData &initData) -> VToolCutSplinePat const auto splPath = initData.data->GeometricObject(initData.baseCurveId); SCASSERT(splPath != nullptr) - //Declare special variable "CurrentLength" - VCurveLength *length = new VCurveLength(initData.baseCurveId, initData.baseCurveId, splPath.data(), - *initData.data->GetPatternUnit()); + // Declare special variable "CurrentLength" + VCurveLength *length = + new VCurveLength(initData.baseCurveId, initData.baseCurveId, splPath.data(), *initData.data->GetPatternUnit()); length->SetName(currentLength); initData.data->AddVariable(length); @@ -146,8 +152,8 @@ auto VToolCutSplinePath::Create(VToolCutInitData &initData) -> VToolCutSplinePat VSplinePath *splPath1 = nullptr; VSplinePath *splPath2 = nullptr; - VPointF *p = VToolCutSplinePath::CutSplinePath( - VAbstractValApplication::VApp()->toPixel(result), splPath, initData.name, &splPath1, &splPath2); + VPointF *p = VToolCutSplinePath::CutSplinePath(VAbstractValApplication::VApp()->toPixel(result), splPath, + initData.name, &splPath1, &splPath2); SCASSERT(splPath1 != nullptr) SCASSERT(splPath2 != nullptr) @@ -200,7 +206,7 @@ auto VToolCutSplinePath::Create(VToolCutInitData &initData) -> VToolCutSplinePat VAbstractPattern::AddTool(initData.id, tool); initData.doc->IncrementReferens(splPath->getIdTool()); } - //Very important to delete it. Only this tool need this special variable. + // Very important to delete it. Only this tool need this special variable. initData.data->RemoveVariable(currentLength); return tool; } @@ -247,19 +253,19 @@ auto VToolCutSplinePath::CutSplinePath(qreal length, const QSharedPointerappend(VSplinePoint(splP1.P(), angle1, angle1F, spl1.GetStartAngle(), spl1.GetStartAngleFormula(), splP1.Length1(), splP1.Length1Formula(), spl1.GetC1Length(), spl1.GetC1LengthFormula())); - const qreal angle2 = spl1.GetEndAngle()+180; + const qreal angle2 = spl1.GetEndAngle() + 180; const QString angle2F = QString::number(angle2); - const auto cutPoint = VSplinePoint(*p, spl1.GetEndAngle(), spl1.GetEndAngleFormula(), angle2, angle2F, - spl1.GetC2Length(), spl1.GetC2LengthFormula(), spl2.GetC1Length(), - spl2.GetC1LengthFormula()); + const auto cutPoint = + VSplinePoint(*p, spl1.GetEndAngle(), spl1.GetEndAngleFormula(), angle2, angle2F, spl1.GetC2Length(), + spl1.GetC2LengthFormula(), spl2.GetC1Length(), spl2.GetC1LengthFormula()); (*splPath1)->append(cutPoint); continue; } @@ -269,17 +275,16 @@ auto VToolCutSplinePath::CutSplinePath(qreal length, const QSharedPointerappend(cutPoint); - const qreal angle2 = spl2.GetEndAngle()+180; + const qreal angle2 = spl2.GetEndAngle() + 180; const QString angle2F = QString::number(angle2); (*splPath2)->append(VSplinePoint(splP2.P(), spl2.GetEndAngle(), spl2.GetEndAngleFormula(), angle2, @@ -301,10 +306,10 @@ void VToolCutSplinePath::ShowContextMenu(QGraphicsSceneContextMenuEvent *event, { ContextMenu(event, id); } - catch(const VExceptionToolWasDeleted &e) + catch (const VExceptionToolWasDeleted &e) { Q_UNUSED(e) - return;//Leave this method immediately!!! + return; // Leave this method immediately!!! } } @@ -326,13 +331,13 @@ void VToolCutSplinePath::SaveDialog(QDomElement &domElement, QList &old doc->SetAttribute(domElement, AttrLength, dialogTool->GetFormula()); doc->SetAttribute(domElement, AttrSplinePath, QString().setNum(dialogTool->getSplinePathId())); doc->SetAttributeOrRemoveIf(domElement, AttrAlias1, dialogTool->GetAliasSuffix1(), - [](const QString &suffix) noexcept {return suffix.isEmpty();}); + [](const QString &suffix) noexcept { return suffix.isEmpty(); }); doc->SetAttributeOrRemoveIf(domElement, AttrAlias2, dialogTool->GetAliasSuffix2(), - [](const QString &suffix) noexcept {return suffix.isEmpty();}); + [](const QString &suffix) noexcept { return suffix.isEmpty(); }); const QString notes = dialogTool->GetNotes(); doc->SetAttributeOrRemoveIf(domElement, AttrNotes, notes, - [](const QString ¬es) noexcept {return notes.isEmpty();}); + [](const QString ¬es) noexcept { return notes.isEmpty(); }); } //--------------------------------------------------------------------------------------------------------------------- @@ -363,8 +368,8 @@ void VToolCutSplinePath::SetVisualization() SCASSERT(visual != nullptr) visual->SetSplinePathId(baseCurveId); - visual->SetLength(VAbstractApplication::VApp()->TrVars() - ->FormulaToUser(formula, VAbstractApplication::VApp()->Settings()->GetOsSeparator())); + visual->SetLength(VAbstractApplication::VApp()->TrVars()->FormulaToUser( + formula, VAbstractApplication::VApp()->Settings()->GetOsSeparator())); const QSharedPointer curve = VAbstractTool::data.GeometricObject(baseCurveId); visual->SetLineStyle(LineStyleToPenStyle(curve->GetPenStyle())); @@ -378,14 +383,14 @@ auto VToolCutSplinePath::MakeToolTip() const -> QString { const auto splPath = VAbstractTool::data.GeometricObject(baseCurveId); - const QString expression = VAbstractApplication::VApp()->TrVars() - ->FormulaToUser(formula, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); + const QString expression = VAbstractApplication::VApp()->TrVars()->FormulaToUser( + formula, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); const qreal length = Visualization::FindValFromUser(expression, VAbstractTool::data.DataVariables()); VSplinePath *splPath1 = nullptr; VSplinePath *splPath2 = nullptr; - VPointF *p = VToolCutSplinePath::CutSplinePath( - VAbstractValApplication::VApp()->toPixel(length), splPath, "X", &splPath1, &splPath2); + VPointF *p = VToolCutSplinePath::CutSplinePath(VAbstractValApplication::VApp()->toPixel(length), splPath, + QChar('X'), &splPath1, &splPath2); delete p; // Don't need this point splPath1->SetAliasSuffix(m_aliasSuffix1); @@ -394,21 +399,20 @@ auto VToolCutSplinePath::MakeToolTip() const -> QString const QString curveStr = QCoreApplication::translate("VToolCutSplinePath", "Curve"); const QString lengthStr = QCoreApplication::translate("VToolCutSplinePath", "length"); - const QString toolTip = QString("" - "" - "" - "" - "" - "
%6: %7
%1: %2 %3
%8: %9
%4: %5 %3
") - .arg(curveStr + QLatin1String("1 ") + lengthStr) + const QString toolTip = + u"" + "" + "" + "" + "" + "
%6: %7
%1: %2 %3
%8: %9
%4: %5 %3
"_s.arg(curveStr + "1 "_L1 + lengthStr) .arg(VAbstractValApplication::VApp()->fromPixel(splPath1->GetLength())) - .arg(UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true), - curveStr + QLatin1String("2 ") + lengthStr) + .arg(UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true), curveStr + "2 "_L1 + lengthStr) .arg(VAbstractValApplication::VApp()->fromPixel(splPath2->GetLength())) - .arg(curveStr + QLatin1String(" 1") + QCoreApplication::translate("VToolCutSplinePath", "label"), - splPath1->ObjectName(), - curveStr + QLatin1String(" 2") + QCoreApplication::translate("VToolCutSplinePath", "label"), - splPath2->ObjectName()); + .arg(curveStr + " 1"_L1 + QCoreApplication::translate("VToolCutSplinePath", "label"), + splPath1->ObjectName(), + curveStr + " 2"_L1 + QCoreApplication::translate("VToolCutSplinePath", "label"), + splPath2->ObjectName()); delete splPath1; delete splPath2; diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolalongline.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolalongline.cpp index 5d1c00e26..dd5049462 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolalongline.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolalongline.cpp @@ -35,22 +35,28 @@ #include "../../../../../dialogs/tools/dialogalongline.h" #include "../../../../../dialogs/tools/dialogtool.h" -#include "../../../../../visualization/visualization.h" #include "../../../../../visualization/line/vistoolalongline.h" +#include "../../../../../visualization/visualization.h" +#include "../../../../vabstracttool.h" +#include "../../../vdrawtool.h" #include "../ifc/exception/vexception.h" #include "../ifc/ifcdef.h" #include "../vgeometry/vgobject.h" #include "../vgeometry/vpointf.h" #include "../vmisc/vabstractapplication.h" #include "../vmisc/vcommonsettings.h" +#include "../vpatterndb/variables/vlinelength.h" #include "../vpatterndb/vcontainer.h" #include "../vpatterndb/vtranslatevars.h" -#include "../vpatterndb/variables/vlinelength.h" #include "../vwidgets/vmaingraphicsscene.h" -#include "../../../../vabstracttool.h" -#include "../../../vdrawtool.h" #include "vtoollinepoint.h" +#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) +#include "../vmisc/compatibility.h" +#endif + +using namespace Qt::Literals::StringLiterals; + template class QSharedPointer; const QString VToolAlongLine::ToolType = QStringLiteral("alongLine"); // NOLINT(cert-err58-cpp) @@ -62,9 +68,9 @@ const QString VToolAlongLine::ToolType = QStringLiteral("alongLine"); // NOLINT( * @param parent parent object. */ VToolAlongLine::VToolAlongLine(const VToolAlongLineInitData &initData, QGraphicsItem *parent) - :VToolLinePoint(initData.doc, initData.data, initData.id, initData.typeLine, initData.lineColor, initData.formula, - initData.firstPointId, 0, initData.notes, parent), - m_secondPointId(initData.secondPointId) + : VToolLinePoint(initData.doc, initData.data, initData.id, initData.typeLine, initData.lineColor, initData.formula, + initData.firstPointId, 0, initData.notes, parent), + m_secondPointId(initData.secondPointId) { ToolCreation(initData.typeCreation); } @@ -105,7 +111,7 @@ void VToolAlongLine::SaveDialog(QDomElement &domElement, QList &oldDepe const QString notes = dialogTool->GetNotes(); doc->SetAttributeOrRemoveIf(domElement, AttrNotes, notes, - [](const QString ¬es) noexcept {return notes.isEmpty();}); + [](const QString ¬es) noexcept { return notes.isEmpty(); }); } //--------------------------------------------------------------------------------------------------------------------- @@ -140,8 +146,8 @@ void VToolAlongLine::SetVisualization() SCASSERT(visual != nullptr) visual->SetPoint1Id(basePointId); visual->SetPoint2Id(m_secondPointId); - visual->SetLength(VAbstractApplication::VApp()->TrVars() - ->FormulaToUser(formulaLength, VAbstractApplication::VApp()->Settings()->GetOsSeparator())); + visual->SetLength(VAbstractApplication::VApp()->TrVars()->FormulaToUser( + formulaLength, VAbstractApplication::VApp()->Settings()->GetOsSeparator())); visual->SetLineStyle(LineStyleToPenStyle(m_lineType)); visual->SetMode(Mode::Show); visual->RefreshGeometry(); @@ -158,21 +164,20 @@ auto VToolAlongLine::MakeToolTip() const -> QString const QLineF curLine(static_cast(*basePoint), static_cast(*current)); const QLineF curToSecond(static_cast(*current), static_cast(*secondPoint)); - const QString toolTip = QString("" - "" - "" - "" - "" - "" - "
%9: %10
%1: %2 %3
%4: %5°
%6: %2 %3
%7: %8 %3
") - .arg(tr("Length")) - .arg(VAbstractValApplication::VApp()->fromPixel(curLine.length())) - .arg(UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true), tr("Angle")) - .arg(curLine.angle()) - .arg(QStringLiteral("%1->%2").arg(basePoint->name(), current->name()), - QStringLiteral("%1->%2").arg(current->name(), secondPoint->name())) - .arg(VAbstractValApplication::VApp()->fromPixel(curToSecond.length())) - .arg(tr("Label"), current->name()); + const QString toolTip = u"" + "" + "" + "" + "" + "" + "
%9: %10
%1: %2 %3
%4: %5°
%6: %2 %3
%7: %8 %3
"_s.arg(tr("Length")) + .arg(VAbstractValApplication::VApp()->fromPixel(curLine.length())) + .arg(UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true), tr("Angle")) + .arg(curLine.angle()) + .arg(QStringLiteral("%1->%2").arg(basePoint->name(), current->name()), + QStringLiteral("%1->%2").arg(current->name(), secondPoint->name())) + .arg(VAbstractValApplication::VApp()->fromPixel(curToSecond.length())) + .arg(tr("Label"), current->name()); return toolTip; } @@ -189,10 +194,10 @@ void VToolAlongLine::ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quin { ContextMenu(event, id); } - catch(const VExceptionToolWasDeleted &e) + catch (const VExceptionToolWasDeleted &e) { Q_UNUSED(e) - return;//Leave this method immediately!!! + return; // Leave this method immediately!!! } } @@ -224,7 +229,7 @@ void VToolAlongLine::SetDialog() * @param data container with variables. */ auto VToolAlongLine::Create(const QPointer &dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, - VContainer *data) -> VToolAlongLine* + VContainer *data) -> VToolAlongLine * { SCASSERT(not dialog.isNull()) const QPointer dialogTool = qobject_cast(dialog); @@ -263,20 +268,20 @@ auto VToolAlongLine::Create(const QPointer &dialog, VMainGraphicsSce * @brief Create help create tool. * @param initData init data. */ -auto VToolAlongLine::Create(VToolAlongLineInitData &initData) -> VToolAlongLine* +auto VToolAlongLine::Create(VToolAlongLineInitData &initData) -> VToolAlongLine * { const QSharedPointer firstPoint = initData.data->GeometricObject(initData.firstPointId); const QSharedPointer secondPoint = initData.data->GeometricObject(initData.secondPointId); QLineF line = QLineF(static_cast(*firstPoint), static_cast(*secondPoint)); - //Declare special variable "CurrentLength" - auto *length = new VLengthLine(firstPoint.data(), initData.firstPointId, secondPoint.data(), - initData.secondPointId, *initData.data->GetPatternUnit()); + // Declare special variable "CurrentLength" + auto *length = new VLengthLine(firstPoint.data(), initData.firstPointId, secondPoint.data(), initData.secondPointId, + *initData.data->GetPatternUnit()); length->SetName(currentLength); initData.data->AddVariable(length); - line.setLength(VAbstractValApplication::VApp()->toPixel( - CheckFormula(initData.id, initData.formula, initData.data))); + line.setLength( + VAbstractValApplication::VApp()->toPixel(CheckFormula(initData.id, initData.formula, initData.data))); auto *p = new VPointF(line.p2(), initData.name, initData.mx, initData.my); p->SetShowLabel(initData.showLabel); @@ -309,7 +314,7 @@ auto VToolAlongLine::Create(VToolAlongLineInitData &initData) -> VToolAlongLine* initData.doc->IncrementReferens(firstPoint->getIdTool()); initData.doc->IncrementReferens(secondPoint->getIdTool()); } - //Very important to delete it. Only this tool need this special variable. + // Very important to delete it. Only this tool need this special variable. initData.data->RemoveVariable(currentLength); return point; } diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolcurveintersectaxis.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolcurveintersectaxis.cpp index 42c7fedf1..a563857a6 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolcurveintersectaxis.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolcurveintersectaxis.cpp @@ -28,55 +28,53 @@ #include "vtoolcurveintersectaxis.h" -#include #include #include #include #include #include +#include #include -#include "../../../../../dialogs/tools/dialogtool.h" #include "../../../../../dialogs/tools/dialogcurveintersectaxis.h" -#include "../ifc/ifcdef.h" +#include "../../../../../dialogs/tools/dialogtool.h" +#include "../../../../vabstracttool.h" +#include "../../../vdrawtool.h" #include "../ifc/exception/vexception.h" #include "../ifc/exception/vexceptionobjecterror.h" -#include "../qmuparser/qmudef.h" +#include "../ifc/ifcdef.h" #include "../toolcut/vtoolcutsplinepath.h" -#include "../vgeometry/vabstractcubicbezier.h" -#include "../vgeometry/vabstractcubicbezierpath.h" #include "../vgeometry/vabstractcurve.h" -#include "../vgeometry/varc.h" -#include "../vgeometry/vellipticalarc.h" #include "../vgeometry/vgobject.h" #include "../vgeometry/vpointf.h" -#include "../vgeometry/vspline.h" -#include "../vgeometry/vsplinepath.h" #include "../vmisc/vabstractapplication.h" #include "../vmisc/vcommonsettings.h" #include "../vpatterndb/vcontainer.h" #include "../vpatterndb/vtranslatevars.h" -#include "../vtools/visualization/visualization.h" #include "../vtools/visualization/line/vistoolcurveintersectaxis.h" +#include "../vtools/visualization/visualization.h" #include "../vwidgets/vmaingraphicsscene.h" -#include "../../../../vabstracttool.h" -#include "../../../vdrawtool.h" #include "vtoollinepoint.h" +#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) +#include "../vmisc/compatibility.h" +#endif + +using namespace Qt::Literals::StringLiterals; + template class QSharedPointer; const QString VToolCurveIntersectAxis::ToolType = QStringLiteral("curveIntersectAxis"); //--------------------------------------------------------------------------------------------------------------------- -VToolCurveIntersectAxis::VToolCurveIntersectAxis(const VToolCurveIntersectAxisInitData &initData, - QGraphicsItem *parent) - :VToolLinePoint(initData.doc, initData.data, initData.id, initData.typeLine, initData.lineColor, QString(), - initData.basePointId, 0, initData.notes, parent), - formulaAngle(initData.formulaAngle), - curveId(initData.curveId), - m_segments(initData.segments), - m_aliasSuffix1(initData.aliasSuffix1), - m_aliasSuffix2(initData.aliasSuffix2) +VToolCurveIntersectAxis::VToolCurveIntersectAxis(const VToolCurveIntersectAxisInitData &initData, QGraphicsItem *parent) + : VToolLinePoint(initData.doc, initData.data, initData.id, initData.typeLine, initData.lineColor, QString(), + initData.basePointId, 0, initData.notes, parent), + formulaAngle(initData.formulaAngle), + curveId(initData.curveId), + m_segments(initData.segments), + m_aliasSuffix1(initData.aliasSuffix1), + m_aliasSuffix2(initData.aliasSuffix2) { ToolCreation(initData.typeCreation); } @@ -152,9 +150,11 @@ auto VToolCurveIntersectAxis::Create(VToolCurveIntersectAxisInitData &initData) { const QString errorMsg = tr("Error calculating point '%1'. There is no intersection with curve '%2' and axis" " through point '%3' with angle %4°") - .arg(initData.name, curve->ObjectName(), basePoint->name()).arg(angle); - VAbstractApplication::VApp()->IsPedantic() ? throw VExceptionObjectError(errorMsg) : - qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; + .arg(initData.name, curve->ObjectName(), basePoint->name()) + .arg(angle); + VAbstractApplication::VApp()->IsPedantic() + ? throw VExceptionObjectError(errorMsg) + : qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; } const qreal segLength = curve->GetLengthByPoint(fPoint); @@ -253,10 +253,10 @@ void VToolCurveIntersectAxis::ShowContextMenu(QGraphicsSceneContextMenuEvent *ev { ContextMenu(event, id); } - catch(const VExceptionToolWasDeleted &e) + catch (const VExceptionToolWasDeleted &e) { Q_UNUSED(e) - return;//Leave this method immediately!!! + return; // Leave this method immediately!!! } } @@ -280,11 +280,11 @@ void VToolCurveIntersectAxis::SaveDialog(QDomElement &domElement, QList doc->SetAttribute(domElement, AttrBasePoint, QString().setNum(dialogTool->GetBasePointId())); doc->SetAttribute(domElement, AttrCurve, QString().setNum(dialogTool->getCurveId())); doc->SetAttributeOrRemoveIf(domElement, AttrAlias1, dialogTool->GetAliasSuffix1(), - [](const QString &suffix) noexcept {return suffix.isEmpty();}); + [](const QString &suffix) noexcept { return suffix.isEmpty(); }); doc->SetAttributeOrRemoveIf(domElement, AttrAlias2, dialogTool->GetAliasSuffix2(), - [](const QString &suffix) noexcept {return suffix.isEmpty();}); + [](const QString &suffix) noexcept { return suffix.isEmpty(); }); doc->SetAttributeOrRemoveIf(domElement, AttrNotes, dialogTool->GetNotes(), - [](const QString ¬es) noexcept {return notes.isEmpty();}); + [](const QString ¬es) noexcept { return notes.isEmpty(); }); } //--------------------------------------------------------------------------------------------------------------------- @@ -297,9 +297,9 @@ void VToolCurveIntersectAxis::SaveOptions(QDomElement &tag, QSharedPointerSetAttribute(tag, AttrBasePoint, basePointId); doc->SetAttribute(tag, AttrCurve, curveId); doc->SetAttributeOrRemoveIf(tag, AttrAlias1, m_aliasSuffix1, - [](const QString &suffix) noexcept {return suffix.isEmpty();}); + [](const QString &suffix) noexcept { return suffix.isEmpty(); }); doc->SetAttributeOrRemoveIf(tag, AttrAlias2, m_aliasSuffix2, - [](const QString &suffix) noexcept {return suffix.isEmpty();}); + [](const QString &suffix) noexcept { return suffix.isEmpty(); }); } //--------------------------------------------------------------------------------------------------------------------- @@ -326,8 +326,8 @@ void VToolCurveIntersectAxis::SetVisualization() visual->SetCurveId(curveId); visual->setAxisPointId(basePointId); - visual->SetAngle(VAbstractApplication::VApp()->TrVars() - ->FormulaToUser(formulaAngle, VAbstractApplication::VApp()->Settings()->GetOsSeparator())); + visual->SetAngle(VAbstractApplication::VApp()->TrVars()->FormulaToUser( + formulaAngle, VAbstractApplication::VApp()->Settings()->GetOsSeparator())); visual->SetLineStyle(LineStyleToPenStyle(m_lineType)); visual->SetMode(Mode::Show); visual->RefreshGeometry(); @@ -342,20 +342,21 @@ auto VToolCurveIntersectAxis::MakeToolTip() const -> QString const QLineF line(static_cast(*first), static_cast(*second)); - const QString toolTip = QString("" - "" - "" - "" - "" - "" - "
%6: %7
%1: %2 %3
%4: %5°
%8: %9
%10: %11
") - .arg(tr("Length")) // 1 - .arg(VAbstractValApplication::VApp()->fromPixel(line.length())) // 2 + const QString toolTip = + u"" + "" + "" + "" + "" + "" + "
%6: %7
%1: %2 %3
%4: %5°
%8: %9
%10: %11
"_s + .arg(tr("Length")) // 1 + .arg(VAbstractValApplication::VApp()->fromPixel(line.length())) // 2 .arg(UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true), tr("Angle")) // 3, 4 - .arg(line.angle()) // 5 - .arg(tr("Label"), second->name(), /* 6, 7 */ - tr("Segment 1"), m_segments.first, /* 8, 9 */ - tr("Segment 2"), m_segments.second); /* 10, 11 */ + .arg(line.angle()) // 5 + .arg(tr("Label"), second->name(), /* 6, 7 */ + tr("Segment 1"), m_segments.first, /* 8, 9 */ + tr("Segment 2"), m_segments.second); /* 10, 11 */ return toolTip; } diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolheight.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolheight.cpp index 598c48f8e..1a3b11a14 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolheight.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolheight.cpp @@ -33,18 +33,24 @@ #include "../../../../../dialogs/tools/dialogheight.h" #include "../../../../../dialogs/tools/dialogtool.h" -#include "../../../../../visualization/visualization.h" #include "../../../../../visualization/line/vistoolheight.h" +#include "../../../../../visualization/visualization.h" +#include "../../../../vabstracttool.h" +#include "../../../vdrawtool.h" #include "../ifc/exception/vexception.h" #include "../ifc/ifcdef.h" #include "../vgeometry/vgobject.h" #include "../vgeometry/vpointf.h" #include "../vpatterndb/vcontainer.h" #include "../vwidgets/vmaingraphicsscene.h" -#include "../../../../vabstracttool.h" -#include "../../../vdrawtool.h" #include "vtoollinepoint.h" +#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) +#include "../vmisc/compatibility.h" +#endif + +using namespace Qt::Literals::StringLiterals; + template class QSharedPointer; const QString VToolHeight::ToolType = QStringLiteral("height"); @@ -55,11 +61,11 @@ const QString VToolHeight::ToolType = QStringLiteral("height"); * @param initData init data. * @param parent parent object. */ -VToolHeight::VToolHeight(const VToolHeightInitData &initData, QGraphicsItem * parent) - :VToolLinePoint(initData.doc, initData.data, initData.id, initData.typeLine, initData.lineColor, QString(), - initData.basePointId, 0, initData.notes, parent), - p1LineId(initData.p1LineId), - p2LineId(initData.p2LineId) +VToolHeight::VToolHeight(const VToolHeightInitData &initData, QGraphicsItem *parent) + : VToolLinePoint(initData.doc, initData.data, initData.id, initData.typeLine, initData.lineColor, QString(), + initData.basePointId, 0, initData.notes, parent), + p1LineId(initData.p1LineId), + p2LineId(initData.p2LineId) { ToolCreation(initData.typeCreation); } @@ -200,8 +206,7 @@ auto VToolHeight::SecondLinePointName() const -> QString /** * @brief SaveDialog save options into file after change in dialog. */ -void VToolHeight::SaveDialog(QDomElement &domElement, QList &oldDependencies, - QList &newDependencies) +void VToolHeight::SaveDialog(QDomElement &domElement, QList &oldDependencies, QList &newDependencies) { SCASSERT(not m_dialog.isNull()) const QPointer dialogTool = qobject_cast(m_dialog); @@ -223,7 +228,7 @@ void VToolHeight::SaveDialog(QDomElement &domElement, QList &oldDepende const QString notes = dialogTool->GetNotes(); doc->SetAttributeOrRemoveIf(domElement, AttrNotes, notes, - [](const QString ¬es) noexcept {return notes.isEmpty();}); + [](const QString ¬es) noexcept { return notes.isEmpty(); }); } //--------------------------------------------------------------------------------------------------------------------- @@ -278,22 +283,21 @@ auto VToolHeight::MakeToolTip() const -> QString const QLineF p1ToCur(static_cast(*p1Line), static_cast(*current)); const QLineF p2ToCur(static_cast(*p2Line), static_cast(*current)); - const QString toolTip = QString("" - "" - "" - "" - "" - "" - "
%10: %11
%1: %2 %3
%4: %5°
%6: %7 %3
%8: %9 %3
") - .arg(tr("Length")) - .arg(VAbstractValApplication::VApp()->fromPixel(curLine.length())) - .arg(UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true), tr("Angle")) - .arg(curLine.angle()) - .arg(QString("%1->%2").arg(p1Line->name(), current->name())) - .arg(VAbstractValApplication::VApp()->fromPixel(p1ToCur.length())) - .arg(QString("%1->%2").arg(p2Line->name(), current->name())) - .arg(VAbstractValApplication::VApp()->fromPixel(p2ToCur.length())) - .arg(tr("Label"), current->name()); + const QString toolTip = u"" + "" + "" + "" + "" + "" + "
%10: %11
%1: %2 %3
%4: %5°
%6: %7 %3
%8: %9 %3
"_s.arg(tr("Length")) + .arg(VAbstractValApplication::VApp()->fromPixel(curLine.length())) + .arg(UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true), tr("Angle")) + .arg(curLine.angle()) + .arg(u"%1->%2"_s.arg(p1Line->name(), current->name())) + .arg(VAbstractValApplication::VApp()->fromPixel(p1ToCur.length())) + .arg(u"%1->%2"_s.arg(p2Line->name(), current->name())) + .arg(VAbstractValApplication::VApp()->fromPixel(p2ToCur.length())) + .arg(tr("Label"), current->name()); return toolTip; } @@ -310,9 +314,9 @@ void VToolHeight::ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 { ContextMenu(event, id); } - catch(const VExceptionToolWasDeleted &e) + catch (const VExceptionToolWasDeleted &e) { Q_UNUSED(e) - return;//Leave this method immediately!!! + return; // Leave this method immediately!!! } } diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoollineintersectaxis.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoollineintersectaxis.cpp index b0c44844f..88dfcac5a 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoollineintersectaxis.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoollineintersectaxis.cpp @@ -34,21 +34,23 @@ #include "../../../../../dialogs/tools/dialoglineintersectaxis.h" #include "../../../../../dialogs/tools/dialogtool.h" -#include "../../../../../visualization/visualization.h" #include "../../../../../visualization/line/vistoollineintersectaxis.h" +#include "../../../../../visualization/visualization.h" +#include "../../../../vabstracttool.h" +#include "../../../vdrawtool.h" #include "../ifc/exception/vexception.h" #include "../ifc/exception/vexceptionobjecterror.h" #include "../ifc/ifcdef.h" #include "../vgeometry/vpointf.h" +#include "../vmisc/compatibility.h" #include "../vmisc/vabstractapplication.h" #include "../vmisc/vcommonsettings.h" #include "../vpatterndb/vcontainer.h" #include "../vpatterndb/vtranslatevars.h" #include "../vwidgets/vmaingraphicsscene.h" -#include "../../../../vabstracttool.h" -#include "../../../vdrawtool.h" #include "vtoollinepoint.h" -#include "../vmisc/compatibility.h" + +using namespace Qt::Literals::StringLiterals; template class QSharedPointer; @@ -56,11 +58,11 @@ const QString VToolLineIntersectAxis::ToolType = QStringLiteral("lineIntersectAx //--------------------------------------------------------------------------------------------------------------------- VToolLineIntersectAxis::VToolLineIntersectAxis(const VToolLineIntersectAxisInitData &initData, QGraphicsItem *parent) - :VToolLinePoint(initData.doc, initData.data, initData.id, initData.typeLine, initData.lineColor, QString(), - initData.basePointId, 0, initData.notes, parent), - formulaAngle(initData.formulaAngle), - firstPointId(initData.firstPointId), - secondPointId(initData.secondPointId) + : VToolLinePoint(initData.doc, initData.data, initData.id, initData.typeLine, initData.lineColor, QString(), + initData.basePointId, 0, initData.notes, parent), + formulaAngle(initData.formulaAngle), + firstPointId(initData.firstPointId), + secondPointId(initData.secondPointId) { ToolCreation(initData.typeCreation); } @@ -118,7 +120,7 @@ auto VToolLineIntersectAxis::Create(const QPointer &dialog, VMainGra auto VToolLineIntersectAxis::Create(VToolLineIntersectAxisInitData &initData) -> VToolLineIntersectAxis * { const QSharedPointer basePoint = initData.data->GeometricObject(initData.basePointId); - QLineF axis = QLineF(static_cast(*basePoint), QPointF(basePoint->x()+100, basePoint->y())); + QLineF axis = QLineF(static_cast(*basePoint), QPointF(basePoint->x() + 100, basePoint->y())); axis.setAngle(CheckFormula(initData.id, initData.formulaAngle, initData.data)); const QSharedPointer firstPoint = initData.data->GeometricObject(initData.firstPointId); @@ -132,9 +134,11 @@ auto VToolLineIntersectAxis::Create(VToolLineIntersectAxisInitData &initData) -> { const QString errorMsg = tr("Error calculating point '%1'. Line (%2;%3) doesn't have intersection with axis " "through point '%4' and angle %5°") - .arg(initData.name, firstPoint->name(), secondPoint->name(), basePoint->name()).arg(axis.angle()); - VAbstractApplication::VApp()->IsPedantic() ? throw VExceptionObjectError(errorMsg) : - qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; + .arg(initData.name, firstPoint->name(), secondPoint->name(), basePoint->name()) + .arg(axis.angle()); + VAbstractApplication::VApp()->IsPedantic() + ? throw VExceptionObjectError(errorMsg) + : qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; } VPointF *p = new VPointF(fPoint, initData.name, initData.mx, initData.my); @@ -184,8 +188,8 @@ auto VToolLineIntersectAxis::FindPoint(const QLineF &axis, const QLineF &line, Q if (intersect == QLineF::UnboundedIntersection || intersect == QLineF::BoundedIntersection) { - if(VFuzzyComparePossibleNulls(axis.angle(), line.angle()) - || VFuzzyComparePossibleNulls(qAbs(axis.angle() - line.angle()), 180)) + if (VFuzzyComparePossibleNulls(axis.angle(), line.angle()) || + VFuzzyComparePossibleNulls(qAbs(axis.angle() - line.angle()), 180)) { return false; } @@ -249,10 +253,10 @@ void VToolLineIntersectAxis::ShowContextMenu(QGraphicsSceneContextMenuEvent *eve { ContextMenu(event, id); } - catch(const VExceptionToolWasDeleted &e) + catch (const VExceptionToolWasDeleted &e) { Q_UNUSED(e) - return;//Leave this method immediately!!! + return; // Leave this method immediately!!! } } @@ -279,7 +283,7 @@ void VToolLineIntersectAxis::SaveDialog(QDomElement &domElement, QList doc->SetAttribute(domElement, AttrP1Line, QString().setNum(dialogTool->GetFirstPointId())); doc->SetAttribute(domElement, AttrP2Line, QString().setNum(dialogTool->GetSecondPointId())); doc->SetAttributeOrRemoveIf(domElement, AttrNotes, dialogTool->GetNotes(), - [](const QString ¬es) noexcept {return notes.isEmpty();}); + [](const QString ¬es) noexcept { return notes.isEmpty(); }); } //--------------------------------------------------------------------------------------------------------------------- @@ -318,8 +322,8 @@ void VToolLineIntersectAxis::SetVisualization() visual->SetPoint1Id(firstPointId); visual->SetPoint2Id(secondPointId); visual->SetAxisPointId(basePointId); - visual->SetAngle(VAbstractApplication::VApp()->TrVars() - ->FormulaToUser(formulaAngle, VAbstractApplication::VApp()->Settings()->GetOsSeparator())); + visual->SetAngle(VAbstractApplication::VApp()->TrVars()->FormulaToUser( + formulaAngle, VAbstractApplication::VApp()->Settings()->GetOsSeparator())); visual->SetLineStyle(LineStyleToPenStyle(m_lineType)); visual->SetMode(Mode::Show); visual->RefreshGeometry(); @@ -338,22 +342,21 @@ auto VToolLineIntersectAxis::MakeToolTip() const -> QString const QLineF firstToCur(static_cast(*firstPoint), static_cast(*current)); const QLineF curToSecond(static_cast(*current), static_cast(*secondPoint)); - const QString toolTip = QString("" - "" - "" - "" - "" - "" - "
%10: %11
%1: %2 %3
%4: %5°
%6: %7 %3
%8: %9 %3
") - .arg(tr("Length")) - .arg(VAbstractValApplication::VApp()->fromPixel(curLine.length())) - .arg(UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true), tr("Angle")) - .arg(curLine.angle()) - .arg(QString("%1->%2").arg(firstPoint->name(), current->name())) - .arg(VAbstractValApplication::VApp()->fromPixel(firstToCur.length())) - .arg(QString("%1->%2").arg(current->name(), secondPoint->name())) - .arg(VAbstractValApplication::VApp()->fromPixel(curToSecond.length())) - .arg(tr("Label"), current->name()); + const QString toolTip = u"" + "" + "" + "" + "" + "" + "
%10: %11
%1: %2 %3
%4: %5°
%6: %7 %3
%8: %9 %3
"_s.arg(tr("Length")) + .arg(VAbstractValApplication::VApp()->fromPixel(curLine.length())) + .arg(UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true), tr("Angle")) + .arg(curLine.angle()) + .arg(u"%1->%2"_s.arg(firstPoint->name(), current->name())) + .arg(VAbstractValApplication::VApp()->fromPixel(firstToCur.length())) + .arg(u"%1->%2"_s.arg(current->name(), secondPoint->name())) + .arg(VAbstractValApplication::VApp()->fromPixel(curToSecond.length())) + .arg(tr("Label"), current->name()); return toolTip; } diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoollinepoint.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoollinepoint.cpp index 9f48f676b..812434556 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoollinepoint.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoollinepoint.cpp @@ -49,6 +49,12 @@ #include "../vtoolsinglepoint.h" #include "../vwidgets/scalesceneitems.h" +#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) +#include "../vmisc/compatibility.h" +#endif + +using namespace Qt::Literals::StringLiterals; + template class QSharedPointer; //--------------------------------------------------------------------------------------------------------------------- @@ -157,12 +163,11 @@ auto VToolLinePoint::MakeToolTip() const -> QString const QLineF line(static_cast(*first), static_cast(*second)); - const QString toolTip = QString("" - "" - "" - "" - "
%6: %7
%1: %2 %3
%4: %5°
") - .arg(tr("Length")) + const QString toolTip = u"" + "" + "" + "" + "
%6: %7
%1: %2 %3
%4: %5°
"_s.arg(tr("Length")) .arg(VAbstractValApplication::VApp()->fromPixel(line.length())) .arg(UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true), tr("Angle")) .arg(line.angle()) diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolshoulderpoint.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolshoulderpoint.cpp index 40a333830..bfaa56628 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolshoulderpoint.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolshoulderpoint.cpp @@ -36,8 +36,10 @@ #include "../../../../../dialogs/tools/dialogshoulderpoint.h" #include "../../../../../dialogs/tools/dialogtool.h" -#include "../../../../../visualization/visualization.h" #include "../../../../../visualization/line/vistoolshoulderpoint.h" +#include "../../../../../visualization/visualization.h" +#include "../../../../vabstracttool.h" +#include "../../../vdrawtool.h" #include "../ifc/exception/vexception.h" #include "../ifc/ifcdef.h" #include "../vgeometry/vgobject.h" @@ -47,10 +49,14 @@ #include "../vpatterndb/vcontainer.h" #include "../vpatterndb/vtranslatevars.h" #include "../vwidgets/vmaingraphicsscene.h" -#include "../../../../vabstracttool.h" -#include "../../../vdrawtool.h" #include "vtoollinepoint.h" +#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) +#include "../vmisc/compatibility.h" +#endif + +using namespace Qt::Literals::StringLiterals; + template class QSharedPointer; const QString VToolShoulderPoint::ToolType = QStringLiteral("shoulder"); @@ -61,11 +67,11 @@ const QString VToolShoulderPoint::ToolType = QStringLiteral("shoulder"); * @param initData init data. * @param parent parent object. */ -VToolShoulderPoint::VToolShoulderPoint(const VToolShoulderPointInitData &initData, QGraphicsItem * parent) - :VToolLinePoint(initData.doc, initData.data, initData.id, initData.typeLine, initData.lineColor, initData.formula, - initData.p1Line, 0, initData.notes, parent), - p2Line(initData.p2Line), - pShoulder(initData.pShoulder) +VToolShoulderPoint::VToolShoulderPoint(const VToolShoulderPointInitData &initData, QGraphicsItem *parent) + : VToolLinePoint(initData.doc, initData.data, initData.id, initData.typeLine, initData.lineColor, initData.formula, + initData.p1Line, 0, initData.notes, parent), + p2Line(initData.p2Line), + pShoulder(initData.pShoulder) { ToolCreation(initData.typeCreation); } @@ -111,7 +117,7 @@ auto VToolShoulderPoint::FindPoint(const QPointF &p1Line, const QPointF &p2Line, QLineF line = QLineF(p1Line, p2Line); const qreal baseLength = line.length(); const int baseAngle = qRound(line.angle()); - line.setLength(length*2); + line.setLength(length * 2); QPointF p1; QPointF p2; @@ -166,7 +172,7 @@ auto VToolShoulderPoint::Create(const QPointer &dialog, VMainGraphic initData.typeCreation = Source::FromGui; initData.notes = dialogTool->GetNotes(); - VToolShoulderPoint * point = Create(initData); + VToolShoulderPoint *point = Create(initData); if (point != nullptr) { point->m_dialog = dialog; @@ -188,10 +194,9 @@ auto VToolShoulderPoint::Create(VToolShoulderPointInitData &initData) -> VToolSh const qreal result = CheckFormula(initData.id, initData.formula, initData.data); - QPointF fPoint = VToolShoulderPoint::FindPoint(static_cast(*firstPoint), - static_cast(*secondPoint), - static_cast(*shoulderPoint), - VAbstractValApplication::VApp()->toPixel(result)); + QPointF fPoint = VToolShoulderPoint::FindPoint( + static_cast(*firstPoint), static_cast(*secondPoint), static_cast(*shoulderPoint), + VAbstractValApplication::VApp()->toPixel(result)); VPointF *p = new VPointF(fPoint, initData.name, initData.mx, initData.my); p->SetShowLabel(initData.showLabel); @@ -282,7 +287,7 @@ void VToolShoulderPoint::SaveDialog(QDomElement &domElement, QList &old const QString notes = dialogTool->GetNotes(); doc->SetAttributeOrRemoveIf(domElement, AttrNotes, notes, - [](const QString ¬es) noexcept {return notes.isEmpty();}); + [](const QString ¬es) noexcept { return notes.isEmpty(); }); } //--------------------------------------------------------------------------------------------------------------------- @@ -321,8 +326,8 @@ void VToolShoulderPoint::SetVisualization() visual->SetLineP1Id(pShoulder); visual->SetLineP1Id(basePointId); visual->SetLineP2Id(p2Line); - visual->SetLength(VAbstractApplication::VApp()->TrVars() - ->FormulaToUser(formulaLength, VAbstractApplication::VApp()->Settings()->GetOsSeparator())); + visual->SetLength(VAbstractApplication::VApp()->TrVars()->FormulaToUser( + formulaLength, VAbstractApplication::VApp()->Settings()->GetOsSeparator())); visual->SetLineStyle(LineStyleToPenStyle(m_lineType)); visual->SetMode(Mode::Show); visual->RefreshGeometry(); @@ -339,19 +344,18 @@ auto VToolShoulderPoint::MakeToolTip() const -> QString const QLineF firstToCur(static_cast(*first), static_cast(*current)); const QLineF secondToCur(static_cast(*second), static_cast(*current)); - const QString toolTip = QString("" - "" - "" - "" - "" - "
%8: %9
%1: %2 %3
%4: %5°
%6: %7 %3
") - .arg(tr("Length")) - .arg(VAbstractValApplication::VApp()->fromPixel(firstToCur.length())) - .arg(UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true), tr("Angle")) - .arg(firstToCur.angle()) - .arg(QString("%1->%2").arg(second->name(), current->name())) - .arg(VAbstractValApplication::VApp()->fromPixel(secondToCur.length())) - .arg(tr("Label"), current->name()); + const QString toolTip = u"" + "" + "" + "" + "" + "
%8: %9
%1: %2 %3
%4: %5°
%6: %7 %3
"_s.arg(tr("Length")) + .arg(VAbstractValApplication::VApp()->fromPixel(firstToCur.length())) + .arg(UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true), tr("Angle")) + .arg(firstToCur.angle()) + .arg(u"%1->%2"_s.arg(second->name(), current->name())) + .arg(VAbstractValApplication::VApp()->fromPixel(secondToCur.length())) + .arg(tr("Label"), current->name()); return toolTip; } @@ -362,10 +366,10 @@ void VToolShoulderPoint::ShowContextMenu(QGraphicsSceneContextMenuEvent *event, { ContextMenu(event, id); } - catch(const VExceptionToolWasDeleted &e) + catch (const VExceptionToolWasDeleted &e) { Q_UNUSED(e) - return;//Leave this method immediately!!! + return; // Leave this method immediately!!! } } diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolbasepoint.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolbasepoint.cpp index a08ba771b..0f18c2b48 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolbasepoint.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolbasepoint.cpp @@ -64,6 +64,12 @@ #include "../vwidgets/vmaingraphicsview.h" #include "vtoolsinglepoint.h" +#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) +#include "../vmisc/compatibility.h" +#endif + +using namespace Qt::Literals::StringLiterals; + const QString VToolBasePoint::ToolType = QStringLiteral("single"); //--------------------------------------------------------------------------------------------------------------------- @@ -331,10 +337,9 @@ auto VToolBasePoint::MakeToolTip() const -> QString { const QSharedPointer point = VAbstractTool::data.GeometricObject(m_id); - const QString toolTip = QString("" - "" - "
%1: %2
") - .arg(tr("Label"), point->name()); + const QString toolTip = u"" + "" + "
%1: %2
"_s.arg(tr("Label"), point->name()); return toolTip; } diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoollineintersect.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoollineintersect.cpp index 0f7f15a39..28b826c90 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoollineintersect.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoollineintersect.cpp @@ -35,20 +35,22 @@ #include #include "../../../../dialogs/tools/dialoglineintersect.h" +#include "../../../../dialogs/tools/dialogtool.h" #include "../../../../visualization/line/vistoollineintersect.h" +#include "../../../../visualization/visualization.h" +#include "../../../vabstracttool.h" +#include "../../vdrawtool.h" #include "../ifc/exception/vexception.h" #include "../ifc/exception/vexceptionobjecterror.h" #include "../ifc/ifcdef.h" #include "../vgeometry/vgobject.h" #include "../vgeometry/vpointf.h" +#include "../vmisc/compatibility.h" #include "../vpatterndb/vcontainer.h" #include "../vwidgets/vmaingraphicsscene.h" -#include "../../../../dialogs/tools/dialogtool.h" -#include "../../../../visualization/visualization.h" -#include "../../../vabstracttool.h" -#include "../../vdrawtool.h" #include "vtoolsinglepoint.h" -#include "../vmisc/compatibility.h" + +using namespace Qt::Literals::StringLiterals; template class QSharedPointer; @@ -61,11 +63,11 @@ const QString VToolLineIntersect::ToolType = QStringLiteral("lineIntersect"); * @param parent parent object. */ VToolLineIntersect::VToolLineIntersect(const VToolLineIntersectInitData &initData, QGraphicsItem *parent) - :VToolSinglePoint(initData.doc, initData.data, initData.id, initData.notes, parent), - p1Line1(initData.p1Line1Id), - p2Line1(initData.p2Line1Id), - p1Line2(initData.p1Line2Id), - p2Line2(initData.p2Line2Id) + : VToolSinglePoint(initData.doc, initData.data, initData.id, initData.notes, parent), + p1Line1(initData.p1Line1Id), + p2Line1(initData.p2Line1Id), + p1Line2(initData.p1Line2Id), + p2Line2(initData.p2Line2Id) { ToolCreation(initData.typeCreation); } @@ -78,7 +80,7 @@ void VToolLineIntersect::SetDialog() { SCASSERT(not m_dialog.isNull()) const QPointer dialogTool = qobject_cast(m_dialog); - SCASSERT(not dialogTool.isNull()) + SCASSERT(not dialogTool.isNull()) const QSharedPointer p = VAbstractTool::data.GeometricObject(m_id); dialogTool->SetP1Line1(p1Line1); dialogTool->SetP2Line1(p2Line1); @@ -117,7 +119,7 @@ auto VToolLineIntersect::Create(const QPointer &dialog, VMainGraphic initData.typeCreation = Source::FromGui; initData.notes = dialogTool->GetNotes(); - VToolLineIntersect* point = Create(initData); + VToolLineIntersect *point = Create(initData); if (point != nullptr) { point->m_dialog = dialog; @@ -145,11 +147,13 @@ auto VToolLineIntersect::Create(VToolLineIntersectInitData initData) -> VToolLin if (intersect == QLineF::NoIntersection) { - const QString errorMsg = tr("Error calculating point '%1'. Lines (%2;%3) and (%4;%5) have no point of " - "intersection") + const QString errorMsg = + tr("Error calculating point '%1'. Lines (%2;%3) and (%4;%5) have no point of " + "intersection") .arg(initData.name, p1Line1->name(), p2Line1->name(), p1Line2->name(), p2Line2->name()); - VAbstractApplication::VApp()->IsPedantic() ? throw VExceptionObjectError(errorMsg) : - qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; + VAbstractApplication::VApp()->IsPedantic() + ? throw VExceptionObjectError(errorMsg) + : qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; } VPointF *p = new VPointF(fPoint, initData.name, initData.mx, initData.my); @@ -259,7 +263,7 @@ void VToolLineIntersect::SaveDialog(QDomElement &domElement, QList &old doc->SetAttribute(domElement, AttrP1Line2, QString().setNum(dialogTool->GetP1Line2())); doc->SetAttribute(domElement, AttrP2Line2, QString().setNum(dialogTool->GetP2Line2())); doc->SetAttributeOrRemoveIf(domElement, AttrNotes, dialogTool->GetNotes(), - [](const QString ¬es) noexcept {return notes.isEmpty();}); + [](const QString ¬es) noexcept { return notes.isEmpty(); }); } //--------------------------------------------------------------------------------------------------------------------- @@ -316,23 +320,22 @@ auto VToolLineIntersect::MakeToolTip() const -> QString const QLineF p1L2ToCur(static_cast(*p1L2), static_cast(*current)); const QLineF curToP2L2(static_cast(*current), static_cast(*p2L2)); - const QString toolTip = QString("" - "" - "" - "" - "" - "" - "
%10: %11
%1: %2 %3
%4: %5 %3
%6: %7 %3
%8: %9 %3
") - .arg(QString("%1->%2").arg(p1L1->name(), current->name())) - .arg(VAbstractValApplication::VApp()->fromPixel(p1L1ToCur.length())) - .arg(UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true), - QString("%1->%2").arg(current->name(), p2L1->name())) - .arg(VAbstractValApplication::VApp()->fromPixel(curToP2L1.length())) - .arg(QString("%1->%2").arg(p1L2->name(), current->name())) - .arg(VAbstractValApplication::VApp()->fromPixel(p1L2ToCur.length())) - .arg(QString("%1->%2").arg(current->name(), p2L2->name())) - .arg(VAbstractValApplication::VApp()->fromPixel(curToP2L2.length())) - .arg(tr("Label"), current->name()); + const QString toolTip = u"" + "" + "" + "" + "" + "" + "
%10: %11
%1: %2 %3
%4: %5 %3
%6: %7 %3
%8: %9 %3
"_s.arg(u"%1->%2"_s.arg(p1L1->name(), current->name())) + .arg(VAbstractValApplication::VApp()->fromPixel(p1L1ToCur.length())) + .arg(UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true), + u"%1->%2"_s.arg(current->name(), p2L1->name())) + .arg(VAbstractValApplication::VApp()->fromPixel(curToP2L1.length())) + .arg(u"%1->%2"_s.arg(p1L2->name(), current->name())) + .arg(VAbstractValApplication::VApp()->fromPixel(p1L2ToCur.length())) + .arg(u"%1->%2"_s.arg(current->name(), p2L2->name())) + .arg(VAbstractValApplication::VApp()->fromPixel(curToP2L2.length())) + .arg(tr("Label"), current->name()); return toolTip; } @@ -349,9 +352,9 @@ void VToolLineIntersect::ShowContextMenu(QGraphicsSceneContextMenuEvent *event, { ContextMenu(event, id); } - catch(const VExceptionToolWasDeleted &e) + catch (const VExceptionToolWasDeleted &e) { Q_UNUSED(e) - return;//Leave this method immediately!!! + return; // Leave this method immediately!!! } } diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofcontact.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofcontact.cpp index 59368db22..d6c57d6ed 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofcontact.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofcontact.cpp @@ -36,12 +36,14 @@ #include "../../../../dialogs/tools/dialogpointofcontact.h" #include "../../../../dialogs/tools/dialogtool.h" -#include "../../../../visualization/visualization.h" #include "../../../../visualization/line/vistoolpointofcontact.h" +#include "../../../../visualization/visualization.h" +#include "../../../vabstracttool.h" +#include "../../vdrawtool.h" #include "../ifc/exception/vexception.h" #include "../ifc/exception/vexceptionobjecterror.h" -#include "../ifc/xml/vdomdocument.h" #include "../ifc/ifcdef.h" +#include "../ifc/xml/vdomdocument.h" #include "../vgeometry/vgobject.h" #include "../vgeometry/vpointf.h" #include "../vmisc/vabstractapplication.h" @@ -50,10 +52,14 @@ #include "../vpatterndb/vformula.h" #include "../vpatterndb/vtranslatevars.h" #include "../vwidgets/vmaingraphicsscene.h" -#include "../../../vabstracttool.h" -#include "../../vdrawtool.h" #include "vtoolsinglepoint.h" +#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) +#include "../vmisc/compatibility.h" +#endif + +using namespace Qt::Literals::StringLiterals; + template class QSharedPointer; const QString VToolPointOfContact::ToolType = QStringLiteral("pointOfContact"); @@ -65,11 +71,11 @@ const QString VToolPointOfContact::ToolType = QStringLiteral("pointOfContact"); * @param parent parent object. */ VToolPointOfContact::VToolPointOfContact(const VToolPointOfContactInitData &initData, QGraphicsItem *parent) - : VToolSinglePoint(initData.doc, initData.data, initData.id, initData.notes, parent), - arcRadius(initData.radius), - center(initData.center), - firstPointId(initData.firstPointId), - secondPointId(initData.secondPointId) + : VToolSinglePoint(initData.doc, initData.data, initData.id, initData.notes, parent), + arcRadius(initData.radius), + center(initData.center), + firstPointId(initData.firstPointId), + secondPointId(initData.secondPointId) { ToolCreation(initData.typeCreation); } @@ -118,10 +124,10 @@ auto VToolPointOfContact::FindPoint(qreal radius, const QPointF ¢er, const Q return true; case 2: { - const bool flagP1 = VGObject::IsPointOnLineSegment (p1, firstPoint, secondPoint); - const bool flagP2 = VGObject::IsPointOnLineSegment (p2, firstPoint, secondPoint); + const bool flagP1 = VGObject::IsPointOnLineSegment(p1, firstPoint, secondPoint); + const bool flagP2 = VGObject::IsPointOnLineSegment(p2, firstPoint, secondPoint); if ((flagP1 == true && flagP2 == true) || - (flagP1 == false && flagP2 == false)/*In case we have something wrong*/) + (flagP1 == false && flagP2 == false) /*In case we have something wrong*/) { // We don't have options for choosing correct point. Use closest to segment first point. if (QLineF(firstPoint, p1).length() <= QLineF(firstPoint, p2).length()) @@ -202,18 +208,20 @@ auto VToolPointOfContact::Create(VToolPointOfContactInitData &initData) -> VTool const qreal result = CheckFormula(initData.id, initData.radius, initData.data); QPointF fPoint; - const bool success = VToolPointOfContact::FindPoint(VAbstractValApplication::VApp()->toPixel(result), - static_cast(*centerP), - static_cast(*firstP), static_cast(*secondP), - &fPoint); + const bool success = + VToolPointOfContact::FindPoint(VAbstractValApplication::VApp()->toPixel(result), static_cast(*centerP), + static_cast(*firstP), static_cast(*secondP), &fPoint); if (not success) { const QString errorMsg = tr("Error calculating point '%1'. Circle with center '%2' and radius '%3' doesn't " "have intersection with line (%4;%5)") - .arg(initData.name, centerP->name()).arg(result).arg(firstP->name(), secondP->name()); - VAbstractApplication::VApp()->IsPedantic() ? throw VExceptionObjectError(errorMsg) : - qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; + .arg(initData.name, centerP->name()) + .arg(result) + .arg(firstP->name(), secondP->name()); + VAbstractApplication::VApp()->IsPedantic() + ? throw VExceptionObjectError(errorMsg) + : qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; } VPointF *p = new VPointF(fPoint, initData.name, initData.mx, initData.my); @@ -310,7 +318,7 @@ void VToolPointOfContact::SaveDialog(QDomElement &domElement, QList &ol doc->SetAttribute(domElement, AttrFirstPoint, QString().setNum(dialogTool->GetFirstPoint())); doc->SetAttribute(domElement, AttrSecondPoint, QString().setNum(dialogTool->GetSecondPoint())); doc->SetAttributeOrRemoveIf(domElement, AttrNotes, dialogTool->GetNotes(), - [](const QString ¬es) noexcept {return notes.isEmpty();}); + [](const QString ¬es) noexcept { return notes.isEmpty(); }); } //--------------------------------------------------------------------------------------------------------------------- @@ -347,8 +355,8 @@ void VToolPointOfContact::SetVisualization() visual->SetLineP1Id(firstPointId); visual->SetLineP2Id(secondPointId); visual->SetRadiusId(center); - visual->SetRadius(VAbstractApplication::VApp()->TrVars() - ->FormulaToUser(arcRadius, VAbstractApplication::VApp()->Settings()->GetOsSeparator())); + visual->SetRadius(VAbstractApplication::VApp()->TrVars()->FormulaToUser( + arcRadius, VAbstractApplication::VApp()->Settings()->GetOsSeparator())); visual->SetMode(Mode::Show); visual->RefreshGeometry(); } @@ -366,23 +374,22 @@ auto VToolPointOfContact::MakeToolTip() const -> QString const QLineF p2ToCur(static_cast(*p2), static_cast(*current)); const QLineF centerToCur(static_cast(*centerP), static_cast(*current)); - const QString toolTip = QString("" - "" - "" - "" - "" - "" - "
%10: %11
%1: %2 %3
%4: %5 %3
%6: %7 %3
%8: %9°
") - .arg(QStringLiteral("%1->%2").arg(p1->name(), current->name())) - .arg(VAbstractValApplication::VApp()->fromPixel(p1ToCur.length())) - .arg(UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true), - QStringLiteral("%1->%2").arg(p2->name(), current->name())) - .arg(VAbstractValApplication::VApp()->fromPixel(p2ToCur.length())) - .arg(QStringLiteral("%1 %2->%3").arg(tr("Length"), centerP->name(), current->name())) - .arg(VAbstractValApplication::VApp()->fromPixel(centerToCur.length())) - .arg(QStringLiteral("%1 %2->%3").arg(tr("Angle"), centerP->name(), current->name())) - .arg(centerToCur.angle()) - .arg(tr("Label"), current->name()); + const QString toolTip = u"" + "" + "" + "" + "" + "" + "
%10: %11
%1: %2 %3
%4: %5 %3
%6: %7 %3
%8: %9°
"_s.arg(u"%1->%2"_s.arg(p1->name(), current->name())) + .arg(VAbstractValApplication::VApp()->fromPixel(p1ToCur.length())) + .arg(UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true), + u"%1->%2"_s.arg(p2->name(), current->name())) + .arg(VAbstractValApplication::VApp()->fromPixel(p2ToCur.length())) + .arg(u"%1 %2->%3"_s.arg(tr("Length"), centerP->name(), current->name())) + .arg(VAbstractValApplication::VApp()->fromPixel(centerToCur.length())) + .arg(u"%1 %2->%3"_s.arg(tr("Angle"), centerP->name(), current->name())) + .arg(centerToCur.angle()) + .arg(tr("Label"), current->name()); return toolTip; } @@ -399,10 +406,10 @@ void VToolPointOfContact::ShowContextMenu(QGraphicsSceneContextMenuEvent *event, { ContextMenu(event, id); } - catch(const VExceptionToolWasDeleted &e) + catch (const VExceptionToolWasDeleted &e) { Q_UNUSED(e) - return;//Leave this method immediately!!! + return; // Leave this method immediately!!! } } diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncurves.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncurves.cpp index e29bb2638..f4894ed9f 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncurves.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncurves.cpp @@ -47,6 +47,12 @@ #include "../vwidgets/vmaingraphicsscene.h" #include "vtoolsinglepoint.h" +#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) +#include "../vmisc/compatibility.h" +#endif + +using namespace Qt::Literals::StringLiterals; + template class QSharedPointer; const QString VToolPointOfIntersectionCurves::ToolType = QStringLiteral("pointOfIntersectionCurves"); @@ -480,13 +486,13 @@ auto VToolPointOfIntersectionCurves::MakeToolTip() const -> QString { const QSharedPointer p = VAbstractTool::data.GeometricObject(m_id); - const QString toolTip = QString("" - "" - "" - "" - "" - "" - "
%1: %2
%3: %4
%5: %6
%7: %8
%9: %10
") + const QString toolTip = u"" + "" + "" + "" + "" + "" + "
%1: %2
%3: %4
%5: %6
%7: %8
%9: %10
"_s .arg(tr("Label"), p->name(), /* 1, 2 */ tr("Curve 1 segment 1"), m_curve1Segments.first, /* 3, 4 */ tr("Curve 1 segment 2"), m_curve1Segments.second) /* 5, 6 */ diff --git a/src/libs/vtools/tools/drawTools/vtoolline.cpp b/src/libs/vtools/tools/drawTools/vtoolline.cpp index 6484d212d..2dee0f1f6 100644 --- a/src/libs/vtools/tools/drawTools/vtoolline.cpp +++ b/src/libs/vtools/tools/drawTools/vtoolline.cpp @@ -52,6 +52,12 @@ #include "../vwidgets/vmaingraphicsscene.h" #include "vdrawtool.h" +#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) +#include "../vmisc/compatibility.h" +#endif + +using namespace Qt::Literals::StringLiterals; + template class QSharedPointer; //--------------------------------------------------------------------------------------------------------------------- @@ -441,11 +447,10 @@ auto VToolLine::MakeToolTip() const -> QString const QLineF line(static_cast(*first), static_cast(*second)); - const QString toolTip = QString("" - "" - "" - "
%1: %2 %3
%4: %5°
") - .arg(tr("Length")) + const QString toolTip = u"" + "" + "" + "
%1: %2 %3
%4: %5°
"_s.arg(tr("Length")) .arg(VAbstractValApplication::VApp()->fromPixel(line.length())) .arg(UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true), tr("Angle")) .arg(line.angle()); diff --git a/src/libs/vtools/tools/vabstracttool.cpp b/src/libs/vtools/tools/vabstracttool.cpp index a29152e61..9a889da79 100644 --- a/src/libs/vtools/tools/vabstracttool.cpp +++ b/src/libs/vtools/tools/vabstracttool.cpp @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -45,34 +46,39 @@ #include #include #include -#include -#include "../vgeometry/vpointf.h" -#include "../vwidgets/vmaingraphicsview.h" +#include "../dialogs/support/dialogeditwrongformula.h" +#include "../dialogs/support/dialogundo.h" #include "../ifc/exception/vexception.h" #include "../ifc/exception/vexceptionundo.h" #include "../ifc/xml/vtoolrecord.h" #include "../undocommands/deltool.h" #include "../vgeometry/../ifc/ifcdef.h" -#include "../vgeometry/vgeometrydef.h" -#include "../vgeometry/vgobject.h" +#include "../vgeometry/varc.h" #include "../vgeometry/vcubicbezier.h" #include "../vgeometry/vcubicbezierpath.h" -#include "../vgeometry/vsplinepath.h" -#include "../vgeometry/varc.h" #include "../vgeometry/vellipticalarc.h" +#include "../vgeometry/vgeometrydef.h" +#include "../vgeometry/vgobject.h" +#include "../vgeometry/vpointf.h" +#include "../vgeometry/vsplinepath.h" +#include "../vpatterndb/calculator.h" #include "../vpatterndb/vcontainer.h" #include "../vpatterndb/vpiecenode.h" -#include "../vpatterndb/calculator.h" -#include "../dialogs/support/dialogundo.h" -#include "../dialogs/support/dialogeditwrongformula.h" -#include "toolsdef.h" +#include "../vwidgets/vmaingraphicsview.h" #include "nodeDetails/vabstractnode.h" -#include "nodeDetails/vnodepoint.h" #include "nodeDetails/vnodearc.h" #include "nodeDetails/vnodeellipticalarc.h" +#include "nodeDetails/vnodepoint.h" #include "nodeDetails/vnodespline.h" #include "nodeDetails/vnodesplinepath.h" +#include "toolsdef.h" + +#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) +#include "../vmisc/compatibility.h" +#endif + +using namespace Qt::Literals::StringLiterals; template class QSharedPointer; @@ -88,11 +94,11 @@ const QString VAbstractTool::AttrInUse = QStringLiteral("inUse"); * @param parent parent object. */ VAbstractTool::VAbstractTool(VAbstractPattern *doc, VContainer *data, quint32 id, QObject *parent) - :VDataTool(data, parent), - doc(doc), - m_id(id), - vis(), - selectionType(SelectionType::ByMouseRelease) + : VDataTool(data, parent), + doc(doc), + m_id(id), + vis(), + selectionType(SelectionType::ByMouseRelease) { SCASSERT(doc != nullptr) connect(this, &VAbstractTool::toolhaveChange, this->doc, &VAbstractPattern::haveLiteChange); @@ -141,7 +147,7 @@ auto VAbstractTool::CheckFormula(const quint32 &toolId, QString &formula, VConta { qDebug() << "\nMath parser error:\n" << "--------------------------------------\n" - << "Message: " << e.GetMsg() << "\n" + << "Message: " << e.GetMsg() << "\n" << "Expression: " << e.GetExpr() << "\n" << "--------------------------------------"; @@ -155,8 +161,8 @@ auto VAbstractTool::CheckFormula(const quint32 &toolId, QString &formula, VConta const UndoButton resultUndo = dialogUndo->Result(); if (resultUndo == UndoButton::Fix) { - auto *dialog = new DialogEditWrongFormula(data, toolId, - VAbstractValApplication::VApp()->getMainWindow()); + auto *dialog = + new DialogEditWrongFormula(data, toolId, VAbstractValApplication::VApp()->getMainWindow()); dialog->setWindowTitle(tr("Edit wrong formula")); dialog->SetFormula(formula); if (dialog->exec() == QDialog::Accepted) @@ -183,7 +189,7 @@ auto VAbstractTool::CheckFormula(const quint32 &toolId, QString &formula, VConta } else { - throw VExceptionUndo(QString("Undo wrong formula %1").arg(formula)); + throw VExceptionUndo(u"Undo wrong formula %1"_s.arg(formula)); } } else @@ -245,25 +251,10 @@ void VAbstractTool::PerformDelete() //--------------------------------------------------------------------------------------------------------------------- auto VAbstractTool::Colors() -> const QStringList { - return QStringList { - ColorBlack, - ColorGreen, - ColorBlue, - ColorDarkRed, - ColorDarkGreen, - ColorDarkBlue, - ColorYellow, - ColorLightSalmon, - ColorGoldenRod, - ColorOrange, - ColorDeepPink, - ColorViolet, - ColorDarkViolet, - ColorMediumSeaGreen, - ColorLime, - ColorDeepSkyBlue, - ColorCornFlowerBlue - }; + return QStringList{ColorBlack, ColorGreen, ColorBlue, ColorDarkRed, ColorDarkGreen, + ColorDarkBlue, ColorYellow, ColorLightSalmon, ColorGoldenRod, ColorOrange, + ColorDeepPink, ColorViolet, ColorDarkViolet, ColorMediumSeaGreen, ColorLime, + ColorDeepSkyBlue, ColorCornFlowerBlue}; } //--------------------------------------------------------------------------------------------------------------------- @@ -340,9 +331,9 @@ auto VAbstractTool::ColorsList() -> QMap // cppcheck-suppress unusedFunction auto VAbstractTool::PointsList() const -> QMap { - const QHash > *objs = data.CalculationGObjects(); + const QHash> *objs = data.CalculationGObjects(); QMap list; - QHash >::const_iterator i; + QHash>::const_iterator i; for (i = objs->constBegin(); i != objs->constEnd(); ++i) { if (i.key() != m_id) @@ -415,7 +406,7 @@ auto VAbstractTool::GetRecord(const quint32 id, const Tool &toolType, VAbstractP void VAbstractTool::RemoveRecord(const VToolRecord &record, VAbstractPattern *doc) { QVector *history = doc->getHistory(); - for(int i = 0; i < history->size(); ++i) + for (int i = 0; i < history->size(); ++i) { if (history->at(i) == record) { @@ -442,7 +433,7 @@ void VAbstractTool::AddRecord(const VToolRecord &record, VAbstractPattern *doc) else { qint32 index = 0; - for (qint32 i = 0; isize(); ++i) + for (qint32 i = 0; i < history->size(); ++i) { VToolRecord rec = history->at(i); if (rec.getId() == cursor) @@ -451,7 +442,7 @@ void VAbstractTool::AddRecord(const VToolRecord &record, VAbstractPattern *doc) break; } } - history->insert(index+1, record); + history->insert(index + 1, record); } } @@ -513,9 +504,9 @@ auto VAbstractTool::AddSANode(VAbstractPattern *doc, const QString &tagName, con } doc->SetAttributeOrRemoveIf(nod, VAbstractPattern::AttrNodeExcluded, node.IsExcluded(), - [](bool exclude) noexcept {return not exclude;}); + [](bool exclude) noexcept { return not exclude; }); doc->SetAttributeOrRemoveIf(nod, VAbstractPattern::AttrCheckUniqueness, node.IsCheckUniqueness(), - [](bool uniqueness) noexcept {return uniqueness;}); + [](bool uniqueness) noexcept { return uniqueness; }); switch (type) { @@ -535,7 +526,7 @@ auto VAbstractTool::AddSANode(VAbstractPattern *doc, const QString &tagName, con doc->SetAttribute(nod, AttrType, VAbstractPattern::NodeSplinePath); break; default: - qDebug()<<"May be wrong tool type!!! Ignoring."< QVector { QVector nodes; - for (int i = 0; i< path.CountNodes(); ++i) + for (int i = 0; i < path.CountNodes(); ++i) { VPieceNode nodeD = path.at(i); const quint32 id = PrepareNode(nodeD, scene, doc, data); @@ -684,7 +675,7 @@ auto VAbstractTool::PrepareNode(const VPieceNode &node, VMainGraphicsScene *scen VNodeSplinePath::Create(initData); break; default: - qDebug()<<"May be wrong tool type!!! Ignoring."< #include #include -#include #include #include +using namespace Qt::Literals::StringLiterals; + const int FancyTabBar::m_rounding = 22; //--------------------------------------------------------------------------------------------------------------------- FancyTabBar::FancyTabBar(const TabBarPosition position, QWidget *parent) - : QWidget(parent), - m_position(position), - m_hoverRect(), - m_hoverIndex(-1), - m_currentIndex(-1), - m_attachedTabs(), - m_timerTriggerChangedSignal() + : QWidget(parent), + m_position(position), + m_hoverRect(), + m_hoverIndex(-1), + m_currentIndex(-1), + m_attachedTabs(), + m_timerTriggerChangedSignal() { if (m_position == FancyTabBar::Above || m_position == FancyTabBar::Below) { @@ -81,17 +83,17 @@ auto FancyTabBar::TabSizeHint(bool minimum) const -> QSize int spacing = 8; int maxLabelwidth = 0; - for (int tab=0 ; tab 1) { QString sentence; for (const auto &word : words) { - sentence = sentence.isEmpty() ? sentence = word : sentence + QLatin1Char(' ') + word; + sentence = sentence.isEmpty() ? sentence = word : sentence + ' '_L1 + word; const int width = TextWidth(fm, sentence); if (maxLabelwidth < width) @@ -109,7 +111,6 @@ auto FancyTabBar::TabSizeHint(bool minimum) const -> QSize maxLabelwidth = width; } } - } int width = 60 + spacing + 2; int iconHeight = minimum ? 0 : 32; @@ -120,10 +121,10 @@ auto FancyTabBar::TabSizeHint(bool minimum) const -> QSize //--------------------------------------------------------------------------------------------------------------------- auto FancyTabBar::GetCorner(const QRect &rect, const Corner corner) const -> QPoint { - switch(m_position) + switch (m_position) { case Above: - switch(corner) + switch (corner) { case OutsideBeginning: return rect.topLeft(); @@ -138,7 +139,7 @@ auto FancyTabBar::GetCorner(const QRect &rect, const Corner corner) const -> QPo } break; case Below: - switch(corner) + switch (corner) { case OutsideBeginning: return rect.bottomLeft(); @@ -153,7 +154,7 @@ auto FancyTabBar::GetCorner(const QRect &rect, const Corner corner) const -> QPo } break; case Left: - switch(corner) + switch (corner) { case OutsideBeginning: return rect.topLeft(); @@ -168,7 +169,7 @@ auto FancyTabBar::GetCorner(const QRect &rect, const Corner corner) const -> QPo } break; case Right: - switch(corner) + switch (corner) { case OutsideBeginning: return rect.topRight(); @@ -203,7 +204,7 @@ auto FancyTabBar::GetCorner(const QRect &rect, const Corner corner) const -> QPo auto FancyTabBar::AdjustRect(const QRect &rect, const qint8 offsetOutside, const qint8 offsetInside, const qint8 offsetBeginning, const qint8 offsetEnd) const -> QRect { - switch(m_position) + switch (m_position) { case Above: return rect.adjusted(-offsetBeginning, -offsetOutside, offsetEnd, offsetInside); @@ -226,7 +227,7 @@ auto FancyTabBar::AdjustRect(const QRect &rect, const qint8 offsetOutside, const auto FancyTabBar::AdjustPoint(const QPoint &point, const qint8 offsetInsideOutside, const qint8 offsetBeginningEnd) const -> QPoint { - switch(m_position) + switch (m_position) { case Above: return point + QPoint(offsetBeginningEnd, -offsetInsideOutside); @@ -328,7 +329,7 @@ auto FancyTabBar::event(QEvent *event) -> bool QString tt = TabToolTip(m_hoverIndex); if (!tt.isEmpty()) { - QToolTip::showText(static_cast(event)->globalPos(), tt, this); + QToolTip::showText(static_cast(event)->globalPos(), tt, this); return true; } } @@ -356,7 +357,7 @@ void FancyTabBar::leaveEvent(QEvent *e) Q_UNUSED(e) m_hoverIndex = -1; m_hoverRect = QRect(); - for (int i = 0 ; i < m_attachedTabs.count() ; ++i) + for (int i = 0; i < m_attachedTabs.count(); ++i) { m_attachedTabs[i]->fadeOut(); } @@ -392,9 +393,9 @@ auto FancyTabBar::sizeHint() const -> QSize auto FancyTabBar::minimumSizeHint() const -> QSize { const QSize sh = TabSizeHint(true); -// return QSize(sh.width(), sh.height() * mAttachedTabs.count()); + // return QSize(sh.width(), sh.height() * mAttachedTabs.count()); - if(m_position == Above || m_position == Below) + if (m_position == Above || m_position == Below) { return QSize(sh.width() * static_cast(m_attachedTabs.count()), sh.height()); } @@ -407,7 +408,7 @@ auto FancyTabBar::TabRect(int index) const -> QRect { QSize sh = TabSizeHint(); - if(m_position == Above || m_position == Below) + if (m_position == Above || m_position == Below) { if (sh.width() * m_attachedTabs.count() > width()) { @@ -425,7 +426,6 @@ auto FancyTabBar::TabRect(int index) const -> QRect return QRect(0, index * sh.height(), sh.width(), sh.height()); } - } //--------------------------------------------------------------------------------------------------------------------- @@ -470,7 +470,7 @@ void FancyTabBar::PaintTab(QPainter *painter, int tabIndex) const bool selected = (tabIndex == m_currentIndex); bool enabled = IsTabEnabled(tabIndex); - if(selected) + if (selected) { // background painter->save(); @@ -519,8 +519,8 @@ void FancyTabBar::PaintTab(QPainter *painter, int tabIndex) const boldFont.setBold(true); painter->setFont(boldFont); painter->setPen(selected ? QColor(255, 255, 255, 160) : QColor(0, 0, 0, 110)); - const int textFlags = static_cast(Qt::AlignCenter | (drawIcon ? Qt::AlignBottom : Qt::AlignVCenter) - | Qt::TextWordWrap); + const int textFlags = + static_cast(Qt::AlignCenter | (drawIcon ? Qt::AlignBottom : Qt::AlignVCenter) | Qt::TextWordWrap); if (enabled) { painter->drawText(tabTextRect, textFlags, tabText); @@ -533,7 +533,7 @@ void FancyTabBar::PaintTab(QPainter *painter, int tabIndex) const #ifndef Q_OS_MAC // hover - if(!selected && enabled) + if (!selected && enabled) { painter->save(); int fader = int(m_attachedTabs[tabIndex]->fader()); @@ -545,7 +545,7 @@ void FancyTabBar::PaintTab(QPainter *painter, int tabIndex) const painter->fillRect(rect, grad); painter->setPen(QPen(grad, 1.0)); - if(m_position == Above || m_position == Below) + if (m_position == Above || m_position == Below) { painter->drawLine(rect.topLeft(), rect.bottomLeft()); painter->drawLine(rect.topRight(), rect.bottomRight()); @@ -558,7 +558,7 @@ void FancyTabBar::PaintTab(QPainter *painter, int tabIndex) const painter->restore(); } -#endif //#ifndef Q_OS_MAC +#endif // #ifndef Q_OS_MAC if (!enabled) { @@ -567,8 +567,8 @@ void FancyTabBar::PaintTab(QPainter *painter, int tabIndex) const if (drawIcon) { - int textHeight = painter->fontMetrics().boundingRect(QRect(0, 0, width(), height()), Qt::TextWordWrap, - tabText).height(); + int textHeight = + painter->fontMetrics().boundingRect(QRect(0, 0, width(), height()), Qt::TextWordWrap, tabText).height(); tabIconRect.adjust(0, 0, 0, -textHeight); StyleHelper::drawIconWithShadow(TabIcon(tabIndex), tabIconRect, painter, enabled ? QIcon::Normal : QIcon::Disabled); @@ -623,7 +623,7 @@ auto FancyTabBar::TabText(int index) const -> QString //--------------------------------------------------------------------------------------------------------------------- void FancyTabBar::SetTabText(int index, const QString &text) { - m_attachedTabs.at(index)->m_text=text; + m_attachedTabs.at(index)->m_text = text; setMaximumWidth(TabSizeHint(false).width()); update(); } diff --git a/src/libs/vwidgets/vabstractmainwindow.cpp b/src/libs/vwidgets/vabstractmainwindow.cpp index e2bd018aa..9a656b83a 100644 --- a/src/libs/vwidgets/vabstractmainwindow.cpp +++ b/src/libs/vwidgets/vabstractmainwindow.cpp @@ -51,6 +51,8 @@ #include +using namespace Qt::Literals::StringLiterals; + QT_WARNING_PUSH QT_WARNING_DISABLE_CLANG("-Wmissing-prototypes") QT_WARNING_DISABLE_INTEL(1418) @@ -142,7 +144,7 @@ auto RecentFiles(const QStringList &paths) -> QStringList VAbstractMainWindow::VAbstractMainWindow(QWidget *parent) : QMainWindow(parent), m_curFileFormatVersion(0x0), - m_curFileFormatVersionStr(QLatin1String("0.0.0")) + m_curFileFormatVersionStr("0.0.0"_L1) { for (int i = 0; i < MaxRecentFiles; ++i) { @@ -200,9 +202,9 @@ void VAbstractMainWindow::ToolBarStyle(QToolBar *bar) const //--------------------------------------------------------------------------------------------------------------------- auto VAbstractMainWindow::CSVFilePath() -> QString { - const QString filters = tr("Comma-Separated Values") + QLatin1String(" (*.csv)"); - const QString suffix("csv"); - const QString path = QDir::homePath() + QChar('/') + tr("values") + QChar('.') + suffix; + const QString filters = tr("Comma-Separated Values") + " (*.csv)"_L1; + const QString suffix("csv"_L1); + const QString path = QDir::homePath() + '/'_L1 + tr("values") + '.'_L1 + suffix; QString fileName = QFileDialog::getSaveFileName(this, tr("Export to CSV"), path, filters, nullptr, VAbstractApplication::VApp()->NativeFileDialog()); @@ -215,7 +217,7 @@ auto VAbstractMainWindow::CSVFilePath() -> QString QFileInfo f(fileName); if (f.suffix().isEmpty() && f.suffix() != suffix) { - fileName += QChar('.') + suffix; + fileName += '.'_L1 + suffix; } return fileName; diff --git a/src/libs/vwidgets/velidedlabel.cpp b/src/libs/vwidgets/velidedlabel.cpp index 51cd5ed66..48d8f7618 100644 --- a/src/libs/vwidgets/velidedlabel.cpp +++ b/src/libs/vwidgets/velidedlabel.cpp @@ -35,6 +35,12 @@ #include // and, not, or #endif +#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) +#include "../vmisc/compatibility.h" +#endif + +using namespace Qt::Literals::StringLiterals; + //--------------------------------------------------------------------------------------------------------------------- VElidedLabel::VElidedLabel(QWidget *parent) : QFrame(parent) @@ -98,9 +104,9 @@ void VElidedLabel::paintEvent(QPaintEvent *event) { if (i != 0) { - toolTip.append(QString("
")); + toolTip.append("
"_L1); } - toolTip.append(QString("%1").arg(paragraphs.at(i))); + toolTip.append(u"%1"_s.arg(paragraphs.at(i))); } setToolTip(toolTip); } diff --git a/src/libs/vwidgets/vlineedit.cpp b/src/libs/vwidgets/vlineedit.cpp index a90deeb8e..9d114b6e2 100644 --- a/src/libs/vwidgets/vlineedit.cpp +++ b/src/libs/vwidgets/vlineedit.cpp @@ -48,6 +48,12 @@ using namespace bpstd::literals::chrono_literals; #endif // __cplusplus >= 201402L #endif //(defined(Q_CC_GNU) && Q_CC_GNU < 409) && !defined(Q_CC_CLANG) +#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) +#include "../vmisc/compatibility.h" +#endif + +using namespace Qt::Literals::StringLiterals; + namespace { class MultiSelectCompleter : public QCompleter @@ -92,7 +98,7 @@ auto MultiSelectCompleter::splitPath(const QString &path) const -> QStringList { vsizetype pos = path.lastIndexOf(',') + 1; - while (pos < path.length() && path.at(pos) == QLatin1Char(' ')) + while (pos < path.length() && path.at(pos) == ' '_L1) { pos++; } diff --git a/src/libs/vwidgets/vpiecegrainline_p.h b/src/libs/vwidgets/vpiecegrainline_p.h index 41146c22c..4603e994c 100644 --- a/src/libs/vwidgets/vpiecegrainline_p.h +++ b/src/libs/vwidgets/vpiecegrainline_p.h @@ -107,8 +107,8 @@ inline auto operator>>(QDataStream &dataStream, VPieceGrainlinePrivate &data) -> { QString message = QCoreApplication::tr("VPieceGrainlinePrivate prefix mismatch error: actualStreamHeader = " "0x%1 and streamHeader = 0x%2") - .arg(actualStreamHeader, 8, 0x10, QChar('0')) - .arg(VPieceGrainlinePrivate::streamHeader, 8, 0x10, QChar('0')); + .arg(actualStreamHeader, 8, 0x10, QLatin1Char('0')) + .arg(VPieceGrainlinePrivate::streamHeader, 8, 0x10, QLatin1Char('0')); throw VException(message); } diff --git a/src/test/CollectionTest/tst_tapecommandline.cpp b/src/test/CollectionTest/tst_tapecommandline.cpp index 9279899a3..7223c8bc6 100644 --- a/src/test/CollectionTest/tst_tapecommandline.cpp +++ b/src/test/CollectionTest/tst_tapecommandline.cpp @@ -32,12 +32,18 @@ #include #include +#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) +#include "../vmisc/compatibility.h" +#endif + +using namespace Qt::Literals::StringLiterals; + namespace { QT_WARNING_PUSH QT_WARNING_DISABLE_CLANG("-Wunused-member-function") -Q_GLOBAL_STATIC_WITH_ARGS(const QString, tmpTestFolder, (QLatin1String("tst_tape_tmp"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, tmpTestFolder, ("tst_tape_tmp"_L1)) // NOLINT QT_WARNING_POP } // namespace diff --git a/src/test/CollectionTest/tst_valentinacommandline.cpp b/src/test/CollectionTest/tst_valentinacommandline.cpp index f2b241e64..f418f86c9 100644 --- a/src/test/CollectionTest/tst_valentinacommandline.cpp +++ b/src/test/CollectionTest/tst_valentinacommandline.cpp @@ -32,14 +32,20 @@ #include #include +#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) +#include "../vmisc/compatibility.h" +#endif + +using namespace Qt::Literals::StringLiterals; + namespace { QT_WARNING_PUSH QT_WARNING_DISABLE_CLANG("-Wunused-member-function") -Q_GLOBAL_STATIC_WITH_ARGS(const QString, tmpTestFolder, (QLatin1String("tst_valentina_tmp"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, tmpTestFolder, ("tst_valentina_tmp"_L1)) // NOLINT // NOLINTNEXTLINE -Q_GLOBAL_STATIC_WITH_ARGS(const QString, tmpTestCollectionFolder, (QLatin1String("tst_valentina_collection_tmp"))) +Q_GLOBAL_STATIC_WITH_ARGS(const QString, tmpTestCollectionFolder, ("tst_valentina_collection_tmp"_L1)) QT_WARNING_POP } // namespace @@ -60,8 +66,7 @@ void TST_ValentinaCommandLine::initTestCase() QFAIL("Fail to remove test temp directory."); } - if (not CopyRecursively(QCoreApplication::applicationDirPath() + QDir::separator() + - QLatin1String("tst_valentina"), + if (not CopyRecursively(QCoreApplication::applicationDirPath() + QDir::separator() + "tst_valentina"_L1, QCoreApplication::applicationDirPath() + QDir::separator() + *tmpTestFolder)) { QFAIL("Fail to prepare test files for testing."); @@ -76,7 +81,7 @@ void TST_ValentinaCommandLine::initTestCase() } if (not CopyRecursively(QCoreApplication::applicationDirPath() + QDir::separator() + - QLatin1String("tst_valentina_collection"), + "tst_valentina_collection"_L1, QCoreApplication::applicationDirPath() + QDir::separator() + *tmpTestCollectionFolder)) { QFAIL("Fail to prepare collection files for testing."); @@ -135,7 +140,7 @@ void TST_ValentinaCommandLine::ExportMode_data() const const QString tmp = QCoreApplication::applicationDirPath() + QDir::separator() + *tmpTestFolder; - QTest::newRow("Issue #372") << "issue_372.val" << QString("-p;;0;;-d;;%1;;-b;;output;;--coefficient;;1").arg(tmp) + QTest::newRow("Issue #372") << "issue_372.val" << u"-p;;0;;-d;;%1;;-b;;output;;--coefficient;;1"_s.arg(tmp) << V_EX_OK; } @@ -164,29 +169,25 @@ void TST_ValentinaCommandLine::TestMode_data() const const QString tmp = QCoreApplication::applicationDirPath() + QDir::separator() + *tmpTestFolder; - QTest::newRow("Issue #256. Correct path.") << "issue_256.val" << QString("--test") << V_EX_OK; + QTest::newRow("Issue #256. Correct path.") << "issue_256.val" << u"--test"_s << V_EX_OK; - QTest::newRow("Issue #256. Wrong path.") << "issue_256_wrong_path.vit" << QString("--test") << V_EX_NOINPUT; + QTest::newRow("Issue #256. Wrong path.") << "issue_256_wrong_path.vit" << u"--test"_s << V_EX_NOINPUT; QTest::newRow("Issue #256. Correct individual measurements.") - << "issue_256.val" - << QString("--test;;-m;;%1").arg(tmp + QDir::separator() + QLatin1String("issue_256_correct.vit")) << V_EX_OK; + << "issue_256.val" << u"--test;;-m;;%1"_s.arg(tmp + QDir::separator() + "issue_256_correct.vit"_L1) << V_EX_OK; QTest::newRow("Issue #256. Wrong individual measurements.") - << "issue_256.val" - << QString("--test;;-m;;%1").arg(tmp + QDir::separator() + QLatin1String("issue_256_wrong.vit")) + << "issue_256.val" << u"--test;;-m;;%1"_s.arg(tmp + QDir::separator() + "issue_256_wrong.vit"_L1) << V_EX_NOINPUT; QTest::newRow("Issue #256. Correct multisize measurements.") - << "issue_256.val" - << QString("--test;;-m;;%1").arg(tmp + QDir::separator() + QLatin1String("issue_256_correct.vst")) << V_EX_OK; + << "issue_256.val" << u"--test;;-m;;%1"_s.arg(tmp + QDir::separator() + "issue_256_correct.vst"_L1) << V_EX_OK; QTest::newRow("Issue #256. Wrong multisize measurements.") - << "issue_256.val" - << QString("--test;;-m;;%1").arg(tmp + QDir::separator() + QLatin1String("issue_256_wrong.vst")) + << "issue_256.val" << u"--test;;-m;;%1"_s.arg(tmp + QDir::separator() + "issue_256_wrong.vst"_L1) << V_EX_NOINPUT; - QTest::newRow("Wrong formula.") << "wrong_formula.val" << QString("--test") << V_EX_DATAERR; + QTest::newRow("Wrong formula.") << "wrong_formula.val" << u"--test"_s << V_EX_DATAERR; } //--------------------------------------------------------------------------------------------------------------------- @@ -198,7 +199,7 @@ void TST_ValentinaCommandLine::TestMode() QString error; const QString tmp = QCoreApplication::applicationDirPath() + QDir::separator() + *tmpTestFolder; - const QStringList arg = QStringList() << tmp + QDir::separator() + file << arguments.split(";;"); + const QStringList arg = QStringList() << tmp + QDir::separator() + file << arguments.split(";;"_L1); const int exit = Run(exitCode, ValentinaPath(), arg, error); QVERIFY2(exit == exitCode, qUtf8Printable(error.right(350))); @@ -212,7 +213,7 @@ void TST_ValentinaCommandLine::TestOpenCollection_data() const QTest::addColumn("exitCode"); const QString tmp = QCoreApplication::applicationDirPath() + QDir::separator() + *tmpTestCollectionFolder; - const QString testGOST = QString("--test;;-m;;%1").arg(tmp + QDir::separator() + QLatin1String("GOST_man_ru.vst")); + const QString testGOST = u"--test;;-m;;%1"_s.arg(tmp + QDir::separator() + "GOST_man_ru.vst"_L1); const QString keyTest = QStringLiteral("--test"); QTest::newRow("bra") << "bra.val" << keyTest << V_EX_OK; diff --git a/src/test/TranslationsTest/tst_abstractregexp.cpp b/src/test/TranslationsTest/tst_abstractregexp.cpp index 6cbf81a13..07a36636b 100644 --- a/src/test/TranslationsTest/tst_abstractregexp.cpp +++ b/src/test/TranslationsTest/tst_abstractregexp.cpp @@ -35,6 +35,8 @@ #include #include +using namespace Qt::Literals::StringLiterals; + namespace { auto PrepareValidNameChars() -> QString @@ -66,12 +68,12 @@ TST_AbstractRegExp::~TST_AbstractRegExp() auto TST_AbstractRegExp::LoadVariables(const QString &checkedLocale) -> int { const QString path = TranslationsPath(); - const QString file = QString("valentina_%1.qm").arg(checkedLocale); + const QString file = u"valentina_%1.qm"_s.arg(checkedLocale); - if (QFileInfo(path + QLatin1String("/") + file).size() <= 34) + if (QFileInfo(path + '/'_L1 + file).size() <= 34) { - const QString message = QString("Translation variables for locale = %1 is empty. \nFull path: %2/%3") - .arg(checkedLocale, path, file); + const QString message = + u"Translation variables for locale = %1 is empty. \nFull path: %2/%3"_s.arg(checkedLocale, path, file); QWARN(qUtf8Printable(message)); return ErrorSize; @@ -81,8 +83,8 @@ auto TST_AbstractRegExp::LoadVariables(const QString &checkedLocale) -> int if (not m_vTranslator->load(file, path)) { - const QString message = QString("Can't load translation variables for locale = %1. \nFull path: %2/%3") - .arg(checkedLocale, path, file); + const QString message = + u"Can't load translation variables for locale = %1. \nFull path: %2/%3"_s.arg(checkedLocale, path, file); QWARN(qUtf8Printable(message)); delete m_vTranslator; @@ -92,8 +94,8 @@ auto TST_AbstractRegExp::LoadVariables(const QString &checkedLocale) -> int if (not QCoreApplication::installTranslator(m_vTranslator)) { - const QString message = QString("Can't install translation variables for locale = %1. \nFull path: %2/%3") - .arg(checkedLocale, path, file); + const QString message = + u"Can't install translation variables for locale = %1. \nFull path: %2/%3"_s.arg(checkedLocale, path, file); QWARN(qUtf8Printable(message)); delete m_vTranslator; @@ -113,7 +115,7 @@ void TST_AbstractRegExp::RemoveTrVariables(const QString &checkedLocale) if (result == false) { - const QString message = QString("Can't remove translation variables for locale = %1").arg(checkedLocale); + const QString message = u"Can't remove translation variables for locale = %1"_s.arg(checkedLocale); QWARN(qUtf8Printable(message)); } delete m_vTranslator; @@ -139,9 +141,9 @@ void TST_AbstractRegExp::CallTestCheckNoEndLine() QFETCH(QString, originalName); const QString translated = m_trMs->VarToUser(originalName); - if (translated.endsWith(QLatin1String("\n"))) + if (translated.endsWith('\n'_L1)) { - const QString message = QString("Translated string '%1' shouldn't contain new line character.").arg(translated); + const QString message = u"Translated string '%1' shouldn't contain new line character."_s.arg(translated); QFAIL(qUtf8Printable(message)); } } @@ -155,7 +157,7 @@ void TST_AbstractRegExp::CallTestCheckRegExpNames() const QString translated = m_trMs->VarToUser(originalName); if (not re.match(translated).hasMatch()) { - const QString message = QString("Original name:'%1', translated name:'%2'").arg(originalName, translated); + const QString message = u"Original name:'%1', translated name:'%2'"_s.arg(originalName, translated); QFAIL(qUtf8Printable(message)); } } @@ -173,9 +175,8 @@ void TST_AbstractRegExp::CallTestCheckNoOriginalNamesInTranslation() { if (originalName != translated) { - const QString message = QString("Translation repeat original name from other place. " - "Original name:'%1', translated name:'%2'") - .arg(originalName, translated); + const QString message = u"Translation repeat original name from other place. " + "Original name:'%1', translated name:'%2'"_s.arg(originalName, translated); QFAIL(qUtf8Printable(message)); } } diff --git a/src/test/TranslationsTest/tst_abstracttranslation.cpp b/src/test/TranslationsTest/tst_abstracttranslation.cpp index 9f3440a99..f1367ccf7 100644 --- a/src/test/TranslationsTest/tst_abstracttranslation.cpp +++ b/src/test/TranslationsTest/tst_abstracttranslation.cpp @@ -29,38 +29,45 @@ #include -const QString TST_AbstractTranslation::TagName = QStringLiteral("name"); -const QString TST_AbstractTranslation::TagMessage = QStringLiteral("message"); -const QString TST_AbstractTranslation::TagSource = QStringLiteral("source"); -const QString TST_AbstractTranslation::TagTranslation = QStringLiteral("translation"); +#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) +#include "../vmisc/compatibility.h" +#endif -const QString TST_AbstractTranslation::AttrType = QStringLiteral("type"); -const QString TST_AbstractTranslation::AttrValVanished = QStringLiteral("vanished"); +using namespace Qt::Literals::StringLiterals; + +const QString TST_AbstractTranslation::TagName = QStringLiteral("name"); +const QString TST_AbstractTranslation::TagMessage = QStringLiteral("message"); +const QString TST_AbstractTranslation::TagSource = QStringLiteral("source"); +const QString TST_AbstractTranslation::TagTranslation = QStringLiteral("translation"); + +const QString TST_AbstractTranslation::AttrType = QStringLiteral("type"); +const QString TST_AbstractTranslation::AttrValVanished = QStringLiteral("vanished"); const QString TST_AbstractTranslation::AttrValUnfinished = QStringLiteral("unfinished"); -const QString TST_AbstractTranslation::AttrValObsolete = QStringLiteral("obsolete"); +const QString TST_AbstractTranslation::AttrValObsolete = QStringLiteral("obsolete"); //--------------------------------------------------------------------------------------------------------------------- TST_AbstractTranslation::TST_AbstractTranslation(QObject *parent) - : QObject(parent), - tsFile(), - tsXML() -{} + : QObject(parent), + tsFile(), + tsXML() +{ +} //--------------------------------------------------------------------------------------------------------------------- auto TST_AbstractTranslation::LoadTSFile(const QString &filename) -> QDomNodeList { tsFile.reset(); - tsFile = QSharedPointer(new QFile(QString("%1/%2").arg(TS_DIR, filename))); + tsFile = QSharedPointer(new QFile(u"%1/%2"_s.arg(TS_DIR, filename))); if (not tsFile->exists()) { - const QString message = QString("Can't find '%1'.\n%2.").arg(filename, tsFile->errorString()); + const QString message = u"Can't find '%1'.\n%2."_s.arg(filename, tsFile->errorString()); QWARN(qUtf8Printable(message)); return QDomNodeList(); } if (tsFile->open(QIODevice::ReadOnly) == false) { - const QString message = QString("Can't open file '%1'.\n%2.").arg(filename, tsFile->errorString()); + const QString message = u"Can't open file '%1'.\n%2."_s.arg(filename, tsFile->errorString()); QWARN(qUtf8Printable(message)); return QDomNodeList(); } @@ -72,8 +79,8 @@ auto TST_AbstractTranslation::LoadTSFile(const QString &filename) -> QDomNodeLis tsXML = QSharedPointer(new QDomDocument()); if (tsXML->setContent(tsFile.data(), &errorMsg, &errorLine, &errorColumn) == false) { - const QString message = QString("Parsing error file %1 in line %2 column %3.") - .arg(filename).arg(errorLine).arg(errorColumn); + const QString message = + u"Parsing error file %1 in line %2 column %3."_s.arg(filename).arg(errorLine).arg(errorColumn); QWARN(qUtf8Printable(message)); return QDomNodeList(); } diff --git a/src/test/TranslationsTest/tst_buitinregexp.cpp b/src/test/TranslationsTest/tst_buitinregexp.cpp index 767b1b79a..e2a141e9f 100644 --- a/src/test/TranslationsTest/tst_buitinregexp.cpp +++ b/src/test/TranslationsTest/tst_buitinregexp.cpp @@ -34,6 +34,12 @@ #include #include +#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) +#include "../vmisc/compatibility.h" +#endif + +using namespace Qt::Literals::StringLiterals; + //--------------------------------------------------------------------------------------------------------------------- TST_BuitInRegExp::TST_BuitInRegExp(const QString &locale, QObject *parent) : TST_AbstractRegExp(locale, parent) @@ -57,7 +63,7 @@ void TST_BuitInRegExp::initTestCase() if (LoadVariables(m_locale) != NoError) { - const QString message = QString("Couldn't load variables. Locale = %1").arg(m_locale); + const QString message = u"Couldn't load variables. Locale = %1"_s.arg(m_locale); QSKIP(qUtf8Printable(message)); } @@ -106,7 +112,7 @@ void TST_BuitInRegExp::TestCheckIsNamesUnique_data() QList keys = names.uniqueKeys(); for (const auto &key : keys) { - const QString tag = QString("Locale: '%1'. Name '%2'").arg(m_locale, key); + const QString tag = u"Locale: '%1'. Name '%2'"_s.arg(m_locale, key); QTest::newRow(qUtf8Printable(tag)) << key << QStringList(names.values(key)); } } @@ -119,8 +125,8 @@ void TST_BuitInRegExp::TestCheckIsNamesUnique() if (originalNames.size() > 1) { - const QString message = QString("Name is not unique. Translated name:'%1' also assosiated with: %2.") - .arg(translatedName, originalNames.join(", ")); + const QString message = u"Name is not unique. Translated name:'%1' also assosiated with: %2."_s.arg( + translatedName, originalNames.join(", ")); QFAIL(qUtf8Printable(message)); } } @@ -181,7 +187,7 @@ void TST_BuitInRegExp::TestCheckUnderlineExists_data() auto i = data.constBegin(); while (i != data.constEnd()) { - const QString tag = QString("Locale: '%1'. Name '%2'").arg(m_locale, i.key()); + const QString tag = u"Locale: '%1'. Name '%2'"_s.arg(m_locale, i.key()); QTest::newRow(qUtf8Printable(tag)) << i.key() << i.value(); ++i; } @@ -194,10 +200,10 @@ void TST_BuitInRegExp::TestCheckUnderlineExists() QFETCH(bool, exists); const QString translated = m_trMs->InternalVarToUser(name); - if ((translated.right(1) == QLatin1String("_")) != exists) + if ((translated.right(1) == '_'_L1) != exists) { const QString message = - QString("String '%1' doesn't contain underline. Original string is '%2'").arg(translated, name); + u"String '%1' doesn't contain underline. Original string is '%2'"_s.arg(translated, name); QFAIL(qUtf8Printable(message)); } } @@ -210,7 +216,7 @@ void TST_BuitInRegExp::TestCheckInternalVaribleRegExp_data() for (const auto &var : BuilInVariables()) { - const QString tag = QString("Locale: '%1'. Var '%2'").arg(m_locale, var); + const QString tag = u"Locale: '%1'. Var '%2'"_s.arg(m_locale, var); const QStringList originalNames = AllNames(); for (const auto &str : originalNames) { @@ -227,11 +233,11 @@ void TST_BuitInRegExp::TestCheckInternalVaribleRegExp() static const QString regex = QStringLiteral("(.){1,}_(.){1,}$"); - const QString sourceRegex = QChar('^') + var + regex; + const QString sourceRegex = '^'_L1 + var + regex; const QRegularExpression sourceRe(sourceRegex); const QString translated = m_trMs->InternalVarToUser(var); - const QString translationRegex = QChar('^') + translated + regex; + const QString translationRegex = '^'_L1 + translated + regex; const QRegularExpression translationRe(translationRegex); { @@ -277,7 +283,7 @@ void TST_BuitInRegExp::PrepareData() for (const auto &str : originalNames) { - const QString tag = QString("Locale: '%1'. Name '%2'").arg(m_locale, str); + const QString tag = u"Locale: '%1'. Name '%2'"_s.arg(m_locale, str); QTest::newRow(qUtf8Printable(tag)) << str; } } diff --git a/src/test/TranslationsTest/tst_measurementregexp.cpp b/src/test/TranslationsTest/tst_measurementregexp.cpp index b0c8507be..693279c97 100644 --- a/src/test/TranslationsTest/tst_measurementregexp.cpp +++ b/src/test/TranslationsTest/tst_measurementregexp.cpp @@ -35,6 +35,12 @@ #include #include +#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) +#include "../vmisc/compatibility.h" +#endif + +using namespace Qt::Literals::StringLiterals; + namespace { auto InitializePmSystems() noexcept -> QStringList @@ -82,8 +88,7 @@ void TST_MeasurementRegExp::initTestCase() const int res = LoadMeasurements(m_systemCode, m_locale); if (res != NoError) { - const QString message = - QStringLiteral("Couldn't load measurements. System = %1, locale = %2").arg(m_systemCode, m_locale); + const QString message = u"Couldn't load measurements. System = %1, locale = %2"_s.arg(m_systemCode, m_locale); if (res == ErrorMissing) { @@ -93,8 +98,7 @@ void TST_MeasurementRegExp::initTestCase() if (LoadVariables(m_locale) != NoError) { - const QString message = - QString("Couldn't load variables. System = %1, locale = %2").arg(m_systemCode, m_locale); + const QString message = u"Couldn't load variables. System = %1, locale = %2"_s.arg(m_systemCode, m_locale); QSKIP(qUtf8Printable(message)); } @@ -143,7 +147,7 @@ void TST_MeasurementRegExp::TestCheckIsNamesUnique_data() QList keys = names.uniqueKeys(); for (const auto &key : keys) { - const QString tag = QString("System: '%1', locale: '%2'. Name '%3'").arg(m_systemCode, m_locale, key); + const QString tag = u"System: '%1', locale: '%2'. Name '%3'"_s.arg(m_systemCode, m_locale, key); QTest::newRow(qUtf8Printable(tag)) << key << QStringList(names.values(key)); } } @@ -156,8 +160,8 @@ void TST_MeasurementRegExp::TestCheckIsNamesUnique() if (originalNames.size() > 1) { - const QString message = QString("Name is not unique. Translated name:'%1' also assosiated with: %2.") - .arg(translatedName, originalNames.join(", ")); + const QString message = u"Name is not unique. Translated name:'%1' also assosiated with: %2."_s.arg( + translatedName, originalNames.join(", ")); QFAIL(qUtf8Printable(message)); } } @@ -202,8 +206,7 @@ void TST_MeasurementRegExp::TestCombinations(const QStringList &locales) const const QStringList fileNames = dir.entryList(QStringList("measurements_p*_*.qm")); // cppcheck-suppress unreadVariable - const QString error = - QString("Unexpected count of files. Excpected %1, got %2.").arg(combinations).arg(fileNames.size()); + const QString error = u"Unexpected count of files. Excpected %1, got %2."_s.arg(combinations).arg(fileNames.size()); QVERIFY2(combinations == fileNames.size(), qUtf8Printable(error)); } @@ -216,7 +219,7 @@ void TST_MeasurementRegExp::PrepareData() for (const auto &str : originalNames) { - const QString tag = QString("System: '%1', locale: '%2'. Name '%3'").arg(m_systemCode, m_locale, str); + const QString tag = u"System: '%1', locale: '%2'. Name '%3'"_s.arg(m_systemCode, m_locale, str); QTest::newRow(qUtf8Printable(tag)) << str; } } @@ -233,22 +236,22 @@ auto TST_MeasurementRegExp::LoadMeasurements(const QString &checkedSystem, const const QString path = TranslationsPath(); const QString file = QStringLiteral("measurements_%1_%2.qm").arg(checkedSystem, checkedLocale); - QFileInfo info(path + QLatin1String("/") + file); + QFileInfo info(path + '/'_L1 + file); if (not info.exists()) { const QString message = - QString("File for translation for system = %1 and locale = %2 doesn't exists. \nFull path: %3/%4") - .arg(checkedSystem, checkedLocale, path, file); + u"File for translation for system = %1 and locale = %2 doesn't exists. \nFull path: %3/%4"_s.arg( + checkedSystem, checkedLocale, path, file); QWARN(qUtf8Printable(message)); return ErrorMissing; } - if (QFileInfo(path + QLatin1String("/") + file).size() <= 34) + if (QFileInfo(path + '/'_L1 + file).size() <= 34) { - const QString message = QString("Translation for system = %1 and locale = %2 is empty. \nFull path: %3/%4") - .arg(checkedSystem, checkedLocale, path, file); + const QString message = u"Translation for system = %1 and locale = %2 is empty. \nFull path: %3/%4"_s.arg( + checkedSystem, checkedLocale, path, file); QWARN(qUtf8Printable(message)); return ErrorSize; @@ -259,8 +262,8 @@ auto TST_MeasurementRegExp::LoadMeasurements(const QString &checkedSystem, const if (not m_pmsTranslator->load(file, path)) { - const QString message = QString("Can't load translation for system = %1 and locale = %2. \nFull path: %3/%4") - .arg(checkedSystem, checkedLocale, path, file); + const QString message = u"Can't load translation for system = %1 and locale = %2. \nFull path: %3/%4"_s.arg( + checkedSystem, checkedLocale, path, file); QWARN(qUtf8Printable(message)); delete m_pmsTranslator; @@ -270,8 +273,8 @@ auto TST_MeasurementRegExp::LoadMeasurements(const QString &checkedSystem, const if (not QCoreApplication::installTranslator(m_pmsTranslator)) { - const QString message = QString("Can't install translation for system = %1 and locale = %2. \nFull path: %3/%4") - .arg(checkedSystem, checkedLocale, path, file); + const QString message = u"Can't install translation for system = %1 and locale = %2. \nFull path: %3/%4"_s.arg( + checkedSystem, checkedLocale, path, file); QWARN(qUtf8Printable(message)); delete m_pmsTranslator; @@ -292,7 +295,7 @@ void TST_MeasurementRegExp::RemoveTrMeasurements(const QString &checkedSystem, c if (result == false) { const QString message = - QString("Can't remove translation for system = %1 and locale = %2").arg(checkedSystem, checkedLocale); + u"Can't remove translation for system = %1 and locale = %2"_s.arg(checkedSystem, checkedLocale); QWARN(qUtf8Printable(message)); } delete m_pmsTranslator; diff --git a/src/test/TranslationsTest/tst_qmuparsererrormsg.cpp b/src/test/TranslationsTest/tst_qmuparsererrormsg.cpp index 9d42bbf2c..f12c32bc4 100644 --- a/src/test/TranslationsTest/tst_qmuparsererrormsg.cpp +++ b/src/test/TranslationsTest/tst_qmuparsererrormsg.cpp @@ -31,12 +31,18 @@ #include +#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) +#include "../vmisc/compatibility.h" +#endif + +using namespace Qt::Literals::StringLiterals; + //--------------------------------------------------------------------------------------------------------------------- TST_QmuParserErrorMsg::TST_QmuParserErrorMsg(const QString &locale, QObject *parent) - : AbstractTest(parent), - m_locale(locale), - appTranslator(nullptr), - msg(nullptr) + : AbstractTest(parent), + m_locale(locale), + appTranslator(nullptr), + msg(nullptr) { } @@ -68,7 +74,7 @@ void TST_QmuParserErrorMsg::initTestCase() if (LoadTranslation(m_locale) != NoError) { - const QString message = QString("Couldn't load variables. Locale = %1").arg(m_locale); + const QString message = u"Couldn't load variables. Locale = %1"_s.arg(m_locale); QSKIP(qUtf8Printable(message)); } } @@ -129,8 +135,8 @@ void TST_QmuParserErrorMsg::TestEErrorCodes() // cppcheck-suppress unreadVariable const QString message = QStringLiteral("String: '%1'.").arg(translated); - QVERIFY2((translated.indexOf(QLatin1String("$TOK$")) != -1) == tok, qUtf8Printable(message)); - QVERIFY2((translated.indexOf(QLatin1String("$POS$")) != -1) == pos, qUtf8Printable(message)); + QVERIFY2((translated.indexOf("$TOK$"_L1) != -1) == tok, qUtf8Printable(message)); + QVERIFY2((translated.indexOf("$POS$"_L1) != -1) == pos, qUtf8Printable(message)); } //--------------------------------------------------------------------------------------------------------------------- @@ -142,7 +148,7 @@ void TST_QmuParserErrorMsg::cleanupTestCase() //--------------------------------------------------------------------------------------------------------------------- void TST_QmuParserErrorMsg::AddCase(int code, bool tok, bool pos) { - const QString tag = QString("Check translation code=%1 in file valentina_%2.qm").arg(code).arg(m_locale); + const QString tag = u"Check translation code=%1 in file valentina_%2.qm"_s.arg(code).arg(m_locale); QTest::newRow(qUtf8Printable(tag)) << code << tok << pos; } @@ -150,12 +156,12 @@ void TST_QmuParserErrorMsg::AddCase(int code, bool tok, bool pos) auto TST_QmuParserErrorMsg::LoadTranslation(const QString &checkedLocale) -> int { const QString path = TranslationsPath(); - const QString file = QString("valentina_%1.qm").arg(checkedLocale); + const QString file = u"valentina_%1.qm"_s.arg(checkedLocale); - if (QFileInfo(path+QLatin1String("/")+file).size() <= 34) + if (QFileInfo(path + '/'_L1 + file).size() <= 34) { - const QString message = QString("Translation for locale = %1 is empty. \nFull path: %2/%3") - .arg(checkedLocale, path, file); + const QString message = + u"Translation for locale = %1 is empty. \nFull path: %2/%3"_s.arg(checkedLocale, path, file); QWARN(qUtf8Printable(message)); return ErrorSize; @@ -165,8 +171,8 @@ auto TST_QmuParserErrorMsg::LoadTranslation(const QString &checkedLocale) -> int if (not appTranslator->load(file, path)) { - const QString message = QString("Can't load translation for locale = %1. \nFull path: %2/%3") - .arg(checkedLocale, path, file); + const QString message = + u"Can't load translation for locale = %1. \nFull path: %2/%3"_s.arg(checkedLocale, path, file); QWARN(qUtf8Printable(message)); delete appTranslator; @@ -176,8 +182,8 @@ auto TST_QmuParserErrorMsg::LoadTranslation(const QString &checkedLocale) -> int if (not QCoreApplication::installTranslator(appTranslator)) { - const QString message = QString("Can't install translation for locale = %1. \nFull path: %2/%3") - .arg(checkedLocale, path, file); + const QString message = + u"Can't install translation for locale = %1. \nFull path: %2/%3"_s.arg(checkedLocale, path, file); QWARN(qUtf8Printable(message)); delete appTranslator; @@ -186,7 +192,7 @@ auto TST_QmuParserErrorMsg::LoadTranslation(const QString &checkedLocale) -> int } delete msg; - msg = new qmu::QmuParserErrorMsg();//Very important do it after load QM file. + msg = new qmu::QmuParserErrorMsg(); // Very important do it after load QM file. return NoError; } @@ -200,7 +206,7 @@ void TST_QmuParserErrorMsg::RemoveTranslation() if (result == false) { - const QString message = QString("Can't remove translation for locale = %1").arg(m_locale); + const QString message = u"Can't remove translation for locale = %1"_s.arg(m_locale); QWARN(qUtf8Printable(message)); } delete appTranslator; diff --git a/src/test/TranslationsTest/tst_tslocaletranslation.cpp b/src/test/TranslationsTest/tst_tslocaletranslation.cpp index 180843031..634a9d1ba 100644 --- a/src/test/TranslationsTest/tst_tslocaletranslation.cpp +++ b/src/test/TranslationsTest/tst_tslocaletranslation.cpp @@ -30,6 +30,12 @@ #include +#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) +#include "../vmisc/compatibility.h" +#endif + +using namespace Qt::Literals::StringLiterals; + //--------------------------------------------------------------------------------------------------------------------- TST_TSLocaleTranslation::TST_TSLocaleTranslation(const QString &locale, QObject *parent) : TST_AbstractTranslation(parent), @@ -113,8 +119,8 @@ void TST_TSLocaleTranslation::CheckPlaceMarkerExist() ++sourceMarkCount; if (sourceMarkCount != i) { - const QString message = QString("In source string '%1' was missed place marker ").arg(source) + - QLatin1String("'%") + QString().setNum(sourceMarkCount) + QLatin1String("'."); + const QString message = u"In source string '%1' was missed place marker "_s.arg(source) + "'%"_L1 + + QString().setNum(sourceMarkCount) + "'."_L1; QFAIL(qUtf8Printable(message)); } } @@ -125,17 +131,16 @@ void TST_TSLocaleTranslation::CheckPlaceMarkerExist() ++translationMarkCount; if (translationMarkCount != i) { - const QString message = - QString("In translation string '%1' was missed place marker ").arg(translation) + - QLatin1String("'%") + QString().setNum(translationMarkCount) + QLatin1String("'."); + const QString message = u"In translation string '%1' was missed place marker "_s.arg(translation) + + "'%"_L1 + QString().setNum(translationMarkCount) + "'."_L1; QFAIL(qUtf8Printable(message)); } } if (sourceMarkerFlag != translationMarkerFlag) { - const QString message = QString("String '%1'. Placemark '%%2' mismatch. ") - .arg(translation, QString().setNum(sourceMarkCount + 1)); + const QString message = + u"String '%1'. Placemark '%%2' mismatch. "_s.arg(translation, QString().setNum(sourceMarkCount + 1)); QFAIL(qUtf8Printable(message)); } } @@ -148,7 +153,7 @@ void TST_TSLocaleTranslation::TestPunctuation_data() QTest::addColumn("source"); QTest::addColumn("translation"); - const QString filename = QString("valentina_%1.ts").arg(m_locale); + const QString filename = u"valentina_%1.ts"_s.arg(m_locale); const QDomNodeList messages = LoadTSFile(filename); if (messages.isEmpty()) @@ -220,18 +225,15 @@ void TST_TSLocaleTranslation::TestPunctuation() { testFail = true; - if (locale == QLatin1String("el_GR") - // Greek question mark - // https://en.wikipedia.org/wiki/Question_mark#Greek_question_mark - && (cSource == QLatin1Char('?') && cTranslation == QLatin1Char(';'))) - { - testFail = false; - } - else if (locale == QLatin1String("zh_CN") - // Beside usage similar to that of English, the colon has other functions. Several - // compatibility forms for Chinese and Japanese typography are encoded in Unicode. - // https://en.wikipedia.org/wiki/Colon_(punctuation)#Usage_in_other_languages - && (cSource == QLatin1Char(':') && cTranslation == QString(":"))) + if ((locale == "el_GR"_L1 + // Greek question mark + // https://en.wikipedia.org/wiki/Question_mark#Greek_question_mark + && (cSource == '?'_L1 && cTranslation == ';'_L1)) || + (locale == "zh_CN"_L1 + // Beside usage similar to that of English, the colon has other functions. Several + // compatibility forms for Chinese and Japanese typography are encoded in Unicode. + // https://en.wikipedia.org/wiki/Colon_(punctuation)#Usage_in_other_languages + && (cSource == ':'_L1 && cTranslation == QStringLiteral(":")))) { testFail = false; } @@ -247,11 +249,9 @@ void TST_TSLocaleTranslation::TestPunctuation() } if (testFail) { - const QString message = QString("Translation string does not end with the same punctuation character '%1' or " - "vice versa. ") - .arg(cPunctuation) + - QString("Original name:'%1'").arg(source) + - QString(", translated name:'%1'").arg(translation); + const QString message = u"Translation string does not end with the same punctuation character '%1' or " + "vice versa. "_s.arg(cPunctuation) + + u"Original name:'%1'"_s.arg(source) + u", translated name:'%1'"_s.arg(translation); QFAIL(qUtf8Printable(message)); } } @@ -262,7 +262,7 @@ void TST_TSLocaleTranslation::TestHTMLTags_data() QTest::addColumn("source"); QTest::addColumn("translation"); - const QString filename = QString("valentina_%1.ts").arg(m_locale); + const QString filename = u"valentina_%1.ts"_s.arg(m_locale); const QDomNodeList messages = LoadTSFile(filename); if (messages.isEmpty()) @@ -313,24 +313,24 @@ void TST_TSLocaleTranslation::TestHTMLTags() QFETCH(QString, source); QFETCH(QString, translation); - static const QStringList tags = QStringList() - << QLatin1String("p") << QLatin1String("html") << QLatin1String("body"); + static const QStringList tags = QStringList() << "p"_L1 + << "html"_L1 + << "body"_L1; static const QString pattern("{1}.*>"); for (const auto &tag : tags) { - const QRegularExpression openRegex(QLatin1String("<") + tag + pattern, - QRegularExpression::DotMatchesEverythingOption); + const QRegularExpression openRegex("<"_L1 + tag + pattern, QRegularExpression::DotMatchesEverythingOption); if (source.contains(openRegex)) { const auto countOpenTag = source.count(openRegex); - const QRegularExpression closeRegex(QLatin1String("'. ").arg(tag) + - QString("Original name:'%1'").arg(source) + - QString(", translated name:'%1'").arg(translation); + const QString message = u"Tag mismatch. Tag: '<%1>'. "_s.arg(tag) + + u"Original name:'%1'"_s.arg(source) + + u", translated name:'%1'"_s.arg(translation); QFAIL(qUtf8Printable(message)); } } diff --git a/src/test/TranslationsTest/tst_tstranslation.cpp b/src/test/TranslationsTest/tst_tstranslation.cpp index 58f0e2b1a..036f2723d 100644 --- a/src/test/TranslationsTest/tst_tstranslation.cpp +++ b/src/test/TranslationsTest/tst_tstranslation.cpp @@ -31,6 +31,12 @@ #include #include +#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) +#include "../vmisc/compatibility.h" +#endif + +using namespace Qt::Literals::StringLiterals; + Q_DECLARE_METATYPE(QDomElement) // Need for testing //--------------------------------------------------------------------------------------------------------------------- @@ -131,7 +137,7 @@ void TST_TSTranslation::CheckEmptyToolButton() QFETCH(QString, source); QFETCH(QDomElement, message); - if (source == QLatin1String("...")) + if (source == "..."_L1) { const QDomElement translationTag = message.firstChildElement(TagTranslation); if (translationTag.hasAttribute(AttrType)) @@ -150,7 +156,7 @@ void TST_TSTranslation::CheckEmptyToolButton() } const QString contextName = context.firstChildElement(TagName).text(); - const QString error = QString("Found '...' in context '%1'").arg(contextName); + const QString error = u"Found '...' in context '%1'"_s.arg(contextName); QFAIL(qUtf8Printable(error)); } } @@ -187,7 +193,7 @@ void TST_TSTranslation::CheckEllipsis() const QString contextName = context.firstChildElement(TagName).text(); const QString error = - QString("String '%1' ends with '...' in context '%2'. Repalce it with '…'.").arg(source, contextName); + u"String '%1' ends with '...' in context '%2'. Repalce it with '…'."_s.arg(source, contextName); QFAIL(qUtf8Printable(error)); } } @@ -204,7 +210,7 @@ void TST_TSTranslation::CheckInvalidCharacter() QFETCH(QString, source); QFETCH(QDomElement, message); - if (source == QChar('=') or source == QChar('%')) + if (source == '='_L1 or source == '%'_L1) { const QDomNode context = message.parentNode(); if (context.isNull()) @@ -213,9 +219,8 @@ void TST_TSTranslation::CheckInvalidCharacter() } const QString contextName = context.firstChildElement(TagName).text(); - const QString error = QString("String contains invalid character '%1' in context '%2'. It should not be " - "marked for translation.") - .arg(source, contextName); + const QString error = u"String contains invalid character '%1' in context '%2'. It should not be " + "marked for translation."_s.arg(source, contextName); QFAIL(qUtf8Printable(error)); } } diff --git a/src/test/ValentinaTest/tst_nameregexp.cpp b/src/test/ValentinaTest/tst_nameregexp.cpp index 252e5635c..bc4bedbae 100644 --- a/src/test/ValentinaTest/tst_nameregexp.cpp +++ b/src/test/ValentinaTest/tst_nameregexp.cpp @@ -32,9 +32,15 @@ #include +#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) +#include "../vmisc/compatibility.h" +#endif + +using namespace Qt::Literals::StringLiterals; + //--------------------------------------------------------------------------------------------------------------------- -TST_NameRegExp::TST_NameRegExp(QObject *parent) : - QObject(parent) +TST_NameRegExp::TST_NameRegExp(QObject *parent) + : QObject(parent) { } @@ -46,9 +52,9 @@ void TST_NameRegExp::TestNameRegExp_data() QTest::addColumn("result"); const QList allLocales = - QLocale::matchingLocales(QLocale::AnyLanguage, QLocale::AnyScript, QLocale::AnyCountry); + QLocale::matchingLocales(QLocale::AnyLanguage, QLocale::AnyScript, QLocale::AnyCountry); - for(const auto &locale : allLocales) + for (const auto &locale : allLocales) { INIT_LOCALE_VARIABLES(locale); Q_UNUSED(positiveSign) @@ -57,55 +63,55 @@ void TST_NameRegExp::TestNameRegExp_data() const QString localeName = locale.name(); - QString tag = localeName+QLatin1String(". First character can't be ")+sign0; - QTest::newRow(qUtf8Printable(tag)) << sign0+QLatin1String("a") << false; + QString tag = localeName + ". First character can't be "_L1 + sign0; + QTest::newRow(qUtf8Printable(tag)) << sign0 + 'a'_L1 << false; - tag = localeName+QLatin1String(". First character can't be ")+sign1; - QTest::newRow(qUtf8Printable(tag)) << sign1+QLatin1String("a") << false; + tag = localeName + ". First character can't be "_L1 + sign1; + QTest::newRow(qUtf8Printable(tag)) << sign1 + 'a'_L1 << false; - tag = localeName+QLatin1String(". First character can't be ")+sign2; - QTest::newRow(qUtf8Printable(tag)) << sign2+QLatin1String("a") << false; + tag = localeName + ". First character can't be "_L1 + sign2; + QTest::newRow(qUtf8Printable(tag)) << sign2 + 'a'_L1 << false; - tag = localeName+QLatin1String(". First character can't be ")+sign3; - QTest::newRow(qUtf8Printable(tag)) << sign3+QLatin1String("a") << false; + tag = localeName + ". First character can't be "_L1 + sign3; + QTest::newRow(qUtf8Printable(tag)) << sign3 + 'a'_L1 << false; - tag = localeName+QLatin1String(". First character can't be ")+sign4; - QTest::newRow(qUtf8Printable(tag)) << sign4+QLatin1String("a") << false; + tag = localeName + ". First character can't be "_L1 + sign4; + QTest::newRow(qUtf8Printable(tag)) << sign4 + 'a'_L1 << false; - tag = localeName+QLatin1String(". First character can't be ")+sign5; - QTest::newRow(qUtf8Printable(tag)) << sign5+QLatin1String("a") << false; + tag = localeName + ". First character can't be "_L1 + sign5; + QTest::newRow(qUtf8Printable(tag)) << sign5 + 'a'_L1 << false; - tag = localeName+QLatin1String(". First character can't be ")+sign6; - QTest::newRow(qUtf8Printable(tag)) << sign6+QLatin1String("a") << false; + tag = localeName + ". First character can't be "_L1 + sign6; + QTest::newRow(qUtf8Printable(tag)) << sign6 + 'a'_L1 << false; - tag = localeName+QLatin1String(". First character can't be ")+sign7; - QTest::newRow(qUtf8Printable(tag)) << sign7+QLatin1String("a") << false; + tag = localeName + ". First character can't be "_L1 + sign7; + QTest::newRow(qUtf8Printable(tag)) << sign7 + 'a'_L1 << false; - tag = localeName+QLatin1String(". First character can't be ")+sign8; - QTest::newRow(qUtf8Printable(tag)) << sign8+QLatin1String("a") << false; + tag = localeName + ". First character can't be "_L1 + sign8; + QTest::newRow(qUtf8Printable(tag)) << sign8 + 'a'_L1 << false; - tag = localeName+QLatin1String(". First character can't be ")+sign9; - QTest::newRow(qUtf8Printable(tag)) << sign9+QLatin1String("a") << false; + tag = localeName + ". First character can't be "_L1 + sign9; + QTest::newRow(qUtf8Printable(tag)) << sign9 + 'a'_L1 << false; - tag = localeName+QLatin1String(". First character can't be \"")+negativeSign+QLatin1String("\""); - QTest::newRow(qUtf8Printable(tag)) << negativeSign+QLatin1String("a") << false; + tag = localeName + ". First character can't be \""_L1 + negativeSign + '\"'_L1; + QTest::newRow(qUtf8Printable(tag)) << negativeSign + 'a'_L1 << false; - tag = localeName+QLatin1String(". First character can't be \"")+decimalPoint+QLatin1String("\""); - QTest::newRow(qUtf8Printable(tag)) << decimalPoint+QLatin1String("a") << false; + tag = localeName + ". First character can't be \""_L1 + decimalPoint + '\"'_L1; + QTest::newRow(qUtf8Printable(tag)) << decimalPoint + 'a'_L1 << false; - tag = localeName+QLatin1String(". First character can't be \"")+groupSeparator+QLatin1String("\""); - QTest::newRow(qUtf8Printable(tag)) << groupSeparator+QLatin1String("a") << false; + tag = localeName + ". First character can't be \""_L1 + groupSeparator + '\"'_L1; + QTest::newRow(qUtf8Printable(tag)) << groupSeparator + 'a'_L1 << false; - tag = localeName+QLatin1String(". Any next character can't be \"")+negativeSign+QLatin1String("\""); - QTest::newRow(qUtf8Printable(tag)) << QLatin1String("a")+negativeSign << false; + tag = localeName + ". Any next character can't be \""_L1 + negativeSign + '\"'_L1; + QTest::newRow(qUtf8Printable(tag)) << 'a'_L1 + negativeSign << false; - tag = localeName+QLatin1String(". Any next character can't be \"")+decimalPoint+QLatin1String("\""); - QTest::newRow(qUtf8Printable(tag)) << QLatin1String("a")+decimalPoint << false; + tag = localeName + ". Any next character can't be \""_L1 + decimalPoint + '\"'_L1; + QTest::newRow(qUtf8Printable(tag)) << 'a'_L1 + decimalPoint << false; if (groupSeparator != '\'') { - tag = localeName+QLatin1String(". Any next character can't be \"")+groupSeparator+QLatin1String("\""); - QTest::newRow(qUtf8Printable(tag)) << QLatin1String("a")+groupSeparator << false; + tag = localeName + ". Any next character can't be \""_L1 + groupSeparator + '\"'_L1; + QTest::newRow(qUtf8Printable(tag)) << 'a'_L1 + groupSeparator << false; } } @@ -175,7 +181,7 @@ void TST_NameRegExp::TestOriginalMeasurementNamesRegExp_data() const QStringList originalNames = AllGroupNames(); for (const auto &str : originalNames) { - const QString name = QString("Measurement '%1'").arg(str); + const QString name = u"Measurement '%1'"_s.arg(str); QTest::newRow(qUtf8Printable(name)) << str; } } @@ -358,7 +364,7 @@ void TST_NameRegExp::TestCorrectOrderMeasurement_data() QTest::newRow("J07") << bustpointToShoulderTip_M << "bustpoint_to_shoulder_tip"; QTest::newRow("J08") << bustpointToWaistFront_M << "bustpoint_to_waist_front"; QTest::newRow("J09") << bustpointToBustpointHalter_M << "bustpoint_to_bustpoint_halter"; - QTest::newRow("J10") << bustpointToShoulderCenter_M << "bustpoint_to_shoulder_center"; + QTest::newRow("J10") << bustpointToShoulderCenter_M << "bustpoint_to_shoulder_center"; QTest::newRow("K01") << shoulderTipToWaistFront_M << "shoulder_tip_to_waist_front"; QTest::newRow("K02") << neckFrontToWaistSide_M << "neck_front_to_waist_side"; QTest::newRow("K03") << neckSideToWaistSideF_M << "neck_side_to_waist_side_f"; diff --git a/src/test/ValentinaTest/tst_qmutokenparser.cpp b/src/test/ValentinaTest/tst_qmutokenparser.cpp index aa7fd8ffd..ee3445e03 100644 --- a/src/test/ValentinaTest/tst_qmutokenparser.cpp +++ b/src/test/ValentinaTest/tst_qmutokenparser.cpp @@ -32,6 +32,12 @@ #include +#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) +#include "../vmisc/compatibility.h" +#endif + +using namespace Qt::Literals::StringLiterals; + //--------------------------------------------------------------------------------------------------------------------- TST_QmuTokenParser::TST_QmuTokenParser(QObject *parent) : QObject(parent), @@ -118,19 +124,19 @@ void TST_QmuTokenParser::PrepareVal(qreal val, const QLocale &locale) { const QString formula = locale.toString(val); QString string = formula; - QString tag = QString("%1. String '%2'").arg(locale.name(), string); + QString tag = u"%1. String '%2'"_s.arg(locale.name(), string); QTest::newRow(qUtf8Printable(tag)) << string << true << locale; - string = formula + QLatin1String("+"); - tag = QString("%1. String '%2'").arg(locale.name(), string); + string = formula + '+'_L1; + tag = u"%1. String '%2'"_s.arg(locale.name(), string); QTest::newRow(qUtf8Printable(tag)) << string << false << locale; - string = formula + QLatin1String("+") + formula; - tag = QString("%1. String '%2'").arg(locale.name(), string); + string = formula + '+'_L1 + formula; + tag = u"%1. String '%2'"_s.arg(locale.name(), string); QTest::newRow(qUtf8Printable(tag)) << string << false << locale; - string = formula + QString("+б"); - tag = QString("%1. String '%2'").arg(locale.name(), string); + string = formula + u"+б"_s; + tag = u"%1. String '%2'"_s.arg(locale.name(), string); QTest::newRow(qUtf8Printable(tag)) << string << false << locale; } diff --git a/src/test/ValentinaTest/tst_readval.cpp b/src/test/ValentinaTest/tst_readval.cpp index 3a95be604..a2b27e4cd 100644 --- a/src/test/ValentinaTest/tst_readval.cpp +++ b/src/test/ValentinaTest/tst_readval.cpp @@ -33,10 +33,12 @@ #include #include +using namespace Qt::Literals::StringLiterals; + //--------------------------------------------------------------------------------------------------------------------- TST_ReadVal::TST_ReadVal(QObject *parent) - : QObject(parent), - m_systemLocale(QLocale::system()) + : QObject(parent), + m_systemLocale(QLocale::system()) { } @@ -49,8 +51,8 @@ void TST_ReadVal::TestReadVal_data() QTest::addColumn("locale"); const QList allLocales = - QLocale::matchingLocales(QLocale::AnyLanguage, QLocale::AnyScript, QLocale::AnyCountry); - for(const auto &locale : allLocales) + QLocale::matchingLocales(QLocale::AnyLanguage, QLocale::AnyScript, QLocale::AnyCountry); + for (const auto &locale : allLocales) { if (not SupportedLocale(locale)) { @@ -88,19 +90,19 @@ void TST_ReadVal::TestInvalidData_data() // Test invalid values const QLocale locale = QLocale::c(); PrepareString(QString(), locale); - PrepareString(QString("-1.000.5"), locale); - PrepareString(QString("1.000.5"), locale); - PrepareString(QString("-1.000,5"), locale); - PrepareString(QString("1.000,5"), locale); - PrepareString(QString("-1.0.00,5"), locale); - PrepareString(QString("1.0.00,5"), locale); - PrepareString(QString("7,5"), locale); - PrepareString(QString("-7,5"), locale); - PrepareString(QString("- 7,5"), locale); - PrepareString(QString("- 7.5"), locale); - PrepareString(QString("1,0,00.5"), locale); - PrepareString(QString("1,,000.5"), locale); - PrepareString(QString(",5"), locale); + PrepareString(u"-1.000.5"_s, locale); + PrepareString(u"1.000.5"_s, locale); + PrepareString(u"-1.000,5"_s, locale); + PrepareString(u"1.000,5"_s, locale); + PrepareString(u"-1.0.00,5"_s, locale); + PrepareString(u"1.0.00,5"_s, locale); + PrepareString(u"7,5"_s, locale); + PrepareString(u"-7,5"_s, locale); + PrepareString(u"- 7,5"_s, locale); + PrepareString(u"- 7.5"_s, locale); + PrepareString(u"1,0,00.5"_s, locale); + PrepareString(u"1,,000.5"_s, locale); + PrepareString(u",5"_s, locale); PrepareString(QChar(','), locale); PrepareString(QChar('.'), locale); } diff --git a/src/test/ValentinaTest/tst_varc.cpp b/src/test/ValentinaTest/tst_varc.cpp index 742c4aabf..28cbbfa8f 100644 --- a/src/test/ValentinaTest/tst_varc.cpp +++ b/src/test/ValentinaTest/tst_varc.cpp @@ -32,6 +32,12 @@ #include +#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) +#include "../vmisc/compatibility.h" +#endif + +using namespace Qt::Literals::StringLiterals; + namespace { void PrepareTestCase(const QPointF ¢er, qreal startAngle, qreal endAngle) @@ -43,16 +49,13 @@ void PrepareTestCase(const QPointF ¢er, qreal startAngle, qreal endAngle) VArc arc(VPointF(center), radius, startAngle, endAngle); const QVector points = arc.GetPoints(); - const QString testStartAngle = QString("Test start angel. Arc radius %1, start angle %2, end angle %3") - .arg(radius) + const QString testStartAngle = u"Test start angel. Arc radius %1, start angle %2, end angle %3"_s.arg(radius) .arg(startAngle) .arg(endAngle); QTest::newRow(qUtf8Printable(testStartAngle)) << center << startAngle << points << points.constFirst() << true; - const QString testEndAngle = QString("Test end angel. Arc radius %1, start angle %2, end angle %3") - .arg(radius) - .arg(startAngle) - .arg(endAngle); + const QString testEndAngle = + u"Test end angel. Arc radius %1, start angle %2, end angle %3"_s.arg(radius).arg(startAngle).arg(endAngle); QTest::newRow(qUtf8Printable(testEndAngle)) << center << endAngle << points << points.constLast() << true; radius += UnitConvertor(5, Unit::Cm, Unit::Px); @@ -213,9 +216,8 @@ void TST_VArc::TestGetPoints() QLineF rLine(static_cast(center), point); const qreal value = qAbs(rLine.length() - radius); // cppcheck-suppress unreadVariable - const QString errorMsg = QString("Broken the first rule. All points should be on the same distance from " - "the center. Error ='%1'.") - .arg(value); + const QString errorMsg = u"Broken the first rule. All points should be on the same distance from " + "the center. Error ='%1'."_s.arg(value); QVERIFY2(value <= epsRadius, qUtf8Printable(errorMsg)); } } @@ -238,7 +240,7 @@ void TST_VArc::TestGetPoints() const qreal value = qAbs(gSquare - cSquare); // cppcheck-suppress unreadVariable const QString errorMsg = - QString("Broken the second rule. Interpolation has too big computing error. Error ='%1'.").arg(value); + u"Broken the second rule. Interpolation has too big computing error. Error ='%1'."_s.arg(value); const qreal epsSquare = gSquare * 0.24 / 100; // computing error 0.24 % from origin square QVERIFY2(value <= epsSquare, qUtf8Printable(errorMsg)); } @@ -276,7 +278,7 @@ void TST_VArc::TestRotation() QCOMPARE(arcOrigin.AngleArc(), rotatedArc.AngleArc()); QCOMPARE(arcOrigin.GetRadius(), rotatedArc.GetRadius()); // cppcheck-suppress unreadVariable - const QString errorMsg = QString("The name doesn't contain the prefix '%1'.").arg(prefix); + const QString errorMsg = u"The name doesn't contain the prefix '%1'."_s.arg(prefix); QVERIFY2(rotatedArc.name().endsWith(prefix), qUtf8Printable(errorMsg)); } @@ -342,7 +344,7 @@ void TST_VArc::TestFlip() const VArc res = originArc.Flip(axis, prefix); // cppcheck-suppress unreadVariable - const QString errorMsg = QString("The name doesn't contain the prefix '%1'.").arg(prefix); + const QString errorMsg = u"The name doesn't contain the prefix '%1'."_s.arg(prefix); QVERIFY2(res.name().endsWith(prefix), qUtf8Printable(errorMsg)); QVERIFY2(res.IsFlipped(), qUtf8Printable("The arc is not flipped")); diff --git a/src/test/ValentinaTest/tst_vcommandline.cpp b/src/test/ValentinaTest/tst_vcommandline.cpp index 1f3e17d72..f9f266f74 100644 --- a/src/test/ValentinaTest/tst_vcommandline.cpp +++ b/src/test/ValentinaTest/tst_vcommandline.cpp @@ -36,6 +36,12 @@ #include // and, not, or #endif +#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) +#include "../vmisc/compatibility.h" +#endif + +using namespace Qt::Literals::StringLiterals; + //--------------------------------------------------------------------------------------------------------------------- TST_VCommandLine::TST_VCommandLine(QObject *parent) : QObject(parent) @@ -52,7 +58,7 @@ void TST_VCommandLine::UniqueKeys() for (const auto &str : options) { // cppcheck-suppress unreadVariable - const QString message = QString("Options '%1' is not unique!").arg(str); + const QString message = u"Options '%1' is not unique!"_s.arg(str); QVERIFY2(not unique.contains(str), qUtf8Printable(message)); unique.insert(str); } diff --git a/src/test/ValentinaTest/tst_vellipticalarc.cpp b/src/test/ValentinaTest/tst_vellipticalarc.cpp index 1786def00..7b86bd55b 100644 --- a/src/test/ValentinaTest/tst_vellipticalarc.cpp +++ b/src/test/ValentinaTest/tst_vellipticalarc.cpp @@ -33,6 +33,12 @@ #include #include +#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) +#include "../vmisc/compatibility.h" +#endif + +using namespace Qt::Literals::StringLiterals; + //--------------------------------------------------------------------------------------------------------------------- TST_VEllipticalArc::TST_VEllipticalArc(QObject *parent) : AbstractTest(parent) @@ -88,8 +94,7 @@ void TST_VEllipticalArc::CompareTwoWays() const qreal lengthEps = ToPixel(0.45, Unit::Mm); // computing error // cppcheck-suppress unreadVariable - QString errorLengthMsg = - QString("Difference between real and computing lengthes bigger than eps = %1. l1 = %2; l2 = %3"); + QString errorLengthMsg = u"Difference between real and computing lengthes bigger than eps = %1. l1 = %2; l2 = %3"_s; QVERIFY2(qAbs(arc2.GetLength() - length) <= lengthEps, qUtf8Printable(errorLengthMsg.arg(lengthEps).arg(arc2.GetLength()).arg(length))); QVERIFY2(qAbs(arc1.GetLength() - arc2.GetLength()) <= lengthEps, @@ -98,7 +103,7 @@ void TST_VEllipticalArc::CompareTwoWays() const qreal angleEps = 0.4; // cppcheck-suppress unreadVariable const QString errorAngleMsg = - QString("Difference between real and computing angles bigger than eps = %1. f1 = %2; f2 = %3"); + u"Difference between real and computing angles bigger than eps = %1. f1 = %2; f2 = %3"_s; // compare angles const qreal diff = qAbs(arc1.GetEndAngle() - arc2.GetEndAngle()); QVERIFY2(qAbs(diff - 360.0 * (diff / 360.0)) <= angleEps, @@ -124,7 +129,7 @@ void TST_VEllipticalArc::NegativeArc() const qreal eps = ToPixel(0.45, Unit::Mm); // computing error // cppcheck-suppress unreadVariable const QString errorMsg = - QString("Difference between real and computing lengthes bigger than eps = %1. v1 = %2; v2 = %3"); + u"Difference between real and computing lengthes bigger than eps = %1. v1 = %2; v2 = %3"_s; QVERIFY2(qAbs(arc.GetLength() + length) <= eps, qUtf8Printable(errorMsg.arg(eps).arg(arc.GetLength()).arg(length))); @@ -294,9 +299,8 @@ void TST_VEllipticalArc::TestGetPoints1() const qreal equationRes = p.rx() * p.rx() / (radius1 * radius1) + p.ry() * p.ry() / (radius2 * radius2); const qreal diff = qAbs(equationRes - 1); // cppcheck-suppress unreadVariable - const QString errorMsg = QString("Broken the first rule. Any point must satisfy the equation of ellipse." - "diff = '%1' > eps = '%2'") - .number(diff) + const QString errorMsg = u"Broken the first rule. Any point must satisfy the equation of ellipse." + "diff = '%1' > eps = '%2'"_s.number(diff) .number(eps); QVERIFY2(diff <= eps, qUtf8Printable(errorMsg)); } @@ -367,11 +371,10 @@ void TST_VEllipticalArc::TestGetPoints2() const qreal resultingDistance = rLine1.length() + rLine2.length(); const qreal diff = qAbs(resultingDistance - distance); // cppcheck-suppress unreadVariable - const QString errorMsg = QString("Broken the first rule, part 2. Distance from the any point to the focus1" - " plus distance from this point to the focus2 should be the same. Problem" - " with point '%1'. The disired distance is '%2', but resulting distance" - " is '%3'. Difference is '%4' and it biggest than eps '%5')") - .number(i) + const QString errorMsg = u"Broken the first rule, part 2. Distance from the any point to the focus1" + " plus distance from this point to the focus2 should be the same. Problem" + " with point '%1'. The disired distance is '%2', but resulting distance" + " is '%3'. Difference is '%4' and it biggest than eps '%5')"_s.number(i) .number(distance) .number(resultingDistance) .number(diff) @@ -403,9 +406,8 @@ void TST_VEllipticalArc::TestGetPoints3() const qreal arcSquare = qAbs(VAbstractPiece::SumTrapezoids(points) / 2.0); const qreal diffSquare = qAbs(ellipseSquare - arcSquare); // cppcheck-suppress unreadVariable - const QString errorMsg1 = QString("Broken the second rule. Interpolation has too big computing error. " - "Difference ='%1' bigger than eps = '%2'.") - .arg(diffSquare) + const QString errorMsg1 = u"Broken the second rule. Interpolation has too big computing error. " + "Difference ='%1' bigger than eps = '%2'."_s.arg(diffSquare) .arg(epsSquare); QVERIFY2(diffSquare <= epsSquare, qUtf8Printable(errorMsg1)); } @@ -434,9 +436,8 @@ void TST_VEllipticalArc::TestGetPoints4() const qreal arcLength = VEllipticalArc(center, radius1, radius2, 0, 360, 0).GetLength(); const qreal diffLength = qAbs(arcLength - ellipseLength); // cppcheck-suppress unreadVariable - const QString errorMsg2 = QString("Difference between real and computing lengthes " - "(diff = '%1') bigger than eps = '%2'.") - .arg(diffLength) + const QString errorMsg2 = u"Difference between real and computing lengthes " + "(diff = '%1') bigger than eps = '%2'."_s.arg(diffLength) .arg(epsLength); QVERIFY2(diffLength <= epsLength, qUtf8Printable(errorMsg2)); } @@ -543,11 +544,10 @@ void TST_VEllipticalArc::TestRotation() const VEllipticalArc rotatedArc = arcOrigin.Rotate(rotatePoint, degrees, prefix); QVERIFY2(qAbs(arcOrigin.AngleArc() - rotatedArc.AngleArc()) <= 1.6, - qUtf8Printable(QString("a1 = %1, a2 - %2").arg(arcOrigin.AngleArc()).arg(rotatedArc.AngleArc()))); + qUtf8Printable(u"a1 = %1, a2 - %2"_s.arg(arcOrigin.AngleArc()).arg(rotatedArc.AngleArc()))); // cppcheck-suppress unreadVariable - QString errorLengthMsg = - QString("Difference between real and computing lengthes bigger than eps = %1. l1 = %2; l2 = %3"); + QString errorLengthMsg = u"Difference between real and computing lengthes bigger than eps = %1. l1 = %2; l2 = %3"_s; QVERIFY2(qAbs(arcOrigin.GetLength() - rotatedArc.GetLength()) <= ToPixel(1, Unit::Mm), qUtf8Printable( errorLengthMsg.arg(ToPixel(1, Unit::Mm)).arg(arcOrigin.GetLength()).arg(rotatedArc.GetLength()))); @@ -556,7 +556,7 @@ void TST_VEllipticalArc::TestRotation() QCOMPARE(arcOrigin.GetRadius2(), rotatedArc.GetRadius2()); QCOMPARE(arcOrigin.GetRotationAngle(), rotatedArc.GetRotationAngle()); // cppcheck-suppress unreadVariable - const QString errorMsg = QString("The name doesn't contain the prefix '%1'.").arg(prefix); + const QString errorMsg = u"The name doesn't contain the prefix '%1'."_s.arg(prefix); QVERIFY2(rotatedArc.name().endsWith(prefix), qUtf8Printable(errorMsg)); } diff --git a/src/test/ValentinaTest/tst_vmeasurements.cpp b/src/test/ValentinaTest/tst_vmeasurements.cpp index 24e46be0d..b614004e9 100644 --- a/src/test/ValentinaTest/tst_vmeasurements.cpp +++ b/src/test/ValentinaTest/tst_vmeasurements.cpp @@ -27,17 +27,23 @@ *************************************************************************/ #include "tst_vmeasurements.h" -#include "../vformat/vmeasurements.h" -#include "../ifc/xml/vvstconverter.h" #include "../ifc/xml/vvitconverter.h" -#include "../vpatterndb/vcontainer.h" +#include "../ifc/xml/vvstconverter.h" +#include "../vformat/vmeasurements.h" #include "../vpatterndb/pmsystems.h" +#include "../vpatterndb/vcontainer.h" #include +#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) +#include "../vmisc/compatibility.h" +#endif + +using namespace Qt::Literals::StringLiterals; + //--------------------------------------------------------------------------------------------------------------------- -TST_VMeasurements::TST_VMeasurements(QObject *parent) : - QObject(parent) +TST_VMeasurements::TST_VMeasurements(QObject *parent) + : QObject(parent) { } @@ -49,8 +55,8 @@ void TST_VMeasurements::CreateEmptyMultisizeFile() { Unit mUnit = Unit::Cm; - QSharedPointer data = QSharedPointer(new VContainer(nullptr, &mUnit, - VContainer::UniqueNamespace())); + QSharedPointer data = + QSharedPointer(new VContainer(nullptr, &mUnit, VContainer::UniqueNamespace())); auto m_xDimension = QSharedPointer::create(mUnit, 50, 200, 6); m_xDimension->SetBaseValue(176); @@ -58,10 +64,9 @@ void TST_VMeasurements::CreateEmptyMultisizeFile() m_yDimension->SetBaseValue(50); m_yDimension->SetBodyMeasurement(true); - QVector dimensions{m_xDimension, m_yDimension}; + QVector dimensions{m_xDimension, m_yDimension}; - QSharedPointer m = - QSharedPointer(new VMeasurements(mUnit, dimensions, data.data())); + QSharedPointer m = QSharedPointer(new VMeasurements(mUnit, dimensions, data.data())); QTemporaryFile file; QString fileName; @@ -101,11 +106,10 @@ void TST_VMeasurements::CreateEmptyIndividualFile() { Unit mUnit = Unit::Cm; - QSharedPointer data = QSharedPointer(new VContainer(nullptr, &mUnit, - VContainer::UniqueNamespace())); + QSharedPointer data = + QSharedPointer(new VContainer(nullptr, &mUnit, VContainer::UniqueNamespace())); - QSharedPointer m = - QSharedPointer(new VMeasurements(mUnit, data.data())); + QSharedPointer m = QSharedPointer(new VMeasurements(mUnit, data.data())); QTemporaryFile file; QString fileName; @@ -143,8 +147,8 @@ void TST_VMeasurements::ValidPMCodesMultisizeFile() { Unit mUnit = Unit::Cm; - QSharedPointer data = QSharedPointer(new VContainer(nullptr, &mUnit, - VContainer::UniqueNamespace())); + QSharedPointer data = + QSharedPointer(new VContainer(nullptr, &mUnit, VContainer::UniqueNamespace())); auto m_xDimension = QSharedPointer::create(mUnit, 50, 200, 6); m_xDimension->SetBaseValue(176); @@ -153,10 +157,9 @@ void TST_VMeasurements::ValidPMCodesMultisizeFile() m_yDimension->SetBaseValue(50); m_yDimension->SetBodyMeasurement(true); - QVector dimensions{m_xDimension, m_yDimension}; + QVector dimensions{m_xDimension, m_yDimension}; - QSharedPointer m = - QSharedPointer(new VMeasurements(mUnit, dimensions, data.data())); + QSharedPointer m = QSharedPointer(new VMeasurements(mUnit, dimensions, data.data())); const QStringList listSystems = ListPMSystems(); for (int i = 0; i < listSystems.size(); ++i) @@ -176,7 +179,7 @@ void TST_VMeasurements::ValidPMCodesMultisizeFile() const bool result = m->SaveDocument(fileName, error); // cppcheck-suppress unreadVariable - const QString message = QString("Error: %1 for code=%2").arg(error, listSystems.at(i)); + const QString message = u"Error: %1 for code=%2"_s.arg(error, listSystems.at(i)); QVERIFY2(result, qUtf8Printable(message)); } else @@ -190,7 +193,7 @@ void TST_VMeasurements::ValidPMCodesMultisizeFile() } catch (VException &e) { - const QString message = QString("Error: %1 for code=%2").arg(e.ErrorMessage(), listSystems.at(i)); + const QString message = u"Error: %1 for code=%2"_s.arg(e.ErrorMessage(), listSystems.at(i)); QFAIL(qUtf8Printable(message)); } } @@ -205,11 +208,10 @@ void TST_VMeasurements::ValidPMCodesIndividualFile() { Unit mUnit = Unit::Cm; - QSharedPointer data = QSharedPointer(new VContainer(nullptr, &mUnit, - VContainer::UniqueNamespace())); + QSharedPointer data = + QSharedPointer(new VContainer(nullptr, &mUnit, VContainer::UniqueNamespace())); - QSharedPointer m = - QSharedPointer(new VMeasurements(mUnit, data.data())); + QSharedPointer m = QSharedPointer(new VMeasurements(mUnit, data.data())); const QStringList listSystems = ListPMSystems(); for (int i = 0; i < listSystems.size(); ++i) @@ -229,7 +231,7 @@ void TST_VMeasurements::ValidPMCodesIndividualFile() const bool result = m->SaveDocument(fileName, error); // cppcheck-suppress unreadVariable - const QString message = QString("Error: %1 for code=%2").arg(error, listSystems.at(i)); + const QString message = u"Error: %1 for code=%2"_s.arg(error, listSystems.at(i)); QVERIFY2(result, qUtf8Printable(message)); } else @@ -243,7 +245,7 @@ void TST_VMeasurements::ValidPMCodesIndividualFile() } catch (VException &e) { - const QString message = QString("Error: %1 for code=%2").arg(e.ErrorMessage(), listSystems.at(i)); + const QString message = u"Error: %1 for code=%2"_s.arg(e.ErrorMessage(), listSystems.at(i)); QFAIL(qUtf8Printable(message)); } } diff --git a/src/test/ValentinaTest/tst_vpointf.cpp b/src/test/ValentinaTest/tst_vpointf.cpp index b3ab2d72a..3d382a22d 100644 --- a/src/test/ValentinaTest/tst_vpointf.cpp +++ b/src/test/ValentinaTest/tst_vpointf.cpp @@ -31,9 +31,15 @@ #include +#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) +#include "../vmisc/compatibility.h" +#endif + +using namespace Qt::Literals::StringLiterals; + //--------------------------------------------------------------------------------------------------------------------- TST_VPointF::TST_VPointF(QObject *parent) - : QObject(parent) + : QObject(parent) { } @@ -59,10 +65,10 @@ void TST_VPointF::TestFlip_data() QLineF l = QLineF(QPointF(), QPointF(10, 0)); l.setAngle(315); flipped = l.p2(); - l.setLength(l.length()/2.0); + l.setLength(l.length() / 2.0); axis = QLineF(l.p2(), l.p1()); - axis.setAngle(axis.angle()+90); + axis.setAngle(axis.angle() + 90); QTest::newRow("Diagonal axis") << originPoint << axis << flipped << "a2"; } @@ -78,9 +84,8 @@ void TST_VPointF::TestFlip() const VPointF res = originPoint.Flip(axis, prefix); // cppcheck-suppress unreadVariable - const QString errorMsg = QString("The name doesn't contain the prefix '%1'.").arg(prefix); + const QString errorMsg = u"The name doesn't contain the prefix '%1'."_s.arg(prefix); QVERIFY2(res.name().endsWith(prefix), qUtf8Printable(errorMsg)); QCOMPARE(flipped.toPoint(), res.toQPointF().toPoint()); } - diff --git a/src/test/ValentinaTest/tst_vsplinepath.cpp b/src/test/ValentinaTest/tst_vsplinepath.cpp index af5495ffa..b50867ba5 100644 --- a/src/test/ValentinaTest/tst_vsplinepath.cpp +++ b/src/test/ValentinaTest/tst_vsplinepath.cpp @@ -31,11 +31,16 @@ #include +#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) +#include "../vmisc/compatibility.h" +#endif + +using namespace Qt::Literals::StringLiterals; + //--------------------------------------------------------------------------------------------------------------------- TST_VSplinePath::TST_VSplinePath(QObject *parent) - : QObject (parent) + : QObject(parent) { - } //--------------------------------------------------------------------------------------------------------------------- @@ -58,15 +63,15 @@ void TST_VSplinePath::TestRotation_data() { VPointF pSpline(198.77104389529981, 249.18158602595835, "X", 5.0000125984251973, 9.9999874015748045); - VSplinePoint p(pSpline, 146.43199999999999, "146.432", 326.43200000000002, "326.432", - 36.387590551181106, "0.962755", 60.978897637795278, "1.6134"); + VSplinePoint p(pSpline, 146.43199999999999, "146.432", 326.43200000000002, "326.432", 36.387590551181106, + "0.962755", 60.978897637795278, "1.6134"); originPoints.append(p); } { VPointF pSpline(820.42771653543309, 417.95262992125987, "X", 5.0000125984251973, 9.9999874015748045); - VSplinePoint p(pSpline, 173.39500000000001, "173.395", 353.39499999999998, "353.395", - 381.23716535433073, "10.0869", 0, QChar('0')); + VSplinePoint p(pSpline, 173.39500000000001, "173.395", 353.39499999999998, "353.395", 381.23716535433073, + "10.0869", 0, QChar('0')); originPoints.append(p); } @@ -81,8 +86,8 @@ void TST_VSplinePath::TestRotation_data() { VPointF pSpline(-130.81610509751462, 241.58508512833563, "X", 5.0000125984251973, 9.9999874015748045); - VSplinePoint p(pSpline, 233.79130000000001, "233.791", 53.791300000000014, "53.7913", - 36.387590551181141, "0.962755", 60.978897637795207, "1.6134"); + VSplinePoint p(pSpline, 233.79130000000001, "233.791", 53.791300000000014, "53.7913", 36.387590551181141, + "0.962755", 60.978897637795207, "1.6134"); rotatedPoints.append(p); } @@ -93,7 +98,6 @@ void TST_VSplinePath::TestRotation_data() rotatedPoints.append(p); } - QTest::newRow("Test spline path 1") << originPoints << QPointF(30, 417.95262992125987) << 87.359300000000005 << "a2" << rotatedPoints; } @@ -117,12 +121,12 @@ void TST_VSplinePath::TestRotation() QCOMPARE(rotatedPath.CountPoints(), res.CountPoints()); // cppcheck-suppress unreadVariable - const QString errorMsg = QString("The name doesn't contain the prefix '%1'.").arg(prefix); + const QString errorMsg = u"The name doesn't contain the prefix '%1'."_s.arg(prefix); QVERIFY2(res.name().endsWith(prefix), qUtf8Printable(errorMsg)); const QVector resPoints = res.GetSplinePath(); - for (int i=0; i < resPoints.size(); ++i) + for (int i = 0; i < resPoints.size(); ++i) { const VSplinePoint resPoint = resPoints.at(i); const VSplinePoint rotatedPoint = rotatedPoints.at(i); @@ -153,15 +157,15 @@ void TST_VSplinePath::TestFlip_data() { VPointF pSpline(198.77104389529981, 249.18158602595835, "X", 5.0000125984251973, 9.9999874015748045); - VSplinePoint p(pSpline, 146.43199999999999, "146.432", 326.43200000000002, "326.432", - 36.387590551181106, "0.962755", 60.978897637795278, "1.6134"); + VSplinePoint p(pSpline, 146.43199999999999, "146.432", 326.43200000000002, "326.432", 36.387590551181106, + "0.962755", 60.978897637795278, "1.6134"); originPoints.append(p); } { VPointF pSpline(820.42771653543309, 417.95262992125987, "X", 5.0000125984251973, 9.9999874015748045); - VSplinePoint p(pSpline, 173.39500000000001, "173.395", 353.39499999999998, "353.395", - 381.23716535433073, "10.0869", 0, QChar('0')); + VSplinePoint p(pSpline, 173.39500000000001, "173.395", 353.39499999999998, "353.395", 381.23716535433073, + "10.0869", 0, QChar('0')); originPoints.append(p); } @@ -196,4 +200,3 @@ void TST_VSplinePath::TestFlip() QCOMPARE(splPath.GetLength(), res.GetLength()); QCOMPARE(splPath.CountPoints(), res.CountPoints()); } - diff --git a/src/test/ValentinaTest/tst_vtooluniondetails.cpp b/src/test/ValentinaTest/tst_vtooluniondetails.cpp index 7177306d5..a8acadad8 100644 --- a/src/test/ValentinaTest/tst_vtooluniondetails.cpp +++ b/src/test/ValentinaTest/tst_vtooluniondetails.cpp @@ -27,19 +27,25 @@ *************************************************************************/ #include "tst_vtooluniondetails.h" -#include "../vpatterndb/vpiecepath.h" #include "../vpatterndb/vpiecenode.h" +#include "../vpatterndb/vpiecepath.h" #include "../vtools/tools/vtooluniondetails.h" #include +#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) +#include "../vmisc/compatibility.h" +#endif + +using namespace Qt::Literals::StringLiterals; + typedef QPair UnitedPathNode; Q_DECLARE_METATYPE(UnitedPathNode) //--------------------------------------------------------------------------------------------------------------------- TST_VToolUnionDetails::TST_VToolUnionDetails(QObject *parent) - : QObject (parent) + : QObject(parent) { } @@ -156,19 +162,21 @@ void TST_VToolUnionDetails::TestUnitingMainPaths() QVERIFY(result.size() == out.size()); - for (int i=0; i < out.size(); ++i) + for (int i = 0; i < out.size(); ++i) { const VPieceNode resP = result.at(i).second; const VPieceNode outP = out.at(i).second; // cppcheck-suppress unreadVariable - const QString msg = QString("Index: %1. Got item with id = %2, type = %3; Expected item with id = %4, " - "type = %5.") - .arg(i).arg(outP.GetId()).arg(static_cast(outP.GetTypeTool())) - .arg(resP.GetId()).arg(static_cast(resP.GetTypeTool())); + const QString msg = u"Index: %1. Got item with id = %2, type = %3; Expected item with id = %4, " + "type = %5."_s.arg(i) + .arg(outP.GetId()) + .arg(static_cast(outP.GetTypeTool())) + .arg(resP.GetId()) + .arg(static_cast(resP.GetTypeTool())); - QVERIFY2(out.at(i).first == result.at(i).first - && outP.GetId() == resP.GetId() - && outP.GetTypeTool() == resP.GetTypeTool(), qUtf8Printable(msg)); + QVERIFY2(out.at(i).first == result.at(i).first && outP.GetId() == resP.GetId() && + outP.GetTypeTool() == resP.GetTypeTool(), + qUtf8Printable(msg)); } } diff --git a/src/test/ValentinaTest/tst_vtranslatevars.cpp b/src/test/ValentinaTest/tst_vtranslatevars.cpp index 8174ec60a..36997b8e3 100644 --- a/src/test/ValentinaTest/tst_vtranslatevars.cpp +++ b/src/test/ValentinaTest/tst_vtranslatevars.cpp @@ -27,18 +27,20 @@ *************************************************************************/ #include "tst_vtranslatevars.h" -#include "../vpatterndb/vtranslatevars.h" #include "../qmuparser/qmudef.h" -#include "testvapplication.h" #include "../vmisc/compatibility.h" +#include "../vpatterndb/vtranslatevars.h" +#include "testvapplication.h" #include +using namespace Qt::Literals::StringLiterals; + //--------------------------------------------------------------------------------------------------------------------- TST_VTranslateVars::TST_VTranslateVars(QObject *parent) - : QObject(parent), - m_trMs(nullptr), - m_systemLocale(QLocale::system()) + : QObject(parent), + m_trMs(nullptr), + m_systemLocale(QLocale::system()) { } @@ -57,7 +59,7 @@ void TST_VTranslateVars::TestFormulaFromUser_data() QTest::addColumn("locale"); const QList allLocales = - QLocale::matchingLocales(QLocale::AnyLanguage, QLocale::AnyScript, QLocale::AnyCountry); + QLocale::matchingLocales(QLocale::AnyLanguage, QLocale::AnyScript, QLocale::AnyCountry); for (const auto &locale : allLocales) { if (not SupportedLocale(locale)) @@ -92,7 +94,7 @@ void TST_VTranslateVars::TestFormulaToUser_data() QTest::addColumn("locale"); const QList allLocales = - QLocale::matchingLocales(QLocale::AnyLanguage, QLocale::AnyScript, QLocale::AnyCountry); + QLocale::matchingLocales(QLocale::AnyLanguage, QLocale::AnyScript, QLocale::AnyCountry); for (const auto &locale : allLocales) { if (not SupportedLocale(locale)) @@ -156,17 +158,17 @@ void TST_VTranslateVars::PrepareVal(const QString &inputFormula, const QString & auto PREPARE_CASE = [locale](const QString &inputString, const QString &outputString) { - QString tag = QString("%1. String '%2'").arg(locale.name(), inputString); + QString tag = u"%1. String '%2'"_s.arg(locale.name(), inputString); QTest::newRow(qUtf8Printable(tag)) << inputString << outputString << locale; }; PREPARE_CASE(inputString, outputString); - inputString = inputFormula+QLatin1String("+")+inputFormula; - outputString = outputFormula+QLatin1String("+")+outputFormula; + inputString = inputFormula + '+'_L1 + inputFormula; + outputString = outputFormula + '+'_L1 + outputFormula; PREPARE_CASE(inputString, outputString); - inputString = inputFormula+QString("+a"); - outputString = outputFormula+QString("+a"); + inputString = inputFormula + u"+a"_s; + outputString = outputFormula + u"+a"_s; PREPARE_CASE(inputString, outputString); }