Refactoring.

Code style.
This commit is contained in:
Roman Telezhynskyi 2023-07-25 14:02:01 +03:00
parent ccdabec868
commit d1cbb61238
20 changed files with 984 additions and 990 deletions

View File

@ -27,10 +27,10 @@
*************************************************************************/
#include "vpdialogabout.h"
#include "ui_vpdialogabout.h"
#include "../vmisc/projectversion.h"
#include "../vmisc/def.h"
#include "../fervor/fvupdater.h"
#include "../vmisc/def.h"
#include "../vmisc/projectversion.h"
#include "ui_vpdialogabout.h"
#include <QDate>
#include <QDesktopServices>
@ -46,24 +46,26 @@
//---------------------------------------------------------------------------------------------------------------------
VPDialogAbout::VPDialogAbout(QWidget *parent)
:QDialog(parent),
: QDialog(parent),
ui(new Ui::VPDialogAbout),
m_isInitialized(false)
{
ui->setupUi(this);
//mApp->Settings()->GetOsSeparator() ? setLocale(QLocale()) : setLocale(QLocale::c());
// mApp->Settings()->GetOsSeparator() ? setLocale(QLocale()) : setLocale(QLocale::c());
RetranslateUi();
connect(ui->pushButton_Web_Site, &QPushButton::clicked, this, []()
connect(ui->pushButton_Web_Site, &QPushButton::clicked, this,
[]()
{
if ( not QDesktopServices::openUrl(QUrl(QStringLiteral(VER_COMPANYDOMAIN_STR))))
if (not QDesktopServices::openUrl(QUrl(QStringLiteral(VER_COMPANYDOMAIN_STR))))
{
qWarning() << tr("Cannot open your default browser");
}
});
connect(ui->buttonBox, &QDialogButtonBox::accepted, this, &VPDialogAbout::close);
connect(ui->pushButtonCheckUpdate, &QPushButton::clicked, []()
connect(ui->pushButtonCheckUpdate, &QPushButton::clicked,
[]()
{
// Set feed URL before doing anything else
FvUpdater::sharedUpdater()->SetFeedURL(FvUpdater::CurrentFeedURL());
@ -99,8 +101,8 @@ void VPDialogAbout::changeEvent(QEvent *event)
//---------------------------------------------------------------------------------------------------------------------
void VPDialogAbout::showEvent(QShowEvent *event)
{
QDialog::showEvent( event );
if ( event->spontaneous() )
QDialog::showEvent(event);
if (event->spontaneous())
{
return;
}
@ -114,7 +116,7 @@ void VPDialogAbout::showEvent(QShowEvent *event)
setMaximumSize(size());
setMinimumSize(size());
m_isInitialized = true;//first show windows are held
m_isInitialized = true; // first show windows are held
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -65,8 +65,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
@ -92,6 +90,8 @@ auto main(int argc, char *argv[]) -> int
VPApplication 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)
VPApplication::setDesktopFileName(QStringLiteral("ua.com.smart-pattern.puzzle.desktop"));
#endif

View File

@ -27,10 +27,10 @@
*************************************************************************/
#include "dialogabouttape.h"
#include "ui_dialogabouttape.h"
#include "../fervor/fvupdater.h"
#include "../vmisc/def.h"
#include "../vmisc/projectversion.h"
#include "../fervor/fvupdater.h"
#include "ui_dialogabouttape.h"
#include <QDate>
#include <QDesktopServices>
@ -46,16 +46,17 @@
//---------------------------------------------------------------------------------------------------------------------
DialogAboutTape::DialogAboutTape(QWidget *parent)
:QDialog(parent),
: QDialog(parent),
ui(new Ui::DialogAboutTape),
m_isInitialized(false)
{
ui->setupUi(this);
//mApp->Settings()->GetOsSeparator() ? setLocale(QLocale()) : setLocale(QLocale::c());
// mApp->Settings()->GetOsSeparator() ? setLocale(QLocale()) : setLocale(QLocale::c());
RetranslateUi();
connect(ui->pushButton_Web_Site, &QPushButton::clicked, this, []()
connect(ui->pushButton_Web_Site, &QPushButton::clicked, this,
[]()
{
if (not QDesktopServices::openUrl(
QUrl(QStringLiteral("https://%1").arg(QStringLiteral(VER_COMPANYDOMAIN_STR)))))
@ -64,7 +65,8 @@ DialogAboutTape::DialogAboutTape(QWidget *parent)
}
});
connect(ui->buttonBox, &QDialogButtonBox::accepted, this, &DialogAboutTape::close);
connect(ui->pushButtonCheckUpdate, &QPushButton::clicked, []()
connect(ui->pushButtonCheckUpdate, &QPushButton::clicked,
[]()
{
// Set feed URL before doing anything else
FvUpdater::sharedUpdater()->SetFeedURL(FvUpdater::CurrentFeedURL());
@ -100,8 +102,8 @@ void DialogAboutTape::changeEvent(QEvent *event)
//---------------------------------------------------------------------------------------------------------------------
void DialogAboutTape::showEvent(QShowEvent *event)
{
QDialog::showEvent( event );
if ( event->spontaneous() )
QDialog::showEvent(event);
if (event->spontaneous())
{
return;
}
@ -115,7 +117,7 @@ void DialogAboutTape::showEvent(QShowEvent *event)
setMaximumSize(size());
setMinimumSize(size());
m_isInitialized = true;//first show windows are held
m_isInitialized = true; // first show windows are held
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -63,8 +63,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
@ -90,6 +88,8 @@ auto main(int argc, char *argv[]) -> int
MApplication 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)
MApplication::setDesktopFileName(QStringLiteral("ua.com.smart-pattern.tape.desktop"));
#endif

View File

@ -27,15 +27,15 @@
*************************************************************************/
#include "dialogaboutapp.h"
#include "../fervor/fvupdater.h"
#include "../vmisc/projectversion.h"
#include "../vmisc/vabstractvalapplication.h"
#include "../vmisc/vvalentinasettings.h"
#include "ui_dialogaboutapp.h"
#include <QDate>
#include <QDesktopServices>
#include <QMessageBox>
#include <QtDebug>
#include "../fervor/fvupdater.h"
#include "../vmisc/projectversion.h"
#include "../vmisc/vabstractvalapplication.h"
#include "../vmisc/vvalentinasettings.h"
#if !defined(BUILD_REVISION) && defined(QBS_BUILD)
#include <vcsRepoState.h>
@ -43,8 +43,8 @@
#endif
//---------------------------------------------------------------------------------------------------------------------
DialogAboutApp::DialogAboutApp(QWidget *parent) :
QDialog(parent),
DialogAboutApp::DialogAboutApp(QWidget *parent)
: QDialog(parent),
ui(new Ui::DialogAboutApp)
{
ui->setupUi(this);
@ -64,9 +64,9 @@ DialogAboutApp::DialogAboutApp(QWidget *parent) :
"KIND, INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY "
"AND FITNESS FOR A PARTICULAR PURPOSE."));
ui->pushButton_Web_Site->setText(tr("Web site : %1").arg(QStringLiteral(VER_COMPANYDOMAIN_STR)));
connect(ui->pushButton_Web_Site, &QPushButton::clicked, this, []()
connect(ui->pushButton_Web_Site, &QPushButton::clicked, this,
[]()
{
if (not QDesktopServices::openUrl(
QUrl(QStringLiteral("https://%1").arg(QStringLiteral(VER_COMPANYDOMAIN_STR)))))
@ -75,7 +75,8 @@ DialogAboutApp::DialogAboutApp(QWidget *parent) :
}
});
connect(ui->pushButtonCheckUpdate, &QPushButton::clicked, []()
connect(ui->pushButtonCheckUpdate, &QPushButton::clicked,
[]()
{
// Set feed URL before doing anything else
FvUpdater::sharedUpdater()->SetFeedURL(FvUpdater::CurrentFeedURL());
@ -98,8 +99,8 @@ DialogAboutApp::~DialogAboutApp()
//---------------------------------------------------------------------------------------------------------------------
void DialogAboutApp::showEvent(QShowEvent *event)
{
QDialog::showEvent( event );
if ( event->spontaneous() )
QDialog::showEvent(event);
if (event->spontaneous())
{
return;
}
@ -113,7 +114,7 @@ void DialogAboutApp::showEvent(QShowEvent *event)
setMaximumSize(size());
setMinimumSize(size());
m_isInitialized = true;//first show windows are held
m_isInitialized = true; // first show windows are held
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -27,17 +27,17 @@
*************************************************************************/
#include "dialoglayoutsettings.h"
#include "ui_dialoglayoutsettings.h"
#include "../vmisc/vvalentinasettings.h"
#include "../vmisc/vabstractvalapplication.h"
#include "../vmisc/vvalentinasettings.h"
#include "ui_dialoglayoutsettings.h"
#if QT_VERSION < QT_VERSION_CHECK(5, 7, 0)
#include "../vmisc/backport/qoverload.h"
#endif // QT_VERSION < QT_VERSION_CHECK(5, 7, 0)
#include "../vlayout/vlayoutgenerator.h"
#include <QMessageBox>
#include <QPushButton>
#include <QPrinterInfo>
#include <QPushButton>
//---------------------------------------------------------------------------------------------------------------------
DialogLayoutSettings::DialogLayoutSettings(VLayoutGenerator *generator, QWidget *parent, bool disableSettings)
@ -54,8 +54,8 @@ DialogLayoutSettings::DialogLayoutSettings(VLayoutGenerator *generator, QWidget
VAbstractValApplication::VApp()->ValentinaSettings()->GetOsSeparator() ? setLocale(QLocale())
: setLocale(QLocale::c());
//moved from ReadSettings - well...it seems it can be done once only (i.e. constructor) because Init funcs dont
//even cleanse lists before adding
// moved from ReadSettings - well...it seems it can be done once only (i.e. constructor) because Init funcs dont
// even cleanse lists before adding
InitPaperUnits();
InitLayoutUnits();
InitTemplates(ui->comboBoxTemplates);
@ -63,7 +63,7 @@ DialogLayoutSettings::DialogLayoutSettings(VLayoutGenerator *generator, QWidget
MinimumLayoutSize();
InitPrinter();
//in export console mode going to use defaults
// in export console mode going to use defaults
if (not disableSettings)
{
ReadSettings();
@ -73,35 +73,35 @@ DialogLayoutSettings::DialogLayoutSettings(VLayoutGenerator *generator, QWidget
RestoreDefaults();
}
connect(ui->comboBoxPrinter, QOverload<int>::of(&QComboBox::currentIndexChanged),
this, &DialogLayoutSettings::PrinterMargins);
connect(ui->comboBoxPrinter, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
&DialogLayoutSettings::PrinterMargins);
connect(ui->comboBoxTemplates, QOverload<int>::of(&QComboBox::currentIndexChanged),
this, &DialogLayoutSettings::TemplateSelected);
connect(ui->comboBoxPaperSizeUnit, QOverload<int>::of(&QComboBox::currentIndexChanged),
this, &DialogLayoutSettings::ConvertPaperSize);
connect(ui->comboBoxTemplates, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
&DialogLayoutSettings::TemplateSelected);
connect(ui->comboBoxPaperSizeUnit, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
&DialogLayoutSettings::ConvertPaperSize);
connect(ui->doubleSpinBoxPaperWidth, QOverload<double>::of(&QDoubleSpinBox::valueChanged),
this, &DialogLayoutSettings::PaperSizeChanged);
connect(ui->doubleSpinBoxPaperHeight, QOverload<double>::of(&QDoubleSpinBox::valueChanged),
this, &DialogLayoutSettings::PaperSizeChanged);
connect(ui->doubleSpinBoxPaperWidth, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this,
&DialogLayoutSettings::PaperSizeChanged);
connect(ui->doubleSpinBoxPaperHeight, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this,
&DialogLayoutSettings::PaperSizeChanged);
connect(ui->doubleSpinBoxPaperWidth, QOverload<double>::of(&QDoubleSpinBox::valueChanged),
this, &DialogLayoutSettings::FindTemplate);
connect(ui->doubleSpinBoxPaperHeight, QOverload<double>::of(&QDoubleSpinBox::valueChanged),
this, &DialogLayoutSettings::FindTemplate);
connect(ui->doubleSpinBoxPaperWidth, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this,
&DialogLayoutSettings::FindTemplate);
connect(ui->doubleSpinBoxPaperHeight, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this,
&DialogLayoutSettings::FindTemplate);
connect(ui->doubleSpinBoxPaperWidth, QOverload<double>::of(&QDoubleSpinBox::valueChanged),
this, &DialogLayoutSettings::CorrectMaxFileds);
connect(ui->doubleSpinBoxPaperHeight, QOverload<double>::of(&QDoubleSpinBox::valueChanged),
this, &DialogLayoutSettings::CorrectMaxFileds);
connect(ui->doubleSpinBoxPaperWidth, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this,
&DialogLayoutSettings::CorrectMaxFileds);
connect(ui->doubleSpinBoxPaperHeight, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this,
&DialogLayoutSettings::CorrectMaxFileds);
connect(ui->checkBoxIgnoreFileds, &QCheckBox::stateChanged, this, &DialogLayoutSettings::IgnoreAllFields);
connect(ui->toolButtonPortrait, &QToolButton::toggled, this, &DialogLayoutSettings::Swap);
connect(ui->toolButtonLandscape, &QToolButton::toggled, this, &DialogLayoutSettings::Swap);
connect(ui->comboBoxLayoutUnit, QOverload<int>::of(&QComboBox::currentIndexChanged),
this, &DialogLayoutSettings::ConvertLayoutSize);
connect(ui->comboBoxLayoutUnit, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
&DialogLayoutSettings::ConvertLayoutSize);
QPushButton *bOk = ui->buttonBox->button(QDialogButtonBox::Ok);
connect(bOk, &QPushButton::clicked, this, &DialogLayoutSettings::DialogAccepted);
@ -407,7 +407,7 @@ void DialogLayoutSettings::FindTemplate()
const Unit paperUnit = PaperUnit();
const int max = static_cast<int>(PaperSizeTemplate::Custom);
for (int i=0; i < max; ++i)
for (int i = 0; i < max; ++i)
{
const QSizeF tmplSize = GetTemplateSize(static_cast<PaperSizeTemplate>(i), paperUnit);
if (QSizeF(width, height) == tmplSize || QSizeF(height, width) == tmplSize)
@ -473,7 +473,7 @@ void DialogLayoutSettings::ConvertPaperSize()
}
//---------------------------------------------------------------------------------------------------------------------
auto DialogLayoutSettings::SelectPaperUnit(const QString& units) -> bool
auto DialogLayoutSettings::SelectPaperUnit(const QString &units) -> bool
{
qint32 indexUnit = ui->comboBoxPaperSizeUnit->findData(units);
if (indexUnit != -1)
@ -509,15 +509,15 @@ auto DialogLayoutSettings::PageToPixels(qreal value) const -> qreal
//---------------------------------------------------------------------------------------------------------------------
auto DialogLayoutSettings::MakeGroupsHelp() -> QString
{
//that is REALLY dummy ... can't figure fast how to automate generation... :/
// that is REALLY dummy ... can't figure fast how to automate generation... :/
return tr("\n\tThree groups: big, middle, small = 0;\n\tTwo groups: big, small = 1;\n\tDescending area = 2");
}
//---------------------------------------------------------------------------------------------------------------------
void DialogLayoutSettings::showEvent(QShowEvent *event)
{
VAbstractLayoutDialog::showEvent( event );
if ( event->spontaneous() )
VAbstractLayoutDialog::showEvent(event);
if (event->spontaneous())
{
return;
}
@ -534,7 +534,7 @@ void DialogLayoutSettings::showEvent(QShowEvent *event)
resize(sz);
}
m_isInitialized = true;//first show windows are held
m_isInitialized = true; // first show windows are held
}
//---------------------------------------------------------------------------------------------------------------------
@ -585,7 +585,7 @@ void DialogLayoutSettings::PaperSizeChanged()
}
//---------------------------------------------------------------------------------------------------------------------
auto DialogLayoutSettings::SelectTemplate(const PaperSizeTemplate& id) -> bool
auto DialogLayoutSettings::SelectTemplate(const PaperSizeTemplate &id) -> bool
{
int index = ui->comboBoxTemplates->findData(static_cast<VIndexType>(id));
if (index > -1)
@ -657,7 +657,7 @@ void DialogLayoutSettings::DialogAccepted()
QMessageBox::StandardButton answer;
answer = QMessageBox::question(this, tr("Wrong fields."),
tr("Margins go beyond printing. \n\nApply settings anyway?"),
QMessageBox::Yes|QMessageBox::No, QMessageBox::No);
QMessageBox::Yes | QMessageBox::No, QMessageBox::No);
if (answer == QMessageBox::No)
{
SetMinMargins(fields, minFields);
@ -675,7 +675,7 @@ void DialogLayoutSettings::DialogAccepted()
}
}
//don't want to break visual settings when cmd used
// don't want to break visual settings when cmd used
if (not m_disableSettings)
{
WriteSettings();
@ -687,7 +687,7 @@ void DialogLayoutSettings::DialogAccepted()
void DialogLayoutSettings::RestoreDefaults()
{
ui->comboBoxTemplates->blockSignals(true);
ui->comboBoxTemplates->setCurrentIndex(0);//A0
ui->comboBoxTemplates->setCurrentIndex(0); // A0
TemplateSelected();
ui->comboBoxTemplates->blockSignals(false);
@ -734,8 +734,8 @@ void DialogLayoutSettings::CorrectMaxFileds()
const qreal height = ui->doubleSpinBoxPaperHeight->value();
// 80%/2 of paper size for each field
const qreal widthField = (width*80.0/100.0)/2.0;
const qreal heightField = (height*80.0/100.0)/2.0;
const qreal widthField = (width * 80.0 / 100.0) / 2.0;
const qreal heightField = (height * 80.0 / 100.0) / 2.0;
ui->doubleSpinBoxLeftField->setMaximum(widthField);
ui->doubleSpinBoxRightField->setMaximum(widthField);
@ -762,8 +762,8 @@ void DialogLayoutSettings::InitPaperUnits()
// set default unit
m_oldPaperUnit = StrToUnits(VAbstractValApplication::VApp()->ValentinaSettings()->GetUnit());
const qint32 indexUnit = ui->comboBoxPaperSizeUnit->findData(
VAbstractValApplication::VApp()->ValentinaSettings()->GetUnit());
const qint32 indexUnit =
ui->comboBoxPaperSizeUnit->findData(VAbstractValApplication::VApp()->ValentinaSettings()->GetUnit());
if (indexUnit != -1)
{
ui->comboBoxPaperSizeUnit->setCurrentIndex(indexUnit);
@ -779,15 +779,14 @@ void DialogLayoutSettings::InitLayoutUnits()
// set default unit
m_oldLayoutUnit = StrToUnits(VAbstractValApplication::VApp()->ValentinaSettings()->GetUnit());
const qint32 indexUnit = ui->comboBoxLayoutUnit->findData(
VAbstractValApplication::VApp()->ValentinaSettings()->GetUnit());
const qint32 indexUnit =
ui->comboBoxLayoutUnit->findData(VAbstractValApplication::VApp()->ValentinaSettings()->GetUnit());
if (indexUnit != -1)
{
ui->comboBoxLayoutUnit->setCurrentIndex(indexUnit);
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogLayoutSettings::InitPrinter()
{
@ -801,7 +800,7 @@ void DialogLayoutSettings::InitPrinter()
else
{
const int index = ui->comboBoxPrinter->findText(QPrinterInfo::defaultPrinterName());
if(index != -1)
if (index != -1)
{
ui->comboBoxPrinter->setCurrentIndex(index);
}
@ -816,9 +815,9 @@ auto DialogLayoutSettings::MakeHelpTemplateList() -> QString
auto cntr = static_cast<VIndexType>(PaperSizeTemplate::A0);
for (int i = 0; i < VAbstractLayoutDialog::PageFormatNames().size(); ++i)
{
if (cntr < static_cast<int>(PaperSizeTemplate::Custom))// Don't include custom template
if (cntr < static_cast<int>(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)
{
@ -840,7 +839,7 @@ auto DialogLayoutSettings::MakeHelpTiledPdfTemplateList() -> QString
for (int i = 0; i <= static_cast<int>(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<int>(PaperSizeTemplate::Tabloid))
{
@ -1108,7 +1107,6 @@ void DialogLayoutSettings::SetMinMargins(const QMarginsF &fields, const QMargins
if (fields.bottom() < minFields.bottom())
{
ui->doubleSpinBoxBottomField->setValue(UnitConvertor(minFields.bottom(), Unit::Px,
LayoutUnit()));
ui->doubleSpinBoxBottomField->setValue(UnitConvertor(minFields.bottom(), Unit::Px, LayoutUnit()));
}
}

View File

@ -161,14 +161,7 @@ const QString TypeLineDashDotDotLine = QStringLiteral("dashDotDotLine");
*/
auto StylesList() -> QStringList
{
return QStringList{
TypeLineNone,
TypeLineLine,
TypeLineDashLine,
TypeLineDotLine,
TypeLineDashDotLine,
TypeLineDashDotDotLine
};
return {TypeLineNone, TypeLineLine, TypeLineDashLine, TypeLineDotLine, TypeLineDashDotLine, TypeLineDashDotDotLine};
}
//---------------------------------------------------------------------------------------------------------------------
@ -280,7 +273,7 @@ const QString ColorLime = QStringLiteral("lime");
const QString ColorDeepSkyBlue = QStringLiteral("deepskyblue");
const QString ColorCornFlowerBlue = QStringLiteral("cornflowerblue");
//variables
// variables
const QString measurement_ = QStringLiteral("M_");
const QString increment_ = QStringLiteral("Increment_");
const QString line_ = QStringLiteral("Line_");

View File

@ -32,7 +32,7 @@
#include <QtGlobal>
#ifdef Q_OS_WIN
// extern Q_CORE_EXPORT int qt_ntfs_permission_lookup;
# include <qt_windows.h>
#include <qt_windows.h>
#endif /*Q_OS_WIN*/
#include <QColor>
@ -40,8 +40,8 @@
#include <QString>
#include <QStringList>
#include "../vmisc/typedef.h"
#include "../vmisc/def.h"
#include "../vmisc/typedef.h"
#if QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
#include "../vmisc/diagnostic.h"
#endif // QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
@ -50,19 +50,19 @@ extern const QString CustomMSign;
extern const QString CustomIncrSign;
// Detect whether the compiler supports C++11 noexcept exception specifications.
# if defined(__clang__)
# if __has_feature(cxx_noexcept)
# define V_NOEXCEPT_EXPR(x) noexcept(x) // Clang 3.0 and above have noexcept
# endif
# elif defined(__GNUC__)
# if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) && defined(__GXX_EXPERIMENTAL_CXX0X__)
# define V_NOEXCEPT_EXPR(x) noexcept(x) // GCC 4.7 and following have noexcept
# endif
# elif defined(_MSC_FULL_VER) && _MSC_FULL_VER >= 190023026
# define V_NOEXCEPT_EXPR(x) noexcept(x) // Visual Studio 2015 and following have noexcept
# else
# define V_NOEXCEPT_EXPR(x)
# endif
#if defined(__clang__)
#if __has_feature(cxx_noexcept)
#define V_NOEXCEPT_EXPR(x) noexcept(x) // Clang 3.0 and above have noexcept
#endif
#elif defined(__GNUC__)
#if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) && defined(__GXX_EXPERIMENTAL_CXX0X__)
#define V_NOEXCEPT_EXPR(x) noexcept(x) // GCC 4.7 and following have noexcept
#endif
#elif defined(_MSC_FULL_VER) && _MSC_FULL_VER >= 190023026
#define V_NOEXCEPT_EXPR(x) noexcept(x) // Visual Studio 2015 and following have noexcept
#else
#define V_NOEXCEPT_EXPR(x)
#endif
extern const QString AttrType;
extern const QString AttrMx;
@ -112,9 +112,9 @@ extern const QString AttrPoint1;
extern const QString AttrPoint2;
extern const QString AttrPoint3;
extern const QString AttrPoint4;
extern const QString AttrKAsm1;// TODO. Delete if minimal supported version is 0.2.7
extern const QString AttrKAsm2;// TODO. Delete if minimal supported version is 0.2.7
extern const QString AttrKCurve;// TODO. Delete if minimal supported version is 0.2.7
extern const QString AttrKAsm1; // TODO. Delete if minimal supported version is 0.2.7
extern const QString AttrKAsm2; // TODO. Delete if minimal supported version is 0.2.7
extern const QString AttrKCurve; // TODO. Delete if minimal supported version is 0.2.7
extern const QString AttrDuplicate;
extern const QString AttrAScale;
extern const QString AttrPathPoint;
@ -202,7 +202,6 @@ extern const QString ColorLime;
extern const QString ColorDeepSkyBlue;
extern const QString ColorCornFlowerBlue;
// variables name
// Hacks for avoiding the linker error "undefined reference to"
#define SPL_ "Spl_"

View File

@ -2039,7 +2039,7 @@ auto VAbstractPattern::ListFinalMeasurementsExpressions() const -> QVector<VForm
}
//---------------------------------------------------------------------------------------------------------------------
auto VAbstractPattern::IsVariable(const QString &token) const -> bool
auto VAbstractPattern::IsVariable(const QString &token) -> bool
{
for (const auto &var : BuilInVariables())
{
@ -2054,16 +2054,11 @@ auto VAbstractPattern::IsVariable(const QString &token) const -> bool
}
}
if (token.startsWith('#'))
{
return true;
}
return false;
return token.startsWith('#');
}
//---------------------------------------------------------------------------------------------------------------------
auto VAbstractPattern::IsFunction(const QString &token) const -> bool
auto VAbstractPattern::IsFunction(const QString &token) -> bool
{
for (const auto &fn : BuilInFunctions())
{

View File

@ -538,8 +538,8 @@ private:
auto ListPieceExpressions() const -> QVector<VFormulaField>;
auto ListFinalMeasurementsExpressions() const -> QVector<VFormulaField>;
auto IsVariable(const QString &token) const -> bool;
auto IsFunction(const QString &token) const -> bool;
static auto IsVariable(const QString &token) -> bool;
static auto IsFunction(const QString &token) -> bool;
auto ParseItemElement(const QDomElement &domElement) -> QPair<bool, QMap<quint32, quint32>>;

File diff suppressed because it is too large Load Diff

View File

@ -71,7 +71,7 @@ class QMUPARSERSHARED_EXPORT QmuParserBase
public:
QmuParserBase();
explicit QmuParserBase(const QmuParserBase &a_Parser);
QmuParserBase(const QmuParserBase &a_Parser);
auto operator=(const QmuParserBase &a_Parser) -> QmuParserBase &;
virtual ~QmuParserBase();

View File

@ -27,26 +27,15 @@
namespace qmu
{
const QmuParserErrorMsg QmuParserErrorMsg::m_Instance;
//---------------------------------------------------------------------------------------------------------------------
QmuParserErrorMsg::~QmuParserErrorMsg()
{}
#define translate(context, source, disambiguation) QmuTranslation::translate((context), (source), (disambiguation))
//---------------------------------------------------------------------------------------------------------------------
QmuParserErrorMsg::QmuParserErrorMsg()
: m_vErrMsg ()
{
m_vErrMsg.clear();
m_vErrMsg.insert(ecUNASSIGNABLE_TOKEN,
translate("QmuParserErrorMsg", "Unexpected token \"$TOK$\" found at position $POS$.",
"Math parser error messages. Left untouched \"$TOK$\" and $POS$"));
m_vErrMsg.insert(ecINTERNAL_ERROR,
translate("QmuParserErrorMsg", "Internal error",
"Math parser error messages."));
m_vErrMsg.insert(ecINTERNAL_ERROR, translate("QmuParserErrorMsg", "Internal error", "Math parser error messages."));
m_vErrMsg.insert(ecINVALID_NAME,
translate("QmuParserErrorMsg", "Invalid function-, variable- or constant name: \"$TOK$\".",
"Math parser error messages. Left untouched \"$TOK$\""));
@ -59,20 +48,16 @@ QmuParserErrorMsg::QmuParserErrorMsg()
m_vErrMsg.insert(ecINVALID_POSTFIX_IDENT,
translate("QmuParserErrorMsg", "Invalid postfix operator identifier: \"$TOK$\".",
"Math parser error messages. Left untouched \"$TOK$\""));
m_vErrMsg.insert(ecINVALID_FUN_PTR,
translate("QmuParserErrorMsg", "Invalid pointer to callback function.",
m_vErrMsg.insert(ecINVALID_FUN_PTR, translate("QmuParserErrorMsg", "Invalid pointer to callback function.",
"Math parser error messages."));
m_vErrMsg.insert(ecEMPTY_EXPRESSION,
translate("QmuParserErrorMsg", "Expression is empty.",
"Math parser error messages."));
translate("QmuParserErrorMsg", "Expression is empty.", "Math parser error messages."));
m_vErrMsg.insert(ecINVALID_VAR_PTR,
translate("QmuParserErrorMsg", "Invalid pointer to variable.",
"Math parser error messages."));
translate("QmuParserErrorMsg", "Invalid pointer to variable.", "Math parser error messages."));
m_vErrMsg.insert(ecUNEXPECTED_OPERATOR,
translate("QmuParserErrorMsg", "Unexpected operator \"$TOK$\" found at position $POS$",
"Math parser error messages. Left untouched \"$TOK$\" and $POS$"));
m_vErrMsg.insert(ecUNEXPECTED_EOF,
translate("QmuParserErrorMsg", "Unexpected end of expression at position $POS$",
m_vErrMsg.insert(ecUNEXPECTED_EOF, translate("QmuParserErrorMsg", "Unexpected end of expression at position $POS$",
"Math parser error messages. Left untouched $POS$"));
m_vErrMsg.insert(ecUNEXPECTED_ARG_SEP,
translate("QmuParserErrorMsg", "Unexpected argument separator at position $POS$",
@ -80,8 +65,7 @@ QmuParserErrorMsg::QmuParserErrorMsg()
m_vErrMsg.insert(ecUNEXPECTED_PARENS,
translate("QmuParserErrorMsg", "Unexpected parenthesis \"$TOK$\" at position $POS$",
"Math parser error messages. Left untouched \"$TOK$\" and $POS$"));
m_vErrMsg.insert(ecUNEXPECTED_FUN,
translate("QmuParserErrorMsg", "Unexpected function \"$TOK$\" at position $POS$",
m_vErrMsg.insert(ecUNEXPECTED_FUN, translate("QmuParserErrorMsg", "Unexpected function \"$TOK$\" at position $POS$",
"Math parser error messages. Left untouched \"$TOK$\" and $POS$"));
m_vErrMsg.insert(ecUNEXPECTED_VAL,
translate("QmuParserErrorMsg", "Unexpected value \"$TOK$\" found at position $POS$",
@ -93,8 +77,7 @@ QmuParserErrorMsg::QmuParserErrorMsg()
translate("QmuParserErrorMsg", "Function arguments used without a function (position: $POS$)",
"Math parser error messages. Left untouched $POS$"));
m_vErrMsg.insert(ecMISSING_PARENS,
translate("QmuParserErrorMsg", "Missing parenthesis",
"Math parser error messages."));
translate("QmuParserErrorMsg", "Missing parenthesis", "Math parser error messages."));
m_vErrMsg.insert(ecTOO_MANY_PARAMS,
translate("QmuParserErrorMsg",
"Too many parameters for function \"$TOK$\" at expression position $POS$",
@ -103,17 +86,10 @@ QmuParserErrorMsg::QmuParserErrorMsg()
translate("QmuParserErrorMsg",
"Too few parameters for function \"$TOK$\" at expression position $POS$",
"Math parser error messages. Left untouched \"$TOK$\" and $POS$"));
m_vErrMsg.insert(ecDIV_BY_ZERO,
translate("QmuParserErrorMsg", "Divide by zero",
"Math parser error messages."));
m_vErrMsg.insert(ecDOMAIN_ERROR,
translate("QmuParserErrorMsg", "Domain error",
"Math parser error messages."));
m_vErrMsg.insert(ecNAME_CONFLICT,
translate("QmuParserErrorMsg", "Name conflict",
"Math parser error messages."));
m_vErrMsg.insert(ecOPT_PRI,
translate("QmuParserErrorMsg",
m_vErrMsg.insert(ecDIV_BY_ZERO, translate("QmuParserErrorMsg", "Divide by zero", "Math parser error messages."));
m_vErrMsg.insert(ecDOMAIN_ERROR, translate("QmuParserErrorMsg", "Domain error", "Math parser error messages."));
m_vErrMsg.insert(ecNAME_CONFLICT, translate("QmuParserErrorMsg", "Name conflict", "Math parser error messages."));
m_vErrMsg.insert(ecOPT_PRI, translate("QmuParserErrorMsg",
"Invalid value for operator priority (must be greater or equal to zero).",
"Math parser error messages."));
m_vErrMsg.insert(ecBUILTIN_OVERLOAD,
@ -136,11 +112,8 @@ QmuParserErrorMsg::QmuParserErrorMsg()
translate("QmuParserErrorMsg", "No suitable overload for operator \"$TOK$\" at position $POS$.",
"Math parser error messages. Left untouched \"$TOK$\" and $POS$"));
m_vErrMsg.insert(ecSTR_RESULT,
translate("QmuParserErrorMsg", "Function result is a string.",
"Math parser error messages."));
m_vErrMsg.insert(ecGENERIC,
translate("QmuParserErrorMsg", "Parser error.",
"Math parser error messages."));
translate("QmuParserErrorMsg", "Function result is a string.", "Math parser error messages."));
m_vErrMsg.insert(ecGENERIC, translate("QmuParserErrorMsg", "Parser error.", "Math parser error messages."));
m_vErrMsg.insert(ecLOCALE,
translate("QmuParserErrorMsg", "Decimal separator is identic to function argument separator.",
"Math parser error messages."));
@ -150,8 +123,7 @@ QmuParserErrorMsg::QmuParserErrorMsg()
m_vErrMsg.insert(ecMISSING_ELSE_CLAUSE,
translate("QmuParserErrorMsg", "If-then-else operator is missing an else clause",
"Math parser error messages. Do not translate operator name."));
m_vErrMsg.insert(ecMISPLACED_COLON,
translate("QmuParserErrorMsg", "Misplaced colon at position $POS$",
m_vErrMsg.insert(ecMISPLACED_COLON, translate("QmuParserErrorMsg", "Misplaced colon at position $POS$",
"Math parser error messages. Left untouched $POS$"));
}
@ -167,9 +139,15 @@ QmuParserErrorMsg::QmuParserErrorMsg()
* @brief Default constructor.
*/
QmuParserError::QmuParserError()
: QException(), m_sMsg(), m_sExpr(), m_sTok(), m_iPos ( -1 ), m_iErrc ( ecUNDEFINED ),
m_ErrMsg ( QmuParserErrorMsg::Instance() )
{}
: QException(),
m_sMsg(),
m_sExpr(),
m_sTok(),
m_iPos(-1),
m_iErrc(ecUNDEFINED),
m_ErrMsg(QmuParserErrorMsg::Instance())
{
}
//---------------------------------------------------------------------------------------------------------------------
/**
@ -177,23 +155,34 @@ QmuParserError::QmuParserError()
*
* It does not contain any information but the error code.
*/
QmuParserError::QmuParserError ( EErrorCodes a_iErrc )
: QException(), m_sMsg(), m_sExpr(), m_sTok(), m_iPos ( -1 ), m_iErrc ( a_iErrc ),
m_ErrMsg ( QmuParserErrorMsg::Instance() )
QmuParserError::QmuParserError(EErrorCodes a_iErrc)
: QException(),
m_sMsg(),
m_sExpr(),
m_sTok(),
m_iPos(-1),
m_iErrc(a_iErrc),
m_ErrMsg(QmuParserErrorMsg::Instance())
{
m_sMsg = m_ErrMsg[m_iErrc];
m_sMsg.replace("$POS$", QString().setNum ( m_iPos ));
m_sMsg.replace("$TOK$", m_sTok );
m_sMsg.replace("$POS$", QString().setNum(m_iPos));
m_sMsg.replace("$TOK$", m_sTok);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief Construct an error from a message text.
*/
QmuParserError::QmuParserError ( const QString &sMsg )
: QException(), m_sMsg(sMsg), m_sExpr(), m_sTok(), m_iPos ( -1 ), m_iErrc ( ecUNDEFINED ),
m_ErrMsg ( QmuParserErrorMsg::Instance() )
{}
QmuParserError::QmuParserError(const QString &sMsg)
: QException(),
m_sMsg(sMsg),
m_sExpr(),
m_sTok(),
m_iPos(-1),
m_iErrc(ecUNDEFINED),
m_ErrMsg(QmuParserErrorMsg::Instance())
{
}
//---------------------------------------------------------------------------------------------------------------------
/**
@ -203,13 +192,18 @@ QmuParserError::QmuParserError ( const QString &sMsg )
* @param [in] sExpr The expression related to the error.
* @param [in] iPos the position in the expression where the error occured.
*/
QmuParserError::QmuParserError (EErrorCodes iErrc, const QString &sTok, const QString &sExpr, qmusizetype iPos )
: QException(), m_sMsg(), m_sExpr ( sExpr ), m_sTok ( sTok ), m_iPos ( iPos ), m_iErrc ( iErrc ),
m_ErrMsg ( QmuParserErrorMsg::Instance() )
QmuParserError::QmuParserError(EErrorCodes iErrc, const QString &sTok, const QString &sExpr, qmusizetype iPos)
: QException(),
m_sMsg(),
m_sExpr(sExpr),
m_sTok(sTok),
m_iPos(iPos),
m_iErrc(iErrc),
m_ErrMsg(QmuParserErrorMsg::Instance())
{
m_sMsg = m_ErrMsg[m_iErrc];
m_sMsg.replace("$POS$", QString().setNum ( m_iPos ));
m_sMsg.replace("$TOK$", m_sTok );
m_sMsg.replace("$POS$", QString().setNum(m_iPos));
m_sMsg.replace("$TOK$", m_sTok);
}
//---------------------------------------------------------------------------------------------------------------------
@ -219,13 +213,18 @@ QmuParserError::QmuParserError (EErrorCodes iErrc, const QString &sTok, const QS
* @param [in] a_iPos the position in the expression where the error occured.
* @param [in] sTok The token string related to this error.
*/
QmuParserError::QmuParserError ( EErrorCodes a_iErrc, int a_iPos, const QString &sTok )
: QException(), m_sMsg(), m_sExpr(), m_sTok ( sTok ), m_iPos ( a_iPos ), m_iErrc ( a_iErrc ),
m_ErrMsg ( QmuParserErrorMsg::Instance() )
QmuParserError::QmuParserError(EErrorCodes a_iErrc, int a_iPos, const QString &sTok)
: QException(),
m_sMsg(),
m_sExpr(),
m_sTok(sTok),
m_iPos(a_iPos),
m_iErrc(a_iErrc),
m_ErrMsg(QmuParserErrorMsg::Instance())
{
m_sMsg = m_ErrMsg[m_iErrc];
m_sMsg.replace("$POS$", QString().setNum ( m_iPos ));
m_sMsg.replace("$TOK$", m_sTok );
m_sMsg.replace("$POS$", QString().setNum(m_iPos));
m_sMsg.replace("$TOK$", m_sTok);
}
//---------------------------------------------------------------------------------------------------------------------
@ -234,28 +233,39 @@ QmuParserError::QmuParserError ( EErrorCodes a_iErrc, int a_iPos, const QString
* @param [in] iPos the position related to the error.
* @param [in] sTok The token string related to this error.
*/
QmuParserError::QmuParserError ( const QString &szMsg, int iPos, const QString &sTok )
: QException(), m_sMsg ( szMsg ), m_sExpr(), m_sTok ( sTok ), m_iPos ( iPos ), m_iErrc ( ecGENERIC ),
m_ErrMsg ( QmuParserErrorMsg::Instance() )
QmuParserError::QmuParserError(const QString &szMsg, int iPos, const QString &sTok)
: QException(),
m_sMsg(szMsg),
m_sExpr(),
m_sTok(sTok),
m_iPos(iPos),
m_iErrc(ecGENERIC),
m_ErrMsg(QmuParserErrorMsg::Instance())
{
m_sMsg.replace("$POS$", QString().setNum ( m_iPos ));
m_sMsg.replace("$TOK$", m_sTok );
m_sMsg.replace("$POS$", QString().setNum(m_iPos));
m_sMsg.replace("$TOK$", m_sTok);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief Copy constructor.
*/
QmuParserError::QmuParserError ( const QmuParserError &a_Obj )
: QException(), m_sMsg ( a_Obj.m_sMsg ), m_sExpr ( a_Obj.m_sExpr ), m_sTok ( a_Obj.m_sTok ),
m_iPos ( a_Obj.m_iPos ), m_iErrc ( a_Obj.m_iErrc ), m_ErrMsg ( QmuParserErrorMsg::Instance() )
{}
QmuParserError::QmuParserError(const QmuParserError &a_Obj)
: QException(),
m_sMsg(a_Obj.m_sMsg),
m_sExpr(a_Obj.m_sExpr),
m_sTok(a_Obj.m_sTok),
m_iPos(a_Obj.m_iPos),
m_iErrc(a_Obj.m_iErrc),
m_ErrMsg(QmuParserErrorMsg::Instance())
{
}
//---------------------------------------------------------------------------------------------------------------------
/** @brief Assignment operator. */
auto QmuParserError::operator=(const QmuParserError &a_Obj) -> QmuParserError &
{
if ( this == &a_Obj )
if (this == &a_Obj)
{
return *this;
}
@ -303,18 +313,22 @@ auto QmuParserError::clone() const -> QmuParserError *
//---------------------------------------------------------------------------------------------------------------------
QmuParserWarning::QmuParserWarning(const QString &sMsg)
: QException(), m_sMsg ( sMsg )
{}
: QException(),
m_sMsg(sMsg)
{
}
//---------------------------------------------------------------------------------------------------------------------
QmuParserWarning::QmuParserWarning(const QmuParserWarning &a_Obj)
: QException(), m_sMsg(a_Obj.m_sMsg)
{}
: QException(),
m_sMsg(a_Obj.m_sMsg)
{
}
//---------------------------------------------------------------------------------------------------------------------
auto QmuParserWarning::operator=(const QmuParserWarning &a_Obj) -> QmuParserWarning &
{
if ( this == &a_Obj )
if (this == &a_Obj)
{
return *this;
}

View File

@ -104,10 +104,10 @@ enum EErrorCodes
class QMUPARSERSHARED_EXPORT QmuParserErrorMsg
{
public:
typedef QmuParserErrorMsg self_type;
using self_type = QmuParserErrorMsg;
QmuParserErrorMsg();
~QmuParserErrorMsg();
~QmuParserErrorMsg() = default;
static auto Instance() -> const QmuParserErrorMsg &;
auto operator[](int a_iIdx) const -> QString;
@ -115,7 +115,7 @@ public:
private:
// cppcheck-suppress unknownMacro
Q_DISABLE_COPY_MOVE(QmuParserErrorMsg) // NOLINT
QMap<int, QmuTranslation> m_vErrMsg; ///< A map with the predefined error messages
QMap<int, QmuTranslation> m_vErrMsg{}; ///< A map with the predefined error messages
};
//---------------------------------------------------------------------------------------------------------------------

View File

@ -20,7 +20,6 @@
******************************************************************************************************/
#include "qmutranslation.h"
#include "qmuparserdef.h"
#include <QByteArray>
#include <QCoreApplication>
@ -37,14 +36,20 @@ auto QmuTranslation::translate(const char *context, const char *sourceText, cons
{
n = -1;
}
QmuTranslation t(context, sourceText, disambiguation, n);
return t;
return {context, sourceText, disambiguation, n};
}
//---------------------------------------------------------------------------------------------------------------------
QmuTranslation::QmuTranslation()
: mcontext(), msourceText(), mdisambiguation(), mn(-1), localeName(), cachedTranslation()
{}
: mcontext(),
msourceText(),
mdisambiguation(),
mn(-1),
localeName(),
cachedTranslation()
{
}
//---------------------------------------------------------------------------------------------------------------------
QmuTranslation::QmuTranslation(const QString &context, const QString &sourceText, const QString &disambiguation, int n)
@ -54,12 +59,13 @@ QmuTranslation::QmuTranslation(const QString &context, const QString &sourceText
mn(n),
localeName(),
cachedTranslation()
{}
{
}
//---------------------------------------------------------------------------------------------------------------------
auto QmuTranslation::operator=(const QmuTranslation &tr) -> QmuTranslation &
{
if ( &tr == this )
if (&tr == this)
{
return *this;
}
@ -80,7 +86,8 @@ QmuTranslation::QmuTranslation(const QmuTranslation &tr)
mn(tr.mn),
localeName(),
cachedTranslation()
{}
{
}
//---------------------------------------------------------------------------------------------------------------------
auto QmuTranslation::translate(const QString &locale) const -> QString

View File

@ -27,53 +27,53 @@
*************************************************************************/
#include "vpatternrecipe.h"
#include "../ifc/exception/vexceptioninvalidhistory.h"
#include "../ifc/xml/vabstractpattern.h"
#include "../vgeometry/vcubicbezier.h"
#include "../vgeometry/vcubicbezierpath.h"
#include "../vgeometry/vpointf.h"
#include "../vgeometry/vsplinepath.h"
#include "../vmisc/projectversion.h"
#include "../vmisc/vabstractvalapplication.h"
#include "../ifc/xml/vabstractpattern.h"
#include "../ifc/exception/vexceptioninvalidhistory.h"
#include "../vpatterndb/vcontainer.h"
#include "../vgeometry/vpointf.h"
#include "../vgeometry/vcubicbezier.h"
#include "../vgeometry/vsplinepath.h"
#include "../vgeometry/vcubicbezierpath.h"
#include "../vpatterndb/calculator.h"
#include "../vpatterndb/variables/vincrement.h"
#include "../vpatterndb/variables/vmeasurement.h"
#include "../vpatterndb/vcontainer.h"
#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolalongline.h"
#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolbisector.h"
#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolendline.h"
#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolnormal.h"
#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolshoulderpoint.h"
#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolheight.h"
#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoollineintersectaxis.h"
#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolcurveintersectaxis.h"
#include "../vtools/tools/drawTools/operation/flipping/vtoolflippingbyaxis.h"
#include "../vtools/tools/drawTools/operation/flipping/vtoolflippingbyline.h"
#include "../vtools/tools/drawTools/operation/vtoolmove.h"
#include "../vtools/tools/drawTools/operation/vtoolrotation.h"
#include "../vtools/tools/drawTools/toolcurve/vtoolarc.h"
#include "../vtools/tools/drawTools/toolcurve/vtoolellipticalarc.h"
#include "../vtools/tools/drawTools/toolcurve/vtoolarcwithlength.h"
#include "../vtools/tools/drawTools/toolcurve/vtoolspline.h"
#include "../vtools/tools/drawTools/toolcurve/vtoolcubicbezier.h"
#include "../vtools/tools/drawTools/toolcurve/vtoolsplinepath.h"
#include "../vtools/tools/drawTools/toolcurve/vtoolcubicbezierpath.h"
#include "../vtools/tools/drawTools/vtoolline.h"
#include "../vtools/tools/drawTools/toolcurve/vtoolellipticalarc.h"
#include "../vtools/tools/drawTools/toolcurve/vtoolspline.h"
#include "../vtools/tools/drawTools/toolcurve/vtoolsplinepath.h"
#include "../vtools/tools/drawTools/toolpoint/tooldoublepoint/vtooltruedarts.h"
#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutarc.h"
#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutspline.h"
#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutsplinepath.h"
#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutarc.h"
#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoollineintersect.h"
#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofcontact.h"
#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolalongline.h"
#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolbisector.h"
#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolcurveintersectaxis.h"
#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolendline.h"
#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolheight.h"
#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoollineintersectaxis.h"
#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolnormal.h"
#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolshoulderpoint.h"
#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolbasepoint.h"
#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/vtooltriangle.h"
#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoollineintersect.h"
#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromarcandtangent.h"
#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromcircleandtangent.h"
#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofcontact.h"
#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersection.h"
#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectionarcs.h"
#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncircles.h"
#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncurves.h"
#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromcircleandtangent.h"
#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromarcandtangent.h"
#include "../vtools/tools/drawTools/toolpoint/tooldoublepoint/vtooltruedarts.h"
#include "../vtools/tools/drawTools/operation/vtoolrotation.h"
#include "../vtools/tools/drawTools/operation/flipping/vtoolflippingbyline.h"
#include "../vtools/tools/drawTools/operation/flipping/vtoolflippingbyaxis.h"
#include "../vtools/tools/drawTools/operation/vtoolmove.h"
#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/vtooltriangle.h"
#include "../vtools/tools/drawTools/vtoolline.h"
namespace
{
@ -103,7 +103,7 @@ inline auto FileComment() -> QString
//---------------------------------------------------------------------------------------------------------------------
template <typename T> auto GetPatternTool(quint32 id) -> T *
{
T* tool = qobject_cast<T*>(VAbstractPattern::getTool(id));
T *tool = qobject_cast<T *>(VAbstractPattern::getTool(id));
if (not tool)
{
throw VExceptionInvalidHistory(QObject::tr("Cannot cast tool with id '%1'.").arg(id));
@ -127,8 +127,9 @@ VPatternRecipe::VPatternRecipe(VAbstractPattern *pattern, QObject *parent)
recipeElement.appendChild(Content());
appendChild(recipeElement);
insertBefore(createProcessingInstruction(QStringLiteral("xml"),
QStringLiteral("version=\"1.0\" encoding=\"UTF-8\"")), firstChild());
insertBefore(
createProcessingInstruction(QStringLiteral("xml"), QStringLiteral("version=\"1.0\" encoding=\"UTF-8\"")),
firstChild());
}
//---------------------------------------------------------------------------------------------------------------------
@ -150,8 +151,8 @@ auto VPatternRecipe::Prerequisite() -> QDomElement
QDomElement prerequisiteElement = createElement(QStringLiteral("prerequisite"));
prerequisiteElement.appendChild(CreateElementWithText(QStringLiteral("valentina"), AppVersionStr()));
prerequisiteElement.appendChild(CreateElementWithText(QStringLiteral("unit"),
UnitsToStr(VAbstractValApplication::VApp()->patternUnits())));
prerequisiteElement.appendChild(
CreateElementWithText(QStringLiteral("unit"), UnitsToStr(VAbstractValApplication::VApp()->patternUnits())));
prerequisiteElement.appendChild(CreateElementWithText(QStringLiteral("author"), m_pattern->GetCompanyName()));
prerequisiteElement.appendChild(CreateElementWithText(QStringLiteral("pattenName"), m_pattern->GetPatternName()));
prerequisiteElement.appendChild(CreateElementWithText(QStringLiteral("description"), m_pattern->GetDescription()));
@ -174,9 +175,9 @@ auto VPatternRecipe::Measurements() -> QDomElement
// Resore order
std::sort(patternMeasurements.begin(), patternMeasurements.end(),
[](const QSharedPointer<VMeasurement> &a, const QSharedPointer<VMeasurement> &b)
{return a->Index() < b->Index();});
{ return a->Index() < b->Index(); });
for(auto &m : patternMeasurements)
for (auto &m : patternMeasurements)
{
measurements.appendChild(Measurement(m));
}
@ -231,9 +232,9 @@ auto VPatternRecipe::Increments() -> QDomElement
// Resore order
std::sort(patternIncrements.begin(), patternIncrements.end(),
[](const QSharedPointer<VIncrement> &a, const QSharedPointer<VIncrement> &b)
{return a->GetIndex() < b->GetIndex();});
{ return a->GetIndex() < b->GetIndex(); });
for(auto &incr : patternIncrements)
for (auto &incr : patternIncrements)
{
if (not incr->IsPreviewCalculation())
{
@ -255,9 +256,9 @@ auto VPatternRecipe::PreviewCalculations() -> QDomElement
// Resore order
std::sort(patternIncrements.begin(), patternIncrements.end(),
[](const QSharedPointer<VIncrement> &a, const QSharedPointer<VIncrement> &b)
{return a->GetIndex() < b->GetIndex();});
{ return a->GetIndex() < b->GetIndex(); });
for(auto &incr : patternIncrements)
for (auto &incr : patternIncrements)
{
if (incr->IsPreviewCalculation())
{
@ -295,7 +296,7 @@ auto VPatternRecipe::Content() -> QDomElement
QDomElement content = createElement(QStringLiteral("content"));
const QDomNodeList draws = m_pattern->documentElement().elementsByTagName(VAbstractPattern::TagDraw);
for (int i=0; i < draws.size(); ++i)
for (int i = 0; i < draws.size(); ++i)
{
QDomElement draw = draws.at(i).toElement();
if (draw.isNull())
@ -350,8 +351,8 @@ auto VPatternRecipe::Step(const VToolRecord &tool, const VContainer &data) -> QD
}
try
{
QT_WARNING_PUSH
QT_WARNING_DISABLE_GCC("-Wswitch-default")
QT_WARNING_PUSH
QT_WARNING_DISABLE_GCC("-Wswitch-default")
switch (tool.getTypeTool())
{
case Tool::Arrow:
@ -360,8 +361,8 @@ QT_WARNING_DISABLE_GCC("-Wswitch-default")
case Tool::LinePoint:
case Tool::AbstractSpline:
case Tool::Cut:
case Tool::Midpoint:// Same as Tool::AlongLine, but tool will never has such type
case Tool::ArcIntersectAxis:// Same as Tool::CurveIntersectAxis, but tool will never has such type
case Tool::Midpoint: // Same as Tool::AlongLine, but tool will never has such type
case Tool::ArcIntersectAxis: // Same as Tool::CurveIntersectAxis, but tool will never has such type
case Tool::BackgroundImage:
case Tool::BackgroundImageControls:
case Tool::BackgroundPixmapImage:
@ -437,8 +438,8 @@ QT_WARNING_DISABLE_GCC("-Wswitch-default")
return FlippingByAxis(tool, data);
case Tool::Move:
return Move(tool, data);
//Because "history" not only show history of pattern, but help restore current data for each pattern's
//piece, we need add record about details and nodes, but don't show them.
// Because "history" not only show history of pattern, but help restore current data for each pattern's
// piece, we need add record about details and nodes, but don't show them.
case Tool::Piece:
case Tool::UnionDetails:
case Tool::NodeArc:
@ -454,7 +455,7 @@ QT_WARNING_DISABLE_GCC("-Wswitch-default")
case Tool::DuplicateDetail:
return QDomElement();
}
QT_WARNING_POP
QT_WARNING_POP
}
catch (const VExceptionBadId &e)
{
@ -495,20 +496,22 @@ 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."),
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));
VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg)
: qWarning()
<< VAbstractValApplication::warningMessageSignature + errorMsg;
"Please, check your calculations.")
.arg(fm.name));
VAbstractApplication::VApp()->IsPedantic()
? throw VException(errorMsg)
: qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg;
}
SetAttribute(recipeFinalMeasurement, QStringLiteral("value"), result);
}
catch (const qmu::QmuParserError &e)
{
throw VExceptionInvalidHistory(tr("Unable to create record for final measurement '%1'. Error: %2")
.arg(fm.name).arg(e.GetMsg()));
throw VExceptionInvalidHistory(
tr("Unable to create record for final measurement '%1'. Error: %2").arg(fm.name).arg(e.GetMsg()));
}
return recipeFinalMeasurement;
@ -1157,39 +1160,34 @@ inline void VPatternRecipe::Formula(QDomElement &step, const VFormula &formula,
}
//---------------------------------------------------------------------------------------------------------------------
template<typename T>
inline void VPatternRecipe::LineAttributes(QDomElement &step, T *tool)
template <typename T> inline void VPatternRecipe::LineAttributes(QDomElement &step, T *tool)
{
SetAttribute(step, AttrLineColor, tool->GetLineColor());
SetAttribute(step, AttrTypeLine, tool->getLineType());
}
//---------------------------------------------------------------------------------------------------------------------
template<typename T>
void VPatternRecipe::CurveAttributes(QDomElement &step, T *tool)
template <typename T> void VPatternRecipe::CurveAttributes(QDomElement &step, T *tool)
{
SetAttribute(step, AttrLineColor, tool->GetLineColor());
SetAttribute(step, AttrPenStyle, tool->GetPenStyle());
SetAttribute(step, AttrAScale, tool->GetApproximationScale());
SetAttribute(step, AttrDuplicate, tool->GetDuplicate());
SetAttributeOrRemoveIf<QString>(step, AttrAlias, tool->GetAliasSuffix(),
[](const QString &suffix) noexcept {return suffix.isEmpty();});
[](const QString &suffix) noexcept { return suffix.isEmpty(); });
}
//---------------------------------------------------------------------------------------------------------------------
template<typename T>
void VPatternRecipe::CutCurveAttributes(QDomElement &step, T *tool)
template <typename T> void VPatternRecipe::CutCurveAttributes(QDomElement &step, T *tool)
{
SetAttributeOrRemoveIf<QString>(step, AttrAlias1, tool->GetAliasSuffix1(),
[](const QString &suffix) noexcept {return suffix.isEmpty();});
[](const QString &suffix) noexcept { return suffix.isEmpty(); });
SetAttributeOrRemoveIf<QString>(step, AttrAlias2, tool->GetAliasSuffix2(),
[](const QString &suffix) noexcept {return suffix.isEmpty();});
[](const QString &suffix) noexcept { return suffix.isEmpty(); });
}
//---------------------------------------------------------------------------------------------------------------------
template<typename T>
inline void VPatternRecipe::ToolAttributes(QDomElement &step, T *tool)
template <typename T> inline void VPatternRecipe::ToolAttributes(QDomElement &step, T *tool)
{
SetAttribute(step, AttrType, T::ToolType);
SetAttribute(step, AttrLabel, tool->name());
@ -1221,13 +1219,13 @@ auto VPatternRecipe::GroupOperationSource(VAbstractOperation *tool, quint32 id,
}
catch (const VExceptionBadId &e)
{
qCritical() << e.ErrorMessage()<<Q_FUNC_INFO;
qCritical() << e.ErrorMessage() << Q_FUNC_INFO;
continue;
}
SetAttribute(node, AttrItem, obj->ObjectName());
SetAttributeOrRemoveIf<QString>(node, AttrAlias, item.alias,
[](const QString &alias) noexcept {return alias.isEmpty();});
[](const QString &alias) noexcept { return alias.isEmpty(); });
if (obj->getType() != GOType::Point)
{
@ -1244,7 +1242,7 @@ auto VPatternRecipe::GroupOperationSource(VAbstractOperation *tool, quint32 id,
QT_WARNING_PUSH
QT_WARNING_DISABLE_GCC("-Wswitch-default")
switch(static_cast<GOType>(obj->getType()))
switch (static_cast<GOType>(obj->getType()))
{
case GOType::Point:
SetAttribute(node, AttrType, QStringLiteral("point"));

View File

@ -38,7 +38,7 @@ const QString degreeSymbol = QStringLiteral("°");
const QString trueStr = QStringLiteral("true");
const QString falseStr = QStringLiteral("false");
//functions
// functions
const QString degTorad_F = QStringLiteral("degTorad");
const QString radTodeg_F = QStringLiteral("radTodeg");
const QString sin_F = QStringLiteral("sin");

View File

@ -28,8 +28,8 @@
#ifndef LITERALS_H
#define LITERALS_H
#include <QtGlobal>
#include <QtCore/qcontainerfwd.h>
#include <QtGlobal>
class QString;
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)

View File

@ -39,7 +39,7 @@ auto AppVersionStr() -> const QString &;
constexpr inline auto FormatVersion(unsigned major, unsigned minor, unsigned patch) -> unsigned
{
return ((major<<16u)|(minor<<8u)|patch);
return ((major << 16u) | (minor << 8u) | patch);
}
constexpr inline auto AppVersion() -> unsigned
@ -50,7 +50,7 @@ constexpr inline auto AppVersion() -> unsigned
// Change version number in projectversion.cpp too.
// Synchronize valentina.nsi
#define VER_FILEVERSION 0,7,52
#define VER_FILEVERSION 0, 7, 52
#define VER_FILEVERSION_STR "0.7.52\0"
#define V_PRERELEASE // Mark prerelease builds
@ -59,13 +59,13 @@ constexpr inline auto AppVersion() -> unsigned
#define VER_PRODUCTVERSION_STR VER_FILEVERSION_STR
#define VER_COMPANYNAME_STR "ValentinaTeam"
//#define VER_FILEDESCRIPTION_STR "Patternmaking program." // Defined in program
//#define VER_INTERNALNAME_STR "Valentina" // Defined in program
// #define VER_FILEDESCRIPTION_STR "Patternmaking program." // Defined in program
// #define VER_INTERNALNAME_STR "Valentina" // Defined in program
#define VER_LEGALCOPYRIGHT_STR "Copyright © 2014-2022 Valentina Team"
#define VER_LEGALTRADEMARKS1_STR "All Rights Reserved"
#define VER_LEGALTRADEMARKS2_STR VER_LEGALTRADEMARKS1_STR
//#define VER_ORIGINALFILENAME_STR "valentina.exe" // Defined in program
//#define VER_PRODUCTNAME_STR "Valentina" // Defined in program
// #define VER_ORIGINALFILENAME_STR "valentina.exe" // Defined in program
// #define VER_PRODUCTNAME_STR "Valentina" // Defined in program
#define VER_COMPANYDOMAIN_STR "smart-pattern.com.ua"

View File

@ -27,13 +27,12 @@
*************************************************************************/
#include "tst_buitinregexp.h"
#include "../qmuparser/qmudef.h"
#include "../vpatterndb/vtranslatevars.h"
#include "../ifc/ifcdef.h"
#include "../vmisc/literals.h"
#include "../vpatterndb/vtranslatevars.h"
#include <QtTest>
#include <QTranslator>
#include <QtTest>
//---------------------------------------------------------------------------------------------------------------------
TST_BuitInRegExp::TST_BuitInRegExp(const QString &locale, QObject *parent)
@ -64,7 +63,7 @@ void TST_BuitInRegExp::initTestCase()
QLocale::setDefault(QLocale(m_locale));
InitTrMs();//Very important do this after loading QM files.
InitTrMs(); // Very important do this after loading QM files.
}
//---------------------------------------------------------------------------------------------------------------------
@ -197,8 +196,8 @@ void TST_BuitInRegExp::TestCheckUnderlineExists()
const QString translated = m_trMs->InternalVarToUser(name);
if ((translated.right(1) == QLatin1String("_")) != exists)
{
const QString message = QString("String '%1' doesn't contain underline. Original string is '%2'")
.arg(translated, name);
const QString message =
QString("String '%1' doesn't contain underline. Original string is '%2'").arg(translated, name);
QFAIL(qUtf8Printable(message));
}
}