From d6653ca9afd27e7002635b6bbaae67479b82fc85 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Fri, 23 Oct 2015 20:47:33 +0300 Subject: [PATCH] Successful build with MSVC 2012. --HG-- branch : develop --- src/app/tape/tmainwindow.h | 2 +- src/app/valentina/core/vapplication.cpp | 5 +- src/app/valentina/core/vapplication.h | 2 +- src/app/valentina/core/vcmdexport.cpp | 263 +++++++++--------- src/app/valentina/core/vcmdexport.h | 2 + .../dialogs/dialoglayoutsettings.cpp | 37 +-- .../valentina/dialogs/dialoglayoutsettings.h | 16 +- .../valentina/dialogs/dialogsavelayout.cpp | 67 +++-- src/app/valentina/dialogs/dialogsavelayout.h | 47 +--- src/app/valentina/mainwindow.h | 2 +- src/app/valentina/xml/vpattern.cpp | 3 +- src/libs/qmuparser/qmudef.h | 2 +- src/libs/vlayout/vbank.h | 12 + src/libs/vmisc/def.cpp | 24 +- src/libs/vmisc/projectversion.cpp | 2 +- src/libs/vmisc/vlockguard.h | 10 +- src/libs/vmisc/vsysexits.h | 46 +-- src/libs/vobj/{delaunay.c => delaunay.cpp} | 13 +- .../vobj/{predicates.c => predicates.cpp} | 12 +- src/libs/vobj/vobj.pri | 6 +- .../vpropertyexplorer/checkablemessagebox.h | 5 +- src/test/ValentinaTest/abstracttest.h | 10 +- 22 files changed, 312 insertions(+), 276 deletions(-) rename src/libs/vobj/{delaunay.c => delaunay.cpp} (98%) rename src/libs/vobj/{predicates.c => predicates.cpp} (99%) diff --git a/src/app/tape/tmainwindow.h b/src/app/tape/tmainwindow.h index 9cbe6530d..1f822e442 100644 --- a/src/app/tape/tmainwindow.h +++ b/src/app/tape/tmainwindow.h @@ -137,7 +137,7 @@ private: QComboBox *gradationSizes; QComboBox *comboBoxUnits; int formulaBaseHeight; - VLockGuardPtr lock; + std::shared_ptr> lock; QSharedPointer search; QLabel *labelGradationHeights; QLabel *labelGradationSizes; diff --git a/src/app/valentina/core/vapplication.cpp b/src/app/valentina/core/vapplication.cpp index d9f76bdfb..11c1d3632 100644 --- a/src/app/valentina/core/vapplication.cpp +++ b/src/app/valentina/core/vapplication.cpp @@ -68,7 +68,7 @@ Q_LOGGING_CATEGORY(vApp, "v.application") #pragma warning( pop ) #endif -constexpr auto DAYS_TO_KEEP_LOGS = 3; +Q_DECL_CONSTEXPR auto DAYS_TO_KEEP_LOGS = 3; //--------------------------------------------------------------------------------------------------------------------- inline void noisyFailureMsgHandler(QtMsgType type, const QMessageLogContext &context, const QString &msg) @@ -503,9 +503,8 @@ void VApplication::BeginLogging() //--------------------------------------------------------------------------------------------------------------------- void VApplication::ClearOldLogs() const { - QStringList filters{"*.log"}; QDir logsDir(LogDirPath()); - logsDir.setNameFilters(filters); + logsDir.setNameFilters(QStringList("*.log")); logsDir.setCurrent(LogDirPath()); const QStringList allFiles = logsDir.entryList(QDir::NoDotAndDotDot | QDir::Files); diff --git a/src/app/valentina/core/vapplication.h b/src/app/valentina/core/vapplication.h index a2f658b0f..60b14d573 100644 --- a/src/app/valentina/core/vapplication.h +++ b/src/app/valentina/core/vapplication.h @@ -96,7 +96,7 @@ private: VTranslateVars *trVars; QTimer *autoSaveTimer; - VLockGuardPtr lockLog; + std::shared_ptr> lockLog; std::shared_ptr out; void InitLineWidth(); diff --git a/src/app/valentina/core/vcmdexport.cpp b/src/app/valentina/core/vcmdexport.cpp index a0bbb3d84..b93685aee 100644 --- a/src/app/valentina/core/vcmdexport.cpp +++ b/src/app/valentina/core/vcmdexport.cpp @@ -65,131 +65,8 @@ const static auto SINGLE_OPTION_GRADATIONHEIGHT = QStringLiteral("e"); #define translate(context, source) QCoreApplication::translate((context), (source)) -//such a tricky initialization is used, because it uses static functions which relay on static variables and order of -//initialization is not defined between compiled units. i.e. - segv is possible (I hit it when -//VDomDocument::UnitsHelpString() was crashing because of not inited string vars). //--------------------------------------------------------------------------------------------------------------------- -VCommandLine::VCommandLine() : parser() - , optionsUsed ({ - //keep in mind order here - that is how user will see it, so group-up for usability - //=================================================================================== - - {LONG_OPTION_BASENAME, - new QCommandLineOption(QStringList() << SINGLE_OPTION_BASENAME << LONG_OPTION_BASENAME, - translate("VCommandLine", "The base filename of exported layout files. Use it to " - "enable console export mode."), - translate("VCommandLine", "The base filename of layout files"))}, - - {LONG_OPTION_DESTINATION, - new QCommandLineOption(QStringList() << SINGLE_OPTION_DESTINATION << LONG_OPTION_DESTINATION, - translate("VCommandLine", "The path to output destination folder."), - translate("VCommandLine", "The destination folder"))}, - - {LONG_OPTION_MEASUREFILE, - new QCommandLineOption(QStringList() << SINGLE_OPTION_MEASUREFILE << LONG_OPTION_MEASUREFILE, - translate("VCommandLine", "Path to custom measure file (export mode)."), - translate("VCommandLine", "The measure file"))}, - - {LONG_OPTION_EXP2FORMAT, - new QCommandLineOption(QStringList() << SINGLE_OPTION_EXP2FORMAT << LONG_OPTION_EXP2FORMAT, - translate("VCommandLine", "Number corresponding to output format (default = 0, " - "export mode): ") + DialogSaveLayout::MakeHelpFormatList(), - translate("VCommandLine", "Format number"), "0")}, - - {LONG_OPTION_GRADATIONSIZE, - new QCommandLineOption(QStringList() << SINGLE_OPTION_GRADATIONSIZE << LONG_OPTION_GRADATIONSIZE, - translate("VCommandLine", "Set size value a pattern file, that was opened with " - "standard measurements (export mode). Valid values: %1cm.") - .arg(VMeasurement::WholeListSizes(Unit::Cm).join(", ")), - translate("VCommandLine", "The size value"))}, - - {LONG_OPTION_GRADATIONHEIGHT, - new QCommandLineOption(QStringList() << SINGLE_OPTION_GRADATIONHEIGHT << LONG_OPTION_GRADATIONHEIGHT, - translate("VCommandLine", "Set height value a pattern file, that was opened with " - "standard measurements (export mode). Valid values: %1cm.") - .arg(VMeasurement::WholeListHeights(Unit::Cm).join(", ")), - translate("VCommandLine", "The height value"))}, - - //=================================================================================== - - {LONG_OPTION_PAGETEMPLATE, - new QCommandLineOption(QStringList() << SINGLE_OPTION_PAGETEMPLATE << LONG_OPTION_PAGETEMPLATE, - translate("VCommandLine", "Number corresponding to page template (default = 0, " - "export mode): ") + DialogLayoutSettings::MakeHelpTemplateList(), - translate("VCommandLine", "Template number"), "0")}, - - - {LONG_OPTION_PAGEW, - new QCommandLineOption(QStringList() << SINGLE_OPTION_PAGEW << LONG_OPTION_PAGEW, - translate("VCommandLine", "Page width in current units like 12.0 (cannot be used " - "with \"%1\", export mode).").arg(LONG_OPTION_PAGETEMPLATE), - translate("VCommandLine", "The page width"))}, - - {LONG_OPTION_PAGEH, - new QCommandLineOption(QStringList() << SINGLE_OPTION_PAGEH << LONG_OPTION_PAGEH, - translate("VCommandLine", "Page height in current units like 12.0 (cannot be used " - "with \"%1\", export mode).").arg(LONG_OPTION_PAGETEMPLATE), - ("The page height"))}, - - {LONG_OPTION_PAGEUNITS, - new QCommandLineOption(QStringList() << SINGLE_OPTION_PAGEUNITS << LONG_OPTION_PAGEUNITS, - translate("VCommandLine", "Page height/width measure units (cannot be used " - "with \"%1\", export mode): ") - .arg(LONG_OPTION_PAGETEMPLATE) + VDomDocument::UnitsHelpString(), - translate("VCommandLine", "The measure unit"))}, - - //=================================================================================== - - {LONG_OPTION_ROTATE, - new QCommandLineOption(QStringList() << SINGLE_OPTION_ROTATE << LONG_OPTION_ROTATE, - translate("VCommandLine", "Rotation in degrees (one of predefined). Default (or " - "0) is no-rotate (export mode)."), - translate("VCommandLine", "Angle"))}, - - {LONG_OPTION_CROP, - new QCommandLineOption(QStringList() << SINGLE_OPTION_CROP << LONG_OPTION_CROP, - translate("VCommandLine", "Auto crop unused length (export mode)."))}, - - {LONG_OPTION_UNITE, - new QCommandLineOption(QStringList() << SINGLE_OPTION_UNITE << LONG_OPTION_UNITE, - translate("VCommandLine", "Unite pages if possible (export mode)."))}, - - //=================================================================================== - - {LONG_OPTION_SAVELENGTH, - new QCommandLineOption(QStringList() << SINGLE_OPTION_SAVELENGTH << LONG_OPTION_SAVELENGTH, - translate("VCommandLine", "Save length of the sheet if set. (export mode)."))}, - - {LONG_OPTION_SHIFTUNITS, - new QCommandLineOption(QStringList() << SINGLE_OPTION_SHIFTUNITS << LONG_OPTION_SHIFTUNITS, - translate("VCommandLine", "Layout units (as paper's one except px, export mode)."), - translate("VCommandLine", "The unit"))}, - - {LONG_OPTION_SHIFTLENGTH, - new QCommandLineOption(QStringList() << SINGLE_OPTION_SHIFTLENGTH << LONG_OPTION_SHIFTLENGTH, - translate("VCommandLine", "Shift layout length measured in layout units (export " - "mode)."), - translate("VCommandLine", "Shift length"))}, - - {LONG_OPTION_GAPWIDTH, - new QCommandLineOption(QStringList() << SINGLE_OPTION_GAPWIDTH << LONG_OPTION_GAPWIDTH, - translate("VCommandLine", "Gap width x2, measured in layout units. (export mode)."), - translate("VCommandLine", "The gap width"))}, - - {LONG_OPTION_GROUPPING, - new QCommandLineOption(QStringList() << SINGLE_OPTION_GROUPPING << LONG_OPTION_GROUPPING, - translate("VCommandLine", "Sets layout groupping (export mode): ") - + DialogLayoutSettings::MakeGroupsHelp(), - translate("VCommandLine", "Grouping type"), "2")}, - - {LONG_OPTION_TEST, - new QCommandLineOption(QStringList() << SINGLE_OPTION_TEST << LONG_OPTION_TEST, - translate("VCommandLine", "Run the program in a test mode. The program this mode " - "load a single pattern file and silently quit without showing the main " - "window. The key have priority before key '%1'.") - .arg(LONG_OPTION_BASENAME))} - }), - isGuiEnabled(false) +VCommandLine::VCommandLine() : parser(), optionsUsed(InitOptionsUsed()), isGuiEnabled(false) { parser.setApplicationDescription(translate("VCommandLine", "Pattern making program.")); parser.addHelpOption(); @@ -204,7 +81,7 @@ VCommandLine::VCommandLine() : parser() } } -//------------------------------------------------------------------------------------------------------ +//--------------------------------------------------------------------------------------------------------------------- int VCommandLine::Lo2Px(const QString &src, const DialogLayoutSettings &converter) { //that is dirty-dirty hack ...eventually number is converted float <--> int 3 or 4 times including inside dialog ... @@ -212,12 +89,146 @@ int VCommandLine::Lo2Px(const QString &src, const DialogLayoutSettings &converte return converter.LayoutToPixels(src.toFloat()); } -//------------------------------------------------------------------------------------------------------ +//--------------------------------------------------------------------------------------------------------------------- int VCommandLine::Pg2Px(const QString& src, const DialogLayoutSettings& converter) { return converter.PageToPixels(src.toFloat()); } +//--------------------------------------------------------------------------------------------------------------------- +QMap VCommandLine::InitOptionsUsed() +{ + QMap options; + + //keep in mind order here - that is how user will see it, so group-up for usability + //================================================================================================================= + options.insert(LONG_OPTION_BASENAME, + new QCommandLineOption(QStringList() << SINGLE_OPTION_BASENAME << LONG_OPTION_BASENAME, + translate("VCommandLine", "The base filename of exported layout files. Use " + "it to enable console export mode."), + translate("VCommandLine", "The base filename of layout files"))); + + options.insert(LONG_OPTION_DESTINATION, + new QCommandLineOption(QStringList() << SINGLE_OPTION_DESTINATION << LONG_OPTION_DESTINATION, + translate("VCommandLine", "The path to output destination folder."), + translate("VCommandLine", "The destination folder"))); + + options.insert(LONG_OPTION_MEASUREFILE, + new QCommandLineOption(QStringList() << SINGLE_OPTION_MEASUREFILE << LONG_OPTION_MEASUREFILE, + translate("VCommandLine", "Path to custom measure file (export mode)."), + translate("VCommandLine", "The measure file"))); + + options.insert(LONG_OPTION_EXP2FORMAT, + new QCommandLineOption(QStringList() << SINGLE_OPTION_EXP2FORMAT << LONG_OPTION_EXP2FORMAT, + translate("VCommandLine", "Number corresponding to output format (default = " + "0, export mode): ") + + DialogSaveLayout::MakeHelpFormatList(), + translate("VCommandLine", "Format number"), "0")); + + options.insert(LONG_OPTION_GRADATIONSIZE, + new QCommandLineOption(QStringList() << SINGLE_OPTION_GRADATIONSIZE << LONG_OPTION_GRADATIONSIZE, + translate("VCommandLine", "Set size value a pattern file, that was opened " + "with standard measurements (export mode). Valid " + "values: %1cm.") + .arg(VMeasurement::WholeListSizes(Unit::Cm).join(", ")), + translate("VCommandLine", "The size value"))); + + options.insert(LONG_OPTION_GRADATIONHEIGHT, + new QCommandLineOption(QStringList() << SINGLE_OPTION_GRADATIONHEIGHT << LONG_OPTION_GRADATIONHEIGHT, + translate("VCommandLine", "Set height value a pattern file, that was opened " + "with standard measurements (export mode). Valid " + "values: %1cm.") + .arg(VMeasurement::WholeListHeights(Unit::Cm).join(", ")), + translate("VCommandLine", "The height value"))); + + //================================================================================================================= + + options.insert(LONG_OPTION_PAGETEMPLATE, + new QCommandLineOption(QStringList() << SINGLE_OPTION_PAGETEMPLATE << LONG_OPTION_PAGETEMPLATE, + translate("VCommandLine", "Number corresponding to page template (default = " + "0, export mode): ") + + DialogLayoutSettings::MakeHelpTemplateList(), + translate("VCommandLine", "Template number"), "0")); + + + options.insert(LONG_OPTION_PAGEW, + new QCommandLineOption(QStringList() << SINGLE_OPTION_PAGEW << LONG_OPTION_PAGEW, + translate("VCommandLine", "Page width in current units like 12.0 (cannot be " + "used with \"%1\", export mode).") + .arg(LONG_OPTION_PAGETEMPLATE), + translate("VCommandLine", "The page width"))); + + options.insert(LONG_OPTION_PAGEH, + new QCommandLineOption(QStringList() << SINGLE_OPTION_PAGEH << LONG_OPTION_PAGEH, + translate("VCommandLine", "Page height in current units like 12.0 (cannot " + "be used with \"%1\", export mode).") + .arg(LONG_OPTION_PAGETEMPLATE), + ("The page height"))); + + options.insert(LONG_OPTION_PAGEUNITS, + new QCommandLineOption(QStringList() << SINGLE_OPTION_PAGEUNITS << LONG_OPTION_PAGEUNITS, + translate("VCommandLine", "Page height/width measure units (cannot be used " + "with \"%1\", export mode): ") + .arg(LONG_OPTION_PAGETEMPLATE) + VDomDocument::UnitsHelpString(), + translate("VCommandLine", "The measure unit"))); + + //================================================================================================================= + + options.insert(LONG_OPTION_ROTATE, + new QCommandLineOption(QStringList() << SINGLE_OPTION_ROTATE << LONG_OPTION_ROTATE, + translate("VCommandLine", "Rotation in degrees (one of predefined). Default " + "(or 0) is no-rotate (export mode)."), + translate("VCommandLine", "Angle"))); + + options.insert(LONG_OPTION_CROP, + new QCommandLineOption(QStringList() << SINGLE_OPTION_CROP << LONG_OPTION_CROP, + translate("VCommandLine", "Auto crop unused length (export mode)."))); + + options.insert(LONG_OPTION_UNITE, + new QCommandLineOption(QStringList() << SINGLE_OPTION_UNITE << LONG_OPTION_UNITE, + translate("VCommandLine", "Unite pages if possible (export mode)."))); + + //================================================================================================================= + + options.insert(LONG_OPTION_SAVELENGTH, + new QCommandLineOption(QStringList() << SINGLE_OPTION_SAVELENGTH << LONG_OPTION_SAVELENGTH, + translate("VCommandLine", + "Save length of the sheet if set. (export mode)."))); + + options.insert(LONG_OPTION_SHIFTUNITS, + new QCommandLineOption(QStringList() << SINGLE_OPTION_SHIFTUNITS << LONG_OPTION_SHIFTUNITS, + translate("VCommandLine", + "Layout units (as paper's one except px, export mode)."), + translate("VCommandLine", "The unit"))); + + options.insert(LONG_OPTION_SHIFTLENGTH, + new QCommandLineOption(QStringList() << SINGLE_OPTION_SHIFTLENGTH << LONG_OPTION_SHIFTLENGTH, + translate("VCommandLine", "Shift layout length measured in layout units " + "(export mode)."), + translate("VCommandLine", "Shift length"))); + + options.insert(LONG_OPTION_GAPWIDTH, + new QCommandLineOption(QStringList() << SINGLE_OPTION_GAPWIDTH << LONG_OPTION_GAPWIDTH, + translate("VCommandLine", + "Gap width x2, measured in layout units. (export mode)."), + translate("VCommandLine", "The gap width"))); + + options.insert(LONG_OPTION_GROUPPING, + new QCommandLineOption(QStringList() << SINGLE_OPTION_GROUPPING << LONG_OPTION_GROUPPING, + translate("VCommandLine", "Sets layout groupping (export mode): ") + + DialogLayoutSettings::MakeGroupsHelp(), + translate("VCommandLine", "Grouping type"), "2")); + + options.insert(LONG_OPTION_TEST, + new QCommandLineOption(QStringList() << SINGLE_OPTION_TEST << LONG_OPTION_TEST, + translate("VCommandLine", "Run the program in a test mode. The program this " + "mode load a single pattern file and silently " + "quit without showing the main window. The key " + "have priority before key '%1'.") + .arg(LONG_OPTION_BASENAME))); + return options; +} + //------------------------------------------------------------------------------------------------------ VLayoutGeneratorPtr VCommandLine::DefaultGenerator() const { diff --git a/src/app/valentina/core/vcmdexport.h b/src/app/valentina/core/vcmdexport.h index 7baa66011..1254fa38a 100644 --- a/src/app/valentina/core/vcmdexport.h +++ b/src/app/valentina/core/vcmdexport.h @@ -87,6 +87,8 @@ private: static int Lo2Px(const QString& src, const DialogLayoutSettings& converter); static int Pg2Px(const QString& src, const DialogLayoutSettings& converter); + + static QMap InitOptionsUsed(); }; #endif // VCMDEXPORT_H diff --git a/src/app/valentina/dialogs/dialoglayoutsettings.cpp b/src/app/valentina/dialogs/dialoglayoutsettings.cpp index 5990dab8f..d99d6f449 100644 --- a/src/app/valentina/dialogs/dialoglayoutsettings.cpp +++ b/src/app/valentina/dialogs/dialoglayoutsettings.cpp @@ -31,7 +31,6 @@ #include "../core/vapplication.h" #include "../ifc/xml/vdomdocument.h" #include "../vmisc/vsettings.h" -#include #if QT_VERSION < QT_VERSION_CHECK(5, 1, 0) # include "../vmisc/vmath.h" @@ -42,20 +41,19 @@ #include //must be the same order as PaperSizeTemplate constants -const DialogLayoutSettings::FormatsVector DialogLayoutSettings::pageFormatNames={ - "A0", - "A1", - "A2", - "A3", - "A4", - tr("Letter"), - tr("Legal"), - tr("Roll 24in"), - tr("Roll 30in"), - tr("Roll 36in"), - tr("Roll 42in"), - tr("Roll 44in"), -}; +const DialogLayoutSettings::FormatsVector DialogLayoutSettings::pageFormatNames = + DialogLayoutSettings::FormatsVector () << QLatin1Literal("A0") + << QLatin1Literal("A1") + << QLatin1Literal("A2") + << QLatin1Literal("A3") + << QLatin1Literal("A4") + << QApplication::translate("DialogLayoutSettings", "Letter") + << QApplication::translate("DialogLayoutSettings", "Legal") + << QApplication::translate("DialogLayoutSettings", "Roll 24in") + << QApplication::translate("DialogLayoutSettings", "Roll 30in") + << QApplication::translate("DialogLayoutSettings", "Roll 36in") + << QApplication::translate("DialogLayoutSettings", "Roll 42in") + << QApplication::translate("DialogLayoutSettings", "Roll 44in"); //--------------------------------------------------------------------------------------------------------------------- DialogLayoutSettings::DialogLayoutSettings(VLayoutGenerator *generator, QWidget *parent, bool disableSettings) @@ -481,7 +479,14 @@ void DialogLayoutSettings::InitTemplates() auto cntr = static_cast(PaperSizeTemplate::A0); foreach(const auto& v, pageFormatNames) { - ui->comboBoxTemplates->addItem(icoPaper, v+" "+pdi, QVariant(cntr++)); + if (cntr <= 6) + { + ui->comboBoxTemplates->addItem(icoPaper, v+" "+pdi, QVariant(cntr++)); + } + else + { + ui->comboBoxTemplates->addItem(icoRoll, v+" "+pdi, QVariant(cntr++)); + } } ui->comboBoxTemplates->setCurrentIndex(-1); } diff --git a/src/app/valentina/dialogs/dialoglayoutsettings.h b/src/app/valentina/dialogs/dialoglayoutsettings.h index c2b8b8d3d..17b54b2e2 100644 --- a/src/app/valentina/dialogs/dialoglayoutsettings.h +++ b/src/app/valentina/dialogs/dialoglayoutsettings.h @@ -47,8 +47,18 @@ class DialogLayoutSettings : public QDialog { Q_OBJECT public: - enum class PaperSizeTemplate : char { A0 = 0, A1, A2, A3, A4, Letter, Legal, Roll24in, Roll30in, Roll36in, Roll42in, - Roll44in}; + enum class PaperSizeTemplate : char { A0 = 0, + A1, + A2, + A3, + A4, + Letter, + Legal, + Roll24in = 7, // Be carefull when change order roll type + Roll30in, // Used also for showing icon + Roll36in, + Roll42in, + Roll44in = 11}; explicit DialogLayoutSettings(VLayoutGenerator *generator, QWidget *parent = nullptr, bool disableSettings = false); ~DialogLayoutSettings(); @@ -103,7 +113,7 @@ public slots: private: Q_DISABLE_COPY(DialogLayoutSettings) - typedef std::vector FormatsVector; + typedef QStringList FormatsVector; typedef int VIndexType; const static FormatsVector pageFormatNames; diff --git a/src/app/valentina/dialogs/dialogsavelayout.cpp b/src/app/valentina/dialogs/dialogsavelayout.cpp index 0e1301aa0..48f5e0b6c 100644 --- a/src/app/valentina/dialogs/dialogsavelayout.cpp +++ b/src/app/valentina/dialogs/dialogsavelayout.cpp @@ -39,28 +39,14 @@ #include #include -using namespace nm_DialogSaveLayout; - const QString baseFilenameRegExp = QStringLiteral("^[\\w\\-. ]+$"); -bool VFrmWithTest::havePdf = false; -bool VFrmWithTest::tested = false; - -const std::vector DialogSaveLayout::availFormats = -{ - VFrmWithTest(tr("Svg files (*.svg)"), ".svg"), - VFrmWithTest(tr("PDF files (*.pdf)"), ".pdf"), - VFrmWithTest(tr("Images (*.png)"), ".png"), - VFrmWithTest(tr("Wavefront OBJ (*.obj)"), ".obj"), - VFrmWithTest(tr("PS files (*.ps)"), ".ps", 1), //fixme: use 1 to have exe once tested on 1st run, or any other value to test always as original do - VFrmWithTest(tr("EPS files (*.eps)"), ".eps", 1), - VFrmWithTest(tr("DXF files (*.dxf)"), ".dxf"), -}; - +bool DialogSaveLayout::havePdf = false; +bool DialogSaveLayout::tested = false; //--------------------------------------------------------------------------------------------------------------------- DialogSaveLayout::DialogSaveLayout(int count, const QString &fileName, QWidget *parent) - :QDialog(parent), ui(new Ui::DialogSaveLAyout), count(count) + :QDialog(parent), ui(new Ui::DialogSaveLAyout), count(count), availFormats(InitAvailFormats()) { ui->setupUi(this); @@ -96,10 +82,7 @@ DialogSaveLayout::DialogSaveLayout(int count, const QString &fileName, QWidget * foreach (auto& v , availFormats) { - if (v.test()) - { - ui->comboBoxFormat->addItem(v.pair.first, QVariant(v.pair.second)); - } + ui->comboBoxFormat->addItem(v.first, QVariant(v.second)); } connect(bOk, &QPushButton::clicked, this, &DialogSaveLayout::Save); connect(ui->lineEditFileName, &QLineEdit::textChanged, this, &DialogSaveLayout::ShowExample); @@ -116,7 +99,7 @@ DialogSaveLayout::DialogSaveLayout(int count, const QString &fileName, QWidget * } //--------------------------------------------------------------------------------------------------------------------- -void DialogSaveLayout::SelectFormate(const size_t formate) +void DialogSaveLayout::SelectFormate(const int formate) { if (formate >= availFormats.size()) { @@ -124,7 +107,7 @@ void DialogSaveLayout::SelectFormate(const size_t formate) throw e; } - const int i = ui->comboBoxFormat->findData(availFormats[formate].pair.second); + const int i = ui->comboBoxFormat->findData(availFormats.at(formate).second); if (i < 0) { VException e(tr("Selected not present format.")); @@ -138,12 +121,10 @@ QString DialogSaveLayout::MakeHelpFormatList() { QString out = "\n"; int cntr = 0; + const QVector> availFormats = InitAvailFormats(); foreach(auto& v, availFormats) { - if (v.test()) - { - out += "\t"+v.pair.first+" = "+ QString::number(cntr++)+"\n"; - } + out += "\t"+v.first+" = "+ QString::number(cntr++)+"\n"; } return out; } @@ -264,9 +245,20 @@ void DialogSaveLayout::PathChanged(const QString &text) ui->lineEditPath->setPalette(palette); } -//--------------------------------------------------------------------------------------------------------------------- -bool VFrmWithTest::TestPdf() +//--------------------------------------------------------------------------------------------------------------------- +bool DialogSaveLayout::SupportPSTest() +{ + if (!tested) + { + havePdf = TestPdf(); + tested = true; + } + return havePdf; +} + +//--------------------------------------------------------------------------------------------------------------------- +bool DialogSaveLayout::TestPdf() { bool res = false; @@ -286,3 +278,20 @@ bool VFrmWithTest::TestPdf() } return res; } + +//--------------------------------------------------------------------------------------------------------------------- +QVector> DialogSaveLayout::InitAvailFormats() +{ + QVector> list; + list.append(std::make_pair(tr("Svg files (*.svg)"), QLatin1Literal(".svg"))); + list.append(std::make_pair(tr("PDF files (*.pdf)"), QLatin1Literal(".pdf"))); + list.append(std::make_pair(tr("Images (*.png)"), QLatin1Literal(".png"))); + list.append(std::make_pair(tr("Wavefront OBJ (*.obj)"), QLatin1Literal(".obj"))); + if (SupportPSTest()) + { + list.append(std::make_pair(tr("PS files (*.ps)"), QLatin1Literal(".ps"))); + list.append(std::make_pair(tr("EPS files (*.eps)"), QLatin1Literal(".eps"))); + } + list.append(std::make_pair(tr("DXF files (*.dxf)"), QLatin1Literal(".dxf"))); + return list; +} diff --git a/src/app/valentina/dialogs/dialogsavelayout.h b/src/app/valentina/dialogs/dialogsavelayout.h index bd82d196b..c06d9265a 100644 --- a/src/app/valentina/dialogs/dialogsavelayout.h +++ b/src/app/valentina/dialogs/dialogsavelayout.h @@ -36,43 +36,6 @@ #else # define PDFTOPS "pdftops" #endif -#include -#include - -namespace nm_DialogSaveLayout -{ - struct VFrmWithTest //could declare inside dialog class, but using namespace shorter to write and understand - { - typedef std::function test_func; - const std::pair pair; - const test_func test; - - VFrmWithTest(const QString& v1, const QString& v2) - :pair(std::make_pair(v1,v2)), - test([](){return true;}) - { - } - - VFrmWithTest(const QString& v1, const QString& v2, int dummy) - :pair(std::make_pair(v1,v2)), test((dummy != 1 )?TestPdf:VFrmWithTest::SingleTest) - { - } - private: - static bool havePdf; - static bool tested; - - static bool TestPdf(); - static bool SingleTest() - { - if (!tested) - { - havePdf = TestPdf(); - tested = true; - } - return havePdf; - } - }; -} namespace Ui { @@ -91,7 +54,7 @@ public: QString Path() const; QString FileName() const; QString Formate() const; - void SelectFormate(const size_t formate); + void SelectFormate(const int formate); static QString MakeHelpFormatList(); void SetDestinationPath(const QString& cmdDestinationPath); public slots: @@ -101,10 +64,16 @@ public slots: void PathChanged(const QString &text); private: - const static std::vector availFormats; Q_DISABLE_COPY(DialogSaveLayout) Ui::DialogSaveLAyout *ui; int count; + // Note. We can't make availFormats static because MSVC doesn't support C++11 list initialization + QVector> availFormats; + static bool havePdf; + static bool tested; + static bool SupportPSTest(); + static bool TestPdf(); + static QVector > InitAvailFormats(); }; #endif // DIALOGSAVELAYOUT_H diff --git a/src/app/valentina/mainwindow.h b/src/app/valentina/mainwindow.h index e77635485..d633f9986 100644 --- a/src/app/valentina/mainwindow.h +++ b/src/app/valentina/mainwindow.h @@ -231,7 +231,7 @@ private: QPointer gradationHeightsLabel; QPointer gradationSizesLabel; VToolOptionsPropertyBrowser *toolOptions; - VLockGuardPtr lock; + std::shared_ptr> lock; void ToolBarOption(); void ToolBarStages(); diff --git a/src/app/valentina/xml/vpattern.cpp b/src/app/valentina/xml/vpattern.cpp index 67bcbe8df..8743240f7 100644 --- a/src/app/valentina/xml/vpattern.cpp +++ b/src/app/valentina/xml/vpattern.cpp @@ -2184,8 +2184,7 @@ void VPattern::ParseToolsElement(VMainGraphicsScene *scene, const QDomElement &d Q_ASSERT_X(domElement.isNull() == false, Q_FUNC_INFO, "domElement is null"); Q_ASSERT_X(type.isEmpty() == false, Q_FUNC_INFO, "type of spline is empty"); - QStringList tools{VToolUnionDetails::ToolType}; - + const QStringList tools = QStringList() << VToolUnionDetails::ToolType; switch (tools.indexOf(type)) { case 0: //VToolUnionDetails::ToolType diff --git a/src/libs/qmuparser/qmudef.h b/src/libs/qmuparser/qmudef.h index 6badee71f..39addb376 100644 --- a/src/libs/qmuparser/qmudef.h +++ b/src/libs/qmuparser/qmudef.h @@ -32,7 +32,7 @@ #endif //--------------------------------------------------------------------------------------------------------------------- -QMUPARSERSHARED_EXPORT inline QString NameRegExp() +inline QString NameRegExp() { //Same regexp in pattern.xsd shema file. Don't forget synchronize. return QStringLiteral("^([^0-9*/^+\\-=\\s()?%:;!.,`'\"]){1,1}([^*/^+\\-=\\s()?%:;!.,`'\"]){0,}$"); diff --git a/src/libs/vlayout/vbank.h b/src/libs/vlayout/vbank.h index 79f04e680..9987b1f67 100644 --- a/src/libs/vlayout/vbank.h +++ b/src/libs/vlayout/vbank.h @@ -33,6 +33,14 @@ #include #include +// An annoying char define, from the Windows team in +// #define small char +// http://stuartjames.info/Journal/c--visual-studio-2012-vs2012--win8--converting-projects-up-some-conflicts-i-found.aspx +#if defined (Q_OS_WIN) && defined (Q_CC_MSVC) +#pragma push_macro("small") +#undef small +#endif + class QPointF; class VLayoutDetail; @@ -92,4 +100,8 @@ private: void BiggestBoundingRect(); }; +#if defined (Q_OS_WIN) && defined (Q_CC_MSVC) +#pragma pop_macro("small") +#endif + #endif // VBANK_H diff --git a/src/libs/vmisc/def.cpp b/src/libs/vmisc/def.cpp index 3915fe14a..eef9ab839 100644 --- a/src/libs/vmisc/def.cpp +++ b/src/libs/vmisc/def.cpp @@ -929,18 +929,18 @@ QStringList ListGroupQ() //--------------------------------------------------------------------------------------------------------------------- QStringList SupportedLocales() { - const QStringList locales = {QStringLiteral("ru_RU"), - QStringLiteral("uk_UA"), - QStringLiteral("de_DE"), - QStringLiteral("cs_CZ"), - QStringLiteral("he_IL"), - QStringLiteral("fr_FR"), - QStringLiteral("it_IT"), - QStringLiteral("nl_NL"), - QStringLiteral("id_ID"), - QStringLiteral("es_ES"), - QStringLiteral("fi_FI"), - QStringLiteral("en_US")}; + const QStringList locales = QStringList() << QStringLiteral("ru_RU") + << QStringLiteral("uk_UA") + << QStringLiteral("de_DE") + << QStringLiteral("cs_CZ") + << QStringLiteral("he_IL") + << QStringLiteral("fr_FR") + << QStringLiteral("it_IT") + << QStringLiteral("nl_NL") + << QStringLiteral("id_ID") + << QStringLiteral("es_ES") + << QStringLiteral("fi_FI") + << QStringLiteral("en_US"); return locales; } diff --git a/src/libs/vmisc/projectversion.cpp b/src/libs/vmisc/projectversion.cpp index 67f1d71db..aea71936b 100644 --- a/src/libs/vmisc/projectversion.cpp +++ b/src/libs/vmisc/projectversion.cpp @@ -53,7 +53,7 @@ QString compilerString() #elif defined(Q_CC_MSVC) if (_MSC_VER >= 1800) // 1800: MSVC 2013 (yearly release cycle) { - compiler = QLatin1String("MSVC ") + QString::number(2008 + ((_MSC_VER / 100) - 13)); + return QLatin1String("MSVC ") + QString::number(2008 + ((_MSC_VER / 100) - 13)); } if (_MSC_VER >= 1500) // 1500: MSVC 2008, 1600: MSVC 2010, ... (2-year release cycle) { diff --git a/src/libs/vmisc/vlockguard.h b/src/libs/vmisc/vlockguard.h index d25db7b77..d5511ae05 100644 --- a/src/libs/vmisc/vlockguard.h +++ b/src/libs/vmisc/vlockguard.h @@ -169,29 +169,25 @@ bool VLockGuard::TryLock(const QString &lockName, int stale, int timeou //use pointer and function below to persistent things like class-member, because lock is taken by constructor //helper functions allow to write shorter creating and setting new lock-pointer -//new C++11 - "template typedef" http://stackoverflow.com/questions/2795023/c-template-typedef -template -using VLockGuardPtr = std::shared_ptr>; - #if defined (Q_CC_INTEL) #pragma warning( push ) #pragma warning( disable: 1418 ) #endif template -void VlpCreateLock(VLockGuardPtr& r, const QString& lockName, int stale = 0, int timeout = 0) +void VlpCreateLock(std::shared_ptr>& r, const QString& lockName, int stale = 0, int timeout = 0) { r.reset(new VLockGuard(lockName, stale, timeout)); } template -void VlpCreateLock(VLockGuardPtr& r, const QString& lockName, Alloc a, int stale = 0, int timeout = 0) +void VlpCreateLock(std::shared_ptr>& r, const QString& lockName, Alloc a, int stale = 0, int timeout = 0) { r.reset(new VLockGuard(lockName, a, stale, timeout)); } template -void VlpCreateLock(VLockGuardPtr& r, const QString& lockName, Alloc a, Del d, int stale = 0, int timeout = 0) +void VlpCreateLock(std::shared_ptr>& r, const QString& lockName, Alloc a, Del d, int stale = 0, int timeout = 0) { r.reset(new VLockGuard(lockName, a, d, stale, timeout)); } diff --git a/src/libs/vmisc/vsysexits.h b/src/libs/vmisc/vsysexits.h index 86e8101ea..101812530 100644 --- a/src/libs/vmisc/vsysexits.h +++ b/src/libs/vmisc/vsysexits.h @@ -31,40 +31,40 @@ #include -constexpr auto V_EX_OK = 0; /*Indicate the successful exit.*/ +static const auto V_EX_OK = 0; /*Indicate the successful exit.*/ -constexpr auto V_EX_USAGE = 64; /*The command was used incorrectly, e.g., with the wrong number of arguments, a - bad flag, a bad syntax in a parameter, or whatever.*/ +static const auto V_EX_USAGE = 64; /*The command was used incorrectly, e.g., with the wrong number of + arguments, a bad flag, a bad syntax in a parameter, or whatever.*/ -constexpr auto V_EX_DATAERR = 65; /*The input data was incorrect in some way. This should only be used for - user's data and not system files.*/ +static const auto V_EX_DATAERR = 65; /*The input data was incorrect in some way. This should only be used for + user's data and not system files.*/ -constexpr auto V_EX_NOINPUT = 66; /*An input file (not a system file) did not exist or was not readable.*/ +static const auto V_EX_NOINPUT = 66; /*An input file (not a system file) did not exist or was not readable.*/ -constexpr auto V_EX_UNAVAILABLE = 69; /*A service is unavailable. This can occur if a support program or file does - not exist. This can also be used as a catchall message when something you - wanted to do doesn't work, but you don't know why.*/ +static const auto V_EX_UNAVAILABLE = 69; /*A service is unavailable. This can occur if a support program or file + does not exist. This can also be used as a catchall message when + something you wanted to do doesn't work, but you don't know why.*/ -constexpr auto V_EX_SOFTWARE = 70; /*An internal software error has been detected. This should be limited to - nonoperating operating system related errors as possible.*/ +static const auto V_EX_SOFTWARE = 70; /*An internal software error has been detected. This should be limited to + nonoperating operating system related errors as possible.*/ -constexpr auto V_EX_OSERR = 71; /*An operating system error has been detected. This is intended to be used for - such things as ``cannot fork'', ``cannot create pipe'', or the like. It - includes things like getuid returning a user that does not exist in the passwd - file.*/ +static const auto V_EX_OSERR = 71; /*An operating system error has been detected. This is intended to be + used for such things as ``cannot fork'', ``cannot create pipe'', or the + like. It includes things like getuid returning a user that does not exist + in the passwd file.*/ -constexpr auto V_EX_OSFILE = 72; /*Some system file (e.g., /etc/passwd, /var/run/utmp, etc.) does not exist, - cannot be opened, or has some sort of error (e.g., syntax error).*/ +static const auto V_EX_OSFILE = 72; /*Some system file (e.g., /etc/passwd, /var/run/utmp, etc.) does not exist, + cannot be opened, or has some sort of error (e.g., syntax error).*/ -constexpr auto V_EX_CANTCREAT = 73; /*A (user specified) output file cannot be created.*/ +static const auto V_EX_CANTCREAT = 73; /*A (user specified) output file cannot be created.*/ -constexpr auto V_EX_IOERR = 74; /*An error occurred while doing I/O on some file.*/ +static const auto V_EX_IOERR = 74; /*An error occurred while doing I/O on some file.*/ -constexpr auto V_EX_NOPERM = 77; /*You did not have sufficient permission to perform the operation. This is not - intended for file system problems, which should use EX_NOINPUT or EX_CANTCREAT, - but rather for higher level permissions.*/ +static const auto V_EX_NOPERM = 77; /*You did not have sufficient permission to perform the operation. This + is not intended for file system problems, which should use EX_NOINPUT or + EX_CANTCREAT, but rather for higher level permissions.*/ -constexpr auto V_EX_CONFIG = 78; /*Something was found in an unconfigured or misconfigured state.*/ +static const auto V_EX_CONFIG = 78; /*Something was found in an unconfigured or misconfigured state.*/ //--------------------------------------------------------------------------------------------------------------------- inline QTextStream& vStdErr() diff --git a/src/libs/vobj/delaunay.c b/src/libs/vobj/delaunay.cpp similarity index 98% rename from src/libs/vobj/delaunay.c rename to src/libs/vobj/delaunay.cpp index 46c9e040a..47029c742 100644 --- a/src/libs/vobj/delaunay.c +++ b/src/libs/vobj/delaunay.cpp @@ -22,9 +22,16 @@ #include #include #include +#include #include "delaunay.h" +#ifdef Q_CC_GNU + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wold-style-cast" + #pragma GCC diagnostic ignored "-Wcast-qual" +#endif + #if PREDICATE == EXACT_PREDICATE extern void exactinit(); extern real incircle(real* pa, real* pb, real* pc, real* pd); @@ -1061,7 +1068,7 @@ delaunay2d_t* delaunay2d_from(del_point2d_t *points, unsigned int num_points) { res = (delaunay2d_t*)malloc(sizeof(delaunay2d_t)); res->num_points = num_points; - res->points = malloc(sizeof(del_point2d_t) * num_points); + res->points = (del_point2d_t*)malloc(sizeof(del_point2d_t) * num_points); memcpy(res->points, points, sizeof(del_point2d_t) * num_points); res->num_faces = del.num_faces; res->faces = faces; @@ -1074,3 +1081,7 @@ void delaunay2d_release(delaunay2d_t *del) { free(del->points); free(del); } + +#ifdef Q_CC_GNU + #pragma GCC diagnostic pop +#endif diff --git a/src/libs/vobj/predicates.c b/src/libs/vobj/predicates.cpp similarity index 99% rename from src/libs/vobj/predicates.c rename to src/libs/vobj/predicates.cpp index 0ca0e81fa..0e08ed674 100644 --- a/src/libs/vobj/predicates.c +++ b/src/libs/vobj/predicates.cpp @@ -2,7 +2,7 @@ /* */ /* Routines for Arbitrary Precision Floating-point Arithmetic */ /* and Fast Robust Geometric Predicates */ -/* (predicates.c) */ +/* (predicates.cpp) */ /* */ /* May 18, 1996 */ /* */ @@ -110,6 +110,12 @@ #include #include +#ifdef Q_CC_GNU + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wold-style-cast" + #pragma GCC diagnostic ignored "-Wfloat-equal" +#endif + /* On some machines, the exact arithmetic routines might be defeated by the */ /* use of internal extended precision floating-point registers. Sometimes */ /* this problem can be fixed by defining certain values to be volatile, */ @@ -1068,3 +1074,7 @@ qreal incircle(qreal *pa, qreal *pb, qreal *pc, qreal *pd) return incircleadapt(pa, pb, pc, pd, permanent); } + +#ifdef Q_CC_GNU + #pragma GCC diagnostic pop +#endif diff --git a/src/libs/vobj/vobj.pri b/src/libs/vobj/vobj.pri index 15faf94a1..f6ec2b13d 100644 --- a/src/libs/vobj/vobj.pri +++ b/src/libs/vobj/vobj.pri @@ -3,10 +3,10 @@ SOURCES += \ $$PWD/vobjengine.cpp \ - $$PWD/delaunay.c \ - $$PWD/predicates.c \ $$PWD/vobjpaintdevice.cpp \ - $$PWD/stable.cpp + $$PWD/stable.cpp \ + $$PWD/delaunay.cpp \ + $$PWD/predicates.cpp HEADERS += \ $$PWD/vobjengine.h \ diff --git a/src/libs/vpropertyexplorer/checkablemessagebox.h b/src/libs/vpropertyexplorer/checkablemessagebox.h index 3e0e69f86..d71e425f7 100644 --- a/src/libs/vpropertyexplorer/checkablemessagebox.h +++ b/src/libs/vpropertyexplorer/checkablemessagebox.h @@ -18,19 +18,18 @@ #ifndef CHECKABLEMESSAGEBOX_H #define CHECKABLEMESSAGEBOX_H +#include "vpropertyexplorer_global.h" #include #include -QT_BEGIN_NAMESPACE class QSettings; -QT_END_NAMESPACE namespace Utils { class CheckableMessageBoxPrivate; -class Q_DECL_EXPORT CheckableMessageBox : public QDialog +class VPROPERTYEXPLORERSHARED_EXPORT CheckableMessageBox : public QDialog { Q_OBJECT Q_PROPERTY(QString text READ text WRITE setText) diff --git a/src/test/ValentinaTest/abstracttest.h b/src/test/ValentinaTest/abstracttest.h index 349009cff..1932c7347 100644 --- a/src/test/ValentinaTest/abstracttest.h +++ b/src/test/ValentinaTest/abstracttest.h @@ -31,10 +31,14 @@ #include +#ifdef Q_CC_MSVC +#include +#endif /* Q_CC_MSVC */ + // Return codes for testing run application -constexpr auto TST_EX_BIN = -1; // Can't find binary. -constexpr auto TST_EX_TIME_OUT = -2; // The operation timed out or an error occurred. -constexpr auto TST_EX_CRASH = -3; // Program crashed. +static const auto TST_EX_BIN = -1; // Can't find binary. +static const auto TST_EX_TIME_OUT = -2; // The operation timed out or an error occurred. +static const auto TST_EX_CRASH = -3; // Program crashed. enum ErrorState {ErrorLoad = 0, ErrorInstall, ErrorSize, NoError};