From ccdabec8686075a1e29b199761092ac2c5987935 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Tue, 25 Jul 2023 14:01:41 +0300 Subject: [PATCH] Avoid using global static variables. --- src/app/puzzle/dialogs/vpdialogabout.cpp | 2 +- src/app/puzzle/vpapplication.cpp | 4 +- src/app/puzzle/xml/vplayoutfilewriter.cpp | 2 +- src/app/tape/dialogs/dialogabouttape.cpp | 2 +- src/app/tape/mapplication.cpp | 4 +- src/app/valentina/core/vapplication.cpp | 4 +- src/app/valentina/dialogs/dialogaboutapp.cpp | 2 +- .../dialogs/dialoglayoutsettings.cpp | 8 +-- src/app/valentina/main.cpp | 4 +- src/app/valentina/xml/vpattern.cpp | 2 +- src/libs/ifc/ifcdef.cpp | 62 +++++++++---------- src/libs/ifc/ifcdef.h | 2 +- src/libs/ifc/xml/vabstractpattern.cpp | 4 +- src/libs/qmuparser/qmuparserbase.cpp | 2 +- src/libs/qmuparser/qmuparserbase.h | 10 ++- src/libs/qmuparser/qmuparsererror.h | 4 +- src/libs/vformat/vmeasurements.cpp | 2 +- src/libs/vformat/vpatternrecipe.cpp | 5 +- src/libs/vformat/vwatermark.cpp | 2 +- .../vlayout/dialogs/vabstractlayoutdialog.cpp | 47 +++++++------- .../vlayout/dialogs/vabstractlayoutdialog.h | 2 +- src/libs/vmisc/literals.cpp | 30 +++------ src/libs/vmisc/literals.h | 2 +- src/libs/vmisc/projectversion.cpp | 9 ++- src/libs/vmisc/projectversion.h | 2 +- src/libs/vpatterndb/vcontainer.cpp | 4 +- .../TranslationsTest/tst_buitinregexp.cpp | 8 +-- 27 files changed, 116 insertions(+), 115 deletions(-) diff --git a/src/app/puzzle/dialogs/vpdialogabout.cpp b/src/app/puzzle/dialogs/vpdialogabout.cpp index ee3c57d89..dbcf6b363 100644 --- a/src/app/puzzle/dialogs/vpdialogabout.cpp +++ b/src/app/puzzle/dialogs/vpdialogabout.cpp @@ -130,7 +130,7 @@ void VPDialogAbout::FontPointSize(QWidget *w, int pointSize) //--------------------------------------------------------------------------------------------------------------------- void VPDialogAbout::RetranslateUi() { - ui->label_Puzzle_Version->setText(QStringLiteral("Puzzle %1").arg(APP_VERSION_STR)); + ui->label_Puzzle_Version->setText(QStringLiteral("Puzzle %1").arg(AppVersionStr())); ui->labelBuildRevision->setText(tr("Build revision: %1").arg(QStringLiteral(BUILD_REVISION))); ui->label_QT_Version->setText(buildCompatibilityString()); diff --git a/src/app/puzzle/vpapplication.cpp b/src/app/puzzle/vpapplication.cpp index cb1dbec28..5d21fe114 100644 --- a/src/app/puzzle/vpapplication.cpp +++ b/src/app/puzzle/vpapplication.cpp @@ -270,7 +270,7 @@ VPApplication::VPApplication(int &argc, char **argv) setOrganizationName(QStringLiteral(VER_COMPANYNAME_STR)); setOrganizationDomain(QStringLiteral(VER_COMPANYDOMAIN_STR)); // Setting the Application version - setApplicationVersion(APP_VERSION_STR); + setApplicationVersion(AppVersionStr()); // We have been running Puzzle in two different cases. // The first inside own bundle where info.plist is works fine, but the second, // when we run inside Valentina's bundle, require direct setting the icon. @@ -420,7 +420,7 @@ void VPApplication::InitOptions() OpenSettings(); - qCDebug(pApp, "Version: %s", qUtf8Printable(APP_VERSION_STR)); + qCDebug(pApp, "Version: %s", qUtf8Printable(AppVersionStr())); qCDebug(pApp, "Build revision: %s", BUILD_REVISION); qCDebug(pApp, "%s", qUtf8Printable(buildCompatibilityString())); qCDebug(pApp, "Built on %s at %s", __DATE__, __TIME__); diff --git a/src/app/puzzle/xml/vplayoutfilewriter.cpp b/src/app/puzzle/xml/vplayoutfilewriter.cpp index eed84d0c7..46599e081 100644 --- a/src/app/puzzle/xml/vplayoutfilewriter.cpp +++ b/src/app/puzzle/xml/vplayoutfilewriter.cpp @@ -142,7 +142,7 @@ void VPLayoutFileWriter::WriteFile(const VPLayoutPtr &layout, QIODevice *file) writeStartDocument(); writeComment( - QStringLiteral("Layout created with Valentina v%1 (https://smart-pattern.com.ua/).").arg(APP_VERSION_STR)); + QStringLiteral("Layout created with Valentina v%1 (https://smart-pattern.com.ua/).").arg(AppVersionStr())); WriteLayout(layout); writeEndDocument(); } diff --git a/src/app/tape/dialogs/dialogabouttape.cpp b/src/app/tape/dialogs/dialogabouttape.cpp index d54fc9a07..bd5785ac4 100644 --- a/src/app/tape/dialogs/dialogabouttape.cpp +++ b/src/app/tape/dialogs/dialogabouttape.cpp @@ -131,7 +131,7 @@ void DialogAboutTape::FontPointSize(QWidget *w, int pointSize) //--------------------------------------------------------------------------------------------------------------------- void DialogAboutTape::RetranslateUi() { - ui->label_Tape_Version->setText(QStringLiteral("Tape %1").arg(APP_VERSION_STR)); + ui->label_Tape_Version->setText(QStringLiteral("Tape %1").arg(AppVersionStr())); ui->labelBuildRevision->setText(tr("Build revision: %1").arg(QStringLiteral(BUILD_REVISION))); ui->label_QT_Version->setText(buildCompatibilityString()); diff --git a/src/app/tape/mapplication.cpp b/src/app/tape/mapplication.cpp index 31cd39a01..7410c2143 100644 --- a/src/app/tape/mapplication.cpp +++ b/src/app/tape/mapplication.cpp @@ -316,7 +316,7 @@ MApplication::MApplication(int &argc, char **argv) setOrganizationName(QStringLiteral(VER_COMPANYNAME_STR)); setOrganizationDomain(QStringLiteral(VER_COMPANYDOMAIN_STR)); // Setting the Application version - setApplicationVersion(APP_VERSION_STR); + setApplicationVersion(AppVersionStr()); // We have been running Tape in two different cases. // The first inside own bundle where info.plist is works fine, but the second, // when we run inside Valentina's bundle, require direct setting the icon. @@ -471,7 +471,7 @@ void MApplication::InitOptions() OpenSettings(); - qCDebug(mApp, "Version: %s", qUtf8Printable(APP_VERSION_STR)); + qCDebug(mApp, "Version: %s", qUtf8Printable(AppVersionStr())); qCDebug(mApp, "Build revision: %s", BUILD_REVISION); qCDebug(mApp, "%s", qUtf8Printable(buildCompatibilityString())); qCDebug(mApp, "Built on %s at %s", __DATE__, __TIME__); diff --git a/src/app/valentina/core/vapplication.cpp b/src/app/valentina/core/vapplication.cpp index d6e28a56c..a80f2a835 100644 --- a/src/app/valentina/core/vapplication.cpp +++ b/src/app/valentina/core/vapplication.cpp @@ -380,7 +380,7 @@ VApplication::VApplication(int &argc, char **argv) setOrganizationName(QStringLiteral(VER_COMPANYNAME_STR)); setOrganizationDomain(QStringLiteral(VER_COMPANYDOMAIN_STR)); // Setting the Application version - setApplicationVersion(APP_VERSION_STR); + setApplicationVersion(AppVersionStr()); // making sure will create new instance...just in case we will ever do 2 objects of VApplication VCommandLine::Reset(); VTheme::Instance()->StoreDefaultThemeName(QIcon::themeName()); @@ -672,7 +672,7 @@ void VApplication::InitOptions() // Run creation log after sending crash report StartLogging(); - qDebug() << "Version:" << APP_VERSION_STR; + qDebug() << "Version:" << AppVersionStr(); qDebug() << "Build revision:" << BUILD_REVISION; qDebug() << buildCompatibilityString(); qDebug() << "Built on" << __DATE__ << "at" << __TIME__; diff --git a/src/app/valentina/dialogs/dialogaboutapp.cpp b/src/app/valentina/dialogs/dialogaboutapp.cpp index 8554aeb72..52fe6c036 100644 --- a/src/app/valentina/dialogs/dialogaboutapp.cpp +++ b/src/app/valentina/dialogs/dialogaboutapp.cpp @@ -52,7 +52,7 @@ DialogAboutApp::DialogAboutApp(QWidget *parent) : VAbstractValApplication::VApp()->ValentinaSettings()->GetOsSeparator() ? setLocale(QLocale()) : setLocale(QLocale::c()); - ui->label_Valentina_Version->setText(QStringLiteral("Valentina %1").arg(APP_VERSION_STR)); + ui->label_Valentina_Version->setText(QStringLiteral("Valentina %1").arg(AppVersionStr())); ui->labelBuildRevision->setText(QStringLiteral("Build revision: %1").arg(QStringLiteral(BUILD_REVISION))); ui->label_QT_Version->setText(buildCompatibilityString()); diff --git a/src/app/valentina/dialogs/dialoglayoutsettings.cpp b/src/app/valentina/dialogs/dialoglayoutsettings.cpp index b6eb32328..44e59fe12 100644 --- a/src/app/valentina/dialogs/dialoglayoutsettings.cpp +++ b/src/app/valentina/dialogs/dialoglayoutsettings.cpp @@ -814,13 +814,13 @@ auto DialogLayoutSettings::MakeHelpTemplateList() -> QString QString out = QChar('\n'); auto cntr = static_cast(PaperSizeTemplate::A0); - for (int i = 0; i < VAbstractLayoutDialog::pageFormatNames.size(); ++i) + for (int i = 0; i < VAbstractLayoutDialog::PageFormatNames().size(); ++i) { if (cntr < static_cast(PaperSizeTemplate::Custom))// Don't include custom template { - out += "\t* "+VAbstractLayoutDialog::pageFormatNames.at(i)+" = "+ QString::number(cntr++); + out += "\t* "+VAbstractLayoutDialog::PageFormatNames().at(i)+" = "+ QString::number(cntr++); - if (i < VAbstractLayoutDialog::pageFormatNames.size() - 2) + if (i < VAbstractLayoutDialog::PageFormatNames().size() - 2) { out += QLatin1String(",\n"); } @@ -840,7 +840,7 @@ auto DialogLayoutSettings::MakeHelpTiledPdfTemplateList() -> QString for (int i = 0; i <= static_cast(PaperSizeTemplate::Tabloid); ++i) { - out += "\t* "+VAbstractLayoutDialog::pageFormatNames.at(i)+" = "+ QString::number(i); + out += "\t* "+VAbstractLayoutDialog::PageFormatNames().at(i)+" = "+ QString::number(i); if (i < static_cast(PaperSizeTemplate::Tabloid)) { diff --git a/src/app/valentina/main.cpp b/src/app/valentina/main.cpp index b71c58317..cd91d97a5 100644 --- a/src/app/valentina/main.cpp +++ b/src/app/valentina/main.cpp @@ -71,8 +71,6 @@ auto main(int argc, char *argv[]) -> int Q_INIT_RESOURCE(win_theme); // NOLINT #endif - QT_REQUIRE_VERSION(argc, argv, "5.4.0") // clazy:exclude=qstring-arg,qstring-allocations NOLINT - #if defined(Q_OS_WIN) VAbstractApplication::WinAttachConsole(); #endif @@ -103,6 +101,8 @@ auto main(int argc, char *argv[]) -> int VApplication app(argc, argv); app.InitOptions(); + QT_REQUIRE_VERSION(argc, argv, "5.4.0") // clazy:exclude=qstring-arg,qstring-allocations NOLINT + #if QT_VERSION >= QT_VERSION_CHECK(5, 7, 0) VApplication::setDesktopFileName(QStringLiteral("ua.com.smart-pattern.valentina.desktop")); #endif diff --git a/src/app/valentina/xml/vpattern.cpp b/src/app/valentina/xml/vpattern.cpp index 6d10987c8..8dc8aa090 100644 --- a/src/app/valentina/xml/vpattern.cpp +++ b/src/app/valentina/xml/vpattern.cpp @@ -140,7 +140,7 @@ namespace //--------------------------------------------------------------------------------------------------------------------- auto FileComment() -> QString { - return QStringLiteral("Pattern created with Valentina v%1 (https://smart-pattern.com.ua/).").arg(APP_VERSION_STR); + return QStringLiteral("Pattern created with Valentina v%1 (https://smart-pattern.com.ua/).").arg(AppVersionStr()); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/ifc/ifcdef.cpp b/src/libs/ifc/ifcdef.cpp index bb55d1476..d24806947 100644 --- a/src/libs/ifc/ifcdef.cpp +++ b/src/libs/ifc/ifcdef.cpp @@ -317,35 +317,35 @@ const QString rotationElArc_ = rotation_V + elarc_; const QString pieceArea_ = QStringLiteral("PieceArea_"); const QString pieceSeamLineArea_ = QStringLiteral("PieceSeamLineArea_"); -const QStringList builInVariables +auto BuilInVariables() -> QStringList { - measurement_, - increment_, - line_, - angleLine_, - arc_, - elarc_, - spl_, - splPath, - radiusArc_, - radius1ElArc_, - radius2ElArc_, - angle1Arc_, - angle2Arc_, - angle1ElArc_, - angle2ElArc_, - angle1Spl_, - angle2Spl_, - angle1SplPath, - angle2SplPath, - seg_, - currentLength, - currentSeamAllowance, - c1LengthSpl_, - c2LengthSpl_, - c1LengthSplPath, - c2LengthSplPath, - rotationElArc_, - pieceArea_, - pieceSeamLineArea_ -}; + return {measurement_, + increment_, + line_, + angleLine_, + arc_, + elarc_, + spl_, + splPath, + radiusArc_, + radius1ElArc_, + radius2ElArc_, + angle1Arc_, + angle2Arc_, + angle1ElArc_, + angle2ElArc_, + angle1Spl_, + angle2Spl_, + angle1SplPath, + angle2SplPath, + seg_, + currentLength, + currentSeamAllowance, + c1LengthSpl_, + c2LengthSpl_, + c1LengthSplPath, + c2LengthSplPath, + rotationElArc_, + pieceArea_, + pieceSeamLineArea_}; +} diff --git a/src/libs/ifc/ifcdef.h b/src/libs/ifc/ifcdef.h index 1618cb2fc..74516c5e5 100644 --- a/src/libs/ifc/ifcdef.h +++ b/src/libs/ifc/ifcdef.h @@ -245,7 +245,7 @@ extern const QString rotationElArc_; extern const QString pieceArea_; extern const QString pieceSeamLineArea_; -extern const QStringList builInVariables; +auto BuilInVariables() -> QStringList; QT_WARNING_PUSH QT_WARNING_DISABLE_GCC("-Weffc++") diff --git a/src/libs/ifc/xml/vabstractpattern.cpp b/src/libs/ifc/xml/vabstractpattern.cpp index f042fb18a..9b4ad2c4b 100644 --- a/src/libs/ifc/xml/vabstractpattern.cpp +++ b/src/libs/ifc/xml/vabstractpattern.cpp @@ -2041,7 +2041,7 @@ auto VAbstractPattern::ListFinalMeasurementsExpressions() const -> QVector bool { - for (const auto &var : builInVariables) + for (const auto &var : BuilInVariables()) { if (token.indexOf(var) == 0) { @@ -2065,7 +2065,7 @@ auto VAbstractPattern::IsVariable(const QString &token) const -> bool //--------------------------------------------------------------------------------------------------------------------- auto VAbstractPattern::IsFunction(const QString &token) const -> bool { - for (const auto &fn : builInFunctions) + for (const auto &fn : BuilInFunctions()) { if (token.indexOf(fn) == 0) { diff --git a/src/libs/qmuparser/qmuparserbase.cpp b/src/libs/qmuparser/qmuparserbase.cpp index c5bc856b8..54faff58b 100644 --- a/src/libs/qmuparser/qmuparserbase.cpp +++ b/src/libs/qmuparser/qmuparserbase.cpp @@ -551,7 +551,7 @@ void QmuParserBase::DefineOprt( const QString &a_sName, fun_type2 a_pFun, unsign // Check for conflicts with built in operator names for (int i=0; m_bBuiltInOp && i const QStringList & { + /** + * @brief Identifiers for built in binary operators. + * + * When defining custom binary operators with #AddOprt(...) make sure not to choose + * names conflicting with these definitions. + */ + const static QStringList c_DefaultOprt = {"<=", ">=", "!=", "==", QChar('<'), QChar('>'), + QChar('+'), QChar('-'), QChar('*'), QChar('/'), QChar('^'), "&&", + "||", QChar('='), QChar('('), QChar(')'), QChar('?'), QChar(':')}; return c_DefaultOprt; } diff --git a/src/libs/qmuparser/qmuparsererror.h b/src/libs/qmuparser/qmuparsererror.h index 1eb588879..46eadc7a5 100644 --- a/src/libs/qmuparser/qmuparsererror.h +++ b/src/libs/qmuparser/qmuparsererror.h @@ -116,14 +116,14 @@ private: // cppcheck-suppress unknownMacro Q_DISABLE_COPY_MOVE(QmuParserErrorMsg) // NOLINT QMap m_vErrMsg; ///< A map with the predefined error messages - static const self_type m_Instance; ///< The instance pointer }; //--------------------------------------------------------------------------------------------------------------------- // cppcheck-suppress unusedFunction inline auto QmuParserErrorMsg::Instance() -> const QmuParserErrorMsg & { - return m_Instance; + const static QmuParserErrorMsg instance; + return instance; } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vformat/vmeasurements.cpp b/src/libs/vformat/vmeasurements.cpp index 27decb041..15f7ffa02 100644 --- a/src/libs/vformat/vmeasurements.cpp +++ b/src/libs/vformat/vmeasurements.cpp @@ -122,7 +122,7 @@ QT_WARNING_POP //--------------------------------------------------------------------------------------------------------------------- auto FileComment() -> QString { - return QString("Measurements created with Valentina v%1 (https://smart-pattern.com.ua/).").arg(APP_VERSION_STR); + return QString("Measurements created with Valentina v%1 (https://smart-pattern.com.ua/).").arg(AppVersionStr()); } } // namespace diff --git a/src/libs/vformat/vpatternrecipe.cpp b/src/libs/vformat/vpatternrecipe.cpp index decbd6b4a..84ca35b69 100644 --- a/src/libs/vformat/vpatternrecipe.cpp +++ b/src/libs/vformat/vpatternrecipe.cpp @@ -97,8 +97,7 @@ namespace //--------------------------------------------------------------------------------------------------------------------- inline auto FileComment() -> QString { - return QStringLiteral("Recipe created with Valentina v%1 (https://smart-pattern.com.ua/).") - .arg(APP_VERSION_STR); + return QStringLiteral("Recipe created with Valentina v%1 (https://smart-pattern.com.ua/).").arg(AppVersionStr()); } //--------------------------------------------------------------------------------------------------------------------- @@ -150,7 +149,7 @@ auto VPatternRecipe::Prerequisite() -> QDomElement */ QDomElement prerequisiteElement = createElement(QStringLiteral("prerequisite")); - prerequisiteElement.appendChild(CreateElementWithText(QStringLiteral("valentina"), APP_VERSION_STR)); + prerequisiteElement.appendChild(CreateElementWithText(QStringLiteral("valentina"), AppVersionStr())); prerequisiteElement.appendChild(CreateElementWithText(QStringLiteral("unit"), UnitsToStr(VAbstractValApplication::VApp()->patternUnits()))); prerequisiteElement.appendChild(CreateElementWithText(QStringLiteral("author"), m_pattern->GetCompanyName())); diff --git a/src/libs/vformat/vwatermark.cpp b/src/libs/vformat/vwatermark.cpp index 37c7bd48a..8cd0c5119 100644 --- a/src/libs/vformat/vwatermark.cpp +++ b/src/libs/vformat/vwatermark.cpp @@ -47,7 +47,7 @@ namespace //--------------------------------------------------------------------------------------------------------------------- auto FileComment() -> QString { - return QString("Watermark created with Valentina v%1 (https://smart-pattern.com.ua/).").arg(APP_VERSION_STR); + return QString("Watermark created with Valentina v%1 (https://smart-pattern.com.ua/).").arg(AppVersionStr()); } } // namespace diff --git a/src/libs/vlayout/dialogs/vabstractlayoutdialog.cpp b/src/libs/vlayout/dialogs/vabstractlayoutdialog.cpp index 3cbfa578d..df23af027 100644 --- a/src/libs/vlayout/dialogs/vabstractlayoutdialog.cpp +++ b/src/libs/vlayout/dialogs/vabstractlayoutdialog.cpp @@ -32,26 +32,6 @@ #include -// must be the same order as PaperSizeTemplate constants -const VAbstractLayoutDialog::FormatsVector VAbstractLayoutDialog::pageFormatNames{ - QStringLiteral("A0"), - QStringLiteral("A1"), - QStringLiteral("A2"), - QStringLiteral("A3"), - QStringLiteral("A4"), - QApplication::translate("VAbstractLayoutDialog", "Letter", "Paper format"), - QApplication::translate("VAbstractLayoutDialog", "Legal", "Paper format"), - QApplication::translate("VAbstractLayoutDialog", "Tabloid", "Paper format"), - QApplication::translate("VAbstractLayoutDialog", "Roll 24in", "Paper format"), - QApplication::translate("VAbstractLayoutDialog", "Roll 30in", "Paper format"), - QApplication::translate("VAbstractLayoutDialog", "Roll 36in", "Paper format"), - QApplication::translate("VAbstractLayoutDialog", "Roll 42in", "Paper format"), - QApplication::translate("VAbstractLayoutDialog", "Roll 44in", "Paper format"), - QApplication::translate("VAbstractLayoutDialog", "Roll 48in", "Paper format"), - QApplication::translate("VAbstractLayoutDialog", "Roll 62in", "Paper format"), - QApplication::translate("VAbstractLayoutDialog", "Roll 72in", "Paper format"), - QApplication::translate("VAbstractLayoutDialog", "Custom", "Paper format")}; - //--------------------------------------------------------------------------------------------------------------------- VAbstractLayoutDialog::VAbstractLayoutDialog(QWidget *parent) : QDialog(parent) @@ -67,7 +47,7 @@ void VAbstractLayoutDialog::InitTemplates(QComboBox *comboBoxTemplates) const QString pdi = QStringLiteral("(%1ppi)").arg(PrintDPI); auto cntr = static_cast(PaperSizeTemplate::A0); - for (const auto &v : pageFormatNames) + for (const auto &v : PageFormatNames()) { if (cntr <= static_cast(PaperSizeTemplate::Tabloid)) { @@ -103,6 +83,31 @@ void VAbstractLayoutDialog::InitTileTemplates(QComboBox *comboBoxTemplates, bool } } +//--------------------------------------------------------------------------------------------------------------------- +auto VAbstractLayoutDialog::PageFormatNames() -> const VAbstractLayoutDialog::FormatsVector & +{ + // must be the same order as PaperSizeTemplate constants + static const FormatsVector pageFormatNames{ + QStringLiteral("A0"), + QStringLiteral("A1"), + QStringLiteral("A2"), + QStringLiteral("A3"), + QStringLiteral("A4"), + QApplication::translate("VAbstractLayoutDialog", "Letter", "Paper format"), + QApplication::translate("VAbstractLayoutDialog", "Legal", "Paper format"), + QApplication::translate("VAbstractLayoutDialog", "Tabloid", "Paper format"), + QApplication::translate("VAbstractLayoutDialog", "Roll 24in", "Paper format"), + QApplication::translate("VAbstractLayoutDialog", "Roll 30in", "Paper format"), + QApplication::translate("VAbstractLayoutDialog", "Roll 36in", "Paper format"), + QApplication::translate("VAbstractLayoutDialog", "Roll 42in", "Paper format"), + QApplication::translate("VAbstractLayoutDialog", "Roll 44in", "Paper format"), + QApplication::translate("VAbstractLayoutDialog", "Roll 48in", "Paper format"), + QApplication::translate("VAbstractLayoutDialog", "Roll 62in", "Paper format"), + QApplication::translate("VAbstractLayoutDialog", "Roll 72in", "Paper format"), + QApplication::translate("VAbstractLayoutDialog", "Custom", "Paper format")}; + return pageFormatNames; +} + //--------------------------------------------------------------------------------------------------------------------- auto VAbstractLayoutDialog::GetTemplateSize(PaperSizeTemplate tmpl, Unit unit) -> QSizeF { diff --git a/src/libs/vlayout/dialogs/vabstractlayoutdialog.h b/src/libs/vlayout/dialogs/vabstractlayoutdialog.h index 410b3a676..2a16cadee 100644 --- a/src/libs/vlayout/dialogs/vabstractlayoutdialog.h +++ b/src/libs/vlayout/dialogs/vabstractlayoutdialog.h @@ -71,9 +71,9 @@ public: protected: typedef QStringList FormatsVector; - const static FormatsVector pageFormatNames; typedef int VIndexType; + static auto PageFormatNames() -> const FormatsVector &; static auto RoundTemplateSize(qreal width, qreal height, Unit unit) -> QSizeF; private: diff --git a/src/libs/vmisc/literals.cpp b/src/libs/vmisc/literals.cpp index eee3f9bd3..34ba4aa5b 100644 --- a/src/libs/vmisc/literals.cpp +++ b/src/libs/vmisc/literals.cpp @@ -78,31 +78,15 @@ const QString avg_F = QStringLiteral("avg"); const QString fmod_F = QStringLiteral("fmod"); const QString warning_F = QStringLiteral("warning"); -const QStringList builInFunctions +auto BuilInFunctions() -> QStringList { - degTorad_F, radTodeg_F, - sin_F, cos_F, tan_F, - asin_F, acos_F, atan_F, - sinh_F, cosh_F, tanh_F, - asinh_F, acosh_F, atanh_F, - sinD_F, cosD_F, tanD_F, - asinD_F, acosD_F, atanD_F, - log2_F, log10_F, log_F, - ln_F, - exp_F, - sqrt_F, - sign_F, - rint_F, r2cm_F, - csrCm_F, csrInch_F, - abs_F, - min_F, max_F, - sum_F, - avg_F, - fmod_F, - warning_F -}; + return {degTorad_F, radTodeg_F, sin_F, cos_F, tan_F, asin_F, acos_F, atan_F, sinh_F, cosh_F, + tanh_F, asinh_F, acosh_F, atanh_F, sinD_F, cosD_F, tanD_F, asinD_F, acosD_F, atanD_F, + log2_F, log10_F, log_F, ln_F, exp_F, sqrt_F, sign_F, rint_F, r2cm_F, csrCm_F, + csrInch_F, abs_F, min_F, max_F, sum_F, avg_F, fmod_F, warning_F}; +} -const QString pl_size = QStringLiteral("size"); +const QString pl_size = QStringLiteral("size"); const QString pl_height = QStringLiteral("height"); const QString pl_hip = QStringLiteral("hip"); const QString pl_waist = QStringLiteral("waist"); diff --git a/src/libs/vmisc/literals.h b/src/libs/vmisc/literals.h index a0dd738f1..4ad5c560d 100644 --- a/src/libs/vmisc/literals.h +++ b/src/libs/vmisc/literals.h @@ -87,7 +87,7 @@ extern const QString avg_F; extern const QString fmod_F; extern const QString warning_F; -extern const QStringList builInFunctions; +auto BuilInFunctions() -> QStringList; // Placeholders extern const QString pl_height; diff --git a/src/libs/vmisc/projectversion.cpp b/src/libs/vmisc/projectversion.cpp index 2d530ba9e..54d3d0e58 100644 --- a/src/libs/vmisc/projectversion.cpp +++ b/src/libs/vmisc/projectversion.cpp @@ -41,8 +41,13 @@ #define LATEST_TAG_DISTANCE VCS_REPO_STATE_DISTANCE #endif -extern const QString APP_VERSION_STR( - QStringLiteral("%1.%2.%3.%4").arg(MAJOR_VERSION).arg(MINOR_VERSION).arg(DEBUG_VERSION).arg(LATEST_TAG_DISTANCE)); +//--------------------------------------------------------------------------------------------------------------------- +auto AppVersionStr() -> const QString & +{ + static const QString appVersionStr = + QStringLiteral("%1.%2.%3.%4").arg(MAJOR_VERSION).arg(MINOR_VERSION).arg(DEBUG_VERSION).arg(LATEST_TAG_DISTANCE); + return appVersionStr; +} //--------------------------------------------------------------------------------------------------------------------- auto compilerString() -> QString diff --git a/src/libs/vmisc/projectversion.h b/src/libs/vmisc/projectversion.h index 459d3c307..9460ccc24 100644 --- a/src/libs/vmisc/projectversion.h +++ b/src/libs/vmisc/projectversion.h @@ -35,7 +35,7 @@ constexpr unsigned MAJOR_VERSION = 0; constexpr unsigned MINOR_VERSION = 7; constexpr unsigned DEBUG_VERSION = 52; -extern const QString APP_VERSION_STR; +auto AppVersionStr() -> const QString &; constexpr inline auto FormatVersion(unsigned major, unsigned minor, unsigned patch) -> unsigned { diff --git a/src/libs/vpatterndb/vcontainer.cpp b/src/libs/vpatterndb/vcontainer.cpp index b9d1192cb..4de9c7a37 100644 --- a/src/libs/vpatterndb/vcontainer.cpp +++ b/src/libs/vpatterndb/vcontainer.cpp @@ -668,7 +668,7 @@ auto VContainer::IsUnique(const QString &name, const QString &nspace) -> bool { if (uniqueNames.contains(nspace)) { - return (!uniqueNames.value(nspace).contains(name) && !builInFunctions.contains(name)); + return (!uniqueNames.value(nspace).contains(name) && !BuilInFunctions().contains(name)); } else { @@ -687,7 +687,7 @@ auto VContainer::AllUniqueNames(const QString &nspace) -> QStringList { if (uniqueNames.contains(nspace)) { - QStringList names = builInFunctions; + QStringList names = BuilInFunctions(); names.append(uniqueNames.value(nspace).values()); return names; } diff --git a/src/test/TranslationsTest/tst_buitinregexp.cpp b/src/test/TranslationsTest/tst_buitinregexp.cpp index 938283a94..dc99b04f2 100644 --- a/src/test/TranslationsTest/tst_buitinregexp.cpp +++ b/src/test/TranslationsTest/tst_buitinregexp.cpp @@ -173,8 +173,8 @@ void TST_BuitInRegExp::TestCheckUnderlineExists_data() data.insert(pieceArea_, true); data.insert(pieceSeamLineArea_, true); - //Catch case when new internal variable appears. - QCOMPARE(data.size(), builInVariables.size()); + // Catch case when new internal variable appears. + QCOMPARE(data.size(), BuilInVariables().size()); QTest::addColumn("name"); QTest::addColumn("exists"); @@ -209,7 +209,7 @@ void TST_BuitInRegExp::TestCheckInternalVaribleRegExp_data() QTest::addColumn("var"); QTest::addColumn("originalName"); - for (const auto &var : qAsConst(builInVariables)) + for (const auto &var : BuilInVariables()) { const QString tag = QString("Locale: '%1'. Var '%2'").arg(m_locale, var); const QStringList originalNames = AllNames(); @@ -286,5 +286,5 @@ void TST_BuitInRegExp::PrepareData() //--------------------------------------------------------------------------------------------------------------------- auto TST_BuitInRegExp::AllNames() -> QStringList { - return builInFunctions + builInVariables; + return BuilInFunctions() + BuilInVariables(); }