Refactoring.

Code style.
This commit is contained in:
Roman Telezhynskyi 2023-06-21 10:24:51 +03:00
parent 031d6e7a07
commit 1847115627
58 changed files with 4666 additions and 4617 deletions

View File

@ -3,7 +3,6 @@ import qbs.File
VApp { VApp {
Depends { name: "freedesktop2" } Depends { name: "freedesktop2" }
Depends { name: "tenv" }
Depends { name: "windeployqt"; condition: qbs.targetOS.contains("windows") } Depends { name: "windeployqt"; condition: qbs.targetOS.contains("windows") }
Depends { name: "i18nconfig"; } Depends { name: "i18nconfig"; }
Depends { name: "i18n"; } Depends { name: "i18n"; }

View File

@ -27,24 +27,22 @@
*************************************************************************/ *************************************************************************/
#include "puzzlepreferencesconfigurationpage.h" #include "puzzlepreferencesconfigurationpage.h"
#include "ui_puzzlepreferencesconfigurationpage.h"
#include "../../vpapplication.h" #include "../../vpapplication.h"
#include "ui_puzzlepreferencesconfigurationpage.h"
#if QT_VERSION < QT_VERSION_CHECK(5, 7, 0) #if QT_VERSION < QT_VERSION_CHECK(5, 7, 0)
#include "../vmisc/backport/qoverload.h" #include "../vmisc/backport/qoverload.h"
#endif // QT_VERSION < QT_VERSION_CHECK(5, 7, 0) #endif // QT_VERSION < QT_VERSION_CHECK(5, 7, 0)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
PuzzlePreferencesConfigurationPage::PuzzlePreferencesConfigurationPage(QWidget *parent) : PuzzlePreferencesConfigurationPage::PuzzlePreferencesConfigurationPage(QWidget *parent)
QWidget(parent), : QWidget(parent),
ui(new Ui::PuzzlePreferencesConfigurationPage) ui(new Ui::PuzzlePreferencesConfigurationPage)
{ {
ui->setupUi(this); ui->setupUi(this);
InitLanguages(ui->langCombo); InitLanguages(ui->langCombo);
connect(ui->langCombo, QOverload<int>::of(&QComboBox::currentIndexChanged), this, [this]() connect(ui->langCombo, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
{ [this]() { m_langChanged = true; });
m_langChanged = true;
});
VPSettings *settings = VPApplication::VApp()->PuzzleSettings(); VPSettings *settings = VPApplication::VApp()->PuzzleSettings();
@ -60,7 +58,7 @@ PuzzlePreferencesConfigurationPage::PuzzlePreferencesConfigurationPage(QWidget *
// Undo // Undo
ui->undoCount->setValue(settings->GetUndoCount()); ui->undoCount->setValue(settings->GetUndoCount());
//Graphical output // Graphical output
ui->graphOutputCheck->setChecked(settings->GetGraphicalOutput()); ui->graphOutputCheck->setChecked(settings->GetGraphicalOutput());
ui->checkBoxOpenGLRender->setChecked(settings->IsOpenGLRender()); ui->checkBoxOpenGLRender->setChecked(settings->IsOpenGLRender());
@ -121,7 +119,7 @@ auto PuzzlePreferencesConfigurationPage::Apply() -> QStringList
m_langChanged = false; m_langChanged = false;
VAbstractApplication::VApp()->LoadTranslation(locale); VAbstractApplication::VApp()->LoadTranslation(locale);
QCoreApplication::processEvents();// force to call changeEvent QCoreApplication::processEvents(); // force to call changeEvent
} }
/* Maximum number of commands in undo stack may only be set when the undo stack is empty, since setting it on a /* Maximum number of commands in undo stack may only be set when the undo stack is empty, since setting it on a

View File

@ -26,10 +26,10 @@
** **
*************************************************************************/ *************************************************************************/
#include "dialogsavemanuallayout.h" #include "dialogsavemanuallayout.h"
#include "ui_dialogsavemanuallayout.h"
#include "../vpapplication.h"
#include "../ifc/exception/vexception.h" #include "../ifc/exception/vexception.h"
#include "../vlayout/vlayoutexporter.h" #include "../vlayout/vlayoutexporter.h"
#include "../vpapplication.h"
#include "ui_dialogsavemanuallayout.h"
#if QT_VERSION < QT_VERSION_CHECK(5, 7, 0) #if QT_VERSION < QT_VERSION_CHECK(5, 7, 0)
#include "../vmisc/backport/qoverload.h" #include "../vmisc/backport/qoverload.h"
#endif // QT_VERSION < QT_VERSION_CHECK(5, 7, 0) #endif // QT_VERSION < QT_VERSION_CHECK(5, 7, 0)
@ -38,12 +38,24 @@
#include <QShowEvent> #include <QShowEvent>
#include <QtDebug> #include <QtDebug>
#if QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
#include "diagnostic.h"
#endif // QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
namespace
{
QT_WARNING_PUSH
QT_WARNING_DISABLE_CLANG("-Wunused-member-function")
#ifndef Q_OS_WIN #ifndef Q_OS_WIN
Q_GLOBAL_STATIC_WITH_ARGS(const QString, baseFilenameRegExp, (QLatin1String("^[^\\/]+$"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, baseFilenameRegExp, (QLatin1String("^[^\\/]+$"))) // NOLINT
#else #else
Q_GLOBAL_STATIC_WITH_ARGS(const QString, baseFilenameRegExp, (QLatin1String("^[^\\:?\"*|\\/<>]+$"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, baseFilenameRegExp, (QLatin1String("^[^\\:?\"*|\\/<>]+$"))) // NOLINT
#endif #endif
QT_WARNING_POP
} // namespace
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
DialogSaveManualLayout::DialogSaveManualLayout(vsizetype count, bool consoleExport, const QString &fileName, DialogSaveManualLayout::DialogSaveManualLayout(vsizetype count, bool consoleExport, const QString &fileName,
QWidget *parent) QWidget *parent)
@ -64,7 +76,7 @@ DialogSaveManualLayout::DialogSaveManualLayout(vsizetype count, bool consoleExpo
SCASSERT(bOk != nullptr) SCASSERT(bOk != nullptr)
bOk->setEnabled(false); bOk->setEnabled(false);
ui->lineEditFileName->setValidator( new QRegularExpressionValidator(QRegularExpression(*baseFilenameRegExp), this)); ui->lineEditFileName->setValidator(new QRegularExpressionValidator(QRegularExpression(*baseFilenameRegExp), this));
const QString mask = m_count > 1 ? fileName + '_' : fileName; const QString mask = m_count > 1 ? fileName + '_' : fileName;
if (not m_consoleExport) if (not m_consoleExport)
@ -91,14 +103,15 @@ DialogSaveManualLayout::DialogSaveManualLayout(vsizetype count, bool consoleExpo
RemoveFormatFromList(LayoutExportFormats::OBJ); RemoveFormatFromList(LayoutExportFormats::OBJ);
#endif #endif
// RemoveFormatFromList(LayoutExportFormats::NC); // No support for now // RemoveFormatFromList(LayoutExportFormats::NC); // No support for now
connect(bOk, &QPushButton::clicked, this, &DialogSaveManualLayout::Save); connect(bOk, &QPushButton::clicked, this, &DialogSaveManualLayout::Save);
connect(ui->lineEditFileName, &QLineEdit::textChanged, this, &DialogSaveManualLayout::ShowExample); connect(ui->lineEditFileName, &QLineEdit::textChanged, this, &DialogSaveManualLayout::ShowExample);
connect(ui->comboBoxFormat, QOverload<int>::of(&QComboBox::currentIndexChanged), connect(ui->comboBoxFormat, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
this, &DialogSaveManualLayout::ShowExample); &DialogSaveManualLayout::ShowExample);
connect(ui->pushButtonBrowse, &QPushButton::clicked, this, [this]() connect(ui->pushButtonBrowse, &QPushButton::clicked, this,
[this]()
{ {
const QString dirPath = VPApplication::VApp()->PuzzleSettings()->GetPathManualLayouts(); const QString dirPath = VPApplication::VApp()->PuzzleSettings()->GetPathManualLayouts();
bool usedNotExistedDir = false; bool usedNotExistedDir = false;
@ -113,7 +126,7 @@ DialogSaveManualLayout::DialogSaveManualLayout(vsizetype count, bool consoleExpo
VAbstractApplication::VApp()->NativeFileDialog(QFileDialog::ShowDirsOnly | VAbstractApplication::VApp()->NativeFileDialog(QFileDialog::ShowDirsOnly |
QFileDialog::DontResolveSymlinks)); QFileDialog::DontResolveSymlinks));
if (not dir.isEmpty()) if (not dir.isEmpty())
{// If paths equal the signal will not be called, we will do this manually { // If paths equal the signal will not be called, we will do this manually
dir == ui->lineEditPath->text() ? PathChanged(dir) : ui->lineEditPath->setText(dir); dir == ui->lineEditPath->text() ? PathChanged(dir) : ui->lineEditPath->setText(dir);
} }
@ -129,7 +142,7 @@ DialogSaveManualLayout::DialogSaveManualLayout(vsizetype count, bool consoleExpo
ReadSettings(); ReadSettings();
ShowExample();//Show example for current format. ShowExample(); // Show example for current format.
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -175,7 +188,7 @@ void DialogSaveManualLayout::SelectFormat(LayoutExportFormats format)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogSaveManualLayout::SetBinaryDXFFormat(bool binary) void DialogSaveManualLayout::SetBinaryDXFFormat(bool binary)
{ {
switch(Format()) switch (Format())
{ {
case LayoutExportFormats::DXF_AC1006_Flat: case LayoutExportFormats::DXF_AC1006_Flat:
case LayoutExportFormats::DXF_AC1009_Flat: case LayoutExportFormats::DXF_AC1009_Flat:
@ -199,7 +212,7 @@ void DialogSaveManualLayout::SetBinaryDXFFormat(bool binary)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto DialogSaveManualLayout::IsBinaryDXFFormat() const -> bool auto DialogSaveManualLayout::IsBinaryDXFFormat() const -> bool
{ {
switch(Format()) switch (Format())
{ {
case LayoutExportFormats::DXF_AC1006_Flat: case LayoutExportFormats::DXF_AC1006_Flat:
case LayoutExportFormats::DXF_AC1009_Flat: case LayoutExportFormats::DXF_AC1009_Flat:
@ -221,7 +234,7 @@ auto DialogSaveManualLayout::IsBinaryDXFFormat() const -> bool
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogSaveManualLayout::SetShowGrainline(bool show) void DialogSaveManualLayout::SetShowGrainline(bool show)
{ {
switch(Format()) switch (Format())
{ {
case LayoutExportFormats::SVG: case LayoutExportFormats::SVG:
case LayoutExportFormats::PDF: case LayoutExportFormats::PDF:
@ -250,7 +263,7 @@ void DialogSaveManualLayout::SetShowGrainline(bool show)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto DialogSaveManualLayout::IsShowGrainline() const -> bool auto DialogSaveManualLayout::IsShowGrainline() const -> bool
{ {
switch(Format()) switch (Format())
{ {
case LayoutExportFormats::SVG: case LayoutExportFormats::SVG:
case LayoutExportFormats::PDF: case LayoutExportFormats::PDF:
@ -315,7 +328,7 @@ void DialogSaveManualLayout::SetTextAsPaths(bool textAsPaths)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogSaveManualLayout::SetExportUnified(bool value) void DialogSaveManualLayout::SetExportUnified(bool value)
{ {
switch(Format()) switch (Format())
{ {
case LayoutExportFormats::PDF: case LayoutExportFormats::PDF:
case LayoutExportFormats::PDFTiled: case LayoutExportFormats::PDFTiled:
@ -332,7 +345,7 @@ void DialogSaveManualLayout::SetExportUnified(bool value)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto DialogSaveManualLayout::IsExportUnified() const -> bool auto DialogSaveManualLayout::IsExportUnified() const -> bool
{ {
switch(Format()) switch (Format())
{ {
case LayoutExportFormats::PDF: case LayoutExportFormats::PDF:
case LayoutExportFormats::PDFTiled: case LayoutExportFormats::PDFTiled:
@ -347,7 +360,7 @@ auto DialogSaveManualLayout::IsExportUnified() const -> bool
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogSaveManualLayout::SetTilesScheme(bool value) void DialogSaveManualLayout::SetTilesScheme(bool value)
{ {
switch(Format()) switch (Format())
{ {
case LayoutExportFormats::PDFTiled: case LayoutExportFormats::PDFTiled:
ui->checkBoxTilesScheme->setChecked(value); ui->checkBoxTilesScheme->setChecked(value);
@ -361,7 +374,7 @@ void DialogSaveManualLayout::SetTilesScheme(bool value)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto DialogSaveManualLayout::IsTilesScheme() const -> bool auto DialogSaveManualLayout::IsTilesScheme() const -> bool
{ {
switch(Format()) switch (Format())
{ {
case LayoutExportFormats::PDFTiled: case LayoutExportFormats::PDFTiled:
return ui->checkBoxTilesScheme->isChecked(); return ui->checkBoxTilesScheme->isChecked();
@ -373,8 +386,8 @@ auto DialogSaveManualLayout::IsTilesScheme() const -> bool
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogSaveManualLayout::showEvent(QShowEvent *event) void DialogSaveManualLayout::showEvent(QShowEvent *event)
{ {
QDialog::showEvent( event ); QDialog::showEvent(event);
if ( event->spontaneous() ) if (event->spontaneous())
{ {
return; return;
} }
@ -387,7 +400,7 @@ void DialogSaveManualLayout::showEvent(QShowEvent *event)
setFixedHeight(size().height()); setFixedHeight(size().height());
m_isInitialized = true;//first show windows are held m_isInitialized = true; // first show windows are held
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -395,12 +408,12 @@ void DialogSaveManualLayout::Save()
{ {
WriteSettings(); WriteSettings();
for (int i=0; i < m_count; ++i) for (int i = 0; i < m_count; ++i)
{ {
QString name; QString name;
if (m_count > 1 && not IsExportUnified()) if (m_count > 1 && not IsExportUnified())
{ {
name = Path() + '/' + FileName() + QString::number(i+1) + VLayoutExporter::ExportFormatSuffix(Format()); name = Path() + '/' + FileName() + QString::number(i + 1) + VLayoutExporter::ExportFormatSuffix(Format());
} }
else else
{ {
@ -409,9 +422,10 @@ void DialogSaveManualLayout::Save()
if (QFile::exists(name)) if (QFile::exists(name))
{ {
QMessageBox::StandardButton res = QMessageBox::question(this, tr("Name conflict"), QMessageBox::StandardButton res = QMessageBox::question(
tr("Folder already contain file with name %1. Rewrite all conflict file names?") this, tr("Name conflict"),
.arg(name), QMessageBox::Yes|QMessageBox::No, QMessageBox::Yes); tr("Folder already contain file with name %1. Rewrite all conflict file names?").arg(name),
QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
if (res == QMessageBox::No) if (res == QMessageBox::No)
{ {
reject(); reject();
@ -470,7 +484,7 @@ void DialogSaveManualLayout::ShowExample()
ui->checkBoxTilesScheme->setEnabled(false); ui->checkBoxTilesScheme->setEnabled(false);
ui->checkBoxShowGrainline->setEnabled(true); ui->checkBoxShowGrainline->setEnabled(true);
switch(currentFormat) switch (currentFormat)
{ {
case LayoutExportFormats::DXF_AAMA: case LayoutExportFormats::DXF_AAMA:
case LayoutExportFormats::DXF_ASTM: case LayoutExportFormats::DXF_ASTM:
@ -525,14 +539,12 @@ auto DialogSaveManualLayout::SupportPSTest() -> bool
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto DialogSaveManualLayout::InitFormats() -> QVector<std::pair<QString, LayoutExportFormats> > auto DialogSaveManualLayout::InitFormats() -> QVector<std::pair<QString, LayoutExportFormats>>
{ {
QVector<std::pair<QString, LayoutExportFormats>> list; QVector<std::pair<QString, LayoutExportFormats>> list;
auto InitFormat = [&list](LayoutExportFormats format) auto InitFormat = [&list](LayoutExportFormats format)
{ { list.append(std::make_pair(VLayoutExporter::ExportFormatDescription(format), format)); };
list.append(std::make_pair(VLayoutExporter::ExportFormatDescription(format), format));
};
InitFormat(LayoutExportFormats::SVG); InitFormat(LayoutExportFormats::SVG);
InitFormat(LayoutExportFormats::PDF); InitFormat(LayoutExportFormats::PDF);
@ -555,7 +567,7 @@ auto DialogSaveManualLayout::InitFormats() -> QVector<std::pair<QString, LayoutE
InitFormat(LayoutExportFormats::DXF_AAMA); InitFormat(LayoutExportFormats::DXF_AAMA);
InitFormat(LayoutExportFormats::DXF_ASTM); InitFormat(LayoutExportFormats::DXF_ASTM);
InitFormat(LayoutExportFormats::PDFTiled); InitFormat(LayoutExportFormats::PDFTiled);
// InitFormat(LayoutExportFormats::NC); // InitFormat(LayoutExportFormats::NC);
InitFormat(LayoutExportFormats::RLD); InitFormat(LayoutExportFormats::RLD);
InitFormat(LayoutExportFormats::TIF); InitFormat(LayoutExportFormats::TIF);

View File

@ -42,20 +42,24 @@
#include "../layout/vplayout.h" #include "../layout/vplayout.h"
#include "../layout/vppiece.h" #include "../layout/vppiece.h"
#include "../layout/vpsheet.h" #include "../layout/vpsheet.h"
#include "../vlayout/vgraphicsfillitem.h" #include "../vformat/vsinglelineoutlinechar.h"
#include "../vlayout/vtextmanager.h"
#include "../vpapplication.h"
#include "../vlayout/vlayoutpiecepath.h"
#include "compatibility.h"
#include "../vgeometry/vlayoutplacelabel.h" #include "../vgeometry/vlayoutplacelabel.h"
#include "../vlayout/vgraphicsfillitem.h"
#include "../vlayout/vlayoutpiecepath.h"
#include "../vlayout/vtextmanager.h"
#include "../vmisc/svgfont/vsvgfont.h"
#include "../vmisc/svgfont/vsvgfontdatabase.h"
#include "../vmisc/svgfont/vsvgfontengine.h"
#include "../vpapplication.h"
#include "compatibility.h"
#include "undocommands/vpundomovepieceonsheet.h" #include "undocommands/vpundomovepieceonsheet.h"
#include "undocommands/vpundopiecemove.h" #include "undocommands/vpundopiecemove.h"
#include "vpiecegrainline.h" #include "vpiecegrainline.h"
#if QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
#include "../vmisc/diagnostic.h"
#endif // QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
#include <QLoggingCategory> #include <QLoggingCategory>
QT_WARNING_PUSH QT_WARNING_PUSH
@ -68,9 +72,14 @@ QT_WARNING_POP
namespace namespace
{ {
QT_WARNING_PUSH
QT_WARNING_DISABLE_CLANG("-Wunused-member-function")
Q_GLOBAL_STATIC_WITH_ARGS(QColor, mainColor, (Qt::black)) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(QColor, mainColor, (Qt::black)) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(QColor, errorColor, (Qt::red)) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(QColor, errorColor, (Qt::red)) // NOLINT
QT_WARNING_POP
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
inline auto LineMatrix(const VPPiecePtr &piece, const QPointF &topLeft, qreal angle, const QPointF &linePos, inline auto LineMatrix(const VPPiecePtr &piece, const QPointF &topLeft, qreal angle, const QPointF &linePos,
int maxLineWidth) -> QTransform int maxLineWidth) -> QTransform

View File

@ -29,11 +29,11 @@
#ifndef VPGRAPHICSPIECE_H #ifndef VPGRAPHICSPIECE_H
#define VPGRAPHICSPIECE_H #define VPGRAPHICSPIECE_H
#include <QGraphicsItem>
#include <QCursor> #include <QCursor>
#include <QGraphicsItem>
#include "scenedef.h"
#include "../layout/layoutdef.h" #include "../layout/layoutdef.h"
#include "scenedef.h"
#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) #if QT_VERSION < QT_VERSION_CHECK(5, 13, 0)
#include "../vmisc/defglobal.h" #include "../vmisc/defglobal.h"
@ -45,6 +45,7 @@ class VGraphicsFillItem;
class VPGraphicsPiece : public QGraphicsObject class VPGraphicsPiece : public QGraphicsObject
{ {
Q_OBJECT // NOLINT Q_OBJECT // NOLINT
public: public:
explicit VPGraphicsPiece(const VPPiecePtr &piece, QGraphicsItem *parent = nullptr); explicit VPGraphicsPiece(const VPPiecePtr &piece, QGraphicsItem *parent = nullptr);
~VPGraphicsPiece() override = default; ~VPGraphicsPiece() override = default;
@ -55,8 +56,11 @@ public:
*/ */
auto GetPiece() -> VPPiecePtr; auto GetPiece() -> VPPiecePtr;
auto type() const -> int override {return Type;} auto type() const -> int override { return Type; }
enum { Type = UserType + static_cast<int>(PGraphicsItem::Piece)}; enum
{
Type = UserType + static_cast<int>(PGraphicsItem::Piece)
};
void SetStickyPoints(const QVector<QPointF> &newStickyPoint); void SetStickyPoints(const QVector<QPointF> &newStickyPoint);
@ -75,7 +79,7 @@ protected:
auto shape() const -> QPainterPath override; auto shape() const -> QPainterPath override;
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override; void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
void mousePressEvent(QGraphicsSceneMouseEvent * event) override; void mousePressEvent(QGraphicsSceneMouseEvent *event) override;
void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override; void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override;
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override; void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override;
@ -120,7 +124,7 @@ private:
void InitLabels(); void InitLabels();
void InitPieceLabel(const QVector<QPointF> &labelShape, const VTextManager &tm); void InitPieceLabel(const QVector<QPointF> &labelShape, const VTextManager &tm);
void InitGrainlineItem(); void InitGrainlineItem();
void PaintPiece(QPainter *painter=nullptr); void PaintPiece(QPainter *painter = nullptr);
void PaintSeamLine(QPainter *painter, const VPPiecePtr &piece); void PaintSeamLine(QPainter *painter, const VPPiecePtr &piece);
void PaintCuttingLine(QPainter *painter, const VPPiecePtr &piece); void PaintCuttingLine(QPainter *painter, const VPPiecePtr &piece);
void PaintInternalPaths(QPainter *painter, const VPPiecePtr &piece); void PaintInternalPaths(QPainter *painter, const VPPiecePtr &piece);

View File

@ -28,26 +28,30 @@
#include "vpgraphicspiececontrols.h" #include "vpgraphicspiececontrols.h"
#include <QCursor> #include <QCursor>
#include <QFileInfo>
#include <QGraphicsScene> #include <QGraphicsScene>
#include <QGraphicsSceneMouseEvent> #include <QGraphicsSceneMouseEvent>
#include <QGuiApplication>
#include <QIcon> #include <QIcon>
#include <QPainter> #include <QPainter>
#include <QtDebug>
#include <QGuiApplication>
#include <QScreen> #include <QScreen>
#include <QFileInfo> #include <QtDebug>
#include "../vmisc/compatibility.h"
#include "../vwidgets/global.h"
#include "../layout/vplayout.h" #include "../layout/vplayout.h"
#include "../layout/vppiece.h" #include "../layout/vppiece.h"
#include "../layout/vpsheet.h" #include "../layout/vpsheet.h"
#include "../undocommands/vpundopiecerotate.h"
#include "../undocommands/vpundooriginmove.h" #include "../undocommands/vpundooriginmove.h"
#include "../undocommands/vpundopiecerotate.h"
#include "../vmisc/compatibility.h"
#include "../vwidgets/global.h"
#include "qgraphicsscene.h" #include "qgraphicsscene.h"
#include "qgraphicsview.h" #include "qgraphicsview.h"
#include "qnamespace.h" #include "qnamespace.h"
#if QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
#include "../vmisc/diagnostic.h"
#endif // QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
namespace namespace
{ {
constexpr qreal penWidth = 2; constexpr qreal penWidth = 2;
@ -55,9 +59,14 @@ constexpr qreal penWidth = 2;
const qreal centerRadius1 = 5; const qreal centerRadius1 = 5;
const qreal centerRadius2 = 10; const qreal centerRadius2 = 10;
QT_WARNING_PUSH
QT_WARNING_DISABLE_CLANG("-Wunused-member-function")
Q_GLOBAL_STATIC_WITH_ARGS(const QColor, defaultColor, (Qt::black)) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QColor, defaultColor, (Qt::black)) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QColor, hoverColor, (Qt::green)) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QColor, hoverColor, (Qt::green)) // NOLINT
QT_WARNING_POP
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto TransformationOrigin(const VPLayoutPtr &layout, const QRectF &boundingRect) -> VPTransformationOrigon auto TransformationOrigin(const VPLayoutPtr &layout, const QRectF &boundingRect) -> VPTransformationOrigon
{ {
@ -120,7 +129,7 @@ void VPGraphicsTransformationOrigin::on_ShowOrigin(bool show)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VPGraphicsTransformationOrigin::boundingRect() const -> QRectF auto VPGraphicsTransformationOrigin::boundingRect() const -> QRectF
{ {
constexpr qreal halfPenWidth = penWidth/2.; constexpr qreal halfPenWidth = penWidth / 2.;
return Center2().boundingRect().adjusted(-halfPenWidth, -halfPenWidth, halfPenWidth, halfPenWidth); return Center2().boundingRect().adjusted(-halfPenWidth, -halfPenWidth, halfPenWidth, halfPenWidth);
} }
@ -138,7 +147,7 @@ void VPGraphicsTransformationOrigin::paint(QPainter *painter, const QStyleOption
const qreal scale = SceneScale(scene()); const qreal scale = SceneScale(scene());
QPen pen(m_color, penWidth/scale, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); QPen pen(m_color, penWidth / scale, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
painter->setPen(pen); painter->setPen(pen);
@ -160,14 +169,14 @@ void VPGraphicsTransformationOrigin::paint(QPainter *painter, const QStyleOption
void VPGraphicsTransformationOrigin::mousePressEvent(QGraphicsSceneMouseEvent *event) void VPGraphicsTransformationOrigin::mousePressEvent(QGraphicsSceneMouseEvent *event)
{ {
// change the cursor when clicking the left button // change the cursor when clicking the left button
if((event->button() == Qt::LeftButton)) if ((event->button() == Qt::LeftButton))
{ {
setCursor(Qt::ClosedHandCursor); setCursor(Qt::ClosedHandCursor);
event->accept(); event->accept();
} }
else else
{ {
//perform the default behaviour // perform the default behaviour
QGraphicsObject::mousePressEvent(event); QGraphicsObject::mousePressEvent(event);
} }
} }
@ -198,7 +207,7 @@ void VPGraphicsTransformationOrigin::mouseMoveEvent(QGraphicsSceneMouseEvent *ev
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPGraphicsTransformationOrigin::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) void VPGraphicsTransformationOrigin::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{ {
//perform the default behaviour // perform the default behaviour
QGraphicsItem::mouseReleaseEvent(event); QGraphicsItem::mouseReleaseEvent(event);
// change the cursor when clicking left button // change the cursor when clicking left button
@ -229,9 +238,10 @@ auto VPGraphicsTransformationOrigin::RotationCenter(QPainter *painter) const ->
QPainterPath path; QPainterPath path;
const qreal scale = SceneScale(scene()); const qreal scale = SceneScale(scene());
qreal radius = centerRadius1/scale; qreal radius = centerRadius1 / scale;
VPTransformationOrigon transformationOrigin = TransformationOrigin(m_layout, QRectF()); VPTransformationOrigon transformationOrigin = TransformationOrigin(m_layout, QRectF());
QRectF rect(transformationOrigin.origin.x()-radius, transformationOrigin.origin.y()-radius, radius*2., radius*2.); QRectF rect(transformationOrigin.origin.x() - radius, transformationOrigin.origin.y() - radius, radius * 2.,
radius * 2.);
QPainterPath center1; QPainterPath center1;
center1.addEllipse(rect); center1.addEllipse(rect);
@ -245,8 +255,9 @@ auto VPGraphicsTransformationOrigin::RotationCenter(QPainter *painter) const ->
} }
path.addPath(center1); path.addPath(center1);
radius = centerRadius2/scale; radius = centerRadius2 / scale;
rect = QRectF(transformationOrigin.origin.x()-radius, transformationOrigin.origin.y()-radius, radius*2., radius*2.); rect = QRectF(transformationOrigin.origin.x() - radius, transformationOrigin.origin.y() - radius, radius * 2.,
radius * 2.);
QPainterPath center2; QPainterPath center2;
center2.addEllipse(rect); center2.addEllipse(rect);
@ -267,9 +278,10 @@ auto VPGraphicsTransformationOrigin::RotationCenter(QPainter *painter) const ->
auto VPGraphicsTransformationOrigin::Center1() const -> QPainterPath auto VPGraphicsTransformationOrigin::Center1() const -> QPainterPath
{ {
const qreal scale = SceneScale(scene()); const qreal scale = SceneScale(scene());
qreal radius = centerRadius1/scale; qreal radius = centerRadius1 / scale;
VPTransformationOrigon transformationOrigin = TransformationOrigin(m_layout, QRectF()); VPTransformationOrigon transformationOrigin = TransformationOrigin(m_layout, QRectF());
QRectF rect(transformationOrigin.origin.x()-radius, transformationOrigin.origin.y()-radius, radius*2., radius*2.); QRectF rect(transformationOrigin.origin.x() - radius, transformationOrigin.origin.y() - radius, radius * 2.,
radius * 2.);
QPainterPath center1; QPainterPath center1;
center1.addEllipse(rect); center1.addEllipse(rect);
@ -281,10 +293,10 @@ auto VPGraphicsTransformationOrigin::Center1() const -> QPainterPath
auto VPGraphicsTransformationOrigin::Center2() const -> QPainterPath auto VPGraphicsTransformationOrigin::Center2() const -> QPainterPath
{ {
const qreal scale = SceneScale(scene()); const qreal scale = SceneScale(scene());
qreal radius = centerRadius2/scale; qreal radius = centerRadius2 / scale;
VPTransformationOrigon transformationOrigin = TransformationOrigin(m_layout, QRectF()); VPTransformationOrigon transformationOrigin = TransformationOrigin(m_layout, QRectF());
QRectF rect = QRectF(transformationOrigin.origin.x()-radius, transformationOrigin.origin.y()-radius, radius*2., QRectF rect = QRectF(transformationOrigin.origin.x() - radius, transformationOrigin.origin.y() - radius,
radius*2.); radius * 2., radius * 2.);
QPainterPath center2; QPainterPath center2;
center2.addEllipse(rect); center2.addEllipse(rect);
@ -383,19 +395,15 @@ void VPGraphicsPieceControls::paint(QPainter *painter, const QStyleOptionGraphic
if (m_controlsVisible) if (m_controlsVisible)
{ {
painter->drawPixmap(TopLeftHandlerPosition(), painter->drawPixmap(TopLeftHandlerPosition(),
HandlerPixmap(m_handleCorner == VPHandleCorner::TopLeft, HandlerPixmap(m_handleCorner == VPHandleCorner::TopLeft, VPHandleCornerType::TopLeft));
VPHandleCornerType::TopLeft));
painter->drawPixmap(TopRightHandlerPosition(), painter->drawPixmap(TopRightHandlerPosition(),
HandlerPixmap(m_handleCorner == VPHandleCorner::TopRight, HandlerPixmap(m_handleCorner == VPHandleCorner::TopRight, VPHandleCornerType::TopRight));
VPHandleCornerType::TopRight));
painter->drawPixmap(BottomRightHandlerPosition(), painter->drawPixmap(BottomRightHandlerPosition(), HandlerPixmap(m_handleCorner == VPHandleCorner::BottomRight,
HandlerPixmap(m_handleCorner == VPHandleCorner::BottomRight,
VPHandleCornerType::BottomRight)); VPHandleCornerType::BottomRight));
painter->drawPixmap(BottomLeftHandlerPosition(), painter->drawPixmap(BottomLeftHandlerPosition(), HandlerPixmap(m_handleCorner == VPHandleCorner::BottomLeft,
HandlerPixmap(m_handleCorner == VPHandleCorner::BottomLeft,
VPHandleCornerType::BottomLeft)); VPHandleCornerType::BottomLeft));
} }
} }
@ -403,7 +411,7 @@ void VPGraphicsPieceControls::paint(QPainter *painter, const QStyleOptionGraphic
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPGraphicsPieceControls::mousePressEvent(QGraphicsSceneMouseEvent *event) void VPGraphicsPieceControls::mousePressEvent(QGraphicsSceneMouseEvent *event)
{ {
if(event->button() == Qt::LeftButton && event->type() != QEvent::GraphicsSceneMouseDoubleClick) if (event->button() == Qt::LeftButton && event->type() != QEvent::GraphicsSceneMouseDoubleClick)
{ {
m_rotationStartPoint = event->scenePos(); m_rotationStartPoint = event->scenePos();
m_rotationSum = 0; m_rotationSum = 0;
@ -469,8 +477,8 @@ void VPGraphicsPieceControls::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
} }
else if (pieces.size() > 1) else if (pieces.size() > 1)
{ {
auto *command = new VPUndoPiecesRotate(pieces, rotationOrigin, rotateOn, m_rotationSum, auto *command =
allowChangeMerge); new VPUndoPiecesRotate(pieces, rotationOrigin, rotateOn, m_rotationSum, allowChangeMerge);
layout->UndoStack()->push(command); layout->UndoStack()->push(command);
} }
} }
@ -479,7 +487,7 @@ void VPGraphicsPieceControls::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
if (m_originSaved && m_savedOrigin.custom) if (m_originSaved && m_savedOrigin.custom)
{ {
QLineF line(rotationOrigin.origin, m_savedOrigin.origin); QLineF line(rotationOrigin.origin, m_savedOrigin.origin);
line.setAngle(line.angle()+rotateOn); line.setAngle(line.angle() + rotateOn);
m_savedOrigin.origin = line.p2(); m_savedOrigin.origin = line.p2();
} }
@ -491,7 +499,7 @@ void VPGraphicsPieceControls::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPGraphicsPieceControls::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) void VPGraphicsPieceControls::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{ {
if(event->button() == Qt::LeftButton) if (event->button() == Qt::LeftButton)
{ {
m_controlsVisible = true; m_controlsVisible = true;
m_ignorePieceTransformation = false; m_ignorePieceTransformation = false;
@ -568,17 +576,17 @@ void VPGraphicsPieceControls::InitPixmaps()
const QFileInfo fileInfo(fileName); const QFileInfo fileInfo(fileName);
const QString imageName = fileInfo.baseName(); const QString imageName = fileInfo.baseName();
const QString fileNameHover = QStringLiteral("%1/%2-hover.%3") const QString fileNameHover =
.arg(fileInfo.absolutePath(), imageName, fileInfo.suffix()); QStringLiteral("%1/%2-hover.%3").arg(fileInfo.absolutePath(), imageName, fileInfo.suffix());
#if QT_VERSION >= QT_VERSION_CHECK(5, 5, 0) #if QT_VERSION >= QT_VERSION_CHECK(5, 5, 0)
if (QGuiApplication::primaryScreen()->devicePixelRatio() >= 2 ) if (QGuiApplication::primaryScreen()->devicePixelRatio() >= 2)
{ {
const QString fileName2x = QStringLiteral("%1/%2@2x.%3") const QString fileName2x =
.arg(fileInfo.absolutePath(), imageName, fileInfo.suffix()); QStringLiteral("%1/%2@2x.%3").arg(fileInfo.absolutePath(), imageName, fileInfo.suffix());
const QString fileName2xHover = QStringLiteral("%1/%2-hover@2x.%3") const QString fileName2xHover =
.arg(fileInfo.absolutePath(), imageName, fileInfo.suffix()); QStringLiteral("%1/%2-hover@2x.%3").arg(fileInfo.absolutePath(), imageName, fileInfo.suffix());
m_handlePixmaps.insert(type, QPixmap(fileName2x)); m_handlePixmaps.insert(type, QPixmap(fileName2x));
m_handleHoverPixmaps.insert(type, QPixmap(fileName2xHover)); m_handleHoverPixmaps.insert(type, QPixmap(fileName2xHover));
@ -625,8 +633,7 @@ auto VPGraphicsPieceControls::BottomRightHandlerPosition() const -> QPointF
QRectF rect = ControllersRect(); QRectF rect = ControllersRect();
QPixmap handler = m_handlePixmaps.value(VPHandleCornerType::BottomRight); QPixmap handler = m_handlePixmaps.value(VPHandleCornerType::BottomRight);
QSize size = handler.size() / handler.devicePixelRatio(); QSize size = handler.size() / handler.devicePixelRatio();
return {rect.topLeft().x() + (rect.width() - size.width()), return {rect.topLeft().x() + (rect.width() - size.width()), rect.topLeft().y() + (rect.height() - size.height())};
rect.topLeft().y() + (rect.height() - size.height())};
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -701,7 +708,7 @@ auto VPGraphicsPieceControls::ControllersRect() const -> QRectF
QPixmap handler = m_handlePixmaps.value(VPHandleCornerType::TopLeft); QPixmap handler = m_handlePixmaps.value(VPHandleCornerType::TopLeft);
QRectF pieceRect = m_pieceRect; QRectF pieceRect = m_pieceRect;
pieceRect = QRectF(pieceRect.topLeft()*scale, QSizeF(pieceRect.width()*scale, pieceRect.height()*scale)); pieceRect = QRectF(pieceRect.topLeft() * scale, QSizeF(pieceRect.width() * scale, pieceRect.height() * scale));
QRectF rect = pieceRect; QRectF rect = pieceRect;
if (pieceRect.width() < handler.width()) if (pieceRect.width() < handler.width())
@ -717,7 +724,7 @@ auto VPGraphicsPieceControls::ControllersRect() const -> QRectF
} }
const qreal gap = 2; const qreal gap = 2;
rect.adjust(- (handler.width() + gap), - (handler.height() + gap), handler.width() + gap, handler.height() + gap); rect.adjust(-(handler.width() + gap), -(handler.height() + gap), handler.width() + gap, handler.height() + gap);
return rect; return rect;
} }
@ -744,7 +751,7 @@ auto VPGraphicsPieceControls::SelectedPieces() const -> QList<VPPiecePtr>
auto VPGraphicsPieceControls::PiecesBoundingRect(const QList<VPPiecePtr> &selectedPieces) -> QRectF auto VPGraphicsPieceControls::PiecesBoundingRect(const QList<VPPiecePtr> &selectedPieces) -> QRectF
{ {
QRectF rect; QRectF rect;
for (const auto& item : selectedPieces) for (const auto &item : selectedPieces)
{ {
if (not item.isNull()) if (not item.isNull())
{ {
@ -793,7 +800,7 @@ void VPGraphicsPieceControls::UpdateCursor(VPHandleCorner corner)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPGraphicsPieceControls::PrepareTransformationOrigin(bool shiftPressed) void VPGraphicsPieceControls::PrepareTransformationOrigin(bool shiftPressed)
{ {
if(shiftPressed && m_handleCorner != VPHandleCorner::Invalid) if (shiftPressed && m_handleCorner != VPHandleCorner::Invalid)
{ {
if (m_originSaved) if (m_originSaved)
{ {
@ -900,8 +907,7 @@ void VPGraphicsPieceControls::CorrectRotationSum(const VPLayoutPtr &layout,
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VPGraphicsPieceControls::SelectedHandleCorner(const QPointF &pos) const -> VPHandleCorner auto VPGraphicsPieceControls::SelectedHandleCorner(const QPointF &pos) const -> VPHandleCorner
{ {
QMap<VPHandleCorner, QPainterPath> corners QMap<VPHandleCorner, QPainterPath> corners{
{
{VPHandleCorner::TopLeft, TopLeftControl()}, {VPHandleCorner::TopLeft, TopLeftControl()},
{VPHandleCorner::TopRight, TopRightControl()}, {VPHandleCorner::TopRight, TopRightControl()},
{VPHandleCorner::BottomRight, BottomRightControl()}, {VPHandleCorner::BottomRight, BottomRightControl()},
@ -909,12 +915,10 @@ auto VPGraphicsPieceControls::SelectedHandleCorner(const QPointF &pos) const ->
}; };
QPainterPath circle; QPainterPath circle;
circle.addEllipse(pos.x()-4, pos.y()-4, 8, 8); circle.addEllipse(pos.x() - 4, pos.y() - 4, 8, 8);
auto CheckCorner = [circle](const QPainterPath &handler) auto CheckCorner = [circle](const QPainterPath &handler)
{ { return handler.intersects(circle) || handler.contains(circle); };
return handler.intersects(circle) || handler.contains(circle);
};
auto i = corners.constBegin(); auto i = corners.constBegin();
while (i != corners.constEnd()) while (i != corners.constEnd())

View File

@ -29,26 +29,30 @@
#include "vpmaingraphicsview.h" #include "vpmaingraphicsview.h"
#include <QDragEnterEvent> #include <QDragEnterEvent>
#include <QMimeData>
#include <QKeyEvent> #include <QKeyEvent>
#include <QMenu> #include <QMenu>
#include <QMimeData>
#include <QUndoStack> #include <QUndoStack>
#include "../carousel/vpmimedatapiece.h" #include "../carousel/vpmimedatapiece.h"
#include "../layout/vplayout.h" #include "../layout/vplayout.h"
#include "../layout/vpsheet.h"
#include "../layout/vppiece.h" #include "../layout/vppiece.h"
#include "../layout/vpsheet.h"
#include "../vwidgets/vmaingraphicsscene.h" #include "../vwidgets/vmaingraphicsscene.h"
#include "undocommands/vpundopiecezvaluemove.h" #include "undocommands/vpundopiecezvaluemove.h"
#include "vpgraphicspiece.h" #include "vpgraphicspiece.h"
#include "vpgraphicspiececontrols.h" #include "vpgraphicspiececontrols.h"
#include "../undocommands/vpundomovepieceonsheet.h"
#include "../undocommands/vpundooriginmove.h"
#include "../undocommands/vpundopiecemove.h" #include "../undocommands/vpundopiecemove.h"
#include "../undocommands/vpundopiecerotate.h" #include "../undocommands/vpundopiecerotate.h"
#include "../undocommands/vpundooriginmove.h"
#include "../undocommands/vpundomovepieceonsheet.h"
#include "../undocommands/vpundoremovesheet.h" #include "../undocommands/vpundoremovesheet.h"
#if QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
#include "../vmisc/diagnostic.h"
#endif // QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
#include <QLoggingCategory> #include <QLoggingCategory>
QT_WARNING_PUSH QT_WARNING_PUSH
@ -66,11 +70,15 @@ QT_WARNING_PUSH
QT_WARNING_DISABLE_CLANG("-Wenum-enum-conversion") QT_WARNING_DISABLE_CLANG("-Wenum-enum-conversion")
#endif #endif
QT_WARNING_DISABLE_CLANG("-Wunused-member-function")
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
Q_GLOBAL_STATIC_WITH_ARGS(const QKeySequence, restoreOriginShortcut, // NOLINT // NOLINTNEXTLINE
Q_GLOBAL_STATIC_WITH_ARGS(const QKeySequence, restoreOriginShortcut,
(QKeySequence(Qt::ControlModifier | Qt::Key_Asterisk))) (QKeySequence(Qt::ControlModifier | Qt::Key_Asterisk)))
#else #else
Q_GLOBAL_STATIC_WITH_ARGS(const QKeySequence, restoreOriginShortcut, // NOLINT // NOLINTNEXTLINE
Q_GLOBAL_STATIC_WITH_ARGS(const QKeySequence, restoreOriginShortcut,
(QKeySequence(Qt::ControlModifier + Qt::Key_Asterisk))) (QKeySequence(Qt::ControlModifier + Qt::Key_Asterisk)))
#endif #endif
@ -78,8 +86,8 @@ QT_WARNING_POP
} // namespace } // namespace
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VPMainGraphicsView::VPMainGraphicsView(const VPLayoutPtr &layout, QWidget *parent) : VPMainGraphicsView::VPMainGraphicsView(const VPLayoutPtr &layout, QWidget *parent)
VMainGraphicsView(parent), : VMainGraphicsView(parent),
m_layout(layout) m_layout(layout)
{ {
SCASSERT(not layout.isNull()) SCASSERT(not layout.isNull())
@ -131,7 +139,7 @@ void VPMainGraphicsView::dragEnterEvent(QDragEnterEvent *event)
{ {
const QMimeData *mime = event->mimeData(); const QMimeData *mime = event->mimeData();
if(mime->hasFormat(VPMimeDataPiece::mineFormatPiecePtr)) if (mime->hasFormat(VPMimeDataPiece::mineFormatPiecePtr))
{ {
VPLayoutPtr layout = m_layout.toStrongRef(); VPLayoutPtr layout = m_layout.toStrongRef();
if (layout.isNull()) if (layout.isNull())
@ -139,7 +147,7 @@ void VPMainGraphicsView::dragEnterEvent(QDragEnterEvent *event)
return; return;
} }
const auto *mimePiece = qobject_cast<const VPMimeDataPiece *> (mime); const auto *mimePiece = qobject_cast<const VPMimeDataPiece *>(mime);
if (mimePiece != nullptr && mimePiece->LayoutUuid() == layout->Uuid()) if (mimePiece != nullptr && mimePiece->LayoutUuid() == layout->Uuid())
{ {
qCDebug(pMainGraphicsView(), "drag enter"); qCDebug(pMainGraphicsView(), "drag enter");
@ -153,7 +161,7 @@ void VPMainGraphicsView::dragMoveEvent(QDragMoveEvent *event)
{ {
const QMimeData *mime = event->mimeData(); const QMimeData *mime = event->mimeData();
if(mime->hasFormat(VPMimeDataPiece::mineFormatPiecePtr)) if (mime->hasFormat(VPMimeDataPiece::mineFormatPiecePtr))
{ {
VPLayoutPtr layout = m_layout.toStrongRef(); VPLayoutPtr layout = m_layout.toStrongRef();
if (layout.isNull()) if (layout.isNull())
@ -161,7 +169,7 @@ void VPMainGraphicsView::dragMoveEvent(QDragMoveEvent *event)
return; return;
} }
const auto *mimePiece = qobject_cast<const VPMimeDataPiece *> (mime); const auto *mimePiece = qobject_cast<const VPMimeDataPiece *>(mime);
if (mimePiece != nullptr && mimePiece->LayoutUuid() == layout->Uuid()) if (mimePiece != nullptr && mimePiece->LayoutUuid() == layout->Uuid())
{ {
event->acceptProposedAction(); event->acceptProposedAction();
@ -182,7 +190,7 @@ void VPMainGraphicsView::dropEvent(QDropEvent *event)
qCDebug(pMainGraphicsView(), "drop enter , %s", qUtf8Printable(mime->objectName())); qCDebug(pMainGraphicsView(), "drop enter , %s", qUtf8Printable(mime->objectName()));
if(mime->hasFormat(VPMimeDataPiece::mineFormatPiecePtr)) if (mime->hasFormat(VPMimeDataPiece::mineFormatPiecePtr))
{ {
VPLayoutPtr layout = m_layout.toStrongRef(); VPLayoutPtr layout = m_layout.toStrongRef();
if (layout.isNull()) if (layout.isNull())
@ -190,7 +198,7 @@ void VPMainGraphicsView::dropEvent(QDropEvent *event)
return; return;
} }
const auto *mimePiece = qobject_cast<const VPMimeDataPiece *> (mime); const auto *mimePiece = qobject_cast<const VPMimeDataPiece *>(mime);
if (mimePiece == nullptr || mimePiece->LayoutUuid() != layout->Uuid()) if (mimePiece == nullptr || mimePiece->LayoutUuid() != layout->Uuid())
{ {
@ -198,7 +206,7 @@ void VPMainGraphicsView::dropEvent(QDropEvent *event)
} }
VPPiecePtr piece = mimePiece->GetPiecePtr(); VPPiecePtr piece = mimePiece->GetPiecePtr();
if(not piece.isNull()) if (not piece.isNull())
{ {
qCDebug(pMainGraphicsView(), "element dropped, %s", qUtf8Printable(piece->GetName())); qCDebug(pMainGraphicsView(), "element dropped, %s", qUtf8Printable(piece->GetName()));
event->acceptProposedAction(); event->acceptProposedAction();
@ -220,7 +228,7 @@ void VPMainGraphicsView::keyPressEvent(QKeyEvent *event)
const bool controlModifier = (event->modifiers() & Qt::ControlModifier) != 0U; const bool controlModifier = (event->modifiers() & Qt::ControlModifier) != 0U;
const bool altModifier = (event->modifiers() & Qt::AltModifier) != 0U; const bool altModifier = (event->modifiers() & Qt::AltModifier) != 0U;
switch(event->key()) switch (event->key())
{ {
case Qt::Key_Backspace: case Qt::Key_Backspace:
case Qt::Key_Delete: case Qt::Key_Delete:
@ -239,11 +247,11 @@ void VPMainGraphicsView::keyPressEvent(QKeyEvent *event)
shiftModifier ? TranslatePiecesOn(0, 10) : TranslatePiecesOn(0, 1); shiftModifier ? TranslatePiecesOn(0, 10) : TranslatePiecesOn(0, 1);
break; break;
case Qt::Key_BracketLeft: case Qt::Key_BracketLeft:
if(controlModifier) if (controlModifier)
{ {
RotatePiecesByAngle(90); RotatePiecesByAngle(90);
} }
else if(altModifier) else if (altModifier)
{ {
RotatePiecesByAngle(1); RotatePiecesByAngle(1);
} }
@ -253,11 +261,11 @@ void VPMainGraphicsView::keyPressEvent(QKeyEvent *event)
} }
break; break;
case Qt::Key_BracketRight: case Qt::Key_BracketRight:
if(controlModifier) if (controlModifier)
{ {
RotatePiecesByAngle(-90); RotatePiecesByAngle(-90);
} }
else if(altModifier) else if (altModifier)
{ {
RotatePiecesByAngle(-1); RotatePiecesByAngle(-1);
} }
@ -286,7 +294,7 @@ void VPMainGraphicsView::keyPressEvent(QKeyEvent *event)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPMainGraphicsView::keyReleaseEvent(QKeyEvent *event) void VPMainGraphicsView::keyReleaseEvent(QKeyEvent *event)
{ {
switch(event->key()) switch (event->key())
{ {
case Qt::Key_Left: case Qt::Key_Left:
case Qt::Key_Right: case Qt::Key_Right:
@ -360,7 +368,6 @@ void VPMainGraphicsView::contextMenuEvent(QContextMenuEvent *event)
{ {
RestoreOrigin(); RestoreOrigin();
} }
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -382,7 +389,7 @@ void VPMainGraphicsView::RestoreOrigin() const
QRectF boundingRect; QRectF boundingRect;
QList<VPPiecePtr> selectedPieces = sheet->GetSelectedPieces(); QList<VPPiecePtr> selectedPieces = sheet->GetSelectedPieces();
for (const auto& piece : selectedPieces) for (const auto &piece : selectedPieces)
{ {
if (piece->IsSelected()) if (piece->IsSelected())
{ {
@ -582,7 +589,7 @@ void VPMainGraphicsView::ClearSelection()
} }
QList<VPPiecePtr> pieces = sheet->GetSelectedPieces(); QList<VPPiecePtr> pieces = sheet->GetSelectedPieces();
for (const auto& piece : pieces) for (const auto &piece : pieces)
{ {
piece->SetSelected(false); piece->SetSelected(false);
emit layout->PieceSelectionChanged(piece); emit layout->PieceSelectionChanged(piece);
@ -640,15 +647,15 @@ void VPMainGraphicsView::RemovePiece() const
VPSheetPtr sheet = layout->GetFocusedSheet(); VPSheetPtr sheet = layout->GetFocusedSheet();
if (sheet.isNull()) if (sheet.isNull())
{ {
return ; return;
} }
const QList<VPGraphicsPiece *> &graphicsPieces = sheet->SceneData()->GraphicsPieces(); const QList<VPGraphicsPiece *> &graphicsPieces = sheet->SceneData()->GraphicsPieces();
for(auto *graphicsPiece : graphicsPieces) for (auto *graphicsPiece : graphicsPieces)
{ {
VPPiecePtr piece = graphicsPiece->GetPiece(); VPPiecePtr piece = graphicsPiece->GetPiece();
if(not piece.isNull() && piece->IsSelected()) if (not piece.isNull() && piece->IsSelected())
{ {
piece->SetSelected(false); piece->SetSelected(false);
@ -703,11 +710,10 @@ void VPMainGraphicsView::MovePiece(QKeyEvent *event)
{ {
const VPPiecePtr &p = ConstFirst(pieces); const VPPiecePtr &p = ConstFirst(pieces);
auto *command = new VPUndoPieceMove(p, m_stickyTranslateX, m_stickyTranslateY, auto *command = new VPUndoPieceMove(p, m_stickyTranslateX, m_stickyTranslateY, m_allowChangeMerge);
m_allowChangeMerge);
layout->UndoStack()->push(command); layout->UndoStack()->push(command);
VPGraphicsPiece * gPiece = sheet->SceneData()->ScenePiece(p); VPGraphicsPiece *gPiece = sheet->SceneData()->ScenePiece(p);
if (gPiece != nullptr) if (gPiece != nullptr)
{ {
gPiece->SetStickyPoints(QVector<QPointF>()); gPiece->SetStickyPoints(QVector<QPointF>());
@ -750,7 +756,7 @@ void VPMainGraphicsView::on_PieceSheetChanged(const VPPiecePtr &piece)
} }
else // add else // add
{ {
if(graphicsPiece == nullptr) if (graphicsPiece == nullptr)
{ {
graphicsPiece = new VPGraphicsPiece(piece); graphicsPiece = new VPGraphicsPiece(piece);
sheet->SceneData()->AddPiece(graphicsPiece); sheet->SceneData()->AddPiece(graphicsPiece);

File diff suppressed because it is too large Load Diff

View File

@ -28,34 +28,55 @@
#include "vpsettings.h" #include "vpsettings.h"
#include "../vmisc/compatibility.h" #include "../vmisc/compatibility.h"
#if QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
#include "../vmisc/diagnostic.h"
#endif // QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
#include <QMarginsF> #include <QMarginsF>
namespace namespace
{ {
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingDockWidgetPropertiesActive, (QLatin1String("dockWidget/properties"))) // NOLINT QT_WARNING_PUSH
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingDockPropertiesContentsActive, (QLatin1String("dockWidget/contents"))) // NOLINT QT_WARNING_DISABLE_CLANG("-Wunused-member-function")
// NOLINTNEXTLINE
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingDockWidgetPropertiesActive, (QLatin1String("dockWidget/properties")))
// NOLINTNEXTLINE
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingDockPropertiesContentsActive, (QLatin1String("dockWidget/contents")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutUnit, (QLatin1String("layout/unit"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutUnit, (QLatin1String("layout/unit"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutSheetPaperWidth, (QLatin1String("layout/sheetPaperWidth"))) // NOLINT // NOLINTNEXTLINE
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutSheetPaperHeight, (QLatin1String("layout/sheetPaperHeight"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutSheetPaperWidth, (QLatin1String("layout/sheetPaperWidth")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutTilePaperWidth, (QLatin1String("layout/tilePaperWidth"))) // NOLINT // NOLINTNEXTLINE
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutTilePaperHeight, (QLatin1String("layout/tilePaperHeight"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutSheetPaperHeight, (QLatin1String("layout/sheetPaperHeight")))
// NOLINTNEXTLINE
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutTilePaperWidth, (QLatin1String("layout/tilePaperWidth")))
// NOLINTNEXTLINE
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutTilePaperHeight, (QLatin1String("layout/tilePaperHeight")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutSheetMargins, (QLatin1String("layout/sheetMargins"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutSheetMargins, (QLatin1String("layout/sheetMargins"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutTileMargins, (QLatin1String("layout/tileMargins"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutTileMargins, (QLatin1String("layout/tileMargins"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutSheetIgnoreMargins, (QLatin1String("layout/sheetIgnoreMargins"))) // NOLINT // NOLINTNEXTLINE
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutTileIgnoreMargins, (QLatin1String("layout/tileIgnoreMargins"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutSheetIgnoreMargins, (QLatin1String("layout/sheetIgnoreMargins")))
// NOLINTNEXTLINE
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutTileIgnoreMargins, (QLatin1String("layout/tileIgnoreMargins")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutTileShowTiles, (QLatin1String("layout/tileShowTiles"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutTileShowTiles, (QLatin1String("layout/tileShowTiles"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutTileShowWatermark, (QLatin1String("layout/tileShowWatermark"))) // NOLINT // NOLINTNEXTLINE
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutWarningPiecesSuperposition, // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutTileShowWatermark, (QLatin1String("layout/tileShowWatermark")))
// NOLINTNEXTLINE
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutWarningPiecesSuperposition,
(QLatin1String("layout/warningPiecesSuperposition"))) (QLatin1String("layout/warningPiecesSuperposition")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutStickyEdges, (QLatin1String("layout/stickyEdges"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutStickyEdges, (QLatin1String("layout/stickyEdges"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutWarningPiecesOutOfBound, // NOLINT // NOLINTNEXTLINE
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutWarningPiecesOutOfBound,
(QLatin1String("layout/warningPiecesOutOfBound"))) (QLatin1String("layout/warningPiecesOutOfBound")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutFollowGrainline, (QLatin1String("layout/followGrainline"))) // NOLINT // NOLINTNEXTLINE
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutFollowGrainline, (QLatin1String("layout/followGrainline")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutPieceGap, (QLatin1String("layout/pieceGap"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutPieceGap, (QLatin1String("layout/pieceGap"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutExportFormat, (QLatin1String("layout/exportFormat"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutExportFormat, (QLatin1String("layout/exportFormat"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutLineWidth, (QLatin1String("layout/lineWidth"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutLineWidth, (QLatin1String("layout/lineWidth"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutShowGrainline, (QLatin1String("layout/showGrainline"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutShowGrainline, (QLatin1String("layout/showGrainline"))) // NOLINT
QT_WARNING_POP
int cachedLineWidth = -1; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables) int cachedLineWidth = -1; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)
} // namespace } // namespace
@ -66,13 +87,10 @@ Q_DECLARE_METATYPE(QMarginsF) // NOLINT
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VPSettings::VPSettings(Format format, Scope scope, const QString &organization, const QString &application, VPSettings::VPSettings(Format format, Scope scope, const QString &organization, const QString &application,
QObject *parent) QObject *parent)
: VCommonSettings(format, scope, organization, application, parent) : VCommonSettings(format, scope, organization, application, parent){REGISTER_META_TYPE_STREAM_OPERATORS(QMarginsF)}
{
REGISTER_META_TYPE_STREAM_OPERATORS(QMarginsF)
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VPSettings::VPSettings(const QString &fileName, QSettings::Format format, QObject *parent) VPSettings::VPSettings(const QString &fileName, QSettings::Format format, QObject *parent)
: VCommonSettings(fileName, format, parent) : VCommonSettings(fileName, format, parent)
{ {
REGISTER_META_TYPE_STREAM_OPERATORS(QMarginsF) REGISTER_META_TYPE_STREAM_OPERATORS(QMarginsF)
@ -135,7 +153,7 @@ void VPSettings::SetLayoutSheetPaperWidth(qreal width)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VPSettings::GetLayoutSheetPaperWidth() const -> qreal auto VPSettings::GetLayoutSheetPaperWidth() const -> qreal
{ {
return ValueOrDef<qreal>(*this, *settingLayoutSheetPaperWidth, UnitConvertor(841/*A0*/, Unit::Mm, Unit::Px)); return ValueOrDef<qreal>(*this, *settingLayoutSheetPaperWidth, UnitConvertor(841 /*A0*/, Unit::Mm, Unit::Px));
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -147,7 +165,7 @@ void VPSettings::SetLayoutSheetPaperHeight(qreal height)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VPSettings::GetLayoutSheetPaperHeight() const -> qreal auto VPSettings::GetLayoutSheetPaperHeight() const -> qreal
{ {
return ValueOrDef<qreal>(*this, *settingLayoutSheetPaperHeight, UnitConvertor(1189/*A0*/, Unit::Mm, Unit::Px)); return ValueOrDef<qreal>(*this, *settingLayoutSheetPaperHeight, UnitConvertor(1189 /*A0*/, Unit::Mm, Unit::Px));
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -159,7 +177,7 @@ void VPSettings::SetLayoutTilePaperWidth(qreal width)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VPSettings::GetLayoutTilePaperWidth() const -> qreal auto VPSettings::GetLayoutTilePaperWidth() const -> qreal
{ {
return ValueOrDef<qreal>(*this, *settingLayoutTilePaperWidth, UnitConvertor(210/*A4*/, Unit::Mm, Unit::Px)); return ValueOrDef<qreal>(*this, *settingLayoutTilePaperWidth, UnitConvertor(210 /*A4*/, Unit::Mm, Unit::Px));
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -171,7 +189,7 @@ void VPSettings::SetLayoutTilePaperHeight(qreal height)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VPSettings::GetLayoutTilePaperHeight() const -> qreal auto VPSettings::GetLayoutTilePaperHeight() const -> qreal
{ {
return ValueOrDef<qreal>(*this, *settingLayoutTilePaperHeight, UnitConvertor(297/*A4*/, Unit::Mm, Unit::Px)); return ValueOrDef<qreal>(*this, *settingLayoutTilePaperHeight, UnitConvertor(297 /*A4*/, Unit::Mm, Unit::Px));
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View File

@ -2,31 +2,39 @@
#include <QtSvg> #include <QtSvg>
#include "../vwidgets/vmaingraphicsscene.h" #include "../vlayout/vprintlayout.h"
#include "layout/vpsheet.h" #include "../vmisc/compatibility.h"
#include "qobject.h"
#include "scene/vpmaingraphicsview.h"
#include "../vmisc/def.h" #include "../vmisc/def.h"
#include "../vmisc/literals.h" #include "../vmisc/literals.h"
#include "../vmisc/vcommonsettings.h" #include "../vmisc/vcommonsettings.h"
#include "../vmisc/compatibility.h" #include "../vwidgets/vmaingraphicsscene.h"
#include "../vlayout/vprintlayout.h" #include "layout/vpsheet.h"
#include "qobject.h"
#if QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
#include "../vmisc/diagnostic.h"
#endif // QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
namespace namespace
{ {
QT_WARNING_PUSH
QT_WARNING_DISABLE_CLANG("-Wunused-member-function")
Q_GLOBAL_STATIC_WITH_ARGS(QColor, tileColor, (180, 180, 180)) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(QColor, tileColor, (180, 180, 180)) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(QBrush, triangleBush, (QColor(200,200,200))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(QBrush, triangleBush, (QColor(200, 200, 200))) // NOLINT
QT_WARNING_POP
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto Grayscale(QImage image) -> QImage auto Grayscale(QImage image) -> QImage
{ {
for (int ii = 0; ii < image.height(); ii++) for (int ii = 0; ii < image.height(); ii++)
{ {
uchar* scan = image.scanLine(ii); uchar *scan = image.scanLine(ii);
int depth = 4; int depth = 4;
for (int jj = 0; jj < image.width(); jj++) for (int jj = 0; jj < image.width(); jj++)
{ {
auto* rgbpixel = reinterpret_cast<QRgb*>(scan + jj * depth); // NOLINT auto *rgbpixel = reinterpret_cast<QRgb *>(scan + jj * depth); // NOLINT
int gray = qGray(*rgbpixel); int gray = qGray(*rgbpixel);
*rgbpixel = QColor(gray, gray, gray, qAlpha(*rgbpixel)).rgba(); *rgbpixel = QColor(gray, gray, gray, qAlpha(*rgbpixel)).rgba();
} }
@ -41,9 +49,11 @@ auto WatermarkImageFromCache(const VWatermarkData &watermarkData, const QString
{ {
QPixmap pixmap; QPixmap pixmap;
QString imagePath = AbsoluteMPath(watermarkPath, watermarkData.path); QString imagePath = AbsoluteMPath(watermarkPath, watermarkData.path);
QString imageCacheKey = QStringLiteral("puzzle=path%1+rotation%3+grayscale%4+xscale%5+yxcale%6") QString imageCacheKey =
.arg(imagePath, QString::number(watermarkData.imageRotation), QStringLiteral("puzzle=path%1+rotation%3+grayscale%4+xscale%5+yxcale%6")
watermarkData.grayscale ? trueStr : falseStr ).arg(xScale).arg(yScale); .arg(imagePath, QString::number(watermarkData.imageRotation), watermarkData.grayscale ? trueStr : falseStr)
.arg(xScale)
.arg(yScale);
if (not QPixmapCache::find(imageCacheKey, &pixmap)) if (not QPixmapCache::find(imageCacheKey, &pixmap))
{ {
@ -65,9 +75,9 @@ auto WatermarkImageFromCache(const VWatermarkData &watermarkData, const QString
watermark = watermark.transformed(t); watermark = watermark.transformed(t);
t = QTransform(); t = QTransform();
t.translate(watermark.width()/2., watermark.height()/2.); t.translate(watermark.width() / 2., watermark.height() / 2.);
t.rotate(-watermarkData.imageRotation); t.rotate(-watermarkData.imageRotation);
t.translate(-watermark.width()/2., -watermark.height()/2.); t.translate(-watermark.width() / 2., -watermark.height() / 2.);
watermark = watermark.transformed(t); watermark = watermark.transformed(t);
pixmap = QPixmap::fromImage(watermark); pixmap = QPixmap::fromImage(watermark);
@ -82,9 +92,7 @@ auto WatermarkImageFromCache(const VWatermarkData &watermarkData, const QString
auto TriangleBasic() -> QPainterPath auto TriangleBasic() -> QPainterPath
{ {
// ------------- prepare triangles for position marks // ------------- prepare triangles for position marks
QRectF rectBasic = QRectF(-UnitConvertor(0.5, Unit::Cm, Unit::Px), QRectF rectBasic = QRectF(-UnitConvertor(0.5, Unit::Cm, Unit::Px), 0, UnitConvertor(1, Unit::Cm, Unit::Px),
0,
UnitConvertor(1, Unit::Cm, Unit::Px),
UnitConvertor(0.5, Unit::Cm, Unit::Px)); UnitConvertor(0.5, Unit::Cm, Unit::Px));
QPainterPath triangleBasic; QPainterPath triangleBasic;
triangleBasic.moveTo(rectBasic.topLeft()); triangleBasic.moveTo(rectBasic.topLeft());
@ -101,8 +109,8 @@ constexpr qreal VPTileFactory::tileStripeWidth; // NOLINT(readability-redundant
#endif #endif
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VPTileFactory::VPTileFactory(const VPLayoutPtr &layout, VCommonSettings *commonSettings, QObject *parent): VPTileFactory::VPTileFactory(const VPLayoutPtr &layout, VCommonSettings *commonSettings, QObject *parent)
QObject(parent), : QObject(parent),
m_layout(layout), m_layout(layout),
m_commonSettings(commonSettings) m_commonSettings(commonSettings)
{ {
@ -112,7 +120,7 @@ VPTileFactory::VPTileFactory(const VPLayoutPtr &layout, VCommonSettings *commonS
void VPTileFactory::RefreshTileInfos() void VPTileFactory::RefreshTileInfos()
{ {
VPLayoutPtr layout = m_layout.toStrongRef(); VPLayoutPtr layout = m_layout.toStrongRef();
if(not layout.isNull()) if (not layout.isNull())
{ {
QSizeF tilesSize = layout->LayoutSettings().GetTilesSize(); QSizeF tilesSize = layout->LayoutSettings().GetTilesSize();
QMarginsF tilesMargins = layout->LayoutSettings().GetTilesMargins(); QMarginsF tilesMargins = layout->LayoutSettings().GetTilesMargins();
@ -139,7 +147,7 @@ void VPTileFactory::RefreshTileInfos()
void VPTileFactory::RefreshWatermarkData() void VPTileFactory::RefreshWatermarkData()
{ {
VPLayoutPtr layout = m_layout.toStrongRef(); VPLayoutPtr layout = m_layout.toStrongRef();
if(not layout.isNull()) if (not layout.isNull())
{ {
m_watermarkData = layout->WatermarkData(); m_watermarkData = layout->WatermarkData();
} }
@ -156,7 +164,7 @@ void VPTileFactory::drawTile(QPainter *painter, QPrinter *printer, const VPSheet
SCASSERT(printer != nullptr) SCASSERT(printer != nullptr)
VPLayoutPtr layout = m_layout.toStrongRef(); VPLayoutPtr layout = m_layout.toStrongRef();
if(layout.isNull()) if (layout.isNull())
{ {
return; return;
} }
@ -184,7 +192,7 @@ void VPTileFactory::drawTile(QPainter *painter, QPrinter *printer, const VPSheet
const QPair<qreal, qreal> scale = VPrintLayout::PrinterScaleDiff(printer); const QPair<qreal, qreal> scale = VPrintLayout::PrinterScaleDiff(printer);
painter->scale(scale.first, scale.second); painter->scale(scale.first, scale.second);
if(row > 0) if (row > 0)
{ {
// add top triangle // add top triangle
DrawTopTriangle(painter); DrawTopTriangle(painter);
@ -199,7 +207,7 @@ void VPTileFactory::drawTile(QPainter *painter, QPrinter *printer, const VPSheet
DrawSolidTopLine(painter, col, nbCol); DrawSolidTopLine(painter, col, nbCol);
} }
if(col > 0) if (col > 0)
{ {
// add left triangle // add left triangle
DrawLeftTriangle(painter); DrawLeftTriangle(painter);
@ -214,7 +222,7 @@ void VPTileFactory::drawTile(QPainter *painter, QPrinter *printer, const VPSheet
DrawSolidLeftLine(painter, row, nbRow); DrawSolidLeftLine(painter, row, nbRow);
} }
if(row < nbRow-1) if (row < nbRow - 1)
{ {
// add bottom triangle // add bottom triangle
DrawBottomTriangle(painter); DrawBottomTriangle(painter);
@ -230,7 +238,7 @@ void VPTileFactory::drawTile(QPainter *painter, QPrinter *printer, const VPSheet
DrawRuler(painter, scale.first); DrawRuler(painter, scale.first);
DrawWatermark(painter); DrawWatermark(painter);
if(col < nbCol-1) if (col < nbCol - 1)
{ {
// add right triangle // add right triangle
DrawRightTriangle(painter); DrawRightTriangle(painter);
@ -259,7 +267,7 @@ auto VPTileFactory::RowNb(const VPSheetPtr &sheet) const -> int
qreal yScale = 1; qreal yScale = 1;
VPLayoutPtr layout = m_layout.toStrongRef(); VPLayoutPtr layout = m_layout.toStrongRef();
if(not layout.isNull()) if (not layout.isNull())
{ {
yScale = layout->LayoutSettings().VerticalScale(); yScale = layout->LayoutSettings().VerticalScale();
} }
@ -278,7 +286,7 @@ auto VPTileFactory::ColNb(const VPSheetPtr &sheet) const -> int
qreal xScale = 1; qreal xScale = 1;
VPLayoutPtr layout = m_layout.toStrongRef(); VPLayoutPtr layout = m_layout.toStrongRef();
if(not layout.isNull()) if (not layout.isNull())
{ {
xScale = layout->LayoutSettings().HorizontalScale(); xScale = layout->LayoutSettings().HorizontalScale();
} }
@ -309,7 +317,7 @@ auto VPTileFactory::WatermarkData() const -> const VWatermarkData &
void VPTileFactory::DrawRuler(QPainter *painter, qreal scale) const void VPTileFactory::DrawRuler(QPainter *painter, qreal scale) const
{ {
VPLayoutPtr layout = m_layout.toStrongRef(); VPLayoutPtr layout = m_layout.toStrongRef();
if(layout.isNull()) if (layout.isNull())
{ {
return; return;
} }
@ -326,18 +334,18 @@ void VPTileFactory::DrawRuler(QPainter *painter, qreal scale) const
Unit rulerUnits = layoutUnits == Unit::Inch ? layoutUnits : Unit::Cm; Unit rulerUnits = layoutUnits == Unit::Inch ? layoutUnits : Unit::Cm;
const qreal step = UnitConvertor(1, rulerUnits, Unit::Px); const qreal step = UnitConvertor(1, rulerUnits, Unit::Px);
double marksCount = (m_drawingAreaWidth-tileStripeWidth) / step; double marksCount = (m_drawingAreaWidth - tileStripeWidth) / step;
int i = 0; int i = 0;
while (i < marksCount) while (i < marksCount)
{ {
if (i != 0) if (i != 0)
{ // don't need 0 notch { // don't need 0 notch
// middle ruler line // middle ruler line
painter->drawLine(QPointF(step * i - step / 2., m_drawingAreaHeight-tileStripeWidth), painter->drawLine(QPointF(step * i - step / 2., m_drawingAreaHeight - tileStripeWidth),
QPointF(step * i - step / 2., m_drawingAreaHeight - tileStripeWidth + shortNotchHeight)); QPointF(step * i - step / 2., m_drawingAreaHeight - tileStripeWidth + shortNotchHeight));
// ruler line // ruler line
painter->drawLine(QPointF(step * i, m_drawingAreaHeight-tileStripeWidth), painter->drawLine(QPointF(step * i, m_drawingAreaHeight - tileStripeWidth),
QPointF(step * i, m_drawingAreaHeight - tileStripeWidth + notchHeight)); QPointF(step * i, m_drawingAreaHeight - tileStripeWidth + notchHeight));
} }
else else
@ -345,7 +353,7 @@ void VPTileFactory::DrawRuler(QPainter *painter, qreal scale) const
painter->save(); painter->save();
QFont fnt = painter->font(); QFont fnt = painter->font();
const int size = qRound(10/scale); const int size = qRound(10 / scale);
size > 0 ? fnt.setPointSize(size) : fnt.setPointSize(10); size > 0 ? fnt.setPointSize(size) : fnt.setPointSize(10);
painter->setFont(fnt); painter->setFont(fnt);
@ -353,8 +361,9 @@ void VPTileFactory::DrawRuler(QPainter *painter, qreal scale) const
QFontMetrics fm(fnt); QFontMetrics fm(fnt);
QString units = rulerUnits != Unit::Inch ? tr("cm", "unit") : tr("in", "unit"); QString units = rulerUnits != Unit::Inch ? tr("cm", "unit") : tr("in", "unit");
unitsWidth = TextWidth(fm, units); unitsWidth = TextWidth(fm, units);
painter->drawText(QPointF(step*0.5-unitsWidth*0.6, painter->drawText(QPointF(step * 0.5 - unitsWidth * 0.6,
m_drawingAreaHeight - tileStripeWidth + notchHeight+shortNotchHeight), units); m_drawingAreaHeight - tileStripeWidth + notchHeight + shortNotchHeight),
units);
painter->restore(); painter->restore();
} }
@ -370,21 +379,18 @@ void VPTileFactory::DrawWatermark(QPainter *painter) const
SCASSERT(painter != nullptr) SCASSERT(painter != nullptr)
VPLayoutPtr layout = m_layout.toStrongRef(); VPLayoutPtr layout = m_layout.toStrongRef();
if(layout.isNull()) if (layout.isNull())
{ {
return; return;
} }
if (m_watermarkData.opacity > 0) if (m_watermarkData.opacity > 0)
{ {
QRectF img(0, 0, QRectF img(0, 0, m_drawingAreaWidth - tileStripeWidth, m_drawingAreaHeight - tileStripeWidth);
m_drawingAreaWidth - tileStripeWidth,
m_drawingAreaHeight - tileStripeWidth);
if (m_watermarkData.showImage && not m_watermarkData.path.isEmpty()) if (m_watermarkData.showImage && not m_watermarkData.path.isEmpty())
{ {
PaintWatermarkImage(painter, img, m_watermarkData, PaintWatermarkImage(painter, img, m_watermarkData, layout->LayoutSettings().WatermarkPath());
layout->LayoutSettings().WatermarkPath());
} }
if (m_watermarkData.showText && not m_watermarkData.text.isEmpty()) if (m_watermarkData.showText && not m_watermarkData.text.isEmpty())
@ -405,7 +411,7 @@ void VPTileFactory::DrawTilePageContent(QPainter *painter, const VPSheetPtr &she
QPrinter *printer) const QPrinter *printer) const
{ {
VPLayoutPtr layout = m_layout.toStrongRef(); VPLayoutPtr layout = m_layout.toStrongRef();
if(layout.isNull()) if (layout.isNull())
{ {
return; return;
} }
@ -416,23 +422,19 @@ void VPTileFactory::DrawTilePageContent(QPainter *painter, const VPSheetPtr &she
sheetMargins = sheet->GetSheetMargins(); sheetMargins = sheet->GetSheetMargins();
} }
QPen penTileDrawing = QPen(Qt::black, m_commonSettings->WidthMainLine(), Qt::SolidLine, Qt::RoundCap, QPen penTileDrawing =
Qt::RoundJoin); QPen(Qt::black, m_commonSettings->WidthMainLine(), Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
painter->setPen(penTileDrawing); painter->setPen(penTileDrawing);
// paint the content of the page // paint the content of the page
const qreal xScale = layout->LayoutSettings().HorizontalScale(); const qreal xScale = layout->LayoutSettings().HorizontalScale();
const qreal yScale = layout->LayoutSettings().VerticalScale(); const qreal yScale = layout->LayoutSettings().VerticalScale();
QRectF source = QRectF(sheetMargins.left() + col*(m_drawingAreaWidth - tileStripeWidth) / xScale, QRectF source = QRectF(sheetMargins.left() + col * (m_drawingAreaWidth - tileStripeWidth) / xScale,
sheetMargins.top() + row*(m_drawingAreaHeight - tileStripeWidth) / yScale, sheetMargins.top() + row * (m_drawingAreaHeight - tileStripeWidth) / yScale,
m_drawingAreaWidth / xScale, m_drawingAreaWidth / xScale, m_drawingAreaHeight / yScale);
m_drawingAreaHeight / yScale);
QRectF target = QRectF(0, QRectF target = QRectF(0, 0, m_drawingAreaWidth, m_drawingAreaHeight);
0,
m_drawingAreaWidth,
m_drawingAreaHeight);
sheet->SceneData()->Scene()->render(painter, VPrintLayout::SceneTargetRect(printer, target), source, sheet->SceneData()->Scene()->render(painter, VPrintLayout::SceneTargetRect(printer, target), source,
Qt::IgnoreAspectRatio); Qt::IgnoreAspectRatio);
} }
@ -440,30 +442,22 @@ void VPTileFactory::DrawTilePageContent(QPainter *painter, const VPSheetPtr &she
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPTileFactory::DrawTopTriangle(QPainter *painter) const void VPTileFactory::DrawTopTriangle(QPainter *painter) const
{ {
QPainterPath triangleTop = QPainterPath triangleTop = QTransform().translate(m_drawingAreaWidth / 2, 0).map(TriangleBasic());
QTransform()
.translate(m_drawingAreaWidth/2, 0)
.map(TriangleBasic());
painter->fillPath(triangleTop, *triangleBush); painter->fillPath(triangleTop, *triangleBush);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPTileFactory::DrawLeftTriangle(QPainter *painter) const void VPTileFactory::DrawLeftTriangle(QPainter *painter) const
{ {
QPainterPath triangleLeft = QPainterPath triangleLeft = QTransform().translate(0, m_drawingAreaHeight / 2).rotate(-90).map(TriangleBasic());
QTransform()
.translate(0, m_drawingAreaHeight/2)
.rotate(-90)
.map(TriangleBasic());
painter->fillPath(triangleLeft, *triangleBush); painter->fillPath(triangleLeft, *triangleBush);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPTileFactory::DrawBottomTriangle(QPainter *painter) const void VPTileFactory::DrawBottomTriangle(QPainter *painter) const
{ {
QPainterPath triangleBottom = QPainterPath triangleBottom = QTransform()
QTransform() .translate(m_drawingAreaWidth / 2, m_drawingAreaHeight - tileStripeWidth)
.translate(m_drawingAreaWidth/2, m_drawingAreaHeight - tileStripeWidth)
.rotate(180) .rotate(180)
.map(TriangleBasic()); .map(TriangleBasic());
painter->fillPath(triangleBottom, *triangleBush); painter->fillPath(triangleBottom, *triangleBush);
@ -472,9 +466,8 @@ void VPTileFactory::DrawBottomTriangle(QPainter *painter) const
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPTileFactory::DrawRightTriangle(QPainter *painter) const void VPTileFactory::DrawRightTriangle(QPainter *painter) const
{ {
QPainterPath triangleRight = QPainterPath triangleRight = QTransform()
QTransform() .translate(m_drawingAreaWidth - tileStripeWidth, m_drawingAreaHeight / 2)
.translate(m_drawingAreaWidth - tileStripeWidth, m_drawingAreaHeight/2)
.rotate(90) .rotate(90)
.map(TriangleBasic()); .map(TriangleBasic());
painter->fillPath(triangleRight, *triangleBush); painter->fillPath(triangleRight, *triangleBush);
@ -484,8 +477,7 @@ void VPTileFactory::DrawRightTriangle(QPainter *painter) const
void VPTileFactory::DrawTopLineScissors(QPainter *painter) const void VPTileFactory::DrawTopLineScissors(QPainter *painter) const
{ {
QSvgRenderer svgRenderer(QStringLiteral("://puzzleicon/svg/icon_scissors_horizontal.svg")); QSvgRenderer svgRenderer(QStringLiteral("://puzzleicon/svg/icon_scissors_horizontal.svg"));
svgRenderer.render(painter, QRectF(m_drawingAreaWidth - tileStripeWidth, 0, svgRenderer.render(painter, QRectF(m_drawingAreaWidth - tileStripeWidth, 0, UnitConvertor(0.95, Unit::Cm, Unit::Px),
UnitConvertor(0.95, Unit::Cm, Unit::Px),
UnitConvertor(0.56, Unit::Cm, Unit::Px))); UnitConvertor(0.56, Unit::Cm, Unit::Px)));
} }
@ -493,8 +485,8 @@ void VPTileFactory::DrawTopLineScissors(QPainter *painter) const
void VPTileFactory::DrawLeftLineScissors(QPainter *painter) const void VPTileFactory::DrawLeftLineScissors(QPainter *painter) const
{ {
QSvgRenderer svgRenderer(QStringLiteral("://puzzleicon/svg/icon_scissors_vertical.svg")); QSvgRenderer svgRenderer(QStringLiteral("://puzzleicon/svg/icon_scissors_vertical.svg"));
svgRenderer.render(painter, QRectF(0, m_drawingAreaHeight - tileStripeWidth, svgRenderer.render(painter,
UnitConvertor(0.56, Unit::Cm, Unit::Px), QRectF(0, m_drawingAreaHeight - tileStripeWidth, UnitConvertor(0.56, Unit::Cm, Unit::Px),
UnitConvertor(0.95, Unit::Cm, Unit::Px))); UnitConvertor(0.95, Unit::Cm, Unit::Px)));
} }
@ -543,7 +535,7 @@ void VPTileFactory::DrawSolidTopLine(QPainter *painter, int col, int nbCol) cons
penTileInfos.setStyle(Qt::SolidLine); penTileInfos.setStyle(Qt::SolidLine);
painter->setPen(penTileInfos); painter->setPen(penTileInfos);
if(col < nbCol - 1) if (col < nbCol - 1)
{ {
painter->drawLine(QPointF(), QPointF(m_drawingAreaWidth, 0)); painter->drawLine(QPointF(), QPointF(m_drawingAreaWidth, 0));
} }
@ -560,7 +552,7 @@ void VPTileFactory::DrawSolidLeftLine(QPainter *painter, int row, int nbRow) con
penTileInfos.setStyle(Qt::SolidLine); penTileInfos.setStyle(Qt::SolidLine);
painter->setPen(penTileInfos); painter->setPen(penTileInfos);
if(row < nbRow - 1) if (row < nbRow - 1)
{ {
painter->drawLine(QPointF(), QPointF(0, m_drawingAreaHeight)); painter->drawLine(QPointF(), QPointF(0, m_drawingAreaHeight));
} }
@ -577,7 +569,7 @@ void VPTileFactory::DrawSolidBottomLine(QPainter *painter, int col, int nbCol) c
penTileInfos.setStyle(Qt::SolidLine); penTileInfos.setStyle(Qt::SolidLine);
painter->setPen(penTileInfos); painter->setPen(penTileInfos);
if(col < nbCol - 1) if (col < nbCol - 1)
{ {
painter->drawLine(QPointF(0, m_drawingAreaHeight - tileStripeWidth), painter->drawLine(QPointF(0, m_drawingAreaHeight - tileStripeWidth),
QPointF(m_drawingAreaWidth, m_drawingAreaHeight - tileStripeWidth)); QPointF(m_drawingAreaWidth, m_drawingAreaHeight - tileStripeWidth));
@ -585,7 +577,8 @@ void VPTileFactory::DrawSolidBottomLine(QPainter *painter, int col, int nbCol) c
else else
{ {
painter->drawLine(QPointF(0, m_drawingAreaHeight - tileStripeWidth), painter->drawLine(QPointF(0, m_drawingAreaHeight - tileStripeWidth),
QPointF(m_drawingAreaWidth - tileStripeWidth, m_drawingAreaHeight - tileStripeWidth));; QPointF(m_drawingAreaWidth - tileStripeWidth, m_drawingAreaHeight - tileStripeWidth));
;
} }
} }
@ -596,7 +589,7 @@ void VPTileFactory::DrawSolidRightLine(QPainter *painter, int row, int nbRow) co
penTileInfos.setStyle(Qt::SolidLine); penTileInfos.setStyle(Qt::SolidLine);
painter->setPen(penTileInfos); painter->setPen(penTileInfos);
if(row < nbRow - 1) if (row < nbRow - 1)
{ {
painter->drawLine(QPointF(m_drawingAreaWidth - tileStripeWidth, 0), painter->drawLine(QPointF(m_drawingAreaWidth - tileStripeWidth, 0),
QPointF(m_drawingAreaWidth - tileStripeWidth, m_drawingAreaHeight)); QPointF(m_drawingAreaWidth - tileStripeWidth, m_drawingAreaHeight));
@ -617,8 +610,8 @@ void VPTileFactory::DrawTextInformation(QPainter *painter, int row, int col, int
// paint the grid information // paint the grid information
const QString grid = tr("Grid ( %1 , %2 )").arg(row + 1).arg(col + 1); const QString grid = tr("Grid ( %1 , %2 )").arg(row + 1).arg(col + 1);
const QString tileColorStr = QStringLiteral("%1,%2,%3") const QString tileColorStr =
.arg(tileColor->red()).arg(tileColor->green()).arg(tileColor->blue()); QStringLiteral("%1,%2,%3").arg(tileColor->red()).arg(tileColor->green()).arg(tileColor->blue());
td.setHtml(QString("<table width='100%' style='color:rgb(%1);'>" td.setHtml(QString("<table width='100%' style='color:rgb(%1);'>"
"<tr>" "<tr>"
@ -628,7 +621,7 @@ void VPTileFactory::DrawTextInformation(QPainter *painter, int row, int col, int
.arg(tileColorStr, grid)); .arg(tileColorStr, grid));
painter->setPen(PenTileInfos()); painter->setPen(PenTileInfos());
painter->save(); painter->save();
painter->translate(QPointF(UnitConvertor(1, Unit::Cm, Unit::Px), m_drawingAreaHeight - tileStripeWidth/1.3)); painter->translate(QPointF(UnitConvertor(1, Unit::Cm, Unit::Px), m_drawingAreaHeight - tileStripeWidth / 1.3));
td.drawContents(painter); td.drawContents(painter);
painter->restore(); painter->restore();
@ -645,11 +638,12 @@ void VPTileFactory::DrawTextInformation(QPainter *painter, int row, int col, int
"<tr>" "<tr>"
"<td align='center'>%2 - %3</td>" "<td align='center'>%2 - %3</td>"
"</tr>" "</tr>"
"</table>").arg(tileColorStr, page, clippedSheetName)); "</table>")
.arg(tileColorStr, page, clippedSheetName));
painter->save(); painter->save();
painter->rotate(-90); painter->rotate(-90);
painter->translate(QPointF(-(m_drawingAreaHeight) + UnitConvertor(1, Unit::Cm, Unit::Px), painter->translate(
m_drawingAreaWidth - tileStripeWidth)); QPointF(-(m_drawingAreaHeight) + UnitConvertor(1, Unit::Cm, Unit::Px), m_drawingAreaWidth - tileStripeWidth));
td.drawContents(painter); td.drawContents(painter);
painter->restore(); painter->restore();
} }
@ -662,7 +656,7 @@ void VPTileFactory::PaintWatermarkText(QPainter *painter, const QRectF &img, con
painter->save(); painter->save();
painter->setOpacity(watermarkData.opacity/100.); painter->setOpacity(watermarkData.opacity / 100.);
QPen pen = painter->pen(); QPen pen = painter->pen();
pen.setWidth(1); pen.setWidth(1);
@ -700,7 +694,7 @@ void VPTileFactory::PaintWatermarkImage(QPainter *painter, const QRectF &img, co
{ {
SCASSERT(painter != nullptr) SCASSERT(painter != nullptr)
const qreal opacity = watermarkData.opacity/100.; const qreal opacity = watermarkData.opacity / 100.;
auto BrokenImage = [img, watermarkData, watermarkPath, opacity]() auto BrokenImage = [img, watermarkData, watermarkPath, opacity]()
{ {
QPixmap watermark; QPixmap watermark;
@ -711,7 +705,7 @@ void VPTileFactory::PaintWatermarkImage(QPainter *painter, const QRectF &img, co
{ {
QScopedPointer<QSvgRenderer> svgRenderer(new QSvgRenderer()); QScopedPointer<QSvgRenderer> svgRenderer(new QSvgRenderer());
QRect imageRect(0, 0, qRound(img.width()/4.), qRound(img.width()/4.)); QRect imageRect(0, 0, qRound(img.width() / 4.), qRound(img.width() / 4.));
watermark = QPixmap(imageRect.size()); watermark = QPixmap(imageRect.size());
watermark.fill(Qt::transparent); watermark.fill(Qt::transparent);
@ -760,7 +754,7 @@ void VPTileFactory::PaintWatermarkImage(QPainter *painter, const QRectF &img, co
#endif #endif
qint64 pixelSize = fileSize / watermarkImage.height() / watermarkImage.width(); qint64 pixelSize = fileSize / watermarkImage.height() / watermarkImage.width();
QSize scaledSize(qRound(watermarkImage.width() / xScale), qRound(watermarkImage.height() / yScale)); QSize scaledSize(qRound(watermarkImage.width() / xScale), qRound(watermarkImage.height() / yScale));
qint64 scaledImageSize = pixelSize*scaledSize.width()*scaledSize.height() / 1024; qint64 scaledImageSize = pixelSize * scaledSize.width() * scaledSize.height() / 1024;
int limit = QPixmapCache::cacheLimit(); int limit = QPixmapCache::cacheLimit();
if (scaledImageSize > limit && (xScale < 1 || yScale < 1)) if (scaledImageSize > limit && (xScale < 1 || yScale < 1))
@ -797,7 +791,7 @@ void VPTileFactory::PaintWatermarkImage(QPainter *painter, const QRectF &img, co
} }
painter->save(); painter->save();
painter->setOpacity(watermarkData.opacity/100.); painter->setOpacity(watermarkData.opacity / 100.);
QRect imagePosition(0, 0, watermark.width(), watermark.height()); QRect imagePosition(0, 0, watermark.width(), watermark.height());
imagePosition.translate(img.center().toPoint() - imagePosition.center()); imagePosition.translate(img.center().toPoint() - imagePosition.center());

View File

@ -27,21 +27,20 @@
*************************************************************************/ *************************************************************************/
#include "vplayoutfilewriter.h" #include "vplayoutfilewriter.h"
#include "../layout/vplayout.h"
#include "../layout/vpsheet.h"
#include "../layout/vppiece.h"
#include "vplayoutliterals.h"
#include "../ifc/xml/vlayoutconverter.h" #include "../ifc/xml/vlayoutconverter.h"
#include "../vmisc/projectversion.h" #include "../layout/vplayout.h"
#include "../layout/vppiece.h"
#include "../layout/vpsheet.h"
#include "../vgeometry/vlayoutplacelabel.h"
#include "../vlayout/vlayoutpiecepath.h" #include "../vlayout/vlayoutpiecepath.h"
#include "../vlayout/vtextmanager.h" #include "../vlayout/vtextmanager.h"
#include "../vgeometry/vlayoutplacelabel.h" #include "../vmisc/projectversion.h"
#include "vplayoutliterals.h"
namespace namespace
{ {
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
template <class T> template <class T> auto NumberToString(T number) -> QString
auto NumberToString(T number) -> QString
{ {
const QLocale locale = QLocale::c(); const QLocale locale = QLocale::c();
return locale.toString(number, 'g', 12).remove(LocaleGroupSeparator(locale)); return locale.toString(number, 'g', 12).remove(LocaleGroupSeparator(locale));
@ -50,18 +49,9 @@ auto NumberToString(T number) -> QString
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto TransformToString(const QTransform &m) -> QString auto TransformToString(const QTransform &m) -> QString
{ {
QStringList matrix QStringList matrix{NumberToString(m.m11()), NumberToString(m.m12()), NumberToString(m.m13()),
{ NumberToString(m.m21()), NumberToString(m.m22()), NumberToString(m.m23()),
NumberToString(m.m11()), NumberToString(m.m31()), NumberToString(m.m32()), NumberToString(m.m33())};
NumberToString(m.m12()),
NumberToString(m.m13()),
NumberToString(m.m21()),
NumberToString(m.m22()),
NumberToString(m.m23()),
NumberToString(m.m31()),
NumberToString(m.m32()),
NumberToString(m.m33())
};
return matrix.join(ML::groupSep); return matrix.join(ML::groupSep);
} }
@ -88,10 +78,8 @@ auto PathToString(const QVector<QPointF> &pathPoints) -> QString
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto RectToString(const QRectF &r) -> QString auto RectToString(const QRectF &r) -> QString
{ {
return NumberToString(r.x()) + ML::groupSep + return NumberToString(r.x()) + ML::groupSep + NumberToString(r.y()) + ML::groupSep + NumberToString(r.width()) +
NumberToString(r.y()) + ML::groupSep + ML::groupSep + NumberToString(r.height());
NumberToString(r.width()) + ML::groupSep +
NumberToString(r.height());
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -153,8 +141,8 @@ void VPLayoutFileWriter::WriteFile(const VPLayoutPtr &layout, QIODevice *file)
setAutoFormatting(true); setAutoFormatting(true);
writeStartDocument(); writeStartDocument();
writeComment(QStringLiteral("Layout created with Valentina v%1 (https://smart-pattern.com.ua/).") writeComment(
.arg(APP_VERSION_STR)); QStringLiteral("Layout created with Valentina v%1 (https://smart-pattern.com.ua/).").arg(APP_VERSION_STR));
WriteLayout(layout); WriteLayout(layout);
writeEndDocument(); writeEndDocument();
} }
@ -167,7 +155,7 @@ void VPLayoutFileWriter::WriteLayout(const VPLayoutPtr &layout)
WriteLayoutProperties(layout); WriteLayoutProperties(layout);
WritePieceList(layout->GetUnplacedPieces(), ML::TagUnplacedPieces); WritePieceList(layout->GetUnplacedPieces(), ML::TagUnplacedPieces);
WriteSheets(layout); WriteSheets(layout);
writeEndElement(); //layout writeEndElement(); // layout
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -196,7 +184,7 @@ void VPLayoutFileWriter::WriteLayoutProperties(const VPLayoutPtr &layout)
writeStartElement(ML::TagWatermark); writeStartElement(ML::TagWatermark);
SetAttributeOrRemoveIf<bool>(ML::AttrShowPreview, layout->LayoutSettings().GetShowWatermark(), SetAttributeOrRemoveIf<bool>(ML::AttrShowPreview, layout->LayoutSettings().GetShowWatermark(),
[](bool show) noexcept {return not show;}); [](bool show) noexcept { return not show; });
writeCharacters(layout->LayoutSettings().WatermarkPath()); writeCharacters(layout->LayoutSettings().WatermarkPath());
writeEndElement(); // watermark writeEndElement(); // watermark
@ -226,7 +214,7 @@ void VPLayoutFileWriter::WriteSheet(const VPSheetPtr &sheet)
writeStartElement(ML::TagSheet); writeStartElement(ML::TagSheet);
SetAttributeOrRemoveIf<QString>(ML::AttrGrainlineType, GrainlineTypeToStr(sheet->GetGrainlineType()), SetAttributeOrRemoveIf<QString>(ML::AttrGrainlineType, GrainlineTypeToStr(sheet->GetGrainlineType()),
[](const QString &type) noexcept [](const QString &type) noexcept
{return type == GrainlineTypeToStr(GrainlineType::NotFixed);}); { return type == GrainlineTypeToStr(GrainlineType::NotFixed); });
writeTextElement(ML::TagName, sheet->GetName()); writeTextElement(ML::TagName, sheet->GetName());
WriteSize(sheet->GetSheetSize()); WriteSize(sheet->GetSheetSize());
@ -243,9 +231,9 @@ void VPLayoutFileWriter::WriteTiles(const VPLayoutPtr &layout)
SetAttribute(ML::AttrVisible, layout->LayoutSettings().GetShowTiles()); SetAttribute(ML::AttrVisible, layout->LayoutSettings().GetShowTiles());
SetAttribute(ML::AttrMatchingMarks, "standard"); // TODO / Fixme get the right value SetAttribute(ML::AttrMatchingMarks, "standard"); // TODO / Fixme get the right value
SetAttributeOrRemoveIf<bool>(ML::AttrPrintScheme, layout->LayoutSettings().GetPrintTilesScheme(), SetAttributeOrRemoveIf<bool>(ML::AttrPrintScheme, layout->LayoutSettings().GetPrintTilesScheme(),
[](bool print) noexcept {return not print;}); [](bool print) noexcept { return not print; });
SetAttributeOrRemoveIf<bool>(ML::AttrTileNumber, layout->LayoutSettings().GetShowTileNumber(), SetAttributeOrRemoveIf<bool>(ML::AttrTileNumber, layout->LayoutSettings().GetShowTileNumber(),
[](bool show) noexcept {return not show;}); [](bool show) noexcept { return not show; });
WriteSize(layout->LayoutSettings().GetTilesSize()); WriteSize(layout->LayoutSettings().GetTilesSize());
WriteMargins(layout->LayoutSettings().GetTilesMargins(), layout->LayoutSettings().IgnoreTilesMargins()); WriteMargins(layout->LayoutSettings().GetTilesMargins(), layout->LayoutSettings().IgnoreTilesMargins());
@ -272,25 +260,25 @@ void VPLayoutFileWriter::WritePiece(const VPPiecePtr &piece)
SetAttribute(ML::AttrUID, piece->GetUUID().toString()); SetAttribute(ML::AttrUID, piece->GetUUID().toString());
SetAttribute(ML::AttrName, piece->GetName()); SetAttribute(ML::AttrName, piece->GetName());
SetAttributeOrRemoveIf<bool>(ML::AttrMirrored, piece->IsMirror(), SetAttributeOrRemoveIf<bool>(ML::AttrMirrored, piece->IsMirror(),
[](bool mirrored) noexcept {return not mirrored;}); [](bool mirrored) noexcept { return not mirrored; });
SetAttributeOrRemoveIf<bool>(ML::AttrForbidFlipping, piece->IsForbidFlipping(), SetAttributeOrRemoveIf<bool>(ML::AttrForbidFlipping, piece->IsForbidFlipping(),
[](bool forbid) noexcept {return not forbid;}); [](bool forbid) noexcept { return not forbid; });
SetAttributeOrRemoveIf<bool>(ML::AttrForceFlipping, piece->IsForceFlipping(), SetAttributeOrRemoveIf<bool>(ML::AttrForceFlipping, piece->IsForceFlipping(),
[](bool force) noexcept {return not force;}); [](bool force) noexcept { return not force; });
SetAttributeOrRemoveIf<bool>(ML::AttrSewLineOnDrawing, piece->IsSewLineOnDrawing(), SetAttributeOrRemoveIf<bool>(ML::AttrSewLineOnDrawing, piece->IsSewLineOnDrawing(),
[](bool value) noexcept {return not value;}); [](bool value) noexcept { return not value; });
SetAttribute(ML::AttrTransform, TransformToString(piece->GetMatrix())); SetAttribute(ML::AttrTransform, TransformToString(piece->GetMatrix()));
SetAttributeOrRemoveIf<QString>(ML::AttrGradationLabel, piece->GetGradationId(), SetAttributeOrRemoveIf<QString>(ML::AttrGradationLabel, piece->GetGradationId(),
[](const QString &label) noexcept {return label.isEmpty();}); [](const QString &label) noexcept { return label.isEmpty(); });
SetAttribute(ML::AttrCopyNumber, piece->CopyNumber()); SetAttribute(ML::AttrCopyNumber, piece->CopyNumber());
SetAttributeOrRemoveIf<bool>(ML::AttrShowSeamline, not piece->IsHideMainPath(), SetAttributeOrRemoveIf<bool>(ML::AttrShowSeamline, not piece->IsHideMainPath(),
[](bool show) noexcept {return show;}); [](bool show) noexcept { return show; });
SetAttributeOrRemoveIf<qreal>(ML::AttrXScale, piece->GetXScale(), SetAttributeOrRemoveIf<qreal>(ML::AttrXScale, piece->GetXScale(),
[](qreal xs) noexcept {return VFuzzyComparePossibleNulls(xs, 1.0);}); [](qreal xs) noexcept { return VFuzzyComparePossibleNulls(xs, 1.0); });
SetAttributeOrRemoveIf<qreal>(ML::AttrYScale, piece->GetYScale(), SetAttributeOrRemoveIf<qreal>(ML::AttrYScale, piece->GetYScale(),
[](qreal ys) noexcept {return VFuzzyComparePossibleNulls(ys, 1.0);}); [](qreal ys) noexcept { return VFuzzyComparePossibleNulls(ys, 1.0); });
SetAttributeOrRemoveIf<qreal>(ML::AttrZValue, piece->ZValue(), SetAttributeOrRemoveIf<qreal>(ML::AttrZValue, piece->ZValue(),
[](qreal z) noexcept {return VFuzzyComparePossibleNulls(z, 1.0);}); [](qreal z) noexcept { return VFuzzyComparePossibleNulls(z, 1.0); });
writeStartElement(ML::TagSeamLine); writeStartElement(ML::TagSeamLine);
QVector<VLayoutPoint> contourPoints = piece->GetContourPoints(); QVector<VLayoutPoint> contourPoints = piece->GetContourPoints();
@ -302,9 +290,9 @@ void VPLayoutFileWriter::WritePiece(const VPPiecePtr &piece)
writeStartElement(ML::TagSeamAllowance); writeStartElement(ML::TagSeamAllowance);
SetAttributeOrRemoveIf<bool>(ML::AttrEnabled, piece->IsSeamAllowance(), SetAttributeOrRemoveIf<bool>(ML::AttrEnabled, piece->IsSeamAllowance(),
[](bool enabled) noexcept {return not enabled;}); [](bool enabled) noexcept { return not enabled; });
SetAttributeOrRemoveIf<bool>(ML::AttrBuiltIn, piece->IsSeamAllowanceBuiltIn(), SetAttributeOrRemoveIf<bool>(ML::AttrBuiltIn, piece->IsSeamAllowanceBuiltIn(),
[](bool builtin) noexcept {return not builtin;}); [](bool builtin) noexcept { return not builtin; });
if (piece->IsSeamAllowance() && not piece->IsSeamAllowanceBuiltIn()) if (piece->IsSeamAllowance() && not piece->IsSeamAllowanceBuiltIn())
{ {
QVector<VLayoutPoint> seamAllowancePoints = piece->GetSeamAllowancePoints(); QVector<VLayoutPoint> seamAllowancePoints = piece->GetSeamAllowancePoints();
@ -317,7 +305,7 @@ void VPLayoutFileWriter::WritePiece(const VPPiecePtr &piece)
writeStartElement(ML::TagGrainline); writeStartElement(ML::TagGrainline);
SetAttributeOrRemoveIf<bool>(ML::AttrEnabled, piece->IsGrainlineEnabled(), SetAttributeOrRemoveIf<bool>(ML::AttrEnabled, piece->IsGrainlineEnabled(),
[](bool enabled) noexcept {return not enabled;}); [](bool enabled) noexcept { return not enabled; });
if (piece->IsGrainlineEnabled()) if (piece->IsGrainlineEnabled())
{ {
SetAttribute(ML::AttrArrowDirection, GrainlineArrowDirrectionToString(piece->GetGrainline().GetArrowType())); SetAttribute(ML::AttrArrowDirection, GrainlineArrowDirrectionToString(piece->GetGrainline().GetArrowType()));
@ -327,7 +315,7 @@ void VPLayoutFileWriter::WritePiece(const VPPiecePtr &piece)
writeStartElement(ML::TagNotches); writeStartElement(ML::TagNotches);
QVector<VLayoutPassmark> passmarks = piece->GetPassmarks(); QVector<VLayoutPassmark> passmarks = piece->GetPassmarks();
for (const auto& passmark : passmarks) for (const auto &passmark : passmarks)
{ {
writeStartElement(ML::TagNotch); writeStartElement(ML::TagNotch);
SetAttribute(ML::AttrBuiltIn, passmark.isBuiltIn); SetAttribute(ML::AttrBuiltIn, passmark.isBuiltIn);
@ -342,7 +330,7 @@ void VPLayoutFileWriter::WritePiece(const VPPiecePtr &piece)
writeStartElement(ML::TagInternalPaths); writeStartElement(ML::TagInternalPaths);
QVector<VLayoutPiecePath> internalPaths = piece->GetInternalPaths(); QVector<VLayoutPiecePath> internalPaths = piece->GetInternalPaths();
for (const auto& path : internalPaths) for (const auto &path : internalPaths)
{ {
writeStartElement(ML::TagInternalPath); writeStartElement(ML::TagInternalPath);
SetAttribute(ML::AttrCut, path.IsCutPath()); SetAttribute(ML::AttrCut, path.IsCutPath());
@ -360,7 +348,7 @@ void VPLayoutFileWriter::WritePiece(const VPPiecePtr &piece)
writeStartElement(ML::TagMarkers); writeStartElement(ML::TagMarkers);
QVector<VLayoutPlaceLabel> placelabels = piece->GetPlaceLabels(); QVector<VLayoutPlaceLabel> placelabels = piece->GetPlaceLabels();
for (const auto& label : placelabels) for (const auto &label : placelabels)
{ {
writeStartElement(ML::TagMarker); writeStartElement(ML::TagMarker);
SetAttribute(ML::AttrTransform, TransformToString(label.RotationMatrix())); SetAttribute(ML::AttrTransform, TransformToString(label.RotationMatrix()));
@ -400,7 +388,7 @@ void VPLayoutFileWriter::WriteLabelLines(const VTextManager &tm)
for (int i = 0; i < tm.GetSourceLinesCount(); ++i) for (int i = 0; i < tm.GetSourceLinesCount(); ++i)
{ {
writeStartElement(ML::TagLine); writeStartElement(ML::TagLine);
const TextLine& tl = tm.GetSourceLine(i); const TextLine &tl = tm.GetSourceLine(i);
SetAttribute(ML::AttrFontSize, tl.m_iFontSize); SetAttribute(ML::AttrFontSize, tl.m_iFontSize);
SetAttribute(ML::AttrBold, tl.m_bold); SetAttribute(ML::AttrBold, tl.m_bold);
SetAttribute(ML::AttrItalic, tl.m_italic); SetAttribute(ML::AttrItalic, tl.m_italic);
@ -416,12 +404,12 @@ void VPLayoutFileWriter::WriteMargins(const QMarginsF &margins, bool ignore)
{ {
writeStartElement(ML::TagMargin); writeStartElement(ML::TagMargin);
SetAttributeOrRemoveIf<qreal>(ML::AttrLeft, margins.left(), [](qreal margin) noexcept {return margin <= 0;}); SetAttributeOrRemoveIf<qreal>(ML::AttrLeft, margins.left(), [](qreal margin) noexcept { return margin <= 0; });
SetAttributeOrRemoveIf<qreal>(ML::AttrTop, margins.top(), [](qreal margin) noexcept {return margin <= 0;}); SetAttributeOrRemoveIf<qreal>(ML::AttrTop, margins.top(), [](qreal margin) noexcept { return margin <= 0; });
SetAttributeOrRemoveIf<qreal>(ML::AttrRight, margins.right(), [](qreal margin) noexcept {return margin <= 0;}); SetAttributeOrRemoveIf<qreal>(ML::AttrRight, margins.right(), [](qreal margin) noexcept { return margin <= 0; });
SetAttributeOrRemoveIf<qreal>(ML::AttrBottom, margins.bottom(), [](qreal margin) noexcept {return margin <= 0;}); SetAttributeOrRemoveIf<qreal>(ML::AttrBottom, margins.bottom(), [](qreal margin) noexcept { return margin <= 0; });
SetAttributeOrRemoveIf<bool>(ML::AttrIgnoreMargins, ignore, [](bool ignore) noexcept {return not ignore;}); SetAttributeOrRemoveIf<bool>(ML::AttrIgnoreMargins, ignore, [](bool ignore) noexcept { return not ignore; });
writeEndElement(); // margin writeEndElement(); // margin
} }
@ -429,15 +417,16 @@ void VPLayoutFileWriter::WriteMargins(const QMarginsF &margins, bool ignore)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPLayoutFileWriter::WriteSize(QSizeF size) void VPLayoutFileWriter::WriteSize(QSizeF size)
{ {
// maybe not necessary to test this, the writer should "stupidly write", the application should take care of these tests // maybe not necessary to test this, the writer should "stupidly write", the application should take care of these
// tests
qreal width = size.width(); qreal width = size.width();
if(width < 0) if (width < 0)
{ {
width = 0; width = 0;
} }
qreal length = size.height(); qreal length = size.height();
if(length < 0) if (length < 0)
{ {
length = 0; length = 0;
} }
@ -454,7 +443,7 @@ auto VPLayoutFileWriter::WriteLayoutPoint(const VLayoutPoint &point) -> void
writeStartElement(ML::TagPoint); writeStartElement(ML::TagPoint);
SetAttribute(ML::AttrX, point.x()); SetAttribute(ML::AttrX, point.x());
SetAttribute(ML::AttrY, point.y()); SetAttribute(ML::AttrY, point.y());
SetAttributeOrRemoveIf<bool>(ML::AttrTurnPoint, point.TurnPoint(), [](bool val) noexcept {return val;}); SetAttributeOrRemoveIf<bool>(ML::AttrTurnPoint, point.TurnPoint(), [](bool val) noexcept { return val; });
SetAttributeOrRemoveIf<bool>(ML::AttrCurvePoint, point.CurvePoint(), [](bool val) noexcept {return val;}); SetAttributeOrRemoveIf<bool>(ML::AttrCurvePoint, point.CurvePoint(), [](bool val) noexcept { return val; });
writeEndElement(); writeEndElement();
} }

View File

@ -139,5 +139,4 @@ extern const QChar pointsSep;
extern const QChar itemsSep; extern const QChar itemsSep;
} // namespace ML } // namespace ML
#endif // VPLAYOUTLITERALS_H #endif // VPLAYOUTLITERALS_H

View File

@ -31,11 +31,9 @@
#include <QWidget> #include <QWidget>
#include "../vmisc/defglobal.h"
namespace Ui namespace Ui
{ {
class TapePreferencesConfigurationPage; class TapePreferencesConfigurationPage;
} }
class TapePreferencesConfigurationPage : public QWidget class TapePreferencesConfigurationPage : public QWidget
@ -47,8 +45,10 @@ public:
~TapePreferencesConfigurationPage() override; ~TapePreferencesConfigurationPage() override;
auto Apply() -> QStringList; auto Apply() -> QStringList;
protected: protected:
void changeEvent(QEvent* event) override; void changeEvent(QEvent *event) override;
private: private:
// cppcheck-suppress unknownMacro // cppcheck-suppress unknownMacro
Q_DISABLE_COPY_MOVE(TapePreferencesConfigurationPage) // NOLINT Q_DISABLE_COPY_MOVE(TapePreferencesConfigurationPage) // NOLINT

View File

@ -80,6 +80,9 @@ QT_WARNING_POP
namespace namespace
{ {
QT_WARNING_PUSH
QT_WARNING_DISABLE_CLANG("-Wunused-member-function")
Q_GLOBAL_STATIC_WITH_ARGS(const QString, LONG_OPTION_DIMENSION_A, (QLatin1String("dimensionA"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, LONG_OPTION_DIMENSION_A, (QLatin1String("dimensionA"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, SINGLE_OPTION_DIMENSION_A, (QChar('a'))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, SINGLE_OPTION_DIMENSION_A, (QChar('a'))) // NOLINT
@ -93,6 +96,8 @@ Q_GLOBAL_STATIC_WITH_ARGS(const QString, LONG_OPTION_UNITS, (QLatin1String("unit
Q_GLOBAL_STATIC_WITH_ARGS(const QString, SINGLE_OPTION_UNITS, (QChar('u'))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, SINGLE_OPTION_UNITS, (QChar('u'))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, LONG_OPTION_TEST, (QLatin1String("test"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, LONG_OPTION_TEST, (QLatin1String("test"))) // NOLINT
QT_WARNING_POP
} // namespace } // namespace
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

File diff suppressed because it is too large Load Diff

View File

@ -28,27 +28,40 @@
#include "vtapesettings.h" #include "vtapesettings.h"
#include <QVariant> #include <QDir>
#include <QGlobalStatic> #include <QGlobalStatic>
#include <QVariant>
#if QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
#include "diagnostic.h"
#endif // QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
namespace namespace
{ {
QT_WARNING_PUSH
QT_WARNING_DISABLE_CLANG("-Wunused-member-function")
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingDataBaseGeometry, (QLatin1String("database/geometry"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingDataBaseGeometry, (QLatin1String("database/geometry"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchHistoryTape, (QLatin1String("searchHistory/tape"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchHistoryTape, (QLatin1String("searchHistory/tape"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsTapeUseUnicodeProperties, // NOLINT // NOLINTNEXTLINE
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsTapeUseUnicodeProperties,
(QLatin1String("searchOptions/tapeUseUnicodeProperties"))) (QLatin1String("searchOptions/tapeUseUnicodeProperties")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsTapeWholeWord, // NOLINT // NOLINTNEXTLINE
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsTapeWholeWord,
(QLatin1String("searchOptions/tapeWholeWord"))) (QLatin1String("searchOptions/tapeWholeWord")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsTapeRegexp, (QLatin1String("searchOptions/tapeRegexp"))) // NOLINT // NOLINTNEXTLINE
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsTapeMatchCase, // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsTapeRegexp, (QLatin1String("searchOptions/tapeRegexp")))
// NOLINTNEXTLINE
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsTapeMatchCase,
(QLatin1String("searchOptions/tapeMatchCase"))) (QLatin1String("searchOptions/tapeMatchCase")))
QT_WARNING_POP
} // namespace } // namespace
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VTapeSettings::VTapeSettings(Format format, Scope scope, const QString &organization, const QString &application, VTapeSettings::VTapeSettings(Format format, Scope scope, const QString &organization, const QString &application,
QObject *parent) QObject *parent)
:VCommonSettings(format, scope, organization, application, parent) : VCommonSettings(format, scope, organization, application, parent)
{ {
} }

View File

@ -42,6 +42,7 @@
class VTapeSettings : public VCommonSettings class VTapeSettings : public VCommonSettings
{ {
Q_OBJECT // NOLINT Q_OBJECT // NOLINT
public: public:
VTapeSettings(Format format, Scope scope, const QString &organization, const QString &application = QString(), VTapeSettings(Format format, Scope scope, const QString &organization, const QString &application = QString(),
QObject *parent = nullptr); QObject *parent = nullptr);
@ -62,7 +63,7 @@ public:
auto GetTapeSearchOptionRegexp() const -> bool; auto GetTapeSearchOptionRegexp() const -> bool;
void SetTapeSearchOptionRegexp(bool value); void SetTapeSearchOptionRegexp(bool value);
auto GetTapeSearchOptionMatchCase() const ->bool; auto GetTapeSearchOptionMatchCase() const -> bool;
void SetTapeSearchOptionMatchCase(bool value); void SetTapeSearchOptionMatchCase(bool value);
private: private:

File diff suppressed because it is too large Load Diff

View File

@ -29,17 +29,28 @@
#include "preferencespatternpage.h" #include "preferencespatternpage.h"
#include "../dialogdatetimeformats.h" #include "../dialogdatetimeformats.h"
#include "../dialogknownmaterials.h" #include "../dialogknownmaterials.h"
#include "../vmisc/svgfont/vsvgfontdatabase.h"
#include "../vmisc/vabstractvalapplication.h" #include "../vmisc/vabstractvalapplication.h"
#include "../vmisc/vvalentinasettings.h" #include "../vmisc/vvalentinasettings.h"
#include "qnamespace.h"
#include "qnumeric.h"
#include "svgfont/svgdef.h"
#include "svgfont/vsvgfont.h"
#include "svgfont/vsvgfontengine.h"
#include "ui_preferencespatternpage.h" #include "ui_preferencespatternpage.h"
#include "vabstractapplication.h"
#if QT_VERSION < QT_VERSION_CHECK(5, 7, 0) #if QT_VERSION < QT_VERSION_CHECK(5, 7, 0)
#include "../vmisc/backport/qoverload.h" #include "../vmisc/backport/qoverload.h"
#endif // QT_VERSION < QT_VERSION_CHECK(5, 7, 0) #endif // QT_VERSION < QT_VERSION_CHECK(5, 7, 0)
#include "../ifc/xml/vabstractpattern.h" #include "../ifc/xml/vabstractpattern.h"
#include "../vformat/vsinglelineoutlinechar.h"
#include "../vwidgets/vmaingraphicsview.h" #include "../vwidgets/vmaingraphicsview.h"
#include <QCompleter>
#include <QDate> #include <QDate>
#include <QMessageBox> #include <QMessageBox>
#include <QScreen>
#include <QStyledItemDelegate>
#include <QTime> #include <QTime>
namespace namespace

View File

@ -27,39 +27,43 @@
*************************************************************************/ *************************************************************************/
#include "dialogincrements.h" #include "dialogincrements.h"
#include "ui_dialogincrements.h"
#include "../vmisc/vvalentinasettings.h" #include "../vmisc/vvalentinasettings.h"
#include "ui_dialogincrements.h"
#if QT_VERSION < QT_VERSION_CHECK(5, 7, 0) #if QT_VERSION < QT_VERSION_CHECK(5, 7, 0)
#include "../vmisc/backport/qoverload.h" #include "../vmisc/backport/qoverload.h"
#endif // QT_VERSION < QT_VERSION_CHECK(5, 7, 0) #endif // QT_VERSION < QT_VERSION_CHECK(5, 7, 0)
#include "../qmuparser/qmudef.h" #include "../qmuparser/qmudef.h"
#include "../qmuparser/qmutokenparser.h" #include "../qmuparser/qmutokenparser.h"
#include "../vpatterndb/vtranslatevars.h"
#include "../vpatterndb/calculator.h" #include "../vpatterndb/calculator.h"
#include "../vpatterndb/variables/vincrement.h"
#include "../vpatterndb/variables/vlinelength.h"
#include "../vpatterndb/variables/vlineangle.h"
#include "../vpatterndb/variables/vcurveangle.h"
#include "../vpatterndb/variables/vcurvelength.h"
#include "../vpatterndb/variables/vcurveclength.h"
#include "../vpatterndb/variables/varcradius.h" #include "../vpatterndb/variables/varcradius.h"
#include "../vpatterndb/variables/vcurveangle.h"
#include "../vpatterndb/variables/vcurveclength.h"
#include "../vpatterndb/variables/vcurvelength.h"
#include "../vpatterndb/variables/vincrement.h"
#include "../vpatterndb/variables/vlineangle.h"
#include "../vpatterndb/variables/vlinelength.h"
#include "../vpatterndb/vtranslatevars.h"
#include "../vtools/dialogs/support/dialogeditwrongformula.h" #include "../vtools/dialogs/support/dialogeditwrongformula.h"
#include <QFileDialog>
#include <QDir>
#include <QMessageBox>
#include <QCloseEvent> #include <QCloseEvent>
#include <QTableWidget> #include <QDir>
#include <QFileDialog>
#include <QMenu>
#include <QMessageBox>
#include <QSettings> #include <QSettings>
#include <QTableWidget>
#include <QTableWidgetItem> #include <QTableWidgetItem>
#include <QtNumeric> #include <QtNumeric>
#include <QMenu>
constexpr int DIALOG_MAX_FORMULA_HEIGHT = 64; constexpr int DIALOG_MAX_FORMULA_HEIGHT = 64;
namespace namespace
{ {
enum class IncrUnits : qint8 {Pattern, Degrees}; enum class IncrUnits : qint8
{
Pattern,
Degrees
};
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -70,7 +74,7 @@ enum class IncrUnits : qint8 {Pattern, Degrees};
* @param parent parent widget * @param parent parent widget
*/ */
DialogIncrements::DialogIncrements(VContainer *data, VPattern *doc, QWidget *parent) DialogIncrements::DialogIncrements(VContainer *data, VPattern *doc, QWidget *parent)
:DialogTool(data, NULL_ID, parent), : DialogTool(data, NULL_ID, parent),
ui(new Ui::DialogIncrements), ui(new Ui::DialogIncrements),
m_data(data), m_data(data),
m_doc(doc), m_doc(doc),
@ -129,14 +133,13 @@ DialogIncrements::DialogIncrements(VContainer *data, VPattern *doc, QWidget *par
connect(this->m_doc, &VPattern::FullUpdateFromFile, this, &DialogIncrements::FullUpdateFromFile); connect(this->m_doc, &VPattern::FullUpdateFromFile, this, &DialogIncrements::FullUpdateFromFile);
ui->tabWidget->setCurrentIndex(0); ui->tabWidget->setCurrentIndex(0);
auto *validator = new QRegularExpressionValidator(QRegularExpression(QStringLiteral("^$|")+NameRegExp()), this); auto *validator = new QRegularExpressionValidator(QRegularExpression(QStringLiteral("^$|") + NameRegExp()), this);
ui->lineEditName->setValidator(validator); ui->lineEditName->setValidator(validator);
ui->lineEditNamePC->setValidator(validator); ui->lineEditNamePC->setValidator(validator);
connect(ui->tableWidgetIncrement, &QTableWidget::itemSelectionChanged, this, connect(ui->tableWidgetIncrement, &QTableWidget::itemSelectionChanged, this,
&DialogIncrements::ShowIncrementDetails); &DialogIncrements::ShowIncrementDetails);
connect(ui->tableWidgetPC, &QTableWidget::itemSelectionChanged, this, connect(ui->tableWidgetPC, &QTableWidget::itemSelectionChanged, this, &DialogIncrements::ShowIncrementDetails);
&DialogIncrements::ShowIncrementDetails);
ui->toolButtonAdd->setMenu(InitVarTypeMenu(ui->toolButtonAdd->menu(), true /*increments tab*/)); ui->toolButtonAdd->setMenu(InitVarTypeMenu(ui->toolButtonAdd->menu(), true /*increments tab*/));
ui->toolButtonAddPC->setMenu(InitVarTypeMenu(ui->toolButtonAddPC->menu(), false /*preview calculations tab*/)); ui->toolButtonAddPC->setMenu(InitVarTypeMenu(ui->toolButtonAddPC->menu(), false /*preview calculations tab*/));
@ -191,8 +194,7 @@ void DialogIncrements::FillPreviewCalculations()
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
template <typename T> template <typename T> void DialogIncrements::FillTable(const QMap<QString, T> &varTable, QTableWidget *table)
void DialogIncrements::FillTable(const QMap<QString, T> &varTable, QTableWidget *table)
{ {
SCASSERT(table != nullptr) SCASSERT(table != nullptr)
@ -203,7 +205,7 @@ void DialogIncrements::FillTable(const QMap<QString, T> &varTable, QTableWidget
i.next(); i.next();
qreal length = *i.value()->GetValue(); qreal length = *i.value()->GetValue();
currentRow++; currentRow++;
table->setRowCount ( static_cast<int>(varTable.size()) ); table->setRowCount(static_cast<int>(varTable.size()));
auto *item = new QTableWidgetItem(i.key()); auto *item = new QTableWidgetItem(i.key());
item->setTextAlignment(Qt::AlignLeft); item->setTextAlignment(Qt::AlignLeft);
@ -268,17 +270,17 @@ void DialogIncrements::ShowUnits()
{ {
const QString unit = UnitsToStr(VAbstractValApplication::VApp()->patternUnits()); const QString unit = UnitsToStr(VAbstractValApplication::VApp()->patternUnits());
ShowHeaderUnits(ui->tableWidgetIncrement, 1, unit);// calculated value ShowHeaderUnits(ui->tableWidgetIncrement, 1, unit); // calculated value
ShowHeaderUnits(ui->tableWidgetIncrement, 2, unit);// formula ShowHeaderUnits(ui->tableWidgetIncrement, 2, unit); // formula
ShowHeaderUnits(ui->tableWidgetPC, 1, unit);// calculated value ShowHeaderUnits(ui->tableWidgetPC, 1, unit); // calculated value
ShowHeaderUnits(ui->tableWidgetPC, 2, unit);// formula ShowHeaderUnits(ui->tableWidgetPC, 2, unit); // formula
ShowHeaderUnits(ui->tableWidgetLines, 1, unit);// lengths ShowHeaderUnits(ui->tableWidgetLines, 1, unit); // lengths
ShowHeaderUnits(ui->tableWidgetSplines, 1, unit);// lengths ShowHeaderUnits(ui->tableWidgetSplines, 1, unit); // lengths
ShowHeaderUnits(ui->tableWidgetCLength, 1, unit);// lengths ShowHeaderUnits(ui->tableWidgetCLength, 1, unit); // lengths
ShowHeaderUnits(ui->tableWidgetLinesAngles, 1, degreeSymbol);// angle ShowHeaderUnits(ui->tableWidgetLinesAngles, 1, degreeSymbol); // angle
ShowHeaderUnits(ui->tableWidgetRadiusesArcs, 1, unit);// radius ShowHeaderUnits(ui->tableWidgetRadiusesArcs, 1, unit); // radius
ShowHeaderUnits(ui->tableWidgetAnglesCurves, 1, degreeSymbol);// angle ShowHeaderUnits(ui->tableWidgetAnglesCurves, 1, degreeSymbol); // angle
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -292,8 +294,8 @@ void DialogIncrements::ShowHeaderUnits(QTableWidget *table, int column, const QS
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto DialogIncrements::AddCell(QTableWidget *table, const QString &text, int row, int column, int aligment, auto DialogIncrements::AddCell(QTableWidget *table, const QString &text, int row, int column, int aligment, bool ok)
bool ok) -> QTableWidgetItem * -> QTableWidgetItem *
{ {
SCASSERT(table != nullptr) SCASSERT(table != nullptr)
@ -320,7 +322,7 @@ auto DialogIncrements::AddCell(QTableWidget *table, const QString &text, int row
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto DialogIncrements::AddSeparatorCell(QTableWidget *table, const QString &text, int row, int column, int aligment, auto DialogIncrements::AddSeparatorCell(QTableWidget *table, const QString &text, int row, int column, int aligment,
bool ok) -> QTableWidgetItem* bool ok) -> QTableWidgetItem *
{ {
QTableWidgetItem *item = AddCell(table, text, row, column, aligment, ok); QTableWidgetItem *item = AddCell(table, text, row, column, aligment, ok);
@ -368,7 +370,8 @@ auto DialogIncrements::EvalIncrementFormula(const QString &formula, bool fromUse
} }
else else
{ {
postfix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits());//Show unit in dialog lable (cm, mm or inch) postfix =
UnitsToStr(VAbstractValApplication::VApp()->patternUnits()); // Show unit in dialog lable (cm, mm or inch)
} }
if (formula.isEmpty()) if (formula.isEmpty())
{ {
@ -383,8 +386,8 @@ auto DialogIncrements::EvalIncrementFormula(const QString &formula, bool fromUse
// Replace line return character with spaces for calc if exist // Replace line return character with spaces for calc if exist
if (fromUser) if (fromUser)
{ {
f = VAbstractApplication::VApp()->TrVars() f = VAbstractApplication::VApp()->TrVars()->FormulaFromUser(
->FormulaFromUser(formula, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); formula, VAbstractApplication::VApp()->Settings()->GetOsSeparator());
} }
else else
{ {
@ -458,7 +461,7 @@ void DialogIncrements::Controls(QTableWidget *table)
ui->toolButtonDownPC->setEnabled(true); ui->toolButtonDownPC->setEnabled(true);
} }
} }
else if (table->currentRow() == table->rowCount()-1) else if (table->currentRow() == table->rowCount() - 1)
{ {
if (table == ui->tableWidgetIncrement) if (table == ui->tableWidgetIncrement)
{ {
@ -685,7 +688,7 @@ auto DialogIncrements::IncrementUsed(const QString &name) const -> bool
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogIncrements::CacheRename(const QString &name, const QString &newName) void DialogIncrements::CacheRename(const QString &name, const QString &newName)
{ {
for (auto & i : m_renameList) for (auto &i : m_renameList)
{ {
if (i.second == name) if (i.second == name)
{ {
@ -739,7 +742,7 @@ void DialogIncrements::ShowTableIncrementDetails(QTableWidget *table)
{ {
incr = m_data->GetVariable<VIncrement>(nameField->text()); incr = m_data->GetVariable<VIncrement>(nameField->text());
} }
catch(const VExceptionBadId &e) catch (const VExceptionBadId &e)
{ {
Q_UNUSED(e) Q_UNUSED(e)
EnableDetails(table, false); EnableDetails(table, false);
@ -762,8 +765,7 @@ void DialogIncrements::ShowTableIncrementDetails(QTableWidget *table)
EvalIncrementFormula(incr->GetFormula(), false, incr->GetData(), labelCalculatedValue, incr->IsSpecialUnits()); EvalIncrementFormula(incr->GetFormula(), false, incr->GetData(), labelCalculatedValue, incr->IsSpecialUnits());
plainTextEditFormula->blockSignals(true); plainTextEditFormula->blockSignals(true);
QString formula = QString formula = VTranslateVars::TryFormulaToUser(incr->GetFormula(),
VTranslateVars::TryFormulaToUser(incr->GetFormula(),
VAbstractApplication::VApp()->Settings()->GetOsSeparator()); VAbstractApplication::VApp()->Settings()->GetOsSeparator());
plainTextEditFormula->setPlainText(formula); plainTextEditFormula->setPlainText(formula);
@ -829,11 +831,11 @@ void DialogIncrements::AddNewIncrement(IncrementType type)
} }
else else
{ {
currentRow = table->currentRow()+1; currentRow = table->currentRow() + 1;
const QTableWidgetItem *nameField = table->item(table->currentRow(), 0); const QTableWidgetItem *nameField = table->item(table->currentRow(), 0);
incrementMode ? m_doc->AddEmptyIncrementAfter(nameField->text(), name, type) : incrementMode ? m_doc->AddEmptyIncrementAfter(nameField->text(), name, type)
m_doc->AddEmptyPreviewCalculationAfter(nameField->text(), name, type); : m_doc->AddEmptyPreviewCalculationAfter(nameField->text(), name, type);
} }
m_hasChanges = true; m_hasChanges = true;
@ -863,53 +865,62 @@ void DialogIncrements::InitSearch()
UpdateSearchControlsTooltips(); UpdateSearchControlsTooltips();
connect(ui->lineEditFind, &QLineEdit::textEdited, this, [this](const QString &term){m_search->Find(term);}); connect(ui->lineEditFind, &QLineEdit::textEdited, this, [this](const QString &term) { m_search->Find(term); });
connect(ui->lineEditFind, &QLineEdit::editingFinished, this, [this]() connect(ui->lineEditFind, &QLineEdit::editingFinished, this,
[this]()
{ {
SaveIncrementsSearchRequest(); SaveIncrementsSearchRequest();
InitIncrementsSearchHistory(); InitIncrementsSearchHistory();
m_search->Find(ui->lineEditFind->text()); m_search->Find(ui->lineEditFind->text());
}); });
connect(ui->lineEditFindPC, &QLineEdit::textEdited, this, [this](const QString &term){m_searchPC->Find(term);}); connect(ui->lineEditFindPC, &QLineEdit::textEdited, this, [this](const QString &term) { m_searchPC->Find(term); });
connect(ui->lineEditFindPC, &QLineEdit::editingFinished, this, [this]() connect(ui->lineEditFindPC, &QLineEdit::editingFinished, this,
[this]()
{ {
SavePreviewCalculationsSearchRequest(); SavePreviewCalculationsSearchRequest();
InitPreviewCalculationsSearchHistory(); InitPreviewCalculationsSearchHistory();
m_searchPC->Find(ui->lineEditFindPC->text()); m_searchPC->Find(ui->lineEditFindPC->text());
}); });
connect(ui->toolButtonFindPrevious, &QToolButton::clicked, this, [this]() connect(ui->toolButtonFindPrevious, &QToolButton::clicked, this,
[this]()
{ {
SaveIncrementsSearchRequest(); SaveIncrementsSearchRequest();
InitPreviewCalculationsSearchHistory(); InitPreviewCalculationsSearchHistory();
m_search->FindPrevious(); m_search->FindPrevious();
ui->labelResults->setText(QStringLiteral("%1/%2").arg(m_search->MatchIndex()+1).arg(m_search->MatchCount())); ui->labelResults->setText(
QStringLiteral("%1/%2").arg(m_search->MatchIndex() + 1).arg(m_search->MatchCount()));
}); });
connect(ui->toolButtonFindPreviousPC, &QToolButton::clicked, this, [this]() connect(ui->toolButtonFindPreviousPC, &QToolButton::clicked, this,
[this]()
{ {
SavePreviewCalculationsSearchRequest(); SavePreviewCalculationsSearchRequest();
InitPreviewCalculationsSearchHistory(); InitPreviewCalculationsSearchHistory();
m_searchPC->FindPrevious(); m_searchPC->FindPrevious();
ui->labelResultsPC->setText( ui->labelResultsPC->setText(
QStringLiteral("%1/%2").arg(m_searchPC->MatchIndex()+1).arg(m_searchPC->MatchCount())); QStringLiteral("%1/%2").arg(m_searchPC->MatchIndex() + 1).arg(m_searchPC->MatchCount()));
}); });
connect(ui->toolButtonFindNext, &QToolButton::clicked, this, [this]() connect(ui->toolButtonFindNext, &QToolButton::clicked, this,
[this]()
{ {
SaveIncrementsSearchRequest(); SaveIncrementsSearchRequest();
InitIncrementsSearchHistory(); InitIncrementsSearchHistory();
m_search->FindNext(); m_search->FindNext();
ui->labelResults->setText(QStringLiteral("%1/%2").arg(m_search->MatchIndex()+1).arg(m_search->MatchCount())); ui->labelResults->setText(
QStringLiteral("%1/%2").arg(m_search->MatchIndex() + 1).arg(m_search->MatchCount()));
}); });
connect(ui->toolButtonFindNextPC, &QToolButton::clicked, this, [this]() connect(ui->toolButtonFindNextPC, &QToolButton::clicked, this,
[this]()
{ {
SavePreviewCalculationsSearchRequest(); SavePreviewCalculationsSearchRequest();
InitPreviewCalculationsSearchHistory(); InitPreviewCalculationsSearchHistory();
m_searchPC->FindNext(); m_searchPC->FindNext();
ui->labelResultsPC->setText( ui->labelResultsPC->setText(
QStringLiteral("%1/%2").arg(m_searchPC->MatchIndex()+1).arg(m_searchPC->MatchCount())); QStringLiteral("%1/%2").arg(m_searchPC->MatchIndex() + 1).arg(m_searchPC->MatchCount()));
}); });
connect(m_search.data(), &VTableSearch::HasResult, this, [this] (bool state) connect(m_search.data(), &VTableSearch::HasResult, this,
[this](bool state)
{ {
ui->toolButtonFindPrevious->setEnabled(state); ui->toolButtonFindPrevious->setEnabled(state);
ui->toolButtonFindNext->setEnabled(state); ui->toolButtonFindNext->setEnabled(state);
@ -917,7 +928,7 @@ void DialogIncrements::InitSearch()
if (state) if (state)
{ {
ui->labelResults->setText( ui->labelResults->setText(
QStringLiteral("%1/%2").arg(m_search->MatchIndex()+1).arg(m_search->MatchCount())); QStringLiteral("%1/%2").arg(m_search->MatchIndex() + 1).arg(m_search->MatchCount()));
} }
else else
{ {
@ -942,7 +953,8 @@ void DialogIncrements::InitSearch()
} }
}); });
connect(m_searchPC.data(), &VTableSearch::HasResult, this, [this] (bool state) connect(m_searchPC.data(), &VTableSearch::HasResult, this,
[this](bool state)
{ {
ui->toolButtonFindPreviousPC->setEnabled(state); ui->toolButtonFindPreviousPC->setEnabled(state);
ui->toolButtonFindNextPC->setEnabled(state); ui->toolButtonFindNextPC->setEnabled(state);
@ -950,7 +962,7 @@ void DialogIncrements::InitSearch()
if (state) if (state)
{ {
ui->labelResultsPC->setText( ui->labelResultsPC->setText(
QStringLiteral("%1/%2").arg(m_searchPC->MatchIndex()+1).arg(m_searchPC->MatchCount())); QStringLiteral("%1/%2").arg(m_searchPC->MatchIndex() + 1).arg(m_searchPC->MatchCount()));
} }
else else
{ {
@ -975,35 +987,40 @@ void DialogIncrements::InitSearch()
} }
}); });
connect(ui->toolButtonCaseSensitive, &QToolButton::toggled, this, [this](bool checked) connect(ui->toolButtonCaseSensitive, &QToolButton::toggled, this,
[this](bool checked)
{ {
m_search->SetMatchCase(checked); m_search->SetMatchCase(checked);
m_search->Find(ui->lineEditFind->text()); m_search->Find(ui->lineEditFind->text());
ui->lineEditFind->setPlaceholderText(m_search->SearchPlaceholder()); ui->lineEditFind->setPlaceholderText(m_search->SearchPlaceholder());
}); });
connect(ui->toolButtonCaseSensitivePC, &QToolButton::toggled, this, [this](bool checked) connect(ui->toolButtonCaseSensitivePC, &QToolButton::toggled, this,
[this](bool checked)
{ {
m_searchPC->SetMatchCase(checked); m_searchPC->SetMatchCase(checked);
m_searchPC->Find(ui->lineEditFindPC->text()); m_searchPC->Find(ui->lineEditFindPC->text());
ui->lineEditFindPC->setPlaceholderText(m_searchPC->SearchPlaceholder()); ui->lineEditFindPC->setPlaceholderText(m_searchPC->SearchPlaceholder());
}); });
connect(ui->toolButtonWholeWord, &QToolButton::toggled, this, [this](bool checked) connect(ui->toolButtonWholeWord, &QToolButton::toggled, this,
[this](bool checked)
{ {
m_search->SetMatchWord(checked); m_search->SetMatchWord(checked);
m_search->Find(ui->lineEditFind->text()); m_search->Find(ui->lineEditFind->text());
ui->lineEditFind->setPlaceholderText(m_search->SearchPlaceholder()); ui->lineEditFind->setPlaceholderText(m_search->SearchPlaceholder());
}); });
connect(ui->toolButtonWholeWordPC, &QToolButton::toggled, this, [this](bool checked) connect(ui->toolButtonWholeWordPC, &QToolButton::toggled, this,
[this](bool checked)
{ {
m_searchPC->SetMatchWord(checked); m_searchPC->SetMatchWord(checked);
m_searchPC->Find(ui->lineEditFindPC->text()); m_searchPC->Find(ui->lineEditFindPC->text());
ui->lineEditFindPC->setPlaceholderText(m_searchPC->SearchPlaceholder()); ui->lineEditFindPC->setPlaceholderText(m_searchPC->SearchPlaceholder());
}); });
connect(ui->toolButtonRegexp, &QToolButton::toggled, this, [this](bool checked) connect(ui->toolButtonRegexp, &QToolButton::toggled, this,
[this](bool checked)
{ {
m_search->SetMatchRegexp(checked); m_search->SetMatchRegexp(checked);
@ -1028,7 +1045,8 @@ void DialogIncrements::InitSearch()
ui->lineEditFind->setPlaceholderText(m_search->SearchPlaceholder()); ui->lineEditFind->setPlaceholderText(m_search->SearchPlaceholder());
}); });
connect(ui->toolButtonRegexpPC, &QToolButton::toggled, this, [this](bool checked) connect(ui->toolButtonRegexpPC, &QToolButton::toggled, this,
[this](bool checked)
{ {
m_searchPC->SetMatchRegexp(checked); m_searchPC->SetMatchRegexp(checked);
@ -1053,13 +1071,15 @@ void DialogIncrements::InitSearch()
ui->lineEditFindPC->setPlaceholderText(m_searchPC->SearchPlaceholder()); ui->lineEditFindPC->setPlaceholderText(m_searchPC->SearchPlaceholder());
}); });
connect(ui->toolButtonUseUnicodeProperties, &QToolButton::toggled, this, [this](bool checked) connect(ui->toolButtonUseUnicodeProperties, &QToolButton::toggled, this,
[this](bool checked)
{ {
m_search->SetUseUnicodePreperties(checked); m_search->SetUseUnicodePreperties(checked);
m_search->Find(ui->lineEditFind->text()); m_search->Find(ui->lineEditFind->text());
}); });
connect(ui->toolButtonUseUnicodePropertiesPC, &QToolButton::toggled, this, [this](bool checked) connect(ui->toolButtonUseUnicodePropertiesPC, &QToolButton::toggled, this,
[this](bool checked)
{ {
m_searchPC->SetUseUnicodePreperties(checked); m_searchPC->SetUseUnicodePreperties(checked);
m_searchPC->Find(ui->lineEditFindPC->text()); m_searchPC->Find(ui->lineEditFindPC->text());
@ -1080,11 +1100,12 @@ void DialogIncrements::InitIncrementsSearchHistory()
{ {
QStringList searchHistory = VAbstractValApplication::VApp()->ValentinaSettings()->GetIncrementsSearchHistory(); QStringList searchHistory = VAbstractValApplication::VApp()->ValentinaSettings()->GetIncrementsSearchHistory();
m_searchHistory->clear(); m_searchHistory->clear();
for (const auto& term : searchHistory) for (const auto &term : searchHistory)
{ {
QAction *action = m_searchHistory->addAction(term); QAction *action = m_searchHistory->addAction(term);
action->setData(term); action->setData(term);
connect(action, &QAction::triggered, this, [this]() connect(action, &QAction::triggered, this,
[this]()
{ {
auto *action = qobject_cast<QAction *>(sender()); auto *action = qobject_cast<QAction *>(sender());
if (action != nullptr) if (action != nullptr)
@ -1104,11 +1125,12 @@ void DialogIncrements::InitPreviewCalculationsSearchHistory()
QStringList searchHistory = QStringList searchHistory =
VAbstractValApplication::VApp()->ValentinaSettings()->GetPreviewCalculationsSearchHistory(); VAbstractValApplication::VApp()->ValentinaSettings()->GetPreviewCalculationsSearchHistory();
m_searchHistoryPC->clear(); m_searchHistoryPC->clear();
for (const auto& term : searchHistory) for (const auto &term : searchHistory)
{ {
QAction *action = m_searchHistoryPC->addAction(term); QAction *action = m_searchHistoryPC->addAction(term);
action->setData(term); action->setData(term);
connect(action, &QAction::triggered, this, [this]() connect(action, &QAction::triggered, this,
[this]()
{ {
auto *action = qobject_cast<QAction *>(sender()); auto *action = qobject_cast<QAction *>(sender());
if (action != nullptr) if (action != nullptr)
@ -1144,7 +1166,8 @@ void DialogIncrements::SaveIncrementsSearchRequest()
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogIncrements::SavePreviewCalculationsSearchRequest() void DialogIncrements::SavePreviewCalculationsSearchRequest()
{ {
QStringList searchHistory = VAbstractValApplication::VApp()->ValentinaSettings()->GetPreviewCalculationsSearchHistory(); QStringList searchHistory =
VAbstractValApplication::VApp()->ValentinaSettings()->GetPreviewCalculationsSearchHistory();
QString term = ui->lineEditFindPC->text(); QString term = ui->lineEditFindPC->text();
if (term.isEmpty()) if (term.isEmpty())
{ {
@ -1297,7 +1320,7 @@ void DialogIncrements::RefreshPattern()
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogIncrements::FillIncrementsTable(QTableWidget *table, void DialogIncrements::FillIncrementsTable(QTableWidget *table,
const QMap<QString, QSharedPointer<VIncrement> > &increments, const QMap<QString, QSharedPointer<VIncrement>> &increments,
bool takePreviewCalculations) bool takePreviewCalculations)
{ {
SCASSERT(table != nullptr) SCASSERT(table != nullptr)
@ -1305,12 +1328,12 @@ void DialogIncrements::FillIncrementsTable(QTableWidget *table,
table->blockSignals(true); table->blockSignals(true);
table->clearContents(); table->clearContents();
QMap<QString, QSharedPointer<VIncrement> >::const_iterator i; QMap<QString, QSharedPointer<VIncrement>>::const_iterator i;
QMap<quint32, QString> map; QMap<quint32, QString> map;
//Sorting QHash by id // Sorting QHash by id
for (i = increments.constBegin(); i != increments.constEnd(); ++i) for (i = increments.constBegin(); i != increments.constEnd(); ++i)
{ {
const QSharedPointer<VIncrement>& incr = i.value(); const QSharedPointer<VIncrement> &incr = i.value();
if (takePreviewCalculations == incr->IsPreviewCalculation()) if (takePreviewCalculations == incr->IsPreviewCalculation())
{ {
map.insert(incr->GetIndex(), i.key()); map.insert(incr->GetIndex(), i.key());
@ -1319,7 +1342,7 @@ void DialogIncrements::FillIncrementsTable(QTableWidget *table,
qint32 currentRow = -1; qint32 currentRow = -1;
QMapIterator<quint32, QString> iMap(map); QMapIterator<quint32, QString> iMap(map);
table->setRowCount ( static_cast<int>(map.size()) ); table->setRowCount(static_cast<int>(map.size()));
while (iMap.hasNext()) while (iMap.hasNext())
{ {
iMap.next(); iMap.next();
@ -1337,9 +1360,8 @@ void DialogIncrements::FillIncrementsTable(QTableWidget *table,
} }
AddCell(table, calculatedValue, currentRow, 1, Qt::AlignCenter, incr->IsFormulaOk()); // calculated value AddCell(table, calculatedValue, currentRow, 1, Qt::AlignCenter, incr->IsFormulaOk()); // calculated value
QString formula = QString formula = VTranslateVars::TryFormulaToUser(
VTranslateVars::TryFormulaToUser(incr->GetFormula(), incr->GetFormula(), VAbstractApplication::VApp()->Settings()->GetOsSeparator());
VAbstractApplication::VApp()->Settings()->GetOsSeparator());
AddCell(table, formula, currentRow, 2, Qt::AlignVCenter); // formula AddCell(table, formula, currentRow, 2, Qt::AlignVCenter); // formula
@ -1464,7 +1486,7 @@ void DialogIncrements::MoveUp()
m_hasChanges = true; m_hasChanges = true;
LocalUpdateTree(); LocalUpdateTree();
table->selectRow(row-1); table->selectRow(row - 1);
table->repaint(); // Force repain to fix paint artifacts on Mac OS X table->repaint(); // Force repain to fix paint artifacts on Mac OS X
} }
@ -1509,7 +1531,7 @@ void DialogIncrements::MoveDown()
m_hasChanges = true; m_hasChanges = true;
LocalUpdateTree(); LocalUpdateTree();
table->selectRow(row+1); table->selectRow(row + 1);
table->repaint(); // Force repain to fix paint artifacts on Mac OS X table->repaint(); // Force repain to fix paint artifacts on Mac OS X
} }
@ -1704,9 +1726,9 @@ void DialogIncrements::SaveIncrFormula()
} }
else else
{ {
//Show unit in dialog lable (cm, mm or inch) // Show unit in dialog lable (cm, mm or inch)
const QString postfix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits()); const QString postfix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits());
labelCalculatedValue->setText(result->text() + QChar(QChar::Space) +postfix); labelCalculatedValue->setText(result->text() + QChar(QChar::Space) + postfix);
} }
return; return;
} }
@ -1719,7 +1741,7 @@ void DialogIncrements::SaveIncrFormula()
} }
else else
{ {
//Show unit in dialog lable (cm, mm or inch) // Show unit in dialog lable (cm, mm or inch)
const QString postfix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits()); const QString postfix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits());
labelCalculatedValue->setText(tr("Error") + " (" + postfix + "). " + tr("Empty field.")); labelCalculatedValue->setText(tr("Error") + " (" + postfix + "). " + tr("Empty field."));
} }
@ -1738,8 +1760,8 @@ void DialogIncrements::SaveIncrFormula()
try try
{ {
const QString formula = VAbstractApplication::VApp()->TrVars() const QString formula = VAbstractApplication::VApp()->TrVars()->FormulaFromUser(
->FormulaFromUser(text, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); text, VAbstractApplication::VApp()->Settings()->GetOsSeparator());
m_doc->SetIncrementFormula(nameField->text(), formula); m_doc->SetIncrementFormula(nameField->text(), formula);
} }
catch (qmu::QmuParserError &e) // Just in case something bad will happen catch (qmu::QmuParserError &e) // Just in case something bad will happen
@ -1795,16 +1817,16 @@ void DialogIncrements::DeployFormula()
if (plainTextEditFormula->height() < DIALOG_MAX_FORMULA_HEIGHT) if (plainTextEditFormula->height() < DIALOG_MAX_FORMULA_HEIGHT)
{ {
plainTextEditFormula->setFixedHeight(DIALOG_MAX_FORMULA_HEIGHT); plainTextEditFormula->setFixedHeight(DIALOG_MAX_FORMULA_HEIGHT);
//Set icon from theme (internal for Windows system) // Set icon from theme (internal for Windows system)
pushButtonGrow->setIcon(QIcon::fromTheme(QStringLiteral("go-next"), pushButtonGrow->setIcon(
QIcon(":/icons/win.icon.theme/16x16/actions/go-next.png"))); QIcon::fromTheme(QStringLiteral("go-next"), QIcon(":/icons/win.icon.theme/16x16/actions/go-next.png")));
} }
else else
{ {
plainTextEditFormula->setFixedHeight(baseHeight); plainTextEditFormula->setFixedHeight(baseHeight);
//Set icon from theme (internal for Windows system) // Set icon from theme (internal for Windows system)
pushButtonGrow->setIcon(QIcon::fromTheme(QStringLiteral("go-down"), pushButtonGrow->setIcon(
QIcon(":/icons/win.icon.theme/16x16/actions/go-down.png"))); QIcon::fromTheme(QStringLiteral("go-down"), QIcon(":/icons/win.icon.theme/16x16/actions/go-down.png")));
} }
// I found that after change size of formula field, it was filed for angle formula, field for formula became black. // I found that after change size of formula field, it was filed for angle formula, field for formula became black.
@ -1860,7 +1882,7 @@ void DialogIncrements::Fx()
dialog->SetFormula(VTranslateVars::TryFormulaFromUser(plainTextEditFormula->toPlainText(), dialog->SetFormula(VTranslateVars::TryFormulaFromUser(plainTextEditFormula->toPlainText(),
VAbstractApplication::VApp()->Settings()->GetOsSeparator())); VAbstractApplication::VApp()->Settings()->GetOsSeparator()));
const QString postfix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true); const QString postfix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true);
dialog->setPostfix(postfix);//Show unit in dialog lable (cm, mm or inch) dialog->setPostfix(postfix); // Show unit in dialog lable (cm, mm or inch)
if (dialog->exec() == QDialog::Accepted) if (dialog->exec() == QDialog::Accepted)
{ {
@ -1957,7 +1979,7 @@ void DialogIncrements::showEvent(QShowEvent *event)
{ {
// Skip DialogTool implementation // Skip DialogTool implementation
QDialog::showEvent(event); // NOLINT(bugprone-parent-virtual-call) QDialog::showEvent(event); // NOLINT(bugprone-parent-virtual-call)
if ( event->spontaneous() ) if (event->spontaneous())
{ {
return; return;
} }
@ -1974,7 +1996,7 @@ void DialogIncrements::showEvent(QShowEvent *event)
resize(sz); resize(sz);
} }
isInitialized = true;//first show windows are held isInitialized = true; // first show windows are held
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View File

@ -29,29 +29,29 @@
#include "dialogpatternproperties.h" #include "dialogpatternproperties.h"
#include "ui_dialogpatternproperties.h" #include "ui_dialogpatternproperties.h"
#include <QBuffer> #include <QBuffer>
#include <QPushButton>
#include <QFileDialog>
#include <QMenu>
#include <QDate>
#include <QMessageBox>
#include <QRadioButton>
#include <QCompleter> #include <QCompleter>
#include <QSet> #include <QDate>
#include <QImageReader>
#include <QMimeType>
#include <QDesktopServices> #include <QDesktopServices>
#include <QFileDialog>
#include <QImageReader>
#include <QMenu>
#include <QMessageBox>
#include <QMimeType>
#include <QPushButton>
#include <QRadioButton>
#include <QSet>
#include <QUrl> #include <QUrl>
#include "../xml/vpattern.h"
#include "../vpatterndb/vcontainer.h"
#include "../core/vapplication.h" #include "../core/vapplication.h"
#include "../vmisc/vvalentinasettings.h" #include "../vmisc/vvalentinasettings.h"
#include "../vpatterndb/vcontainer.h"
#include "../xml/vpattern.h"
#if QT_VERSION < QT_VERSION_CHECK(5, 7, 0) #if QT_VERSION < QT_VERSION_CHECK(5, 7, 0)
#include "../vmisc/backport/qoverload.h" #include "../vmisc/backport/qoverload.h"
#endif // QT_VERSION < QT_VERSION_CHECK(5, 7, 0) #endif // QT_VERSION < QT_VERSION_CHECK(5, 7, 0)
#include "../qmuparser/qmudef.h"
#include "../ifc/xml/vpatternimage.h"
#include "../ifc/xml/utils.h" #include "../ifc/xml/utils.h"
#include "../ifc/xml/vpatternimage.h"
#include "../qmuparser/qmudef.h"
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
DialogPatternProperties::DialogPatternProperties(VPattern *doc, VContainer *pattern, QWidget *parent) DialogPatternProperties::DialogPatternProperties(VPattern *doc, VContainer *pattern, QWidget *parent)
@ -85,13 +85,11 @@ DialogPatternProperties::DialogPatternProperties(VPattern *doc, VContainer *pat
} }
ui->lineEditPathToFile->setCursorPosition(0); ui->lineEditPathToFile->setCursorPosition(0);
connect(ui->pushButtonShowInExplorer, &QPushButton::clicked, this, []() connect(ui->pushButtonShowInExplorer, &QPushButton::clicked, this,
{ []() { ShowInGraphicalShell(VAbstractValApplication::VApp()->GetPatternPath()); });
ShowInGraphicalShell(VAbstractValApplication::VApp()->GetPatternPath());
});
#if defined(Q_OS_MAC) #if defined(Q_OS_MAC)
ui->pushButtonShowInExplorer->setText(tr("Show in Finder")); ui->pushButtonShowInExplorer->setText(tr("Show in Finder"));
#endif //defined(Q_OS_MAC) #endif // defined(Q_OS_MAC)
//----------------------- Label language //----------------------- Label language
for (auto &name : VApplication::LabelLanguages()) for (auto &name : VApplication::LabelLanguages())
@ -99,8 +97,8 @@ DialogPatternProperties::DialogPatternProperties(VPattern *doc, VContainer *pat
ui->comboBoxLabelLanguage->addItem(QLocale(name).nativeLanguageName(), name); ui->comboBoxLabelLanguage->addItem(QLocale(name).nativeLanguageName(), name);
} }
int index = ui->comboBoxLabelLanguage->findData( int index =
VAbstractValApplication::VApp()->ValentinaSettings()->GetLabelLanguage()); ui->comboBoxLabelLanguage->findData(VAbstractValApplication::VApp()->ValentinaSettings()->GetLabelLanguage());
if (index != -1) if (index != -1)
{ {
ui->comboBoxLabelLanguage->setCurrentIndex(index); ui->comboBoxLabelLanguage->setCurrentIndex(index);
@ -131,7 +129,7 @@ DialogPatternProperties::DialogPatternProperties(VPattern *doc, VContainer *pat
ui->checkBoxPatternReadOnly->setChecked(readOnly); ui->checkBoxPatternReadOnly->setChecked(readOnly);
if (not readOnly) if (not readOnly)
{ {
connect(ui->checkBoxPatternReadOnly, &QRadioButton::toggled, this, [this](){m_securityChanged = true;}); connect(ui->checkBoxPatternReadOnly, &QRadioButton::toggled, this, [this]() { m_securityChanged = true; });
} }
else else
{ {
@ -154,7 +152,8 @@ DialogPatternProperties::DialogPatternProperties(VPattern *doc, VContainer *pat
}); });
ui->lineEditPassmarkLength->setCompleter(m_completerLength); ui->lineEditPassmarkLength->setCompleter(m_completerLength);
connect(ui->lineEditPassmarkLength, &QLineEdit::textEdited, this, [this]() connect(ui->lineEditPassmarkLength, &QLineEdit::textEdited, this,
[this]()
{ {
ValidatePassmarkLength(); ValidatePassmarkLength();
DescEdited(); DescEdited();
@ -191,12 +190,11 @@ DialogPatternProperties::DialogPatternProperties(VPattern *doc, VContainer *pat
ui->lineEditPassmarkWidth->setText(m_oldPassmarkWidth); ui->lineEditPassmarkWidth->setText(m_oldPassmarkWidth);
ValidatePassmarkWidth(); ValidatePassmarkWidth();
//Initialization change value. Set to default value after initialization // Initialization change value. Set to default value after initialization
m_defaultChanged = false; m_defaultChanged = false;
m_securityChanged = false; m_securityChanged = false;
connect(ui->pushButtonBrowsePieceLabelPath, &QPushButton::clicked, this, connect(ui->pushButtonBrowsePieceLabelPath, &QPushButton::clicked, this, &DialogPatternProperties::BrowseLabelPath);
&DialogPatternProperties::BrowseLabelPath);
ui->lineEditPieceLabelPath->setText(m_doc->GetDefaultPieceLabelPath()); ui->lineEditPieceLabelPath->setText(m_doc->GetDefaultPieceLabelPath());
connect(ui->lineEditPieceLabelPath, &QLineEdit::textChanged, this, &DialogPatternProperties::LabelPathChanged); connect(ui->lineEditPieceLabelPath, &QLineEdit::textChanged, this, &DialogPatternProperties::LabelPathChanged);
} }
@ -222,7 +220,7 @@ auto DialogPatternProperties::eventFilter(QObject *object, QEvent *event) -> boo
} }
} }
return false;// clazy:exclude=base-class-event return false; // clazy:exclude=base-class-event
} }
if (ui->lineEditPassmarkWidth == qobject_cast<QLineEdit *>(object)) if (ui->lineEditPassmarkWidth == qobject_cast<QLineEdit *>(object))
@ -330,8 +328,7 @@ void DialogPatternProperties::ValidatePassmarkLength() const
QRegularExpression rx(NameRegExp()); QRegularExpression rx(NameRegExp());
if (not text.isEmpty()) if (not text.isEmpty())
{ {
palette.setColor(foregroundRole, palette.setColor(foregroundRole, rx.match(text).hasMatch() && m_variables.contains(text) ? Qt::black : Qt::red);
rx.match(text).hasMatch() && m_variables.contains(text) ? Qt::black : Qt::red);
} }
else else
{ {
@ -366,7 +363,8 @@ void DialogPatternProperties::InitImage()
{ {
ui->imageLabel->setContextMenuPolicy(Qt::CustomContextMenu); ui->imageLabel->setContextMenuPolicy(Qt::CustomContextMenu);
ui->imageLabel->setScaledContents(true); ui->imageLabel->setScaledContents(true);
connect(ui->imageLabel, &QWidget::customContextMenuRequested, this, [this]() connect(ui->imageLabel, &QWidget::customContextMenuRequested, this,
[this]()
{ {
QMenu menu(this); QMenu menu(this);
menu.addAction(m_deleteAction); menu.addAction(m_deleteAction);
@ -382,7 +380,8 @@ void DialogPatternProperties::InitImage()
m_saveImageAction = new QAction(tr("Save image to file"), this); m_saveImageAction = new QAction(tr("Save image to file"), this);
m_showImageAction = new QAction(tr("Show image"), this); m_showImageAction = new QAction(tr("Show image"), this);
connect(m_deleteAction, &QAction::triggered, this, [this]() connect(m_deleteAction, &QAction::triggered, this,
[this]()
{ {
m_doc->DeleteImage(); m_doc->DeleteImage();
ui->imageLabel->setText(tr("Change image")); ui->imageLabel->setText(tr("Change image"));
@ -411,8 +410,8 @@ void DialogPatternProperties::InitImage()
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogPatternProperties::ChangeImage() void DialogPatternProperties::ChangeImage()
{ {
const QString fileName = QFileDialog::getOpenFileName(this, tr("Image for pattern"), QString(), const QString fileName =
PrepareImageFilters(), nullptr, QFileDialog::getOpenFileName(this, tr("Image for pattern"), QString(), PrepareImageFilters(), nullptr,
VAbstractApplication::VApp()->NativeFileDialog()); VAbstractApplication::VApp()->NativeFileDialog());
if (not fileName.isEmpty()) if (not fileName.isEmpty())
{ {

View File

@ -27,30 +27,41 @@
*************************************************************************/ *************************************************************************/
#include "dialogsavelayout.h" #include "dialogsavelayout.h"
#include "ui_dialogsavelayout.h"
#include "../core/vapplication.h" #include "../core/vapplication.h"
#include "../vmisc/vvalentinasettings.h" #include "../vmisc/vvalentinasettings.h"
#include "ui_dialogsavelayout.h"
#if QT_VERSION < QT_VERSION_CHECK(5, 7, 0) #if QT_VERSION < QT_VERSION_CHECK(5, 7, 0)
#include "../vmisc/backport/qoverload.h" #include "../vmisc/backport/qoverload.h"
#endif // QT_VERSION < QT_VERSION_CHECK(5, 7, 0) #endif // QT_VERSION < QT_VERSION_CHECK(5, 7, 0)
#include "../ifc/exception/vexception.h" #include "../ifc/exception/vexception.h"
#include "../vlayout/vlayoutexporter.h" #include "../vlayout/vlayoutexporter.h"
#if QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
#include "../vmisc/diagnostic.h"
#endif // QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
#include <QDir> #include <QDir>
#include <QFileDialog> #include <QFileDialog>
#include <QGlobalStatic>
#include <QMessageBox> #include <QMessageBox>
#include <QProcess> #include <QProcess>
#include <QtDebug>
#include <QRegularExpression> #include <QRegularExpression>
#include <QtDebug> #include <QtDebug>
#include <QGlobalStatic>
namespace
{
QT_WARNING_PUSH
QT_WARNING_DISABLE_CLANG("-Wunused-member-function")
#ifndef Q_OS_WIN #ifndef Q_OS_WIN
Q_GLOBAL_STATIC_WITH_ARGS(const QString, baseFilenameRegExp, (QLatin1String("^[^\\/]+$"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, baseFilenameRegExp, (QLatin1String("^[^\\/]+$"))) // NOLINT
#else #else
Q_GLOBAL_STATIC_WITH_ARGS(const QString, baseFilenameRegExp, (QLatin1String("^[^\\:?\"*|\\/<>]+$"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, baseFilenameRegExp, (QLatin1String("^[^\\:?\"*|\\/<>]+$"))) // NOLINT
#endif #endif
QT_WARNING_POP
} // namespace
bool DialogSaveLayout::havePdf = false; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables) bool DialogSaveLayout::havePdf = false; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)
bool DialogSaveLayout::tested = false; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables) bool DialogSaveLayout::tested = false; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)
@ -76,7 +87,7 @@ DialogSaveLayout::DialogSaveLayout(int count, Draw mode, const QString &fileName
SCASSERT(bOk != nullptr) SCASSERT(bOk != nullptr)
bOk->setEnabled(false); bOk->setEnabled(false);
ui->lineEditFileName->setValidator( new QRegularExpressionValidator(QRegularExpression(*baseFilenameRegExp), this)); ui->lineEditFileName->setValidator(new QRegularExpressionValidator(QRegularExpression(*baseFilenameRegExp), this));
const QString mask = fileName + '_'; const QString mask = fileName + '_';
if (VApplication::IsGUIMode()) if (VApplication::IsGUIMode())
@ -103,7 +114,7 @@ DialogSaveLayout::DialogSaveLayout(int count, Draw mode, const QString &fileName
RemoveFormatFromList(LayoutExportFormats::OBJ); RemoveFormatFromList(LayoutExportFormats::OBJ);
#endif #endif
// RemoveFormatFromList(LayoutExportFormats::NC); // No support for now // RemoveFormatFromList(LayoutExportFormats::NC); // No support for now
if (m_mode != Draw::Layout) if (m_mode != Draw::Layout)
{ {
@ -117,9 +128,10 @@ DialogSaveLayout::DialogSaveLayout(int count, Draw mode, const QString &fileName
connect(bOk, &QPushButton::clicked, this, &DialogSaveLayout::Save); connect(bOk, &QPushButton::clicked, this, &DialogSaveLayout::Save);
connect(ui->lineEditFileName, &QLineEdit::textChanged, this, &DialogSaveLayout::ShowExample); connect(ui->lineEditFileName, &QLineEdit::textChanged, this, &DialogSaveLayout::ShowExample);
connect(ui->comboBoxFormat, QOverload<int>::of(&QComboBox::currentIndexChanged), connect(ui->comboBoxFormat, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
this, &DialogSaveLayout::ShowExample); &DialogSaveLayout::ShowExample);
connect(ui->pushButtonBrowse, &QPushButton::clicked, this, [this]() connect(ui->pushButtonBrowse, &QPushButton::clicked, this,
[this]()
{ {
const QString dirPath = VAbstractValApplication::VApp()->ValentinaSettings()->GetPathLayout(); const QString dirPath = VAbstractValApplication::VApp()->ValentinaSettings()->GetPathLayout();
bool usedNotExistedDir = false; bool usedNotExistedDir = false;
@ -134,7 +146,7 @@ DialogSaveLayout::DialogSaveLayout(int count, Draw mode, const QString &fileName
VAbstractApplication::VApp()->NativeFileDialog(QFileDialog::ShowDirsOnly | VAbstractApplication::VApp()->NativeFileDialog(QFileDialog::ShowDirsOnly |
QFileDialog::DontResolveSymlinks)); QFileDialog::DontResolveSymlinks));
if (not dir.isEmpty()) if (not dir.isEmpty())
{// If paths equal the signal will not be called, we will do this manually { // If paths equal the signal will not be called, we will do this manually
dir == ui->lineEditPath->text() ? PathChanged(dir) : ui->lineEditPath->setText(dir); dir == ui->lineEditPath->text() ? PathChanged(dir) : ui->lineEditPath->setText(dir);
} }
@ -152,14 +164,14 @@ DialogSaveLayout::DialogSaveLayout(int count, Draw mode, const QString &fileName
connect(ui->toolButtonScaleConnected, &QToolButton::clicked, this, &DialogSaveLayout::ToggleScaleConnection); connect(ui->toolButtonScaleConnected, &QToolButton::clicked, this, &DialogSaveLayout::ToggleScaleConnection);
connect(ui->doubleSpinBoxHorizontalScale, QOverload<double>::of(&QDoubleSpinBox::valueChanged), connect(ui->doubleSpinBoxHorizontalScale, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this,
this, &DialogSaveLayout::HorizontalScaleChanged); &DialogSaveLayout::HorizontalScaleChanged);
connect(ui->doubleSpinBoxVerticalScale, QOverload<double>::of(&QDoubleSpinBox::valueChanged), connect(ui->doubleSpinBoxVerticalScale, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this,
this, &DialogSaveLayout::VerticalScaleChanged); &DialogSaveLayout::VerticalScaleChanged);
ReadSettings(); ReadSettings();
ShowExample();//Show example for current format. ShowExample(); // Show example for current format.
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -182,7 +194,7 @@ void DialogSaveLayout::SelectFormat(LayoutExportFormats format)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogSaveLayout::SetBinaryDXFFormat(bool binary) void DialogSaveLayout::SetBinaryDXFFormat(bool binary)
{ {
switch(Format()) switch (Format())
{ {
case LayoutExportFormats::DXF_AC1006_Flat: case LayoutExportFormats::DXF_AC1006_Flat:
case LayoutExportFormats::DXF_AC1009_Flat: case LayoutExportFormats::DXF_AC1009_Flat:
@ -216,7 +228,7 @@ void DialogSaveLayout::SetBinaryDXFFormat(bool binary)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto DialogSaveLayout::IsBinaryDXFFormat() const -> bool auto DialogSaveLayout::IsBinaryDXFFormat() const -> bool
{ {
switch(Format()) switch (Format())
{ {
case LayoutExportFormats::DXF_AC1006_Flat: case LayoutExportFormats::DXF_AC1006_Flat:
case LayoutExportFormats::DXF_AC1009_Flat: case LayoutExportFormats::DXF_AC1009_Flat:
@ -248,7 +260,7 @@ auto DialogSaveLayout::IsBinaryDXFFormat() const -> bool
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogSaveLayout::SetShowGrainline(bool show) void DialogSaveLayout::SetShowGrainline(bool show)
{ {
switch(Format()) switch (Format())
{ {
case LayoutExportFormats::DXF_AC1006_Flat: case LayoutExportFormats::DXF_AC1006_Flat:
case LayoutExportFormats::DXF_AC1009_Flat: case LayoutExportFormats::DXF_AC1009_Flat:
@ -282,7 +294,7 @@ void DialogSaveLayout::SetShowGrainline(bool show)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto DialogSaveLayout::IsShowGrainline() const -> bool auto DialogSaveLayout::IsShowGrainline() const -> bool
{ {
switch(Format()) switch (Format())
{ {
case LayoutExportFormats::DXF_AC1006_Flat: case LayoutExportFormats::DXF_AC1006_Flat:
case LayoutExportFormats::DXF_AC1009_Flat: case LayoutExportFormats::DXF_AC1009_Flat:
@ -316,10 +328,10 @@ auto DialogSaveLayout::MakeHelpFormatList() -> QString
{ {
QString out(QStringLiteral("\n")); QString out(QStringLiteral("\n"));
const auto formats = InitFormats(); const auto formats = InitFormats();
for(int i = 0; i < formats.size(); ++i) for (int i = 0; i < formats.size(); ++i)
{ {
out += QStringLiteral("\t* ") + formats.at(i).first + QStringLiteral(" = ") out += QStringLiteral("\t* ") + formats.at(i).first + QStringLiteral(" = ") +
+ QString::number(static_cast<int>(formats.at(i).second)); QString::number(static_cast<int>(formats.at(i).second));
if (i < formats.size() - 1) if (i < formats.size() - 1)
{ {
@ -394,14 +406,16 @@ void DialogSaveLayout::Save()
{ {
WriteSettings(); WriteSettings();
for (int i=0; i < m_count; ++i) for (int i = 0; i < m_count; ++i)
{ {
const QString name = Path()+'/'+FileName()+QString::number(i+1)+VLayoutExporter::ExportFormatSuffix(Format()); const QString name =
Path() + '/' + FileName() + QString::number(i + 1) + VLayoutExporter::ExportFormatSuffix(Format());
if (QFile::exists(name)) if (QFile::exists(name))
{ {
QMessageBox::StandardButton res = QMessageBox::question(this, tr("Name conflict"), QMessageBox::StandardButton res = QMessageBox::question(
tr("Folder already contain file with name %1. Rewrite all conflict file names?") this, tr("Name conflict"),
.arg(name), QMessageBox::Yes|QMessageBox::No, QMessageBox::Yes); tr("Folder already contain file with name %1. Rewrite all conflict file names?").arg(name),
QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
if (res == QMessageBox::No) if (res == QMessageBox::No)
{ {
reject(); reject();
@ -442,7 +456,8 @@ void DialogSaveLayout::PathChanged(const QString &text)
void DialogSaveLayout::ShowExample() void DialogSaveLayout::ShowExample()
{ {
const LayoutExportFormats currentFormat = Format(); const LayoutExportFormats currentFormat = Format();
ui->labelExample->setText(tr("Example:") + FileName() + QLatin1Char('1') + VLayoutExporter::ExportFormatSuffix(currentFormat)); ui->labelExample->setText(tr("Example:") + FileName() + QLatin1Char('1') +
VLayoutExporter::ExportFormatSuffix(currentFormat));
ui->checkBoxBinaryDXF->setEnabled(false); ui->checkBoxBinaryDXF->setEnabled(false);
ui->groupBoxPaperFormat->setEnabled(false); ui->groupBoxPaperFormat->setEnabled(false);
@ -450,7 +465,7 @@ void DialogSaveLayout::ShowExample()
ui->checkBoxTextAsPaths->setEnabled(true); ui->checkBoxTextAsPaths->setEnabled(true);
ui->checkBoxShowGrainline->setEnabled(m_mode == Draw::Layout); ui->checkBoxShowGrainline->setEnabled(m_mode == Draw::Layout);
switch(currentFormat) switch (currentFormat)
{ {
case LayoutExportFormats::DXF_AAMA: case LayoutExportFormats::DXF_AAMA:
case LayoutExportFormats::DXF_ASTM: case LayoutExportFormats::DXF_ASTM:
@ -562,12 +577,8 @@ void DialogSaveLayout::SetTiledMargins(QMarginsF margins)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto DialogSaveLayout::GetTiledMargins() const -> QMarginsF auto DialogSaveLayout::GetTiledMargins() const -> QMarginsF
{ {
QMarginsF margins = QMarginsF( QMarginsF margins = QMarginsF(ui->doubleSpinBoxLeftField->value(), ui->doubleSpinBoxTopField->value(),
ui->doubleSpinBoxLeftField->value(), ui->doubleSpinBoxRightField->value(), ui->doubleSpinBoxBottomField->value());
ui->doubleSpinBoxTopField->value(),
ui->doubleSpinBoxRightField->value(),
ui->doubleSpinBoxBottomField->value()
);
return UnitConvertor(margins, VAbstractValApplication::VApp()->patternUnits(), Unit::Mm); return UnitConvertor(margins, VAbstractValApplication::VApp()->patternUnits(), Unit::Mm);
} }
@ -595,7 +606,7 @@ auto DialogSaveLayout::GetTiledPageFormat() const -> VAbstractLayoutDialog::Pape
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogSaveLayout::SetTiledPageOrientation(PageOrientation orientation) void DialogSaveLayout::SetTiledPageOrientation(PageOrientation orientation)
{ {
if(orientation == PageOrientation::Portrait) if (orientation == PageOrientation::Portrait)
{ {
ui->toolButtonPortrait->setChecked(true); ui->toolButtonPortrait->setChecked(true);
} }
@ -608,7 +619,7 @@ void DialogSaveLayout::SetTiledPageOrientation(PageOrientation orientation)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto DialogSaveLayout::GetTiledPageOrientation() const -> PageOrientation auto DialogSaveLayout::GetTiledPageOrientation() const -> PageOrientation
{ {
if(ui->toolButtonPortrait->isChecked()) if (ui->toolButtonPortrait->isChecked())
{ {
return PageOrientation::Portrait; return PageOrientation::Portrait;
} }
@ -643,8 +654,8 @@ auto DialogSaveLayout::GetYScale() const -> qreal
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogSaveLayout::showEvent(QShowEvent *event) void DialogSaveLayout::showEvent(QShowEvent *event)
{ {
QDialog::showEvent( event ); QDialog::showEvent(event);
if ( event->spontaneous() ) if (event->spontaneous())
{ {
return; return;
} }
@ -657,7 +668,7 @@ void DialogSaveLayout::showEvent(QShowEvent *event)
setFixedHeight(size().height()); setFixedHeight(size().height());
m_isInitialized = true;//first show windows are held m_isInitialized = true; // first show windows are held
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -672,14 +683,12 @@ auto DialogSaveLayout::SupportPSTest() -> bool
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto DialogSaveLayout::InitFormats() -> QVector<std::pair<QString, LayoutExportFormats> > auto DialogSaveLayout::InitFormats() -> QVector<std::pair<QString, LayoutExportFormats>>
{ {
QVector<std::pair<QString, LayoutExportFormats>> list; QVector<std::pair<QString, LayoutExportFormats>> list;
auto InitFormat = [&list](LayoutExportFormats format) auto InitFormat = [&list](LayoutExportFormats format)
{ { list.append(std::make_pair(VLayoutExporter::ExportFormatDescription(format), format)); };
list.append(std::make_pair(VLayoutExporter::ExportFormatDescription(format), format));
};
InitFormat(LayoutExportFormats::SVG); InitFormat(LayoutExportFormats::SVG);
InitFormat(LayoutExportFormats::PDF); InitFormat(LayoutExportFormats::PDF);
@ -702,7 +711,7 @@ auto DialogSaveLayout::InitFormats() -> QVector<std::pair<QString, LayoutExportF
InitFormat(LayoutExportFormats::DXF_AAMA); InitFormat(LayoutExportFormats::DXF_AAMA);
InitFormat(LayoutExportFormats::DXF_ASTM); InitFormat(LayoutExportFormats::DXF_ASTM);
InitFormat(LayoutExportFormats::PDFTiled); InitFormat(LayoutExportFormats::PDFTiled);
// InitFormat(LayoutExportFormats::NC); // InitFormat(LayoutExportFormats::NC);
InitFormat(LayoutExportFormats::RLD); InitFormat(LayoutExportFormats::RLD);
InitFormat(LayoutExportFormats::TIF); InitFormat(LayoutExportFormats::TIF);
@ -747,7 +756,7 @@ void DialogSaveLayout::ReadSettings()
const QSizeF size = QSizeF(settings->GetTiledPDFPaperWidth(Unit::Mm), settings->GetTiledPDFPaperHeight(Unit::Mm)); const QSizeF size = QSizeF(settings->GetTiledPDFPaperWidth(Unit::Mm), settings->GetTiledPDFPaperHeight(Unit::Mm));
const int max = static_cast<int>(PaperSizeTemplate::Custom); 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), Unit::Mm); const QSizeF tmplSize = GetTemplateSize(static_cast<PaperSizeTemplate>(i), Unit::Mm);
@ -759,7 +768,7 @@ void DialogSaveLayout::ReadSettings()
} }
// read Orientation // read Orientation
if(settings->GetTiledPDFOrientation() == PageOrientation::Portrait) if (settings->GetTiledPDFOrientation() == PageOrientation::Portrait)
{ {
ui->toolButtonPortrait->setChecked(true); ui->toolButtonPortrait->setChecked(true);
} }
@ -795,13 +804,9 @@ void DialogSaveLayout::WriteSettings() const
const Unit unit = VAbstractValApplication::VApp()->patternUnits(); const Unit unit = VAbstractValApplication::VApp()->patternUnits();
// write Margins top, right, bottom, left // write Margins top, right, bottom, left
QMarginsF margins = QMarginsF( QMarginsF margins = QMarginsF(ui->doubleSpinBoxLeftField->value(), ui->doubleSpinBoxTopField->value(),
ui->doubleSpinBoxLeftField->value(), ui->doubleSpinBoxRightField->value(), ui->doubleSpinBoxBottomField->value());
ui->doubleSpinBoxTopField->value(), settings->SetTiledPDFMargins(margins, unit);
ui->doubleSpinBoxRightField->value(),
ui->doubleSpinBoxBottomField->value()
);
settings->SetTiledPDFMargins(margins,unit);
// write Template // write Template
const PaperSizeTemplate temp = static_cast<PaperSizeTemplate>(ui->comboBoxTemplates->currentData().toInt()); const PaperSizeTemplate temp = static_cast<PaperSizeTemplate>(ui->comboBoxTemplates->currentData().toInt());
@ -811,7 +816,7 @@ void DialogSaveLayout::WriteSettings() const
settings->SetTiledPDFPaperWidth(size.width(), Unit::Mm); settings->SetTiledPDFPaperWidth(size.width(), Unit::Mm);
// write Orientation // write Orientation
if(ui->toolButtonPortrait->isChecked()) if (ui->toolButtonPortrait->isChecked())
{ {
settings->SetTiledPDFOrientation(PageOrientation::Portrait); settings->SetTiledPDFOrientation(PageOrientation::Portrait);
} }
@ -830,4 +835,3 @@ void DialogSaveLayout::WriteSettings() const
settings->SetShowGrainline(IsShowGrainline()); settings->SetShowGrainline(IsShowGrainline());
} }
} }

View File

@ -27,12 +27,16 @@
*************************************************************************/ *************************************************************************/
#include "vwidgetdetails.h" #include "vwidgetdetails.h"
#include "ui_vwidgetdetails.h"
#include "../ifc/xml/vabstractpattern.h" #include "../ifc/xml/vabstractpattern.h"
#include "../vpatterndb/vcontainer.h"
#include "../vmisc/vabstractapplication.h" #include "../vmisc/vabstractapplication.h"
#include "../vtools/undocommands/togglepiecestate.h" #include "../vpatterndb/vcontainer.h"
#include "../vtools/tools/vtoolseamallowance.h" #include "../vtools/tools/vtoolseamallowance.h"
#include "../vtools/undocommands/togglepiecestate.h"
#include "ui_vwidgetdetails.h"
#if QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
#include "../vmisc/diagnostic.h"
#endif // QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
#include <QMenu> #include <QMenu>
#include <QTimer> #include <QTimer>
@ -58,8 +62,13 @@ enum PieceColumn
PieceName = 1 PieceName = 1
}; };
QT_WARNING_PUSH
QT_WARNING_DISABLE_CLANG("-Wunused-member-function")
Q_GLOBAL_STATIC_WITH_ARGS(const QString, allowDetailIcon, (QLatin1String("://icon/16x16/allow_detail.png"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, allowDetailIcon, (QLatin1String("://icon/16x16/allow_detail.png"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, forbidDetailIcon, (QLatin1String("://icon/16x16/forbid_detail.png"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, forbidDetailIcon, (QLatin1String("://icon/16x16/forbid_detail.png"))) // NOLINT
QT_WARNING_POP
} // namespace } // namespace
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -82,10 +91,7 @@ VWidgetDetails::VWidgetDetails(VContainer *data, VAbstractPattern *doc, QWidget
connect(ui->tableWidget, &QTableWidget::customContextMenuRequested, this, &VWidgetDetails::ShowContextMenu); connect(ui->tableWidget, &QTableWidget::customContextMenuRequested, this, &VWidgetDetails::ShowContextMenu);
m_updateListTimer->setSingleShot(true); m_updateListTimer->setSingleShot(true);
connect(m_updateListTimer, &QTimer::timeout, this, [this]() connect(m_updateListTimer, &QTimer::timeout, this, [this]() { FillTable(m_data->DataPieces()); });
{
FillTable(m_data->DataPieces());
});
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -203,12 +209,12 @@ void VWidgetDetails::ToggleSectionDetails(bool select)
return; return;
} }
for (int i = 0; i<ui->tableWidget->rowCount(); ++i) for (int i = 0; i < ui->tableWidget->rowCount(); ++i)
{ {
const quint32 id = ui->tableWidget->item(i, PieceColumn::InLayout)->data(Qt::UserRole).toUInt(); const quint32 id = ui->tableWidget->item(i, PieceColumn::InLayout)->data(Qt::UserRole).toUInt();
if (allDetails->contains(id)) if (allDetails->contains(id))
{ {
if (not (select == allDetails->value(id).IsInLayout())) if (not(select == allDetails->value(id).IsInLayout()))
{ {
auto *togglePrint = new TogglePieceInLayout(id, select, m_data, m_doc); auto *togglePrint = new TogglePieceInLayout(id, select, m_data, m_doc);
connect(togglePrint, &TogglePieceInLayout::Toggled, this, &VWidgetDetails::ToggledPiece); connect(togglePrint, &TogglePieceInLayout::Toggled, this, &VWidgetDetails::ToggledPiece);
@ -229,13 +235,12 @@ void VWidgetDetails::ToggledPieceItem(QTableWidgetItem *item)
if (details->contains(id)) if (details->contains(id))
{ {
const bool inLayout = details->value(id).IsInLayout(); const bool inLayout = details->value(id).IsInLayout();
inLayout ? item->setIcon(QIcon(*allowDetailIcon)) inLayout ? item->setIcon(QIcon(*allowDetailIcon)) : item->setIcon(QIcon(*forbidDetailIcon));
: item->setIcon(QIcon(*forbidDetailIcon));
VToolSeamAllowance *tool = nullptr; VToolSeamAllowance *tool = nullptr;
try try
{ {
tool = qobject_cast<VToolSeamAllowance*>(VAbstractPattern::getTool(id)); tool = qobject_cast<VToolSeamAllowance *>(VAbstractPattern::getTool(id));
tool->setVisible(ui->checkBoxHideNotInLayout->isChecked() ? inLayout : true); tool->setVisible(ui->checkBoxHideNotInLayout->isChecked() ? inLayout : true);
} }
catch (VExceptionBadId &) catch (VExceptionBadId &)
@ -309,11 +314,11 @@ void VWidgetDetails::ShowContextMenu(const QPoint &pos)
pieceMode = true; pieceMode = true;
menu->addSeparator(); menu->addSeparator();
actionPieceOptions = menu->addAction(QIcon::fromTheme(QStringLiteral("preferences-other")), actionPieceOptions =
tr("Piece options")); menu->addAction(QIcon::fromTheme(QStringLiteral("preferences-other")), tr("Piece options"));
actionDeletePiece = menu->addAction(QIcon::fromTheme(QStringLiteral("edit-delete")), actionDeletePiece =
tr("Delete piece")); menu->addAction(QIcon::fromTheme(QStringLiteral("edit-delete")), tr("Delete piece"));
actionDeletePiece->setDisabled(toolPiece->referens() > 0); actionDeletePiece->setDisabled(toolPiece->referens() > 0);
} }
} }
@ -335,7 +340,7 @@ void VWidgetDetails::ShowContextMenu(const QPoint &pos)
auto iter = allDetails->constBegin(); auto iter = allDetails->constBegin();
while (iter != allDetails->constEnd()) while (iter != allDetails->constEnd())
{ {
if(iter.value().IsInLayout()) if (iter.value().IsInLayout())
{ {
selectedDetails++; selectedDetails++;
} }
@ -372,7 +377,7 @@ void VWidgetDetails::ShowContextMenu(const QPoint &pos)
{ {
VAbstractApplication::VApp()->getUndoStack()->beginMacro(tr("invert selection")); VAbstractApplication::VApp()->getUndoStack()->beginMacro(tr("invert selection"));
for (int i = 0; i<ui->tableWidget->rowCount(); ++i) for (int i = 0; i < ui->tableWidget->rowCount(); ++i)
{ {
QTableWidgetItem *item = ui->tableWidget->item(i, PieceColumn::InLayout); QTableWidgetItem *item = ui->tableWidget->item(i, PieceColumn::InLayout);
const quint32 id = item->data(Qt::UserRole).toUInt(); const quint32 id = item->data(Qt::UserRole).toUInt();
@ -398,12 +403,12 @@ void VWidgetDetails::ShowContextMenu(const QPoint &pos)
{ {
toolPiece->DeleteFromMenu(); toolPiece->DeleteFromMenu();
} }
catch(const VExceptionToolWasDeleted &e) catch (const VExceptionToolWasDeleted &e)
{ {
Q_UNUSED(e); Q_UNUSED(e);
return;//Leave this method immediately!!! return; // Leave this method immediately!!!
} }
//Leave this method immediately after call!!! // Leave this method immediately after call!!!
} }
} }

File diff suppressed because it is too large Load Diff

View File

@ -29,17 +29,17 @@
#ifndef MAINWINDOW_H #ifndef MAINWINDOW_H
#define MAINWINDOW_H #define MAINWINDOW_H
#include "mainwindowsnogui.h"
#include "core/vcmdexport.h"
#include "../vmisc/vlockguard.h"
#include "../vformat/vdimensions.h" #include "../vformat/vdimensions.h"
#include "../vmisc/vlockguard.h"
#include "core/vcmdexport.h"
#include "mainwindowsnogui.h"
#include <QDoubleSpinBox> #include <QDoubleSpinBox>
#include <QPointer> #include <QPointer>
namespace Ui namespace Ui
{ {
class MainWindow; class MainWindow;
} }
class VToolOptionsPropertyBrowser; class VToolOptionsPropertyBrowser;
@ -66,6 +66,7 @@ class VWidgetBackgroundImages;
class MainWindow : public MainWindowsNoGUI class MainWindow : public MainWindowsNoGUI
{ {
Q_OBJECT // NOLINT Q_OBJECT // NOLINT
public: public:
explicit MainWindow(QWidget *parent = nullptr); explicit MainWindow(QWidget *parent = nullptr);
~MainWindow() override; ~MainWindow() override;
@ -109,12 +110,13 @@ signals:
void EnableNodePointHover(bool enable); void EnableNodePointHover(bool enable);
void EnableDetailHover(bool enable); void EnableDetailHover(bool enable);
void EnableImageBackgroundHover(bool enable); void EnableImageBackgroundHover(bool enable);
protected: protected:
void keyPressEvent(QKeyEvent *event) override; void keyPressEvent(QKeyEvent *event) override;
void showEvent(QShowEvent *event) override; void showEvent(QShowEvent *event) override;
void changeEvent(QEvent* event) override; void changeEvent(QEvent *event) override;
void closeEvent(QCloseEvent *event) override; void closeEvent(QCloseEvent *event) override;
void customEvent(QEvent * event) override; void customEvent(QEvent *event) override;
void CleanLayout() override; void CleanLayout() override;
void PrepareSceneList(PreviewQuatilty quality) override; void PrepareSceneList(PreviewQuatilty quality) override;
void ExportToCSVData(const QString &fileName, bool withHeader, int mib, const QChar &separator) final; void ExportToCSVData(const QString &fileName, bool withHeader, int mib, const QChar &separator) final;
@ -222,7 +224,7 @@ private slots:
void RemoveWatermark(); void RemoveWatermark();
#if defined(Q_OS_MAC) #if defined(Q_OS_MAC)
void OpenAt(QAction *where); void OpenAt(QAction *where);
#endif //defined(Q_OS_MAC) #endif // defined(Q_OS_MAC)
void DimensionABaseChanged(); void DimensionABaseChanged();
void DimensionBBaseChanged(); void DimensionBBaseChanged();
@ -316,7 +318,7 @@ private:
VWidgetBackgroundImages *m_backgroundImagesWidget{nullptr}; VWidgetBackgroundImages *m_backgroundImagesWidget{nullptr};
QSharedPointer<VLockGuard<char>> m_lock{nullptr}; QSharedPointer<VLockGuard<char>> m_lock{nullptr};
QList<QToolButton*> m_toolButtonPointerList{}; QList<QToolButton *> m_toolButtonPointerList{};
QProgressBar *m_progressBar; QProgressBar *m_progressBar;
QLabel *m_statusLabel; QLabel *m_statusLabel;
@ -332,7 +334,7 @@ private:
QTimer *m_gradation; QTimer *m_gradation;
QMap<QUuid, VBackgroundImageItem *> m_backgroundImages{}; QMap<QUuid, VBackgroundImageItem *> m_backgroundImages{};
VBackgroundImageControls* m_backgroudcontrols{nullptr}; VBackgroundImageControls *m_backgroudcontrols{nullptr};
bool m_groupsActive{false}; bool m_groupsActive{false};
bool m_toolOptionsActive{false}; bool m_toolOptionsActive{false};
@ -366,21 +368,14 @@ private:
template <typename Dialog, typename Func, typename Func2> template <typename Dialog, typename Func, typename Func2>
void SetToolButtonWithApply(bool checked, Tool t, const QString &cursor, const QString &toolTip, void SetToolButtonWithApply(bool checked, Tool t, const QString &cursor, const QString &toolTip,
Func closeDialogSlot, Func2 applyDialogSlot); Func closeDialogSlot, Func2 applyDialogSlot);
template <typename DrawTool> template <typename DrawTool> void ClosedDialog(int result);
void ClosedDialog(int result);
template <typename DrawTool> template <typename DrawTool> void ClosedDialogWithApply(int result, VMainGraphicsScene *scene);
void ClosedDialogWithApply(int result, VMainGraphicsScene *scene); template <typename DrawTool> void ApplyDialog(VMainGraphicsScene *scene);
template <typename DrawTool> template <typename DrawTool> void ClosedDrawDialogWithApply(int result);
void ApplyDialog(VMainGraphicsScene *scene); template <typename DrawTool> void ApplyDrawDialog();
template <typename DrawTool> template <typename DrawTool> void ClosedDetailsDialogWithApply(int result);
void ClosedDrawDialogWithApply(int result); template <typename DrawTool> void ApplyDetailsDialog();
template <typename DrawTool>
void ApplyDrawDialog();
template <typename DrawTool>
void ClosedDetailsDialogWithApply(int result);
template <typename DrawTool>
void ApplyDetailsDialog();
auto SavePattern(const QString &fileName, QString &error) -> bool; auto SavePattern(const QString &fileName, QString &error) -> bool;
void AutoSavePattern(); void AutoSavePattern();
@ -404,7 +399,7 @@ private:
void AddDocks(); void AddDocks();
void InitDocksContain(); void InitDocksContain();
auto OpenNewValentina(const QString &fileName = QString())const -> bool; auto OpenNewValentina(const QString &fileName = QString()) const -> bool;
void FileClosedCorrect(); void FileClosedCorrect();
static auto GetUnlokedRestoreFileList() -> QStringList; static auto GetUnlokedRestoreFileList() -> QStringList;
@ -420,8 +415,8 @@ private:
void ReadMeasurements(qreal baseA, qreal baseB, qreal baseC); void ReadMeasurements(qreal baseA, qreal baseB, qreal baseC);
void ReopenFilesAfterCrash(QStringList &args); void ReopenFilesAfterCrash(QStringList &args);
auto DoExport(const VCommandLinePtr& expParams) -> bool; auto DoExport(const VCommandLinePtr &expParams) -> bool;
auto DoFMExport(const VCommandLinePtr& expParams) -> bool; auto DoFMExport(const VCommandLinePtr &expParams) -> bool;
auto SetDimensionA(int value) -> bool; auto SetDimensionA(int value) -> bool;
auto SetDimensionB(int value) -> bool; auto SetDimensionB(int value) -> bool;
@ -454,7 +449,7 @@ private:
void StoreIndividualMDimensions(); void StoreIndividualMDimensions();
void StoreMultisizeMDimension(const QList<MeasurementDimension_p> &dimensions, int index, qreal currentBase); void StoreMultisizeMDimension(const QList<MeasurementDimension_p> &dimensions, int index, qreal currentBase);
void StoreIndividualMDimension(const QMap<QString, QSharedPointer<VMeasurement> > &measurements, IMD type); void StoreIndividualMDimension(const QMap<QString, QSharedPointer<VMeasurement>> &measurements, IMD type);
auto DimensionRestrictedValues(int index, const MeasurementDimension_p &dimension) -> QVector<qreal>; auto DimensionRestrictedValues(int index, const MeasurementDimension_p &dimension) -> QVector<qreal>;
void SetDimensionBases(); void SetDimensionBases();

View File

@ -21,25 +21,25 @@
#include "fvupdater.h" #include "fvupdater.h"
#include <qsystemdetection.h>
#include <qxmlstream.h>
#include <QApplication> #include <QApplication>
#include <QByteArray> #include <QByteArray>
#include <QDate> #include <QDate>
#include <QDesktopServices> #include <QDesktopServices>
#include <QDir>
#include <QGlobalStatic>
#include <QLatin1String> #include <QLatin1String>
#include <QMessageBox> #include <QMessageBox>
#include <QMessageLogger> #include <QMessageLogger>
#include <QMutex> #include <QMutex>
#include <QNetworkReply> #include <QNetworkReply>
#include <QNetworkRequest> #include <QNetworkRequest>
#include <QSslConfiguration>
#include <QStringList> #include <QStringList>
#include <QVariant> #include <QVariant>
#include <QXmlStreamAttributes> #include <QXmlStreamAttributes>
#include <QtDebug> #include <QtDebug>
#include <QSslConfiguration> #include <qsystemdetection.h>
#include <QDir> #include <qxmlstream.h>
#include <QGlobalStatic>
#include "../ifc/exception/vexception.h" #include "../ifc/exception/vexception.h"
#include "../ifc/xml/vabstractconverter.h" #include "../ifc/xml/vabstractconverter.h"
@ -49,13 +49,24 @@
#include "fvavailableupdate.h" #include "fvavailableupdate.h"
#include "fvupdatewindow.h" #include "fvupdatewindow.h"
#if QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
#include "../vmisc/diagnostic.h"
#endif // QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
namespace namespace
{ {
Q_GLOBAL_STATIC_WITH_ARGS(const QString, defaultFeedURL, // NOLINT QT_WARNING_PUSH
QT_WARNING_DISABLE_CLANG("-Wunused-member-function")
// NOLINTNEXTLINE
Q_GLOBAL_STATIC_WITH_ARGS(const QString, defaultFeedURL,
(QLatin1String("https://valentinaproject.bitbucket.io/Appcast.xml"))) (QLatin1String("https://valentinaproject.bitbucket.io/Appcast.xml")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, testFeedURL, // NOLINT // NOLINTNEXTLINE
Q_GLOBAL_STATIC_WITH_ARGS(const QString, testFeedURL,
(QLatin1String("https://valentinaproject.bitbucket.io/Appcast_testing.xml"))) (QLatin1String("https://valentinaproject.bitbucket.io/Appcast_testing.xml")))
}
QT_WARNING_POP
} // namespace
QPointer<FvUpdater> FvUpdater::m_Instance; QPointer<FvUpdater> FvUpdater::m_Instance;
@ -325,7 +336,8 @@ void FvUpdater::startDownloadFeed(const QUrl &url)
m_reply = m_qnam.get(request); m_reply = m_qnam.get(request);
connect(m_reply.data(), &QNetworkReply::readyRead, this, [this]() connect(m_reply.data(), &QNetworkReply::readyRead, this,
[this]()
{ {
// this slot gets called every time the QNetworkReply has new data. // this slot gets called every time the QNetworkReply has new data.
// We read all of its new data and write it into the file. // We read all of its new data and write it into the file.
@ -333,7 +345,8 @@ void FvUpdater::startDownloadFeed(const QUrl &url)
// signal of the QNetworkReply // signal of the QNetworkReply
m_xml.addData(m_reply->readAll()); m_xml.addData(m_reply->readAll());
}); });
connect(m_reply.data(), &QNetworkReply::downloadProgress, this, [this](qint64 bytesRead, qint64 totalBytes) connect(m_reply.data(), &QNetworkReply::downloadProgress, this,
[this](qint64 bytesRead, qint64 totalBytes)
{ {
Q_UNUSED(bytesRead) Q_UNUSED(bytesRead)
Q_UNUSED(totalBytes) Q_UNUSED(totalBytes)
@ -455,18 +468,15 @@ auto FvUpdater::xmlParseFeed() -> bool
// here (because the topmost is the most recent one, and thus // here (because the topmost is the most recent one, and thus
// the newest version. // the newest version.
return searchDownloadedFeedForUpdates(xmlEnclosureUrl, return searchDownloadedFeedForUpdates(xmlEnclosureUrl, xmlEnclosureVersion, xmlEnclosurePlatform);
xmlEnclosureVersion,
xmlEnclosurePlatform);
} }
} }
if (m_xml.error() && m_xml.error() != QXmlStreamReader::PrematureEndOfDocumentError) if (m_xml.error() && m_xml.error() != QXmlStreamReader::PrematureEndOfDocumentError)
{ {
showErrorDialog(tr("Feed parsing failed: %1 %2.").arg(QString::number(m_xml.lineNumber()), showErrorDialog(
m_xml.errorString()), false); tr("Feed parsing failed: %1 %2.").arg(QString::number(m_xml.lineNumber()), m_xml.errorString()), false);
return false; return false;
} }
} }
@ -575,7 +585,7 @@ void FvUpdater::IgnoreVersion(const QString &version)
catch (const VException &e) catch (const VException &e)
{ {
Q_UNUSED(e) Q_UNUSED(e)
return ; // Ignore invalid version return; // Ignore invalid version
} }
if (decVersion == AppVersion()) if (decVersion == AppVersion())

View File

@ -30,35 +30,39 @@
#include <QDomNode> #include <QDomNode>
#include <QDomNodeList> #include <QDomNodeList>
#include <QFuture>
#include <QLatin1String> #include <QLatin1String>
#include <QList> #include <QList>
#include <QMessageLogger> #include <QMessageLogger>
#include <QSet>
#include <QtDebug>
#include <QtConcurrentMap>
#include <QFuture>
#include <QtConcurrentRun>
#include <QMimeDatabase> #include <QMimeDatabase>
#include <QSet>
#include <QtConcurrentMap>
#include <QtConcurrentRun>
#include <QtDebug>
#include "../exception/vexceptionconversionerror.h"
#include "../exception/vexceptionemptyparameter.h" #include "../exception/vexceptionemptyparameter.h"
#include "../exception/vexceptionobjecterror.h" #include "../exception/vexceptionobjecterror.h"
#include "../exception/vexceptionconversionerror.h"
#include "../qmuparser/qmutokenparser.h"
#include "../ifc/exception/vexceptionbadid.h" #include "../ifc/exception/vexceptionbadid.h"
#include "../ifc/ifcdef.h" #include "../ifc/ifcdef.h"
#include "../qmuparser/qmutokenparser.h"
#include "../vmisc/compatibility.h"
#include "../vmisc/vabstractvalapplication.h"
#include "../vpatterndb/vcontainer.h" #include "../vpatterndb/vcontainer.h"
#include "../vpatterndb/vpiecenode.h" #include "../vpatterndb/vpiecenode.h"
#include "../vtools/tools/vdatatool.h" #include "../vtools/tools/vdatatool.h"
#include "def.h" #include "def.h"
#include "vpatternconverter.h"
#include "vdomdocument.h"
#include "vtoolrecord.h"
#include "../vmisc/vabstractvalapplication.h"
#include "../vmisc/compatibility.h"
#include "vpatternimage.h"
#include "vbackgroundpatternimage.h" #include "vbackgroundpatternimage.h"
#include "vdomdocument.h"
#include "vpatternconverter.h"
#include "vpatternimage.h"
#include "vtoolrecord.h"
#include "vvalentinasettings.h" #include "vvalentinasettings.h"
#if QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
#include "../vmisc/diagnostic.h"
#endif // QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
class QDomElement; class QDomElement;
const QString VAbstractPattern::TagPattern = QStringLiteral("pattern"); const QString VAbstractPattern::TagPattern = QStringLiteral("pattern");
@ -94,7 +98,7 @@ const QString VAbstractPattern::TagCompanyName = QStringLiteral("company");
const QString VAbstractPattern::TagPatternLabel = QStringLiteral("patternLabel"); const QString VAbstractPattern::TagPatternLabel = QStringLiteral("patternLabel");
const QString VAbstractPattern::TagWatermark = QStringLiteral("watermark"); const QString VAbstractPattern::TagWatermark = QStringLiteral("watermark");
const QString VAbstractPattern::TagPatternMaterials = QStringLiteral("patternMaterials"); const QString VAbstractPattern::TagPatternMaterials = QStringLiteral("patternMaterials");
const QString VAbstractPattern::TagFinalMeasurements= QStringLiteral("finalMeasurements"); const QString VAbstractPattern::TagFinalMeasurements = QStringLiteral("finalMeasurements");
const QString VAbstractPattern::TagMaterial = QStringLiteral("material"); const QString VAbstractPattern::TagMaterial = QStringLiteral("material");
const QString VAbstractPattern::TagFMeasurement = QStringLiteral("finalMeasurment"); const QString VAbstractPattern::TagFMeasurement = QStringLiteral("finalMeasurment");
const QString VAbstractPattern::TagGrainline = QStringLiteral("grainline"); const QString VAbstractPattern::TagGrainline = QStringLiteral("grainline");
@ -166,15 +170,20 @@ const QString VAbstractPattern::NodePoint = QStringLiteral("NodePoint");
const QString VAbstractPattern::NodeSpline = QStringLiteral("NodeSpline"); const QString VAbstractPattern::NodeSpline = QStringLiteral("NodeSpline");
const QString VAbstractPattern::NodeSplinePath = QStringLiteral("NodeSplinePath"); const QString VAbstractPattern::NodeSplinePath = QStringLiteral("NodeSplinePath");
QHash<quint32, VDataTool*> VAbstractPattern::tools = QHash<quint32, VDataTool*>(); QHash<quint32, VDataTool *> VAbstractPattern::tools = QHash<quint32, VDataTool *>();
QVector<VLabelTemplateLine> VAbstractPattern::patternLabelLines = QVector<VLabelTemplateLine>(); QVector<VLabelTemplateLine> VAbstractPattern::patternLabelLines = QVector<VLabelTemplateLine>();
QMap<int, QString> VAbstractPattern::patternMaterials = QMap<int, QString>(); QMap<int, QString> VAbstractPattern::patternMaterials = QMap<int, QString>();
bool VAbstractPattern::patternLabelWasChanged = false; bool VAbstractPattern::patternLabelWasChanged = false;
namespace namespace
{ {
QT_WARNING_PUSH
QT_WARNING_DISABLE_CLANG("-Wunused-member-function")
Q_GLOBAL_STATIC_WITH_ARGS(const QString, dimensionDefValue, (QLatin1String("-1"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, dimensionDefValue, (QLatin1String("-1"))) // NOLINT
QT_WARNING_POP
void ReadExpressionAttribute(QVector<VFormulaField> &expressions, const QDomElement &element, const QString &attribute) void ReadExpressionAttribute(QVector<VFormulaField> &expressions, const QDomElement &element, const QString &attribute)
{ {
VFormulaField formula; VFormulaField formula;
@ -276,8 +285,7 @@ auto StringToTransfrom(const QString &matrix) -> QTransform
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
template <class T> template <class T> auto NumberToString(T number) -> QString
auto NumberToString(T number) -> QString
{ {
const QLocale locale = QLocale::c(); const QLocale locale = QLocale::c();
return locale.toString(number, 'g', 12).remove(LocaleGroupSeparator(locale)); return locale.toString(number, 'g', 12).remove(LocaleGroupSeparator(locale));
@ -286,18 +294,9 @@ auto NumberToString(T number) -> QString
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto TransformToString(const QTransform &m) -> QString auto TransformToString(const QTransform &m) -> QString
{ {
QStringList matrix QStringList matrix{NumberToString(m.m11()), NumberToString(m.m12()), NumberToString(m.m13()),
{ NumberToString(m.m21()), NumberToString(m.m22()), NumberToString(m.m23()),
NumberToString(m.m11()), NumberToString(m.m31()), NumberToString(m.m32()), NumberToString(m.m33())};
NumberToString(m.m12()),
NumberToString(m.m13()),
NumberToString(m.m21()),
NumberToString(m.m22()),
NumberToString(m.m23()),
NumberToString(m.m31()),
NumberToString(m.m32()),
NumberToString(m.m33())
};
return matrix.join(QChar(';')); return matrix.join(QChar(';'));
} }
} // namespace } // namespace
@ -307,11 +306,12 @@ VAbstractPattern::VAbstractPattern(QObject *parent)
: VDomDocument(parent), : VDomDocument(parent),
nameActivPP(), nameActivPP(),
cursor(0), cursor(0),
toolsOnRemove(QVector<VDataTool*>()), toolsOnRemove(QVector<VDataTool *>()),
history(QVector<VToolRecord>()), history(QVector<VToolRecord>()),
patternPieces(), patternPieces(),
modified(false) modified(false)
{} {
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VAbstractPattern::~VAbstractPattern() VAbstractPattern::~VAbstractPattern()
@ -329,9 +329,9 @@ auto VAbstractPattern::RequiresMeasurements() const -> bool
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VAbstractPattern::ListMeasurements() const -> QStringList auto VAbstractPattern::ListMeasurements() const -> QStringList
{ {
const QFuture<QStringList> futureIncrements = QtConcurrent::run([this](){return ListIncrements();}); const QFuture<QStringList> futureIncrements = QtConcurrent::run([this]() { return ListIncrements(); });
const QList<QString> tokens = ConvertToList(QtConcurrent::blockingMappedReduced(ListExpressions(), GetTokens, const QList<QString> tokens =
GatherTokens)); ConvertToList(QtConcurrent::blockingMappedReduced(ListExpressions(), GetTokens, GatherTokens));
QSet<QString> measurements; QSet<QString> measurements;
QSet<QString> others = ConvertToSet<QString>(futureIncrements.result()); QSet<QString> others = ConvertToSet<QString>(futureIncrements.result());
@ -378,18 +378,18 @@ auto VAbstractPattern::GetActivDrawElement(QDomElement &element) const -> bool
{ {
if (nameActivPP.isEmpty() == false) if (nameActivPP.isEmpty() == false)
{ {
const QDomNodeList elements = this->documentElement().elementsByTagName( TagDraw ); const QDomNodeList elements = this->documentElement().elementsByTagName(TagDraw);
if (elements.size() == 0) if (elements.size() == 0)
{ {
return false; return false;
} }
for ( qint32 i = 0; i < elements.count(); i++ ) for (qint32 i = 0; i < elements.count(); i++)
{ {
element = elements.at( i ).toElement(); element = elements.at(i).toElement();
if (element.isNull() == false) if (element.isNull() == false)
{ {
const QString fieldName = element.attribute( AttrName ); const QString fieldName = element.attribute(AttrName);
if ( fieldName == nameActivPP ) if (fieldName == nameActivPP)
{ {
return true; return true;
} }
@ -404,7 +404,7 @@ auto VAbstractPattern::GetActivDrawElement(QDomElement &element) const -> bool
auto VAbstractPattern::getLocalHistory(const QString &draw) const -> QVector<VToolRecord> auto VAbstractPattern::getLocalHistory(const QString &draw) const -> QVector<VToolRecord>
{ {
QVector<VToolRecord> historyPP; QVector<VToolRecord> historyPP;
for (qint32 i = 0; i< history.size(); ++i) for (qint32 i = 0; i < history.size(); ++i)
{ {
const VToolRecord &tool = history.at(i); const VToolRecord &tool = history.at(i);
if (tool.getNameDraw() == draw) if (tool.getNameDraw() == draw)
@ -424,17 +424,17 @@ auto VAbstractPattern::getLocalHistory(const QString &draw) const -> QVector<VTo
auto VAbstractPattern::CheckExistNamePP(const QString &name) const -> bool auto VAbstractPattern::CheckExistNamePP(const QString &name) const -> bool
{ {
Q_ASSERT_X(not name.isEmpty(), Q_FUNC_INFO, "name draw is empty"); Q_ASSERT_X(not name.isEmpty(), Q_FUNC_INFO, "name draw is empty");
const QDomNodeList elements = this->documentElement().elementsByTagName( TagDraw ); const QDomNodeList elements = this->documentElement().elementsByTagName(TagDraw);
if (elements.size() == 0) if (elements.size() == 0)
{ {
return false; return false;
} }
for ( qint32 i = 0; i < elements.count(); i++ ) for (qint32 i = 0; i < elements.count(); i++)
{ {
const QDomElement elem = elements.at( i ).toElement(); const QDomElement elem = elements.at(i).toElement();
if (elem.isNull() == false) if (elem.isNull() == false)
{ {
if ( GetParametrString(elem, AttrName) == name ) if (GetParametrString(elem, AttrName) == name)
{ {
return true; return true;
} }
@ -461,7 +461,7 @@ auto VAbstractPattern::GetActivNodeElement(const QString &name, QDomElement &ele
{ {
return false; return false;
} }
element = listElement.at( 0 ).toElement(); element = listElement.at(0).toElement();
if (element.isNull() == false) if (element.isNull() == false)
{ {
return true; return true;
@ -494,7 +494,7 @@ void VAbstractPattern::ParseGroups(const QDomElement &domElement)
{ {
VContainer::UpdateId(GetParametrUInt(domElement, AttrId, NULL_ID_STR), valentinaNamespace); VContainer::UpdateId(GetParametrUInt(domElement, AttrId, NULL_ID_STR), valentinaNamespace);
const QPair<bool, QMap<quint32, quint32> > groupData = ParseItemElement(domElement); const QPair<bool, QMap<quint32, quint32>> groupData = ParseItemElement(domElement);
const QMap<quint32, quint32> group = groupData.second; const QMap<quint32, quint32> group = groupData.second;
auto i = group.constBegin(); auto i = group.constBegin();
while (i != group.constEnd()) while (i != group.constEnd())
@ -519,7 +519,7 @@ void VAbstractPattern::ParseGroups(const QDomElement &domElement)
{ {
if (tools.contains(i.value())) if (tools.contains(i.value()))
{ {
VDataTool* tool = tools.value(i.value()); VDataTool *tool = tools.value(i.value());
tool->GroupVisibility(i.key(), itemVisibility.value(i.key(), true)); tool->GroupVisibility(i.key(), itemVisibility.value(i.key(), true));
} }
++i; ++i;
@ -535,7 +535,7 @@ auto VAbstractPattern::CountPP() const -> int
return 0; return 0;
} }
return rootElement.elementsByTagName( TagDraw ).count(); return rootElement.elementsByTagName(TagDraw).count();
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -543,13 +543,13 @@ auto VAbstractPattern::GetPPElement(const QString &name) -> QDomElement
{ {
if (not name.isEmpty()) if (not name.isEmpty())
{ {
const QDomNodeList elements = this->documentElement().elementsByTagName( TagDraw ); const QDomNodeList elements = this->documentElement().elementsByTagName(TagDraw);
if (elements.size() == 0) if (elements.size() == 0)
{ {
return QDomElement(); return QDomElement();
} }
for ( qint32 i = 0; i < elements.count(); i++ ) for (qint32 i = 0; i < elements.count(); i++)
{ {
QDomElement element = elements.at(i).toElement(); QDomElement element = elements.at(i).toElement();
if (not element.isNull()) if (not element.isNull())
@ -578,13 +578,13 @@ auto VAbstractPattern::ChangeNamePP(const QString &oldName, const QString &newNa
if (CheckExistNamePP(oldName) == false) if (CheckExistNamePP(oldName) == false)
{ {
qDebug()<<"Do not exist pattern piece with name"<<oldName; qDebug() << "Do not exist pattern piece with name" << oldName;
return false; return false;
} }
if (CheckExistNamePP(newName)) if (CheckExistNamePP(newName))
{ {
qDebug()<<"Already exist pattern piece with name"<<newName; qDebug() << "Already exist pattern piece with name" << newName;
return false; return false;
} }
@ -596,7 +596,7 @@ auto VAbstractPattern::ChangeNamePP(const QString &oldName, const QString &newNa
nameActivPP = newName; nameActivPP = newName;
} }
ppElement.setAttribute(AttrName, newName); ppElement.setAttribute(AttrName, newName);
emit patternChanged(false);//For situation when we change name directly, without undocommands. emit patternChanged(false); // For situation when we change name directly, without undocommands.
emit ChangedNameDraw(oldName, newName); emit ChangedNameDraw(oldName, newName);
return true; return true;
} }
@ -735,9 +735,8 @@ auto VAbstractPattern::ParsePieceCSARecords(const QDomElement &domElement) -> QV
record.path = GetParametrUInt(element, VAbstractPattern::AttrPath, NULL_ID_STR); record.path = GetParametrUInt(element, VAbstractPattern::AttrPath, NULL_ID_STR);
record.endPoint = GetParametrUInt(element, VAbstractPattern::AttrEnd, NULL_ID_STR); record.endPoint = GetParametrUInt(element, VAbstractPattern::AttrEnd, NULL_ID_STR);
record.reverse = GetParametrBool(element, VAbstractPattern::AttrNodeReverse, falseStr); record.reverse = GetParametrBool(element, VAbstractPattern::AttrNodeReverse, falseStr);
record.includeType = static_cast<PiecePathIncludeType>(GetParametrUInt(element, record.includeType = static_cast<PiecePathIncludeType>(
VAbstractPattern::AttrIncludeAs, GetParametrUInt(element, VAbstractPattern::AttrIncludeAs, QChar('1')));
QChar('1')));
records.append(record); records.append(record);
} }
} }
@ -822,20 +821,13 @@ auto VAbstractPattern::ParseSANode(const QDomElement &domElement) -> VPieceNode
VDomDocument::GetParametrBool(domElement, VAbstractPattern::AttrManualPassmarkAngle, falseStr); VDomDocument::GetParametrBool(domElement, VAbstractPattern::AttrManualPassmarkAngle, falseStr);
const QString passmarkAngle = VDomDocument::GetParametrEmptyString(domElement, VAbstractPattern::AttrPassmarkAngle); const QString passmarkAngle = VDomDocument::GetParametrEmptyString(domElement, VAbstractPattern::AttrPassmarkAngle);
const bool turnPoint = const bool turnPoint = VDomDocument::GetParametrBool(domElement, VAbstractPattern::AttrNodeTurnPoint, trueStr);
VDomDocument::GetParametrBool(domElement, VAbstractPattern::AttrNodeTurnPoint, trueStr);
const QString t = VDomDocument::GetParametrString(domElement, AttrType, VAbstractPattern::NodePoint); const QString t = VDomDocument::GetParametrString(domElement, AttrType, VAbstractPattern::NodePoint);
Tool tool; Tool tool;
const QStringList types const QStringList types{VAbstractPattern::NodePoint, VAbstractPattern::NodeArc, VAbstractPattern::NodeSpline,
{ VAbstractPattern::NodeSplinePath, VAbstractPattern::NodeElArc};
VAbstractPattern::NodePoint,
VAbstractPattern::NodeArc,
VAbstractPattern::NodeSpline,
VAbstractPattern::NodeSplinePath,
VAbstractPattern::NodeElArc
};
switch (types.indexOf(t)) switch (types.indexOf(t))
{ {
@ -932,7 +924,7 @@ void VAbstractPattern::SetMPath(const QString &path)
} }
else else
{ {
qDebug()<<"Can't save path to measurements"<<Q_FUNC_INFO; qDebug() << "Can't save path to measurements" << Q_FUNC_INFO;
} }
} }
@ -958,8 +950,8 @@ auto VAbstractPattern::SiblingNodeId(const quint32 &nodeId) const -> quint32
{ {
for (qint32 j = i; j > 0; --j) for (qint32 j = i; j > 0; --j)
{ {
const VToolRecord tool = history.at(j-1); const VToolRecord tool = history.at(j - 1);
switch ( tool.getTypeTool() ) switch (tool.getTypeTool())
{ {
case Tool::Arrow: case Tool::Arrow:
case Tool::Piece: case Tool::Piece:
@ -981,7 +973,7 @@ auto VAbstractPattern::SiblingNodeId(const quint32 &nodeId) const -> quint32
continue; continue;
default: default:
siblingId = tool.getId(); siblingId = tool.getId();
j = 0;// break loop j = 0; // break loop
break; break;
} }
} }
@ -1051,7 +1043,7 @@ auto VAbstractPattern::GetCompanyName() const -> QString
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VAbstractPattern::SetCompanyName(const QString& qsName) void VAbstractPattern::SetCompanyName(const QString &qsName)
{ {
m_companyName = qsName; m_companyName = qsName;
CheckTagExists(TagCompanyName); CheckTagExists(TagCompanyName);
@ -1068,7 +1060,7 @@ auto VAbstractPattern::GetPatternNumber() const -> QString
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VAbstractPattern::SetPatternNumber(const QString& qsNum) void VAbstractPattern::SetPatternNumber(const QString &qsNum)
{ {
m_patternNumber = qsNum; m_patternNumber = qsNum;
CheckTagExists(TagPatternNum); CheckTagExists(TagPatternNum);
@ -1085,7 +1077,7 @@ auto VAbstractPattern::GetCustomerName() const -> QString
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VAbstractPattern::SetCustomerName(const QString& qsName) void VAbstractPattern::SetCustomerName(const QString &qsName)
{ {
CheckTagExists(TagCustomerName); CheckTagExists(TagCustomerName);
setTagText(TagCustomerName, qsName); setTagText(TagCustomerName, qsName);
@ -1435,7 +1427,7 @@ void VAbstractPattern::SaveBackgroundImages(const QVector<VBackgroundPatternImag
QDomElement imagesElement = CheckTagExists(TagBackgroundImages); QDomElement imagesElement = CheckTagExists(TagBackgroundImages);
RemoveAllChildren(imagesElement); RemoveAllChildren(imagesElement);
for (const auto& image : images) for (const auto &image : images)
{ {
if (not image.Id().isNull()) if (not image.Id().isNull())
{ {
@ -1622,8 +1614,7 @@ auto VAbstractPattern::CheckTagExists(const QString &tag) -> QDomElement
QDomElement element; QDomElement element;
if (list.isEmpty()) if (list.isEmpty())
{ {
const QStringList tags const QStringList tags{
{
TagUnit, // 0 TagUnit, // 0
TagImage, // 1 TagImage, // 1
TagDescription, // 2 TagDescription, // 2
@ -1644,13 +1635,13 @@ auto VAbstractPattern::CheckTagExists(const QString &tag) -> QDomElement
switch (tags.indexOf(tag)) switch (tags.indexOf(tag))
{ {
case 1: //TagImage case 1: // TagImage
element = createElement(TagImage); element = createElement(TagImage);
break; break;
case 2: //TagDescription case 2: // TagDescription
element = createElement(TagDescription); element = createElement(TagDescription);
break; break;
case 3: //TagNotes case 3: // TagNotes
element = createElement(TagNotes); element = createElement(TagNotes);
break; break;
case 4: // TagPatternName case 4: // TagPatternName
@ -1689,7 +1680,7 @@ auto VAbstractPattern::CheckTagExists(const QString &tag) -> QDomElement
case 15: // TagBackgroundImages case 15: // TagBackgroundImages
element = createElement(TagBackgroundImages); element = createElement(TagBackgroundImages);
break; break;
case 0: //TagUnit (Mandatory tag) case 0: // TagUnit (Mandatory tag)
default: default:
return {}; return {};
} }
@ -1703,7 +1694,7 @@ auto VAbstractPattern::CheckTagExists(const QString &tag) -> QDomElement
void VAbstractPattern::InsertTag(const QStringList &tags, const QDomElement &element) void VAbstractPattern::InsertTag(const QStringList &tags, const QDomElement &element)
{ {
QDomElement pattern = documentElement(); QDomElement pattern = documentElement();
for (vsizetype i = tags.indexOf(element.tagName())-1; i >= 0; --i) for (vsizetype i = tags.indexOf(element.tagName()) - 1; i >= 0; --i)
{ {
const QDomNodeList list = elementsByTagName(tags.at(i)); const QDomNodeList list = elementsByTagName(tags.at(i));
if (not list.isEmpty()) if (not list.isEmpty())
@ -1745,7 +1736,7 @@ auto VAbstractPattern::ListIncrements() const -> QStringList
auto GetExpressions = [&increments, this](const QString &type) auto GetExpressions = [&increments, this](const QString &type)
{ {
const QDomNodeList list = elementsByTagName(type); const QDomNodeList list = elementsByTagName(type);
for (int i=0; i < list.size(); ++i) for (int i = 0; i < list.size(); ++i)
{ {
const QString name = GetParametrEmptyString(list.at(i).toElement(), AttrName); const QString name = GetParametrEmptyString(list.at(i).toElement(), AttrName);
if (not name.isEmpty()) if (not name.isEmpty())
@ -1767,15 +1758,16 @@ auto VAbstractPattern::ListExpressions() const -> QVector<VFormulaField>
// If new tool bring absolutely new type and has formula(s) create new method to cover it. // If new tool bring absolutely new type and has formula(s) create new method to cover it.
// Note. Tool Union Details also contains formulas, but we don't use them for union and keep only to simplifying // Note. Tool Union Details also contains formulas, but we don't use them for union and keep only to simplifying
// working with nodes. Same code for saving reading. // working with nodes. Same code for saving reading.
auto futurePointExpressions = QtConcurrent::run([this](){return ListPointExpressions();}); auto futurePointExpressions = QtConcurrent::run([this]() { return ListPointExpressions(); });
auto futureArcExpressions = QtConcurrent::run([this](){return ListArcExpressions();}); auto futureArcExpressions = QtConcurrent::run([this]() { return ListArcExpressions(); });
auto futureElArcExpressions = QtConcurrent::run([this](){return ListElArcExpressions();}); auto futureElArcExpressions = QtConcurrent::run([this]() { return ListElArcExpressions(); });
auto futureSplineExpressions = QtConcurrent::run([this](){return ListSplineExpressions();}); auto futureSplineExpressions = QtConcurrent::run([this]() { return ListSplineExpressions(); });
auto futureIncrementExpressions = QtConcurrent::run([this](){return ListIncrementExpressions();}); auto futureIncrementExpressions = QtConcurrent::run([this]() { return ListIncrementExpressions(); });
auto futureOperationExpressions = QtConcurrent::run([this](){return ListOperationExpressions();}); auto futureOperationExpressions = QtConcurrent::run([this]() { return ListOperationExpressions(); });
auto futurePathExpressions = QtConcurrent::run([this](){return ListPathExpressions();}); auto futurePathExpressions = QtConcurrent::run([this]() { return ListPathExpressions(); });
auto futurePieceExpressions = QtConcurrent::run([this](){return ListPieceExpressions();}); auto futurePieceExpressions = QtConcurrent::run([this]() { return ListPieceExpressions(); });
auto futureFinalMeasurementsExpressions = QtConcurrent::run([this](){return ListFinalMeasurementsExpressions();}); auto futureFinalMeasurementsExpressions =
QtConcurrent::run([this]() { return ListFinalMeasurementsExpressions(); });
QVector<VFormulaField> list; QVector<VFormulaField> list;
list << futurePointExpressions.result(); list << futurePointExpressions.result();
@ -1801,7 +1793,7 @@ auto VAbstractPattern::ListPointExpressions() const -> QVector<VFormulaField>
QVector<VFormulaField> expressions; QVector<VFormulaField> expressions;
const QDomNodeList list = elementsByTagName(TagPoint); const QDomNodeList list = elementsByTagName(TagPoint);
for (int i=0; i < list.size(); ++i) for (int i = 0; i < list.size(); ++i)
{ {
const QDomElement dom = list.at(i).toElement(); const QDomElement dom = list.at(i).toElement();
@ -1829,7 +1821,7 @@ auto VAbstractPattern::ListArcExpressions() const -> QVector<VFormulaField>
QVector<VFormulaField> expressions; QVector<VFormulaField> expressions;
const QDomNodeList list = elementsByTagName(TagArc); const QDomNodeList list = elementsByTagName(TagArc);
for (int i=0; i < list.size(); ++i) for (int i = 0; i < list.size(); ++i)
{ {
const QDomElement dom = list.at(i).toElement(); const QDomElement dom = list.at(i).toElement();
@ -1853,7 +1845,7 @@ auto VAbstractPattern::ListElArcExpressions() const -> QVector<VFormulaField>
QVector<VFormulaField> expressions; QVector<VFormulaField> expressions;
const QDomNodeList list = elementsByTagName(TagElArc); const QDomNodeList list = elementsByTagName(TagElArc);
for (int i=0; i < list.size(); ++i) for (int i = 0; i < list.size(); ++i)
{ {
const QDomElement dom = list.at(i).toElement(); const QDomElement dom = list.at(i).toElement();
@ -1886,7 +1878,7 @@ auto VAbstractPattern::ListPathPointExpressions() const -> QVector<VFormulaField
QVector<VFormulaField> expressions; QVector<VFormulaField> expressions;
const QDomNodeList list = elementsByTagName(AttrPathPoint); const QDomNodeList list = elementsByTagName(AttrPathPoint);
for (int i=0; i < list.size(); ++i) for (int i = 0; i < list.size(); ++i)
{ {
const QDomElement dom = list.at(i).toElement(); const QDomElement dom = list.at(i).toElement();
@ -1904,7 +1896,7 @@ auto VAbstractPattern::ListIncrementExpressions() const -> QVector<VFormulaField
{ {
QVector<VFormulaField> expressions; QVector<VFormulaField> expressions;
const QDomNodeList list = elementsByTagName(TagIncrement); const QDomNodeList list = elementsByTagName(TagIncrement);
for (int i=0; i < list.size(); ++i) for (int i = 0; i < list.size(); ++i)
{ {
const QDomElement dom = list.at(i).toElement(); const QDomElement dom = list.at(i).toElement();
@ -1924,7 +1916,7 @@ auto VAbstractPattern::ListOperationExpressions() const -> QVector<VFormulaField
QVector<VFormulaField> expressions; QVector<VFormulaField> expressions;
const QDomNodeList list = elementsByTagName(TagOperation); const QDomNodeList list = elementsByTagName(TagOperation);
for (int i=0; i < list.size(); ++i) for (int i = 0; i < list.size(); ++i)
{ {
const QDomElement dom = list.at(i).toElement(); const QDomElement dom = list.at(i).toElement();
@ -1970,7 +1962,7 @@ auto VAbstractPattern::ListPathExpressions() const -> QVector<VFormulaField>
QVector<VFormulaField> expressions; QVector<VFormulaField> expressions;
const QDomNodeList list = elementsByTagName(TagPath); const QDomNodeList list = elementsByTagName(TagPath);
for (int i=0; i < list.size(); ++i) for (int i = 0; i < list.size(); ++i)
{ {
const QDomElement dom = list.at(i).toElement(); const QDomElement dom = list.at(i).toElement();
if (dom.isNull()) if (dom.isNull())
@ -2008,7 +2000,7 @@ auto VAbstractPattern::ListPieceExpressions() const -> QVector<VFormulaField>
QVector<VFormulaField> expressions; QVector<VFormulaField> expressions;
const QDomNodeList list = elementsByTagName(TagDetail); const QDomNodeList list = elementsByTagName(TagDetail);
for (int i=0; i < list.size(); ++i) for (int i = 0; i < list.size(); ++i)
{ {
const QDomElement dom = list.at(i).toElement(); const QDomElement dom = list.at(i).toElement();
if (dom.isNull()) if (dom.isNull())
@ -2031,7 +2023,7 @@ auto VAbstractPattern::ListFinalMeasurementsExpressions() const -> QVector<VForm
{ {
QVector<VFormulaField> expressions; QVector<VFormulaField> expressions;
const QDomNodeList list = elementsByTagName(TagFMeasurement); const QDomNodeList list = elementsByTagName(TagFMeasurement);
for (int i=0; i < list.size(); ++i) for (int i = 0; i < list.size(); ++i)
{ {
const QDomElement dom = list.at(i).toElement(); const QDomElement dom = list.at(i).toElement();
if (dom.isNull()) if (dom.isNull())
@ -2051,7 +2043,7 @@ auto VAbstractPattern::IsVariable(const QString &token) const -> bool
{ {
for (const auto &var : builInVariables) for (const auto &var : builInVariables)
{ {
if (token.indexOf( var ) == 0) if (token.indexOf(var) == 0)
{ {
if (var == currentLength || var == currentSeamAllowance) if (var == currentLength || var == currentSeamAllowance)
{ {
@ -2109,7 +2101,7 @@ auto VAbstractPattern::ParseItemElement(const QDomElement &domElement) -> QPair<
} }
} }
QPair<bool, QMap<quint32, quint32> > group; QPair<bool, QMap<quint32, quint32>> group;
group.first = visible; group.first = visible;
group.second = items; group.second = items;
@ -2210,7 +2202,7 @@ void VAbstractPattern::SetFMeasurements(QDomElement &element, const QVector<VFin
SetAttribute(tagFMeasurement, AttrName, m.name); SetAttribute(tagFMeasurement, AttrName, m.name);
SetAttribute(tagFMeasurement, AttrFormula, m.formula); SetAttribute(tagFMeasurement, AttrFormula, m.formula);
SetAttributeOrRemoveIf<QString>(tagFMeasurement, AttrDescription, m.description, SetAttributeOrRemoveIf<QString>(tagFMeasurement, AttrDescription, m.description,
[](const QString &description) noexcept {return description.isEmpty();}); [](const QString &description) noexcept { return description.isEmpty(); });
element.appendChild(tagFMeasurement); element.appendChild(tagFMeasurement);
} }
@ -2241,8 +2233,8 @@ auto VAbstractPattern::GetBackgroundPatternImage(const QDomElement &element) con
image.SetVisible(GetParametrBool(element, AttrVisible, trueStr)); image.SetVisible(GetParametrBool(element, AttrVisible, trueStr));
VValentinaSettings *settings = VAbstractValApplication::VApp()->ValentinaSettings(); VValentinaSettings *settings = VAbstractValApplication::VApp()->ValentinaSettings();
image.SetOpacity(GetParametrDouble(element, AttrOpacity, image.SetOpacity(
QString::number(settings->GetBackgroundImageDefOpacity()/100.))); GetParametrDouble(element, AttrOpacity, QString::number(settings->GetBackgroundImageDefOpacity() / 100.)));
QString matrix = GetParametrEmptyString(element, AttrTransform); QString matrix = GetParametrEmptyString(element, AttrTransform);
image.SetMatrix(StringToTransfrom(matrix)); image.SetMatrix(StringToTransfrom(matrix));
@ -2296,21 +2288,22 @@ void VAbstractPattern::WriteBackgroundImage(QDomElement &element, const VBackgro
else else
{ {
SetAttributeOrRemoveIf<QString>(element, AttrContentType, image.ContentType(), SetAttributeOrRemoveIf<QString>(element, AttrContentType, image.ContentType(),
[](const QString &contentType) noexcept {return contentType.isEmpty();}); [](const QString &contentType) noexcept { return contentType.isEmpty(); });
setTagText(element, image.ContentData()); setTagText(element, image.ContentData());
SetAttributeOrRemoveIf<QString>(element, AttrPath, image.FilePath(), SetAttributeOrRemoveIf<QString>(element, AttrPath, image.FilePath(),
[](const QString &path) noexcept {return path.isEmpty();}); [](const QString &path) noexcept { return path.isEmpty(); });
} }
SetAttributeOrRemoveIf<QString>(element, AttrName, image.Name(), SetAttributeOrRemoveIf<QString>(element, AttrName, image.Name(),
[](const QString &name) noexcept {return name.isEmpty();}); [](const QString &name) noexcept { return name.isEmpty(); });
SetAttribute(element, AttrTransform, TransformToString(image.Matrix())); SetAttribute(element, AttrTransform, TransformToString(image.Matrix()));
SetAttributeOrRemoveIf<bool>(element, AttrHold, image.Hold(), [](bool hold) noexcept {return not hold;}); SetAttributeOrRemoveIf<bool>(element, AttrHold, image.Hold(), [](bool hold) noexcept { return not hold; });
SetAttributeOrRemoveIf<qreal>(element, AttrZValue, image.ZValue(), [](qreal z) noexcept {return qFuzzyIsNull(z);}); SetAttributeOrRemoveIf<qreal>(element, AttrZValue, image.ZValue(),
SetAttributeOrRemoveIf<bool>(element, AttrVisible, image.Visible(), [](bool visible) noexcept {return visible;}); [](qreal z) noexcept { return qFuzzyIsNull(z); });
SetAttributeOrRemoveIf<bool>(element, AttrVisible, image.Visible(), [](bool visible) noexcept { return visible; });
SetAttributeOrRemoveIf<qreal>(element, AttrOpacity, image.Opacity(), SetAttributeOrRemoveIf<qreal>(element, AttrOpacity, image.Opacity(),
[](qreal o) noexcept {return VFuzzyComparePossibleNulls(o, 1);}); [](qreal o) noexcept { return VFuzzyComparePossibleNulls(o, 1); });
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -2333,7 +2326,7 @@ void VAbstractPattern::SetModified(bool modified)
auto VAbstractPattern::GetDraw(const QString &name) const -> QDomElement auto VAbstractPattern::GetDraw(const QString &name) const -> QDomElement
{ {
const QDomNodeList draws = documentElement().elementsByTagName(TagDraw); const QDomNodeList draws = documentElement().elementsByTagName(TagDraw);
for (int i=0; i < draws.size(); ++i) for (int i = 0; i < draws.size(); ++i)
{ {
QDomElement draw = draws.at(i).toElement(); QDomElement draw = draws.at(i).toElement();
if (draw.isNull()) if (draw.isNull())
@ -2396,17 +2389,17 @@ auto VAbstractPattern::CreateGroup(quint32 id, const QString &name, const QStrin
SetAttribute(group, AttrId, id); SetAttribute(group, AttrId, id);
SetAttribute(group, AttrName, name); SetAttribute(group, AttrName, name);
SetAttribute(group, AttrVisible, true); SetAttribute(group, AttrVisible, true);
SetAttributeOrRemoveIf<vidtype>(group, AttrTool, tool, [](vidtype tool) noexcept { return tool == null_id;}); SetAttributeOrRemoveIf<vidtype>(group, AttrTool, tool, [](vidtype tool) noexcept { return tool == null_id; });
SetAttributeOrRemoveIf<QString>(group, AttrTags, preparedTags, SetAttributeOrRemoveIf<QString>(group, AttrTags, preparedTags,
[](const QString &preparedTags) noexcept {return preparedTags.isEmpty();}); [](const QString &preparedTags) noexcept { return preparedTags.isEmpty(); });
auto i = groupData.constBegin(); auto i = groupData.constBegin();
while (i != groupData.constEnd()) while (i != groupData.constEnd())
{ {
QDomElement item = createElement(TagGroupItem); QDomElement item = createElement(TagGroupItem);
item.setAttribute(AttrTool, i.value()); item.setAttribute(AttrTool, i.value());
SetAttributeOrRemoveIf<vidtype>(item, AttrObject, i.key(), [i](vidtype object) noexcept SetAttributeOrRemoveIf<vidtype>(item, AttrObject, i.key(),
{return object == i.value();}); [i](vidtype object) noexcept { return object == i.value(); });
group.appendChild(item); group.appendChild(item);
++i; ++i;
} }
@ -2417,7 +2410,7 @@ auto VAbstractPattern::CreateGroup(quint32 id, const QString &name, const QStrin
auto VAbstractPattern::GroupLinkedToTool(vidtype toolId) const -> vidtype auto VAbstractPattern::GroupLinkedToTool(vidtype toolId) const -> vidtype
{ {
const QDomNodeList groups = elementsByTagName(TagGroup); const QDomNodeList groups = elementsByTagName(TagGroup);
for (int i=0; i < groups.size(); ++i) for (int i = 0; i < groups.size(); ++i)
{ {
const QDomElement group = groups.at(i).toElement(); const QDomElement group = groups.at(i).toElement();
if (not group.isNull() && group.hasAttribute(AttrTool)) if (not group.isNull() && group.hasAttribute(AttrTool))
@ -2442,7 +2435,6 @@ auto VAbstractPattern::GetGroupName(quint32 id) -> QString
if (group.isElement()) if (group.isElement())
{ {
name = GetParametrString(group, AttrName, name); name = GetParametrString(group, AttrName, name);
} }
return name; return name;
@ -2480,7 +2472,7 @@ void VAbstractPattern::SetGroupTags(quint32 id, const QStringList &tags)
if (group.isElement()) if (group.isElement())
{ {
SetAttributeOrRemoveIf<QString>(group, AttrTags, tags.join(','), SetAttributeOrRemoveIf<QString>(group, AttrTags, tags.join(','),
[](const QString &rawTags) noexcept {return rawTags.isEmpty();}); [](const QString &rawTags) noexcept { return rawTags.isEmpty(); });
modified = true; modified = true;
emit patternChanged(false); emit patternChanged(false);
} }
@ -2495,7 +2487,7 @@ auto VAbstractPattern::GetDimensionAValue() -> double
return GetParametrDouble(domElement, AttrDimensionA, *dimensionDefValue); return GetParametrDouble(domElement, AttrDimensionA, *dimensionDefValue);
} }
qDebug()<<"Can't save dimension A of measurements"<<Q_FUNC_INFO; qDebug() << "Can't save dimension A of measurements" << Q_FUNC_INFO;
return -1; return -1;
} }
@ -2511,7 +2503,7 @@ void VAbstractPattern::SetDimensionAValue(double value)
} }
else else
{ {
qDebug()<<"Can't save dimension A of measurements"<<Q_FUNC_INFO; qDebug() << "Can't save dimension A of measurements" << Q_FUNC_INFO;
} }
} }
@ -2524,7 +2516,7 @@ auto VAbstractPattern::GetDimensionBValue() -> double
return GetParametrDouble(domElement, AttrDimensionB, *dimensionDefValue); return GetParametrDouble(domElement, AttrDimensionB, *dimensionDefValue);
} }
qDebug()<<"Can't save dimension B of measurements"<<Q_FUNC_INFO; qDebug() << "Can't save dimension B of measurements" << Q_FUNC_INFO;
return -1; return -1;
} }
@ -2540,7 +2532,7 @@ void VAbstractPattern::SetDimensionBValue(double value)
} }
else else
{ {
qDebug()<<"Can't save dimension B of measurements"<<Q_FUNC_INFO; qDebug() << "Can't save dimension B of measurements" << Q_FUNC_INFO;
} }
} }
@ -2553,7 +2545,7 @@ auto VAbstractPattern::GetDimensionCValue() -> double
return GetParametrDouble(domElement, AttrDimensionC, *dimensionDefValue); return GetParametrDouble(domElement, AttrDimensionC, *dimensionDefValue);
} }
qDebug()<<"Can't save dimension C of measurements"<<Q_FUNC_INFO; qDebug() << "Can't save dimension C of measurements" << Q_FUNC_INFO;
return -1; return -1;
} }
@ -2569,7 +2561,7 @@ void VAbstractPattern::SetDimensionCValue(double value)
} }
else else
{ {
qDebug()<<"Can't save dimension C of measurements"<<Q_FUNC_INFO; qDebug() << "Can't save dimension C of measurements" << Q_FUNC_INFO;
} }
} }
@ -2579,7 +2571,7 @@ auto VAbstractPattern::GetGroupCategories() const -> QStringList
QSet<QString> categories; QSet<QString> categories;
const QDomNodeList groups = elementsByTagName(TagGroup); const QDomNodeList groups = elementsByTagName(TagGroup);
for (int i=0; i < groups.size(); ++i) for (int i = 0; i < groups.size(); ++i)
{ {
const QDomElement group = groups.at(i).toElement(); const QDomElement group = groups.at(i).toElement();
if (not group.isNull() && group.hasAttribute(AttrTags)) if (not group.isNull() && group.hasAttribute(AttrTags))
@ -2615,9 +2607,8 @@ auto VAbstractPattern::GetGroups(const QString &patternPieceName) -> QMap<quint3
VGroupData groupData; VGroupData groupData;
const quint32 id = GetParametrUInt(group, AttrId, QChar('0')); const quint32 id = GetParametrUInt(group, AttrId, QChar('0'));
groupData.visible = GetParametrBool(group, AttrVisible, trueStr); groupData.visible = GetParametrBool(group, AttrVisible, trueStr);
groupData.name = groupData.name = GetParametrString(
GetParametrString(group, AttrName, group, AttrName, QCoreApplication::translate("VAbstractPattern", "New group"));
QCoreApplication::translate("VAbstractPattern", "New group"));
groupData.tags = FilterGroupTags(GetParametrEmptyString(group, AttrTags)); groupData.tags = FilterGroupTags(GetParametrEmptyString(group, AttrTags));
groupData.tool = GetParametrUInt(group, AttrTool, NULL_ID_STR); groupData.tool = GetParametrUInt(group, AttrTool, NULL_ID_STR);
@ -2672,7 +2663,7 @@ auto VAbstractPattern::GetGroupsContainingItem(quint32 toolId, quint32 objectId,
{ {
QMap<quint32, QString> data; QMap<quint32, QString> data;
if(objectId == 0) if (objectId == 0)
{ {
objectId = toolId; objectId = toolId;
} }
@ -2693,7 +2684,7 @@ auto VAbstractPattern::GetGroupsContainingItem(quint32 toolId, quint32 objectId,
if (group.tagName() == TagGroup) if (group.tagName() == TagGroup)
{ {
bool groupHasItem = GroupHasItem(group, toolId, objectId); bool groupHasItem = GroupHasItem(group, toolId, objectId);
if((containItem && groupHasItem) || (not containItem && not groupHasItem)) if ((containItem && groupHasItem) || (not containItem && not groupHasItem))
{ {
const quint32 groupId = GetParametrUInt(group, AttrId, QChar('0')); const quint32 groupId = GetParametrUInt(group, AttrId, QChar('0'));
const QString name = GetParametrString( const QString name = GetParametrString(
@ -2736,7 +2727,7 @@ auto VAbstractPattern::GroupHasItem(const QDomElement &groupDomElement, quint32
quint32 toolIdIterate = GetParametrUInt(item, AttrTool, QChar('0')); quint32 toolIdIterate = GetParametrUInt(item, AttrTool, QChar('0'));
quint32 objectIdIterate = GetParametrUInt(item, AttrObject, QString::number(toolIdIterate)); quint32 objectIdIterate = GetParametrUInt(item, AttrObject, QString::number(toolIdIterate));
if(toolIdIterate == toolId && objectIdIterate == objectId) if (toolIdIterate == toolId && objectIdIterate == objectId)
{ {
result = true; result = true;
break; break;
@ -2835,15 +2826,15 @@ auto VAbstractPattern::AddItemToGroup(quint32 toolId, quint32 objectId, quint32
if (not group.isNull()) if (not group.isNull())
{ {
if(objectId == 0) if (objectId == 0)
{ {
objectId = toolId; objectId = toolId;
} }
QDomElement item = createElement(TagGroupItem); QDomElement item = createElement(TagGroupItem);
item.setAttribute(AttrTool, toolId); item.setAttribute(AttrTool, toolId);
SetAttributeOrRemoveIf<vidtype>(item, AttrObject, objectId, [toolId](vidtype object) noexcept SetAttributeOrRemoveIf<vidtype>(item, AttrObject, objectId,
{return object == toolId;}); [toolId](vidtype object) noexcept { return object == toolId; });
group.appendChild(item); group.appendChild(item);
// to signalised that the pattern was changed and need to be saved // to signalised that the pattern was changed and need to be saved
@ -2881,7 +2872,7 @@ auto VAbstractPattern::RemoveItemFromGroup(quint32 toolId, quint32 objectId, qui
if (not group.isNull()) if (not group.isNull())
{ {
if(objectId == 0) if (objectId == 0)
{ {
objectId = toolId; objectId = toolId;
} }
@ -2894,10 +2885,10 @@ auto VAbstractPattern::RemoveItemFromGroup(quint32 toolId, quint32 objectId, qui
const QDomElement item = itemNode.toElement(); const QDomElement item = itemNode.toElement();
if (not item.isNull()) if (not item.isNull())
{ {
quint32 toolIdIterate= GetParametrUInt(item, AttrTool, QChar('0')); quint32 toolIdIterate = GetParametrUInt(item, AttrTool, QChar('0'));
quint32 objectIdIterate= GetParametrUInt(item, AttrObject, QString::number(toolIdIterate)); quint32 objectIdIterate = GetParametrUInt(item, AttrObject, QString::number(toolIdIterate));
if(toolIdIterate == toolId && objectIdIterate == objectId) if (toolIdIterate == toolId && objectIdIterate == objectId)
{ {
group.removeChild(itemNode); group.removeChild(itemNode);

View File

@ -28,15 +28,15 @@
#include "vdomdocument.h" #include "vdomdocument.h"
#include <QSaveFile>
#include <qcompilerdetection.h> #include <qcompilerdetection.h>
#include <qdom.h> #include <qdom.h>
#include <QSaveFile>
#include "../exception/vexception.h"
#include "../exception/vexceptionbadid.h" #include "../exception/vexceptionbadid.h"
#include "../exception/vexceptionconversionerror.h" #include "../exception/vexceptionconversionerror.h"
#include "../exception/vexceptionemptyparameter.h" #include "../exception/vexceptionemptyparameter.h"
#include "../exception/vexceptionwrongid.h" #include "../exception/vexceptionwrongid.h"
#include "../exception/vexception.h"
#include "../ifcdef.h" #include "../ifcdef.h"
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
@ -45,9 +45,12 @@
#endif #endif
#include <QByteArray> #include <QByteArray>
#include <QDir>
#include <QDomNodeList> #include <QDomNodeList>
#include <QDomText> #include <QDomText>
#include <QFile> #include <QFile>
#include <QFileInfo>
#include <QFutureWatcher>
#include <QIODevice> #include <QIODevice>
#include <QMessageLogger> #include <QMessageLogger>
#include <QObject> #include <QObject>
@ -55,14 +58,12 @@
#include <QTemporaryFile> #include <QTemporaryFile>
#include <QTextDocument> #include <QTextDocument>
#include <QTextStream> #include <QTextStream>
#include <QTimer>
#include <QUrl> #include <QUrl>
#include <QVector> #include <QVector>
#include <QtDebug>
#include <QXmlStreamWriter> #include <QXmlStreamWriter>
#include <QTimer>
#include <QtConcurrentRun> #include <QtConcurrentRun>
#include <QFutureWatcher> #include <QtDebug>
#include <QRegularExpression>
namespace namespace
{ {
@ -159,7 +160,7 @@ auto LessThen(const QDomNode &element1, const QDomNode &element2) -> bool
QString tag1 = element1.nodeName(); QString tag1 = element1.nodeName();
QString tag2 = element2.nodeName(); QString tag2 = element2.nodeName();
//qDebug() << tag1 <<tag2; // qDebug() << tag1 <<tag2;
if (tag1 != tag2) if (tag1 != tag2)
{ {
return tag1 < tag2; return tag1 < tag2;
@ -169,7 +170,7 @@ auto LessThen(const QDomNode &element1, const QDomNode &element2) -> bool
QList<QDomNode> attributes1 = GetElementAttributes(element1); QList<QDomNode> attributes1 = GetElementAttributes(element1);
QList<QDomNode> attributes2 = GetElementAttributes(element2); QList<QDomNode> attributes2 = GetElementAttributes(element2);
if(attributes1.size() != attributes2.size()) if (attributes1.size() != attributes2.size())
{ {
return attributes1.size() < attributes2.size(); return attributes1.size() < attributes2.size();
} }
@ -179,22 +180,22 @@ auto LessThen(const QDomNode &element1, const QDomNode &element2) -> bool
*stop = false; *stop = false;
std::sort(list1.begin(), list1.end(), LessThen); std::sort(list1.begin(), list1.end(), LessThen);
std::sort(list2.begin(), list2.end(), LessThen); std::sort(list2.begin(), list2.end(), LessThen);
//qDebug() << "comparing sorted lists"; // qDebug() << "comparing sorted lists";
for(int k = 0; k < list1.size(); ++k) for (int k = 0; k < list1.size(); ++k)
{ {
if (!LessThen(list1[k], list2[k])) if (!LessThen(list1[k], list2[k]))
{ {
if (LessThen(list2[k], list1[k])) if (LessThen(list2[k], list1[k]))
{ {
*stop = true; *stop = true;
//qDebug() << "false!"; // qDebug() << "false!";
return false; return false;
} }
} }
else else
{ {
*stop = true; *stop = true;
//qDebug() << "true!"; // qDebug() << "true!";
return true; return true;
} }
} }
@ -214,17 +215,17 @@ auto LessThen(const QDomNode &element1, const QDomNode &element2) -> bool
QString value1, value2; QString value1, value2;
if(elts1.size() != elts2.size()) if (elts1.size() != elts2.size())
{ {
return elts1.size() < elts2.size(); return elts1.size() < elts2.size();
} }
if(elts1.isEmpty()) if (elts1.isEmpty())
{ {
value1 = element1.nodeValue(); value1 = element1.nodeValue();
value2 = element2.nodeValue(); value2 = element2.nodeValue();
//qDebug() <<value1 << value2 << (value1 < value2); // qDebug() <<value1 << value2 << (value1 < value2);
return value1 < value2; return value1 < value2;
} }
@ -316,7 +317,7 @@ auto VDomDocument::elementById(quint32 id, const QString &tagName, bool updateCa
else else
{ {
const QDomNodeList list = elementsByTagName(tagName); const QDomNodeList list = elementsByTagName(tagName);
for (int i=0; i < list.size(); ++i) for (int i = 0; i < list.size(); ++i)
{ {
const QDomElement domElement = list.at(i).toElement(); const QDomElement domElement = list.at(i).toElement();
if (not domElement.isNull() && domElement.hasAttribute(AttrId)) if (not domElement.isNull() && domElement.hasAttribute(AttrId))
@ -367,7 +368,7 @@ auto VDomDocument::find(QHash<quint32, QDomElement> &cache, const QDomElement &n
} }
} }
for (qint32 i=0; i<node.childNodes().length(); ++i) for (qint32 i = 0; i < node.childNodes().length(); ++i)
{ {
const QDomNode n = node.childNodes().at(i); const QDomNode n = node.childNodes().at(i);
if (n.isElement()) if (n.isElement())
@ -381,7 +382,6 @@ auto VDomDocument::find(QHash<quint32, QDomElement> &cache, const QDomElement &n
return false; return false;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VDomDocument::RefreshCache(const QDomElement &root) const -> QHash<quint32, QDomElement> auto VDomDocument::RefreshCache(const QDomElement &root) const -> QHash<quint32, QDomElement>
{ {
@ -500,7 +500,7 @@ auto VDomDocument::GetParametrBool(const QDomElement &domElement, const QString
{ {
parametr = GetParametrString(domElement, name, defValue); parametr = GetParametrString(domElement, name, defValue);
const QStringList bools {trueStr, falseStr, QChar('1'), QChar('0')}; const QStringList bools{trueStr, falseStr, QChar('1'), QChar('0')};
switch (bools.indexOf(parametr)) switch (bools.indexOf(parametr))
{ {
case 0: // true case 0: // true
@ -511,7 +511,7 @@ auto VDomDocument::GetParametrBool(const QDomElement &domElement, const QString
case 3: // 0 case 3: // 0
val = false; val = false;
break; break;
default:// others default: // others
throw VExceptionConversionError(message, name); throw VExceptionConversionError(message, name);
} }
} }
@ -687,7 +687,7 @@ void VDomDocument::CollectId(const QDomElement &node, QVector<quint32> &vector)
vector.append(id); vector.append(id);
} }
for (qint32 i=0; i<node.childNodes().length(); ++i) for (qint32 i = 0; i < node.childNodes().length(); ++i)
{ {
const QDomNode n = node.childNodes().at(i); const QDomNode n = node.childNodes().at(i);
if (n.isElement()) if (n.isElement())
@ -702,7 +702,7 @@ void VDomDocument::RefreshElementIdCache()
{ {
if (m_watcher->isFinished()) if (m_watcher->isFinished())
{ {
m_watcher->setFuture(QtConcurrent::run([this](){return RefreshCache(documentElement());})); m_watcher->setFuture(QtConcurrent::run([this]() { return RefreshCache(documentElement()); }));
} }
} }
@ -736,8 +736,8 @@ void VDomDocument::setXMLContent(const QString &fileName)
{ {
file.close(); file.close();
VException e(errorMsg); VException e(errorMsg);
e.AddMoreInformation(tr("Parsing error file %3 in line %1 column %2").arg(errorLine).arg(errorColumn) e.AddMoreInformation(
.arg(fileName)); tr("Parsing error file %3 in line %1 column %2").arg(errorLine).arg(errorColumn).arg(fileName));
throw e; throw e;
} }
@ -748,7 +748,7 @@ void VDomDocument::setXMLContent(const QString &fileName)
auto VDomDocument::UnitsHelpString() -> QString auto VDomDocument::UnitsHelpString() -> QString
{ {
QString r; QString r;
for (auto i = static_cast<int>(Unit::Mm), last = static_cast<int>(Unit::LAST_UNIT_DO_NOT_USE); i < last;++i) for (auto i = static_cast<int>(Unit::Mm), last = static_cast<int>(Unit::LAST_UNIT_DO_NOT_USE); i < last; ++i)
{ {
r += UnitsToStr(static_cast<Unit>(i)); r += UnitsToStr(static_cast<Unit>(i));
if (i < last - 1) if (i < last - 1)
@ -772,7 +772,7 @@ auto VDomDocument::SaveDocument(const QString &fileName, QString &error) -> bool
{ {
if (fileName.isEmpty()) if (fileName.isEmpty())
{ {
qDebug()<<"Got empty file name."; qDebug() << "Got empty file name.";
return false; return false;
} }
bool success = false; bool success = false;
@ -787,9 +787,9 @@ auto VDomDocument::SaveDocument(const QString &fileName, QString &error) -> bool
} }
// Left these strings in case we will need them for testing purposes // Left these strings in case we will need them for testing purposes
// QTextStream out(&file); // QTextStream out(&file);
//#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) // #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
// out.setCodec("UTF-8"); // out.setCodec("UTF-8");
//#endif // #endif
// save(out, indent); // save(out, indent);
success = file.commit(); success = file.commit();
@ -886,7 +886,7 @@ auto VDomDocument::GetFormatVersion(const QString &version) -> unsigned
return 0x0; return 0x0;
} }
return (major<<16u)|(minor<<8u)|(patch); return (major << 16u) | (minor << 8u) | (patch);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -895,7 +895,7 @@ auto VDomDocument::setTagText(const QString &tag, const QString &text) -> bool
const QDomNodeList nodeList = this->elementsByTagName(tag); const QDomNodeList nodeList = this->elementsByTagName(tag);
if (nodeList.isEmpty()) if (nodeList.isEmpty())
{ {
qDebug()<<"Can't save tag "<<tag<<Q_FUNC_INFO; qDebug() << "Can't save tag " << tag << Q_FUNC_INFO;
} }
else else
{ {
@ -967,11 +967,11 @@ auto VDomDocument::UniqueTag(const QString &tagName) const -> QDomElement
*/ */
void VDomDocument::RemoveAllChildren(QDomElement &domElement) void VDomDocument::RemoveAllChildren(QDomElement &domElement)
{ {
if ( domElement.hasChildNodes() ) if (domElement.hasChildNodes())
{ {
while ( domElement.childNodes().length() >= 1 ) while (domElement.childNodes().length() >= 1)
{ {
domElement.removeChild( domElement.firstChild() ); domElement.removeChild(domElement.firstChild());
} }
} }
} }
@ -1006,12 +1006,12 @@ auto VDomDocument::SafeCopy(const QString &source, const QString &destination, Q
{ {
bool result = false; bool result = false;
//#ifdef Q_OS_WIN32 // #ifdef Q_OS_WIN32
// qt_ntfs_permission_lookup++; // turn checking on // qt_ntfs_permission_lookup++; // turn checking on
//#endif /*Q_OS_WIN32*/ // #endif /*Q_OS_WIN32*/
QTemporaryFile destFile(destination + QLatin1String(".XXXXXX")); QTemporaryFile destFile(destination + QLatin1String(".XXXXXX"));
destFile.setAutoRemove(false);// Will be renamed to be destination file destFile.setAutoRemove(false); // Will be renamed to be destination file
if (not destFile.open()) if (not destFile.open())
{ {
error = destFile.errorString(); error = destFile.errorString();
@ -1060,9 +1060,9 @@ auto VDomDocument::SafeCopy(const QString &source, const QString &destination, Q
} }
} }
//#ifdef Q_OS_WIN32 // #ifdef Q_OS_WIN32
// qt_ntfs_permission_lookup--; // turn off check permission again // qt_ntfs_permission_lookup--; // turn off check permission again
//#endif /*Q_OS_WIN32*/ // #endif /*Q_OS_WIN32*/
return result; return result;
} }

View File

@ -31,6 +31,10 @@
#include "../vlayout/vlayoutpoint.h" #include "../vlayout/vlayoutpoint.h"
#include "compatibility.h" #include "compatibility.h"
#if QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
#include "../vmisc/diagnostic.h"
#endif // QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
/* /*
* Version rules: * Version rules:
* 1. Version have three parts "major.minor.patch"; * 1. Version have three parts "major.minor.patch";
@ -43,11 +47,14 @@ const QString VLayoutConverter::LayoutMinVerStr = QStringLiteral("0.1.0");
const QString VLayoutConverter::LayoutMaxVerStr = QStringLiteral("0.1.5"); const QString VLayoutConverter::LayoutMaxVerStr = QStringLiteral("0.1.5");
const QString VLayoutConverter::CurrentSchema = QStringLiteral("://schema/layout/v0.1.5.xsd"); const QString VLayoutConverter::CurrentSchema = QStringLiteral("://schema/layout/v0.1.5.xsd");
//VLayoutConverter::LayoutMinVer; // <== DON'T FORGET TO UPDATE TOO!!!! // VLayoutConverter::LayoutMinVer; // <== DON'T FORGET TO UPDATE TOO!!!!
//VLayoutConverter::LayoutMaxVer; // <== DON'T FORGET TO UPDATE TOO!!!! // VLayoutConverter::LayoutMaxVer; // <== DON'T FORGET TO UPDATE TOO!!!!
namespace namespace
{ {
QT_WARNING_PUSH
QT_WARNING_DISABLE_CLANG("-Wunused-member-function")
// The list of all string we use for conversion // The list of all string we use for conversion
// Better to use global variables because repeating QStringLiteral blows up code size // Better to use global variables because repeating QStringLiteral blows up code size
Q_GLOBAL_STATIC_WITH_ARGS(const QString, strSeamLineTag, (QLatin1String("seamLine"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, strSeamLineTag, (QLatin1String("seamLine"))) // NOLINT
@ -66,10 +73,12 @@ Q_GLOBAL_STATIC_WITH_ARGS(const QString, strAttrUId, (QLatin1String("uid"))) //
Q_GLOBAL_STATIC_WITH_ARGS(const QString, strAttrAngle, (QLatin1String("angle"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, strAttrAngle, (QLatin1String("angle"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, strAttrArrowDirection, (QLatin1String("arrowDirection"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, strAttrArrowDirection, (QLatin1String("arrowDirection"))) // NOLINT
QT_WARNING_POP
const QChar groupSep = QLatin1Char(';'); const QChar groupSep = QLatin1Char(';');
const QChar coordintatesSep = QLatin1Char(','); const QChar coordintatesSep = QLatin1Char(',');
const QChar pointsSep = QLatin1Char(' '); const QChar pointsSep = QLatin1Char(' ');
//const QChar itemsSep = QLatin1Char('*'); // const QChar itemsSep = QLatin1Char('*');
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto StringV0_1_2ToPoint(const QString &point) -> QPointF auto StringV0_1_2ToPoint(const QString &point) -> QPointF
@ -89,7 +98,7 @@ auto StringV0_1_2ToPath(const QString &path) -> QVector<QPointF>
QVector<QPointF> p; QVector<QPointF> p;
QStringList points = path.split(pointsSep); QStringList points = path.split(pointsSep);
p.reserve(points.size()); p.reserve(points.size());
for (const auto& point : points) for (const auto &point : points)
{ {
p.append(StringV0_1_2ToPoint(point)); p.append(StringV0_1_2ToPoint(point));
} }
@ -204,20 +213,14 @@ auto VLayoutConverter::Schemas() const -> QHash<unsigned int, QString>
void VLayoutConverter::ConvertPiecesToV0_1_3() void VLayoutConverter::ConvertPiecesToV0_1_3()
{ {
// TODO. Delete if minimal supported version is 0.1.3 // TODO. Delete if minimal supported version is 0.1.3
Q_STATIC_ASSERT_X(VLayoutConverter::LayoutMinVer < FormatVersion(0, 1, 3), Q_STATIC_ASSERT_X(VLayoutConverter::LayoutMinVer < FormatVersion(0, 1, 3), "Time to refactor the code.");
"Time to refactor the code.");
const QStringList types const QStringList types{*strSeamLineTag, *strSeamAllowanceTag, *strInternalPathTag};
{
*strSeamLineTag,
*strSeamAllowanceTag,
*strInternalPathTag
};
for (const auto &tagType : types) for (const auto &tagType : types)
{ {
QDomNodeList tags = elementsByTagName(tagType); QDomNodeList tags = elementsByTagName(tagType);
for (int i=0; i < tags.size(); ++i) for (int i = 0; i < tags.size(); ++i)
{ {
QDomElement node = tags.at(i).toElement(); QDomElement node = tags.at(i).toElement();
ConvertPathToV0_1_3(node); ConvertPathToV0_1_3(node);
@ -225,14 +228,14 @@ void VLayoutConverter::ConvertPiecesToV0_1_3()
} }
QDomNodeList tags = elementsByTagName(*strMarkerTag); QDomNodeList tags = elementsByTagName(*strMarkerTag);
for (int i=0; i < tags.size(); ++i) for (int i = 0; i < tags.size(); ++i)
{ {
QDomElement node = tags.at(i).toElement(); QDomElement node = tags.at(i).toElement();
RemoveAllChildren(node); RemoveAllChildren(node);
} }
QDomNodeList pieceTags = elementsByTagName(*strPieceTag); QDomNodeList pieceTags = elementsByTagName(*strPieceTag);
for (int i=0; i < pieceTags.size(); ++i) for (int i = 0; i < pieceTags.size(); ++i)
{ {
QDomElement node = pieceTags.at(i).toElement(); QDomElement node = pieceTags.at(i).toElement();
if (node.isElement() && node.hasAttribute(*strAttrId)) if (node.isElement() && node.hasAttribute(*strAttrId))
@ -374,8 +377,7 @@ void VLayoutConverter::ConvertPiecesToV0_1_5()
void VLayoutConverter::ToV0_1_3() void VLayoutConverter::ToV0_1_3()
{ {
// TODO. Delete if minimal supported version is 0.1.3 // TODO. Delete if minimal supported version is 0.1.3
Q_STATIC_ASSERT_X(VLayoutConverter::LayoutMinVer < FormatVersion(0, 1, 3), Q_STATIC_ASSERT_X(VLayoutConverter::LayoutMinVer < FormatVersion(0, 1, 3), "Time to refactor the code.");
"Time to refactor the code.");
ConvertPiecesToV0_1_3(); ConvertPiecesToV0_1_3();
SetVersion(QStringLiteral("0.1.3")); SetVersion(QStringLiteral("0.1.3"));

View File

@ -34,11 +34,11 @@
#include <QDomText> #include <QDomText>
#include <QFile> #include <QFile>
#include <QFileInfo> #include <QFileInfo>
#include <QGlobalStatic>
#include <QLatin1String> #include <QLatin1String>
#include <QList> #include <QList>
#include <algorithm>
#include <QGlobalStatic>
#include <QUuid> #include <QUuid>
#include <algorithm>
#include "../exception/vexception.h" #include "../exception/vexception.h"
#include "../exception/vexceptionemptyparameter.h" #include "../exception/vexceptionemptyparameter.h"
@ -46,6 +46,10 @@
#include "../qmuparser/qmutokenparser.h" #include "../qmuparser/qmutokenparser.h"
#include "../vmisc/def.h" #include "../vmisc/def.h"
#if QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
#include "../vmisc/diagnostic.h"
#endif // QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
class QDomElement; class QDomElement;
/* /*
@ -60,11 +64,14 @@ const QString VPatternConverter::PatternMinVerStr = QStringLiteral("0.1.4");
const QString VPatternConverter::PatternMaxVerStr = QStringLiteral("0.9.2"); const QString VPatternConverter::PatternMaxVerStr = QStringLiteral("0.9.2");
const QString VPatternConverter::CurrentSchema = QStringLiteral("://schema/pattern/v0.9.2.xsd"); const QString VPatternConverter::CurrentSchema = QStringLiteral("://schema/pattern/v0.9.2.xsd");
//VPatternConverter::PatternMinVer; // <== DON'T FORGET TO UPDATE TOO!!!! // VPatternConverter::PatternMinVer; // <== DON'T FORGET TO UPDATE TOO!!!!
//VPatternConverter::PatternMaxVer; // <== DON'T FORGET TO UPDATE TOO!!!! // VPatternConverter::PatternMaxVer; // <== DON'T FORGET TO UPDATE TOO!!!!
namespace namespace
{ {
QT_WARNING_PUSH
QT_WARNING_DISABLE_CLANG("-Wunused-member-function")
// The list of all string we use for conversion // The list of all string we use for conversion
// Better to use global variables because repeating QStringLiteral blows up code size // Better to use global variables because repeating QStringLiteral blows up code size
Q_GLOBAL_STATIC_WITH_ARGS(const QString, strUnit, (QLatin1String("unit"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, strUnit, (QLatin1String("unit"))) // NOLINT
@ -73,7 +80,7 @@ Q_GLOBAL_STATIC_WITH_ARGS(const QString, strName, (QLatin1String("name"))) // NO
Q_GLOBAL_STATIC_WITH_ARGS(const QString, strBase, (QLatin1String("base"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, strBase, (QLatin1String("base"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, strFormula, (QLatin1String("formula"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, strFormula, (QLatin1String("formula"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, strId, (QLatin1String("id"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, strId, (QLatin1String("id"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, strKGrowth , (QLatin1String("kgrowth"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, strKGrowth, (QLatin1String("kgrowth"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, strKSize, (QLatin1String("ksize"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, strKSize, (QLatin1String("ksize"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, strPoint, (QLatin1String("point"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, strPoint, (QLatin1String("point"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, strLength, (QLatin1String("length"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, strLength, (QLatin1String("length"))) // NOLINT
@ -106,7 +113,8 @@ Q_GLOBAL_STATIC_WITH_ARGS(const QString, strIdTool, (QLatin1String("idTool"))) /
Q_GLOBAL_STATIC_WITH_ARGS(const QString, strIdObject, (QLatin1String("idObject"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, strIdObject, (QLatin1String("idObject"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, strChildren, (QLatin1String("children"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, strChildren, (QLatin1String("children"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, strChild, (QLatin1String("child"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, strChild, (QLatin1String("child"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, strPointOfIntersectionCurves, (QLatin1String("pointOfIntersectionCurves"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, strPointOfIntersectionCurves,
(QLatin1String("pointOfIntersectionCurves"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, strCurveIntersectAxis, (QLatin1String("curveIntersectAxis"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, strCurveIntersectAxis, (QLatin1String("curveIntersectAxis"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, strCurve, (QLatin1String("curve"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, strCurve, (QLatin1String("curve"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, strCurve1, (QLatin1String("curve1"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, strCurve1, (QLatin1String("curve1"))) // NOLINT
@ -114,12 +122,13 @@ Q_GLOBAL_STATIC_WITH_ARGS(const QString, strCurve2, (QLatin1String("curve2"))) /
Q_GLOBAL_STATIC_WITH_ARGS(const QString, strModelingPath, (QLatin1String("modelingPath"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, strModelingPath, (QLatin1String("modelingPath"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, strModelingSpline, (QLatin1String("modelingSpline"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, strModelingSpline, (QLatin1String("modelingSpline"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, strPointFromArcAndTangent, (QLatin1String("pointFromArcAndTangent"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, strPointFromArcAndTangent, (QLatin1String("pointFromArcAndTangent"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, strPointOfIntersectionArcs, (QLatin1String("pointOfIntersectionArcs"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, strPointOfIntersectionArcs,
(QLatin1String("pointOfIntersectionArcs"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, strFirstArc, (QLatin1String("firstArc"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, strFirstArc, (QLatin1String("firstArc"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, strSecondArc, (QLatin1String("secondArc"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, strSecondArc, (QLatin1String("secondArc"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, strDetail, (QLatin1String("detail"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, strDetail, (QLatin1String("detail"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, strSupplement, (QLatin1String("supplement"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, strSupplement, (QLatin1String("supplement"))) // NOLINT
//Q_GLOBAL_STATIC_WITH_ARGS(const QString, strClosed, (QLatin1String("closed"))) // NOLINT // Q_GLOBAL_STATIC_WITH_ARGS(const QString, strClosed, (QLatin1String("closed"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, strWidth, (QLatin1String("width"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, strWidth, (QLatin1String("width"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, strHeight, (QLatin1String("height"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, strHeight, (QLatin1String("height"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, strNode, (QLatin1String("node"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, strNode, (QLatin1String("node"))) // NOLINT
@ -130,11 +139,11 @@ Q_GLOBAL_STATIC_WITH_ARGS(const QString, strGrainline, (QLatin1String("grainline
Q_GLOBAL_STATIC_WITH_ARGS(const QString, strReverse, (QLatin1String("reverse"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, strReverse, (QLatin1String("reverse"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, strMx, (QLatin1String("mx"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, strMx, (QLatin1String("mx"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, strMy, (QLatin1String("my"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, strMy, (QLatin1String("my"))) // NOLINT
//Q_GLOBAL_STATIC_WITH_ARGS(const QString, strForbidFlipping, (QLatin1String("forbidFlipping"))) // NOLINT // Q_GLOBAL_STATIC_WITH_ARGS(const QString, strForbidFlipping, (QLatin1String("forbidFlipping"))) // NOLINT
//Q_GLOBAL_STATIC_WITH_ARGS(const QString, strInLayout, (QLatin1String("inLayout"))) // NOLINT // Q_GLOBAL_STATIC_WITH_ARGS(const QString, strInLayout, (QLatin1String("inLayout"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, strSeamAllowance, (QLatin1String("seamAllowance"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, strSeamAllowance, (QLatin1String("seamAllowance"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, strUUID, (QLatin1String("uuid"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, strUUID, (QLatin1String("uuid"))) // NOLINT
//Q_GLOBAL_STATIC_WITH_ARGS(const QString, strNodeType, (QLatin1String("nodeType"))) // NOLINT // Q_GLOBAL_STATIC_WITH_ARGS(const QString, strNodeType, (QLatin1String("nodeType"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, strDet, (QLatin1String("det"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, strDet, (QLatin1String("det"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, strTypeObject, (QLatin1String("typeObject"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, strTypeObject, (QLatin1String("typeObject"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, strReadOnly, (QLatin1String("readOnly"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, strReadOnly, (QLatin1String("readOnly"))) // NOLINT
@ -159,7 +168,7 @@ Q_GLOBAL_STATIC_WITH_ARGS(const QString, strShowMeasurements, (QLatin1String("sh
Q_GLOBAL_STATIC_WITH_ARGS(const QString, strSize, (QLatin1String("size"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, strSize, (QLatin1String("size"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, strMCP, (QLatin1String("mcp"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, strMCP, (QLatin1String("mcp"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, strLetter, (QLatin1String("letter"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, strLetter, (QLatin1String("letter"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, strMaterial , (QLatin1String("material"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, strMaterial, (QLatin1String("material"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, strUserDefined, (QLatin1String("userDef"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, strUserDefined, (QLatin1String("userDef"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, strPlacement, (QLatin1String("placement"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, strPlacement, (QLatin1String("placement"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, strCutNumber, (QLatin1String("cutNumber"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, strCutNumber, (QLatin1String("cutNumber"))) // NOLINT
@ -170,6 +179,8 @@ Q_GLOBAL_STATIC_WITH_ARGS(const QString, strFirstToCountour, (QLatin1String("fir
Q_GLOBAL_STATIC_WITH_ARGS(const QString, strFirstToContour, (QLatin1String("firstToContour"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, strFirstToContour, (QLatin1String("firstToContour"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, strLastToCountour, (QLatin1String("lastToCountour"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, strLastToCountour, (QLatin1String("lastToCountour"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, strLastToContour, (QLatin1String("lastToContour"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, strLastToContour, (QLatin1String("lastToContour"))) // NOLINT
QT_WARNING_POP
} // anonymous namespace } // anonymous namespace
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -183,8 +194,7 @@ VPatternConverter::VPatternConverter(const QString &fileName)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VPatternConverter::XSDSchemas() -> QHash<unsigned int, QString> auto VPatternConverter::XSDSchemas() -> QHash<unsigned int, QString>
{ {
static const auto schemas = QHash <unsigned, QString> static const auto schemas = QHash<unsigned, QString>{
{
std::make_pair(FormatVersion(0, 1, 4), QStringLiteral("://schema/pattern/v0.1.4.xsd")), std::make_pair(FormatVersion(0, 1, 4), QStringLiteral("://schema/pattern/v0.1.4.xsd")),
std::make_pair(FormatVersion(0, 2, 0), QStringLiteral("://schema/pattern/v0.2.0.xsd")), std::make_pair(FormatVersion(0, 2, 0), QStringLiteral("://schema/pattern/v0.2.0.xsd")),
std::make_pair(FormatVersion(0, 2, 1), QStringLiteral("://schema/pattern/v0.2.1.xsd")), std::make_pair(FormatVersion(0, 2, 1), QStringLiteral("://schema/pattern/v0.2.1.xsd")),
@ -252,8 +262,7 @@ auto VPatternConverter::XSDSchemas() -> QHash<unsigned int, QString>
std::make_pair(FormatVersion(0, 8, 13), QStringLiteral("://schema/pattern/v0.8.13.xsd")), std::make_pair(FormatVersion(0, 8, 13), QStringLiteral("://schema/pattern/v0.8.13.xsd")),
std::make_pair(FormatVersion(0, 9, 0), QStringLiteral("://schema/pattern/v0.9.0.xsd")), std::make_pair(FormatVersion(0, 9, 0), QStringLiteral("://schema/pattern/v0.9.0.xsd")),
std::make_pair(FormatVersion(0, 9, 1), QStringLiteral("://schema/pattern/v0.9.1.xsd")), std::make_pair(FormatVersion(0, 9, 1), QStringLiteral("://schema/pattern/v0.9.1.xsd")),
std::make_pair(FormatVersion(0, 9, 2), CurrentSchema) std::make_pair(FormatVersion(0, 9, 2), CurrentSchema)};
};
return schemas; return schemas;
} }
@ -391,8 +400,7 @@ void VPatternConverter::DowngradeToCurrentMaxVersion()
auto VPatternConverter::IsReadOnly() const -> bool auto VPatternConverter::IsReadOnly() const -> bool
{ {
// Check if attribute readOnly was not changed in file format // Check if attribute readOnly was not changed in file format
Q_STATIC_ASSERT_X(VPatternConverter::PatternMaxVer == FormatVersion(0, 9, 2), Q_STATIC_ASSERT_X(VPatternConverter::PatternMaxVer == FormatVersion(0, 9, 2), "Check attribute readOnly.");
"Check attribute readOnly.");
// Possibly in future attribute readOnly will change position etc. // Possibly in future attribute readOnly will change position etc.
// For now position is the same for all supported format versions. // For now position is the same for all supported format versions.
@ -418,14 +426,13 @@ auto VPatternConverter::Schemas() const -> QHash<unsigned int, QString>
void VPatternConverter::ToV0_2_0() void VPatternConverter::ToV0_2_0()
{ {
// TODO. Delete if minimal supported version is 0.2.0 // TODO. Delete if minimal supported version is 0.2.0
Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 2, 0), Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 2, 0), "Time to refactor the code.");
"Time to refactor the code.");
SetVersion(QStringLiteral("0.2.0")); SetVersion(QStringLiteral("0.2.0"));
TagUnitToV0_2_0(); TagUnitToV0_2_0();
TagIncrementToV0_2_0(); TagIncrementToV0_2_0();
ConvertMeasurementsToV0_2_0(); ConvertMeasurementsToV0_2_0();
TagMeasurementsToV0_2_0();//Alwayse last!!! TagMeasurementsToV0_2_0(); // Alwayse last!!!
Save(); Save();
} }
@ -433,8 +440,7 @@ void VPatternConverter::ToV0_2_0()
void VPatternConverter::ToV0_2_1() void VPatternConverter::ToV0_2_1()
{ {
// TODO. Delete if minimal supported version is 0.2.1 // TODO. Delete if minimal supported version is 0.2.1
Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 2, 1), Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 2, 1), "Time to refactor the code.");
"Time to refactor the code.");
SetVersion(QStringLiteral("0.2.1")); SetVersion(QStringLiteral("0.2.1"));
ConvertMeasurementsToV0_2_1(); ConvertMeasurementsToV0_2_1();
@ -445,8 +451,7 @@ void VPatternConverter::ToV0_2_1()
void VPatternConverter::ToV0_2_4() void VPatternConverter::ToV0_2_4()
{ {
// TODO. Delete if minimal supported version is 0.2.4 // TODO. Delete if minimal supported version is 0.2.4
Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 2, 4), Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 2, 4), "Time to refactor the code.");
"Time to refactor the code.");
FixToolUnionToV0_2_4(); FixToolUnionToV0_2_4();
SetVersion(QStringLiteral("0.2.4")); SetVersion(QStringLiteral("0.2.4"));
@ -457,10 +462,9 @@ void VPatternConverter::ToV0_2_4()
void VPatternConverter::ToV0_3_0() void VPatternConverter::ToV0_3_0()
{ {
// TODO. Delete if minimal supported version is 0.3.0 // TODO. Delete if minimal supported version is 0.3.0
Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 3, 0), Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 3, 0), "Time to refactor the code.");
"Time to refactor the code.");
//Cutting path do not create anymore subpaths // Cutting path do not create anymore subpaths
FixCutPoint(); FixCutPoint();
FixCutPoint(); FixCutPoint();
SetVersion(QStringLiteral("0.3.0")); SetVersion(QStringLiteral("0.3.0"));
@ -471,8 +475,7 @@ void VPatternConverter::ToV0_3_0()
void VPatternConverter::ToV0_3_1() void VPatternConverter::ToV0_3_1()
{ {
// TODO. Delete if minimal supported version is 0.3.1 // TODO. Delete if minimal supported version is 0.3.1
Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 3, 1), Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 3, 1), "Time to refactor the code.");
"Time to refactor the code.");
SetVersion(QStringLiteral("0.3.1")); SetVersion(QStringLiteral("0.3.1"));
RemoveColorToolCutV0_3_1(); RemoveColorToolCutV0_3_1();
@ -483,8 +486,7 @@ void VPatternConverter::ToV0_3_1()
void VPatternConverter::ToV0_4_0() void VPatternConverter::ToV0_4_0()
{ {
// TODO. Delete if minimal supported version is 0.4.0 // TODO. Delete if minimal supported version is 0.4.0
Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 4, 0), Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 4, 0), "Time to refactor the code.");
"Time to refactor the code.");
SetVersion(QStringLiteral("0.4.0")); SetVersion(QStringLiteral("0.4.0"));
TagRemoveAttributeTypeObjectInV0_4_0(); TagRemoveAttributeTypeObjectInV0_4_0();
@ -497,8 +499,7 @@ void VPatternConverter::ToV0_4_0()
void VPatternConverter::ToV0_4_4() void VPatternConverter::ToV0_4_4()
{ {
// TODO. Delete if minimal supported version is 0.4.4 // TODO. Delete if minimal supported version is 0.4.4
Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 4, 4), Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 4, 4), "Time to refactor the code.");
"Time to refactor the code.");
SetVersion(QStringLiteral("0.4.4")); SetVersion(QStringLiteral("0.4.4"));
LabelTagToV0_4_4(*strData); LabelTagToV0_4_4(*strData);
@ -510,8 +511,7 @@ void VPatternConverter::ToV0_4_4()
void VPatternConverter::ToV0_6_0() void VPatternConverter::ToV0_6_0()
{ {
// TODO. Delete if minimal supported version is 0.6.0 // TODO. Delete if minimal supported version is 0.6.0
Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 6, 0), Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 6, 0), "Time to refactor the code.");
"Time to refactor the code.");
SetVersion(QStringLiteral("0.6.0")); SetVersion(QStringLiteral("0.6.0"));
QDomElement label = AddTagPatternLabelV0_5_1(); QDomElement label = AddTagPatternLabelV0_5_1();
PortPatternLabeltoV0_6_0(label); PortPatternLabeltoV0_6_0(label);
@ -524,8 +524,7 @@ void VPatternConverter::ToV0_6_0()
void VPatternConverter::ToV0_6_2() void VPatternConverter::ToV0_6_2()
{ {
// TODO. Delete if minimal supported version is 0.6.2 // TODO. Delete if minimal supported version is 0.6.2
Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 6, 2), Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 6, 2), "Time to refactor the code.");
"Time to refactor the code.");
SetVersion(QStringLiteral("0.6.2")); SetVersion(QStringLiteral("0.6.2"));
AddTagPreviewCalculationsV0_6_2(); AddTagPreviewCalculationsV0_6_2();
Save(); Save();
@ -535,8 +534,7 @@ void VPatternConverter::ToV0_6_2()
void VPatternConverter::ToV0_8_8() void VPatternConverter::ToV0_8_8()
{ {
// TODO. Delete if minimal supported version is 0.8.8 // TODO. Delete if minimal supported version is 0.8.8
Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 8, 8), Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 8, 8), "Time to refactor the code.");
"Time to refactor the code.");
SetVersion(QStringLiteral("0.8.8")); SetVersion(QStringLiteral("0.8.8"));
RemoveGradationV0_8_8(); RemoveGradationV0_8_8();
AddPieceUUIDV0_8_8(); AddPieceUUIDV0_8_8();
@ -547,8 +545,7 @@ void VPatternConverter::ToV0_8_8()
void VPatternConverter::ToV0_9_0() void VPatternConverter::ToV0_9_0()
{ {
// TODO. Delete if minimal supported version is 0.9.0 // TODO. Delete if minimal supported version is 0.9.0
Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 9, 0), Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 9, 0), "Time to refactor the code.");
"Time to refactor the code.");
ConvertImageToV0_9_0(); ConvertImageToV0_9_0();
@ -560,8 +557,7 @@ void VPatternConverter::ToV0_9_0()
void VPatternConverter::ToV0_9_1() void VPatternConverter::ToV0_9_1()
{ {
// TODO. Delete if minimal supported version is 0.9.1 // TODO. Delete if minimal supported version is 0.9.1
Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 9, 1), Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 9, 1), "Time to refactor the code.");
"Time to refactor the code.");
ConvertMeasurementsPathToV0_9_1(); ConvertMeasurementsPathToV0_9_1();
SetVersion(QStringLiteral("0.9.1")); SetVersion(QStringLiteral("0.9.1"));
@ -572,8 +568,7 @@ void VPatternConverter::ToV0_9_1()
void VPatternConverter::ToV0_9_2() void VPatternConverter::ToV0_9_2()
{ {
// TODO. Delete if minimal supported version is 0.9.2 // TODO. Delete if minimal supported version is 0.9.2
Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 9, 2), Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 9, 2), "Time to refactor the code.");
"Time to refactor the code.");
ConvertPathAttributesToV0_9_2(); ConvertPathAttributesToV0_9_2();
SetVersion(QStringLiteral("0.9.2")); SetVersion(QStringLiteral("0.9.2"));
@ -584,8 +579,7 @@ void VPatternConverter::ToV0_9_2()
void VPatternConverter::TagUnitToV0_2_0() void VPatternConverter::TagUnitToV0_2_0()
{ {
// TODO. Delete if minimal supported version is 0.2.0 // TODO. Delete if minimal supported version is 0.2.0
Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 2, 0), Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 2, 0), "Time to refactor the code.");
"Time to refactor the code.");
QDomElement patternElement = documentElement(); QDomElement patternElement = documentElement();
patternElement.insertAfter(CreateElementWithText(*strUnit, MUnitV0_1_4()), patternElement.insertAfter(CreateElementWithText(*strUnit, MUnitV0_1_4()),
@ -596,8 +590,7 @@ void VPatternConverter::TagUnitToV0_2_0()
void VPatternConverter::TagIncrementToV0_2_0() void VPatternConverter::TagIncrementToV0_2_0()
{ {
// TODO. Delete if minimal supported version is 0.2.0 // TODO. Delete if minimal supported version is 0.2.0
Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 2, 0), Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 2, 0), "Time to refactor the code.");
"Time to refactor the code.");
const QSet<QString> names = FixIncrementsToV0_2_0(); const QSet<QString> names = FixIncrementsToV0_2_0();
@ -610,8 +603,7 @@ void VPatternConverter::TagIncrementToV0_2_0()
void VPatternConverter::ConvertMeasurementsToV0_2_0() void VPatternConverter::ConvertMeasurementsToV0_2_0()
{ {
// TODO. Delete if minimal supported version is 0.2.0 // TODO. Delete if minimal supported version is 0.2.0
Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 2, 0), Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 2, 0), "Time to refactor the code.");
"Time to refactor the code.");
const QMap<QString, QString> names = OldNamesToNewNames_InV0_2_0(); const QMap<QString, QString> names = OldNamesToNewNames_InV0_2_0();
ConvertPointExpressionsToV0_2_0(names); ConvertPointExpressionsToV0_2_0(names);
@ -623,8 +615,7 @@ void VPatternConverter::ConvertMeasurementsToV0_2_0()
auto VPatternConverter::FixIncrementsToV0_2_0() -> QSet<QString> auto VPatternConverter::FixIncrementsToV0_2_0() -> QSet<QString>
{ {
// TODO. Delete if minimal supported version is 0.2.0 // TODO. Delete if minimal supported version is 0.2.0
Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 2, 0), Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 2, 0), "Time to refactor the code.");
"Time to refactor the code.");
QSet<QString> names; QSet<QString> names;
const QDomElement incr = TagIncrementsV0_1_4(); const QDomElement incr = TagIncrementsV0_1_4();
@ -642,7 +633,7 @@ auto VPatternConverter::FixIncrementsToV0_2_0() -> QSet<QString>
{ {
const QString name = GetParametrString(domElement, *strName); const QString name = GetParametrString(domElement, *strName);
names.insert(name); names.insert(name);
domElement.setAttribute(*strName, QLatin1String("#")+name); domElement.setAttribute(*strName, QLatin1String("#") + name);
const QString base = GetParametrString(domElement, *strBase); const QString base = GetParametrString(domElement, *strBase);
domElement.setAttribute(*strFormula, base); domElement.setAttribute(*strFormula, base);
@ -669,12 +660,11 @@ auto VPatternConverter::FixIncrementsToV0_2_0() -> QSet<QString>
void VPatternConverter::FixPointExpressionsToV0_2_0(const QSet<QString> &names) void VPatternConverter::FixPointExpressionsToV0_2_0(const QSet<QString> &names)
{ {
// TODO. Delete if minimal supported version is 0.2.0 // TODO. Delete if minimal supported version is 0.2.0
Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 2, 0), Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 2, 0), "Time to refactor the code.");
"Time to refactor the code.");
QString formula; QString formula;
const QDomNodeList list = elementsByTagName(*strPoint); const QDomNodeList list = elementsByTagName(*strPoint);
for (int i=0; i < list.size(); ++i) for (int i = 0; i < list.size(); ++i)
{ {
QDomElement dom = list.at(i).toElement(); QDomElement dom = list.at(i).toElement();
@ -733,12 +723,11 @@ void VPatternConverter::FixPointExpressionsToV0_2_0(const QSet<QString> &names)
void VPatternConverter::FixArcExpressionsToV0_2_0(const QSet<QString> &names) void VPatternConverter::FixArcExpressionsToV0_2_0(const QSet<QString> &names)
{ {
// TODO. Delete if minimal supported version is 0.2.0 // TODO. Delete if minimal supported version is 0.2.0
Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 2, 0), Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 2, 0), "Time to refactor the code.");
"Time to refactor the code.");
QString formula; QString formula;
const QDomNodeList list = elementsByTagName(*strArc); const QDomNodeList list = elementsByTagName(*strArc);
for (int i=0; i < list.size(); ++i) for (int i = 0; i < list.size(); ++i)
{ {
QDomElement dom = list.at(i).toElement(); QDomElement dom = list.at(i).toElement();
@ -788,12 +777,11 @@ void VPatternConverter::FixArcExpressionsToV0_2_0(const QSet<QString> &names)
void VPatternConverter::FixPathPointExpressionsToV0_2_0(const QSet<QString> &names) void VPatternConverter::FixPathPointExpressionsToV0_2_0(const QSet<QString> &names)
{ {
// TODO. Delete if minimal supported version is 0.2.0 // TODO. Delete if minimal supported version is 0.2.0
Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 2, 0), Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 2, 0), "Time to refactor the code.");
"Time to refactor the code.");
QString formula; QString formula;
const QDomNodeList list = elementsByTagName(*strPathPoint); const QDomNodeList list = elementsByTagName(*strPathPoint);
for (int i=0; i < list.size(); ++i) for (int i = 0; i < list.size(); ++i)
{ {
QDomElement dom = list.at(i).toElement(); QDomElement dom = list.at(i).toElement();
@ -833,12 +821,11 @@ void VPatternConverter::FixPathPointExpressionsToV0_2_0(const QSet<QString> &nam
void VPatternConverter::ConvertPointExpressionsToV0_2_0(const QMap<QString, QString> &names) void VPatternConverter::ConvertPointExpressionsToV0_2_0(const QMap<QString, QString> &names)
{ {
// TODO. Delete if minimal supported version is 0.2.0 // TODO. Delete if minimal supported version is 0.2.0
Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 2, 0), Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 2, 0), "Time to refactor the code.");
"Time to refactor the code.");
QString formula; QString formula;
const QDomNodeList list = elementsByTagName(*strPoint); const QDomNodeList list = elementsByTagName(*strPoint);
for (int i=0; i < list.size(); ++i) for (int i = 0; i < list.size(); ++i)
{ {
QDomElement dom = list.at(i).toElement(); QDomElement dom = list.at(i).toElement();
@ -897,12 +884,11 @@ void VPatternConverter::ConvertPointExpressionsToV0_2_0(const QMap<QString, QStr
void VPatternConverter::ConvertArcExpressionsToV0_2_0(const QMap<QString, QString> &names) void VPatternConverter::ConvertArcExpressionsToV0_2_0(const QMap<QString, QString> &names)
{ {
// TODO. Delete if minimal supported version is 0.2.0 // TODO. Delete if minimal supported version is 0.2.0
Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 2, 0), Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 2, 0), "Time to refactor the code.");
"Time to refactor the code.");
QString formula; QString formula;
const QDomNodeList list = elementsByTagName(*strArc); const QDomNodeList list = elementsByTagName(*strArc);
for (int i=0; i < list.size(); ++i) for (int i = 0; i < list.size(); ++i)
{ {
QDomElement dom = list.at(i).toElement(); QDomElement dom = list.at(i).toElement();
@ -952,12 +938,11 @@ void VPatternConverter::ConvertArcExpressionsToV0_2_0(const QMap<QString, QStrin
void VPatternConverter::ConvertPathPointExpressionsToV0_2_0(const QMap<QString, QString> &names) void VPatternConverter::ConvertPathPointExpressionsToV0_2_0(const QMap<QString, QString> &names)
{ {
// TODO. Delete if minimal supported version is 0.2.0 // TODO. Delete if minimal supported version is 0.2.0
Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 2, 0), Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 2, 0), "Time to refactor the code.");
"Time to refactor the code.");
QString formula; QString formula;
const QDomNodeList list = elementsByTagName(*strPathPoint); const QDomNodeList list = elementsByTagName(*strPathPoint);
for (int i=0; i < list.size(); ++i) for (int i = 0; i < list.size(); ++i)
{ {
QDomElement dom = list.at(i).toElement(); QDomElement dom = list.at(i).toElement();
@ -998,17 +983,16 @@ auto VPatternConverter::FixMeasurementInFormulaToV0_2_0(const QString &formula,
-> QString -> QString
{ {
// TODO. Delete if minimal supported version is 0.2.0 // TODO. Delete if minimal supported version is 0.2.0
Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 2, 0), Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 2, 0), "Time to refactor the code.");
"Time to refactor the code.");
QScopedPointer<qmu::QmuTokenParser> cal(new qmu::QmuTokenParser(formula, false, false));// Eval formula QScopedPointer<qmu::QmuTokenParser> cal(new qmu::QmuTokenParser(formula, false, false)); // Eval formula
QMap<vsizetype, QString> tokens = cal->GetTokens();// Tokens (variables, measurements) QMap<vsizetype, QString> tokens = cal->GetTokens(); // Tokens (variables, measurements)
cal.reset(); cal.reset();
QList<vsizetype> tKeys = tokens.keys();// Take all tokens positions QList<vsizetype> tKeys = tokens.keys(); // Take all tokens positions
QList<QString> tValues = tokens.values(); QList<QString> tValues = tokens.values();
QString newFormula = formula;// Local copy for making changes QString newFormula = formula; // Local copy for making changes
for (int i = 0; i < tValues.size(); ++i) for (int i = 0; i < tValues.size(); ++i)
{ {
if (not names.contains(tValues.at(i))) if (not names.contains(tValues.at(i)))
@ -1019,7 +1003,7 @@ auto VPatternConverter::FixMeasurementInFormulaToV0_2_0(const QString &formula,
vsizetype bias = 0; vsizetype bias = 0;
Replace(newFormula, names.value(tValues.at(i)), tKeys.at(i), tValues.at(i), bias); Replace(newFormula, names.value(tValues.at(i)), tKeys.at(i), tValues.at(i), bias);
if (bias != 0) if (bias != 0)
{// Translated token has different length than original. Position next tokens need to be corrected. { // Translated token has different length than original. Position next tokens need to be corrected.
CorrectionsPositions(tKeys.at(i), bias, tokens); CorrectionsPositions(tKeys.at(i), bias, tokens);
tKeys = tokens.keys(); tKeys = tokens.keys();
tValues = tokens.values(); tValues = tokens.values();
@ -1032,17 +1016,16 @@ auto VPatternConverter::FixMeasurementInFormulaToV0_2_0(const QString &formula,
auto VPatternConverter::FixIncrementInFormulaToV0_2_0(const QString &formula, const QSet<QString> &names) -> QString auto VPatternConverter::FixIncrementInFormulaToV0_2_0(const QString &formula, const QSet<QString> &names) -> QString
{ {
// TODO. Delete if minimal supported version is 0.2.0 // TODO. Delete if minimal supported version is 0.2.0
Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 2, 0), Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 2, 0), "Time to refactor the code.");
"Time to refactor the code.");
qmu::QmuTokenParser *cal = new qmu::QmuTokenParser(formula, false, false);// Eval formula qmu::QmuTokenParser *cal = new qmu::QmuTokenParser(formula, false, false); // Eval formula
QMap<vsizetype, QString> tokens = cal->GetTokens();// Tokens (variables, measurements) QMap<vsizetype, QString> tokens = cal->GetTokens(); // Tokens (variables, measurements)
delete cal; delete cal;
QList<vsizetype> tKeys = tokens.keys();// Take all tokens positions QList<vsizetype> tKeys = tokens.keys(); // Take all tokens positions
QList<QString> tValues = tokens.values(); QList<QString> tValues = tokens.values();
QString newFormula = formula;// Local copy for making changes QString newFormula = formula; // Local copy for making changes
for (vsizetype i = 0; i < tValues.size(); ++i) for (vsizetype i = 0; i < tValues.size(); ++i)
{ {
if (not names.contains(tValues.at(i))) if (not names.contains(tValues.at(i)))
@ -1051,9 +1034,9 @@ auto VPatternConverter::FixIncrementInFormulaToV0_2_0(const QString &formula, co
} }
vsizetype bias = 0; vsizetype bias = 0;
Replace(newFormula, "#"+tValues.at(i), tKeys.at(i), tValues.at(i), bias); Replace(newFormula, "#" + tValues.at(i), tKeys.at(i), tValues.at(i), bias);
if (bias != 0) if (bias != 0)
{// Translated token has different length than original. Position next tokens need to be corrected. { // Translated token has different length than original. Position next tokens need to be corrected.
CorrectionsPositions(tKeys.at(i), bias, tokens); CorrectionsPositions(tKeys.at(i), bias, tokens);
tKeys = tokens.keys(); tKeys = tokens.keys();
tValues = tokens.values(); tValues = tokens.values();
@ -1066,8 +1049,7 @@ auto VPatternConverter::FixIncrementInFormulaToV0_2_0(const QString &formula, co
void VPatternConverter::TagMeasurementsToV0_2_0() void VPatternConverter::TagMeasurementsToV0_2_0()
{ {
// TODO. Delete if minimal supported version is 0.2.0 // TODO. Delete if minimal supported version is 0.2.0
Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 2, 0), Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 2, 0), "Time to refactor the code.");
"Time to refactor the code.");
QDomElement ms = TagMeasurementsV0_1_4(); QDomElement ms = TagMeasurementsV0_1_4();
const QString path = GetParametrString(ms, *strPath); const QString path = GetParametrString(ms, *strPath);
@ -1083,8 +1065,7 @@ void VPatternConverter::TagMeasurementsToV0_2_0()
void VPatternConverter::ConvertMeasurementsToV0_2_1() void VPatternConverter::ConvertMeasurementsToV0_2_1()
{ {
// TODO. Delete if minimal supported version is 0.2.1 // TODO. Delete if minimal supported version is 0.2.1
Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 2, 1), Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 2, 1), "Time to refactor the code.");
"Time to refactor the code.");
const QMap<QString, QString> names = OldNamesToNewNames_InV0_2_1(); const QMap<QString, QString> names = OldNamesToNewNames_InV0_2_1();
@ -1098,11 +1079,10 @@ void VPatternConverter::ConvertMeasurementsToV0_2_1()
void VPatternConverter::RemoveColorToolCutV0_3_1() void VPatternConverter::RemoveColorToolCutV0_3_1()
{ {
// TODO. Delete if minimal supported version is 0.3.1 // TODO. Delete if minimal supported version is 0.3.1
Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 3, 1), Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 3, 1), "Time to refactor the code.");
"Time to refactor the code.");
const QDomNodeList list = elementsByTagName(*strPoint); const QDomNodeList list = elementsByTagName(*strPoint);
for (int i=0; i < list.size(); ++i) for (int i = 0; i < list.size(); ++i)
{ {
QDomElement element = list.at(i).toElement(); QDomElement element = list.at(i).toElement();
if (not element.isNull()) if (not element.isNull())
@ -1120,8 +1100,7 @@ void VPatternConverter::RemoveColorToolCutV0_3_1()
auto VPatternConverter::MUnitV0_1_4() const -> QString auto VPatternConverter::MUnitV0_1_4() const -> QString
{ {
// TODO. Delete if minimal supported version is 0.2.0 // TODO. Delete if minimal supported version is 0.2.0
Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 2, 0), Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 2, 0), "Time to refactor the code.");
"Time to refactor the code.");
const QDomElement element = TagMeasurementsV0_1_4(); const QDomElement element = TagMeasurementsV0_1_4();
try try
@ -1140,8 +1119,7 @@ auto VPatternConverter::MUnitV0_1_4() const -> QString
auto VPatternConverter::TagMeasurementsV0_1_4() const -> QDomElement auto VPatternConverter::TagMeasurementsV0_1_4() const -> QDomElement
{ {
// TODO. Delete if minimal supported version is 0.2.0 // TODO. Delete if minimal supported version is 0.2.0
Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 2, 0), Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 2, 0), "Time to refactor the code.");
"Time to refactor the code.");
const QDomNodeList list = elementsByTagName(*strMeasurements); const QDomNodeList list = elementsByTagName(*strMeasurements);
const QDomElement element = list.at(0).toElement(); const QDomElement element = list.at(0).toElement();
@ -1157,8 +1135,7 @@ auto VPatternConverter::TagMeasurementsV0_1_4() const -> QDomElement
auto VPatternConverter::TagIncrementsV0_1_4() const -> QDomElement auto VPatternConverter::TagIncrementsV0_1_4() const -> QDomElement
{ {
// TODO. Delete if minimal supported version is 0.2.0 // TODO. Delete if minimal supported version is 0.2.0
Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 2, 0), Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 2, 0), "Time to refactor the code.");
"Time to refactor the code.");
const QDomNodeList list = elementsByTagName(*strIncrements); const QDomNodeList list = elementsByTagName(*strIncrements);
const QDomElement element = list.at(0).toElement(); const QDomElement element = list.at(0).toElement();
@ -1174,12 +1151,11 @@ auto VPatternConverter::TagIncrementsV0_1_4() const -> QDomElement
void VPatternConverter::FixToolUnionToV0_2_4() void VPatternConverter::FixToolUnionToV0_2_4()
{ {
// TODO. Delete if minimal supported version is 0.2.4 // TODO. Delete if minimal supported version is 0.2.4
Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 2, 4), Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 2, 4), "Time to refactor the code.");
"Time to refactor the code.");
QDomElement root = documentElement(); QDomElement root = documentElement();
const QDomNodeList modelings = root.elementsByTagName(*strModeling); const QDomNodeList modelings = root.elementsByTagName(*strModeling);
for (int i=0; i<modelings.size(); ++i) for (int i = 0; i < modelings.size(); ++i)
{ {
ParseModelingToV0_2_4(modelings.at(i).toElement()); ParseModelingToV0_2_4(modelings.at(i).toElement());
} }
@ -1189,8 +1165,7 @@ void VPatternConverter::FixToolUnionToV0_2_4()
void VPatternConverter::ParseModelingToV0_2_4(const QDomElement &modeling) void VPatternConverter::ParseModelingToV0_2_4(const QDomElement &modeling)
{ {
// TODO. Delete if minimal supported version is 0.2.4 // TODO. Delete if minimal supported version is 0.2.4
Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 2, 4), Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 2, 4), "Time to refactor the code.");
"Time to refactor the code.");
QDomElement node = modeling.firstChild().toElement(); QDomElement node = modeling.firstChild().toElement();
while (not node.isNull()) while (not node.isNull())
@ -1228,8 +1203,7 @@ void VPatternConverter::ParseModelingToV0_2_4(const QDomElement &modeling)
void VPatternConverter::SaveChildrenToolUnionToV0_2_4(quint32 id, const QVector<quint32> &children) void VPatternConverter::SaveChildrenToolUnionToV0_2_4(quint32 id, const QVector<quint32> &children)
{ {
// TODO. Delete if minimal supported version is 0.2.4 // TODO. Delete if minimal supported version is 0.2.4
Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 2, 4), Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 2, 4), "Time to refactor the code.");
"Time to refactor the code.");
QDomElement toolUnion = elementById(id); QDomElement toolUnion = elementById(id);
if (toolUnion.isNull()) if (toolUnion.isNull())
@ -1251,8 +1225,7 @@ void VPatternConverter::SaveChildrenToolUnionToV0_2_4(quint32 id, const QVector<
auto VPatternConverter::OldNamesToNewNames_InV0_2_0() -> QMap<QString, QString> auto VPatternConverter::OldNamesToNewNames_InV0_2_0() -> QMap<QString, QString>
{ {
// TODO. Delete if minimal supported version is 0.2.0 // TODO. Delete if minimal supported version is 0.2.0
Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 2, 0), Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 2, 0), "Time to refactor the code.");
"Time to refactor the code.");
// old name, new name // old name, new name
QMap<QString, QString> names; QMap<QString, QString> names;
@ -1431,8 +1404,7 @@ auto VPatternConverter::OldNamesToNewNames_InV0_2_0() -> QMap<QString, QString>
auto VPatternConverter::OldNamesToNewNames_InV0_2_1() -> QMap<QString, QString> auto VPatternConverter::OldNamesToNewNames_InV0_2_1() -> QMap<QString, QString>
{ {
// TODO. Delete if minimal supported version is 0.2.1 // TODO. Delete if minimal supported version is 0.2.1
Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 2, 1), Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 2, 1), "Time to refactor the code.");
"Time to refactor the code.");
// old name, new name // old name, new name
QMap<QString, QString> names; QMap<QString, QString> names;
@ -1446,34 +1418,32 @@ auto VPatternConverter::OldNamesToNewNames_InV0_2_1() -> QMap<QString, QString>
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPatternConverter::FixCutPoint() void VPatternConverter::FixCutPoint()
{ {
const QStringList types = QStringList() << *strCutSplinePath const QStringList types = QStringList() << *strCutSplinePath << *strCutSpline << *strCutArc;
<< *strCutSpline
<< *strCutArc;
const QDomNodeList list = elementsByTagName(*strPoint); const QDomNodeList list = elementsByTagName(*strPoint);
for (int i=0; i < list.size(); ++i) for (int i = 0; i < list.size(); ++i)
{ {
QDomElement element = list.at(i).toElement(); QDomElement element = list.at(i).toElement();
if (not element.isNull()) if (not element.isNull())
{ {
const QString type = element.attribute(*strType); const QString type = element.attribute(*strType);
switch(types.indexOf(type)) switch (types.indexOf(type))
{ {
case 0: //strCutSplinePath case 0: // strCutSplinePath
{ {
const quint32 id = element.attribute(*strId).toUInt(); const quint32 id = element.attribute(*strId).toUInt();
quint32 curve = element.attribute(*strSplinePath).toUInt(); quint32 curve = element.attribute(*strSplinePath).toUInt();
FixSubPaths(i, id, curve); FixSubPaths(i, id, curve);
break; break;
} }
case 1: //strCutSpline case 1: // strCutSpline
{ {
const quint32 id = element.attribute(*strId).toUInt(); const quint32 id = element.attribute(*strId).toUInt();
quint32 curve = element.attribute(*strSpline).toUInt(); quint32 curve = element.attribute(*strSpline).toUInt();
FixSubPaths(i, id, curve); FixSubPaths(i, id, curve);
break; break;
} }
case 2: //strCutArc case 2: // strCutArc
{ {
const quint32 id = element.attribute(*strId).toUInt(); const quint32 id = element.attribute(*strId).toUInt();
quint32 curve = element.attribute(*strArc).toUInt(); quint32 curve = element.attribute(*strArc).toUInt();
@ -1490,83 +1460,80 @@ void VPatternConverter::FixCutPoint()
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPatternConverter::FixSubPaths(int i, quint32 id, quint32 baseCurve) void VPatternConverter::FixSubPaths(int i, quint32 id, quint32 baseCurve)
{ {
const QStringList pointTypes = QStringList() << *strCutSplinePath const QStringList pointTypes = QStringList() << *strCutSplinePath << *strCutSpline << *strPointOfIntersectionCurves
<< *strCutSpline << *strCurveIntersectAxis << *strPointFromArcAndTangent
<< *strPointOfIntersectionCurves
<< *strCurveIntersectAxis
<< *strPointFromArcAndTangent
<< *strPointOfIntersectionArcs; << *strPointOfIntersectionArcs;
const QDomNodeList listPoints = elementsByTagName(*strPoint); const QDomNodeList listPoints = elementsByTagName(*strPoint);
for (int j = i+1; j < listPoints.size(); ++j) for (int j = i + 1; j < listPoints.size(); ++j)
{ {
QDomElement element = listPoints.at(j).toElement(); QDomElement element = listPoints.at(j).toElement();
if (not element.isNull()) if (not element.isNull())
{ {
const QString type = element.attribute(*strType); const QString type = element.attribute(*strType);
switch(pointTypes.indexOf(type)) switch (pointTypes.indexOf(type))
{ {
case 0: //strCutSplinePath case 0: // strCutSplinePath
{ {
const quint32 spl = element.attribute(*strSplinePath).toUInt(); const quint32 spl = element.attribute(*strSplinePath).toUInt();
if (spl == id+1 || spl == id+2) if (spl == id + 1 || spl == id + 2)
{ {
element.setAttribute(*strSplinePath, baseCurve); element.setAttribute(*strSplinePath, baseCurve);
} }
break; break;
} }
case 1: //strCutSpline case 1: // strCutSpline
{ {
const quint32 spl = element.attribute(*strSpline).toUInt(); const quint32 spl = element.attribute(*strSpline).toUInt();
if (spl == id+1 || spl == id+2) if (spl == id + 1 || spl == id + 2)
{ {
element.setAttribute(*strSpline, baseCurve); element.setAttribute(*strSpline, baseCurve);
} }
break; break;
} }
case 2: //strPointOfIntersectionCurves case 2: // strPointOfIntersectionCurves
{ {
quint32 spl = element.attribute(*strCurve1).toUInt(); quint32 spl = element.attribute(*strCurve1).toUInt();
if (spl == id+1 || spl == id+2) if (spl == id + 1 || spl == id + 2)
{ {
element.setAttribute(*strCurve1, baseCurve); element.setAttribute(*strCurve1, baseCurve);
} }
spl = element.attribute(*strCurve2).toUInt(); spl = element.attribute(*strCurve2).toUInt();
if (spl == id+1 || spl == id+2) if (spl == id + 1 || spl == id + 2)
{ {
element.setAttribute(*strCurve2, baseCurve); element.setAttribute(*strCurve2, baseCurve);
} }
break; break;
} }
case 3: //strCurveIntersectAxis case 3: // strCurveIntersectAxis
{ {
const quint32 spl = element.attribute(*strCurve).toUInt(); const quint32 spl = element.attribute(*strCurve).toUInt();
if (spl == id+1 || spl == id+2) if (spl == id + 1 || spl == id + 2)
{ {
element.setAttribute(*strCurve, baseCurve); element.setAttribute(*strCurve, baseCurve);
} }
break; break;
} }
case 4: //strPointFromArcAndTangent case 4: // strPointFromArcAndTangent
{ {
const quint32 spl = element.attribute(*strArc).toUInt(); const quint32 spl = element.attribute(*strArc).toUInt();
if (spl == id+1 || spl == id+2) if (spl == id + 1 || spl == id + 2)
{ {
element.setAttribute(*strArc, baseCurve); element.setAttribute(*strArc, baseCurve);
} }
break; break;
} }
case 5: //strPointOfIntersectionArcs case 5: // strPointOfIntersectionArcs
{ {
quint32 arc = element.attribute(*strFirstArc).toUInt(); quint32 arc = element.attribute(*strFirstArc).toUInt();
if (arc == id+1 || arc == id+2) if (arc == id + 1 || arc == id + 2)
{ {
element.setAttribute(*strFirstArc, baseCurve); element.setAttribute(*strFirstArc, baseCurve);
} }
arc = element.attribute(*strSecondArc).toUInt(); arc = element.attribute(*strSecondArc).toUInt();
if (arc == id+1 || arc == id+2) if (arc == id + 1 || arc == id + 2)
{ {
element.setAttribute(*strSecondArc, baseCurve); element.setAttribute(*strSecondArc, baseCurve);
} }
@ -1578,8 +1545,7 @@ void VPatternConverter::FixSubPaths(int i, quint32 id, quint32 baseCurve)
} }
} }
const QStringList splTypes = QStringList() << *strModelingPath const QStringList splTypes = QStringList() << *strModelingPath << *strModelingSpline;
<< *strModelingSpline;
const QDomNodeList listSplines = elementsByTagName(*strSpline); const QDomNodeList listSplines = elementsByTagName(*strSpline);
for (int j = 0; j < listSplines.size(); ++j) for (int j = 0; j < listSplines.size(); ++j)
@ -1588,13 +1554,13 @@ void VPatternConverter::FixSubPaths(int i, quint32 id, quint32 baseCurve)
if (not element.isNull()) if (not element.isNull())
{ {
const QString type = element.attribute(*strType); const QString type = element.attribute(*strType);
switch(splTypes.indexOf(type)) switch (splTypes.indexOf(type))
{ {
case 0: //strModelingPath case 0: // strModelingPath
case 1: //strModelingSpline case 1: // strModelingSpline
{ {
const quint32 spl = element.attribute(*strIdObject).toUInt(); const quint32 spl = element.attribute(*strIdObject).toUInt();
if (spl == id+1 || spl == id+2) if (spl == id + 1 || spl == id + 2)
{ {
element.setAttribute(*strIdObject, baseCurve); element.setAttribute(*strIdObject, baseCurve);
} }
@ -1616,7 +1582,7 @@ void VPatternConverter::FixSubPaths(int i, quint32 id, quint32 baseCurve)
if (type == *strModeling) if (type == *strModeling)
{ {
const quint32 arc = element.attribute(*strIdObject).toUInt(); const quint32 arc = element.attribute(*strIdObject).toUInt();
if (arc == id+1 || arc == id+2) if (arc == id + 1 || arc == id + 2)
{ {
element.setAttribute(*strIdObject, baseCurve); element.setAttribute(*strIdObject, baseCurve);
} }
@ -1629,8 +1595,7 @@ void VPatternConverter::FixSubPaths(int i, quint32 id, quint32 baseCurve)
void VPatternConverter::TagRemoveAttributeTypeObjectInV0_4_0() void VPatternConverter::TagRemoveAttributeTypeObjectInV0_4_0()
{ {
// TODO. Delete if minimal supported version is 0.4.0 // TODO. Delete if minimal supported version is 0.4.0
Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 4, 0), Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 4, 0), "Time to refactor the code.");
"Time to refactor the code.");
const QDomNodeList list = elementsByTagName(*strModeling); const QDomNodeList list = elementsByTagName(*strModeling);
for (int i = 0; i < list.size(); ++i) for (int i = 0; i < list.size(); ++i)
@ -1659,11 +1624,10 @@ void VPatternConverter::TagRemoveAttributeTypeObjectInV0_4_0()
void VPatternConverter::TagDetailToV0_4_0() void VPatternConverter::TagDetailToV0_4_0()
{ {
// TODO. Delete if minimal supported version is 0.4.0 // TODO. Delete if minimal supported version is 0.4.0
Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 4, 0), Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 4, 0), "Time to refactor the code.");
"Time to refactor the code.");
const QDomNodeList list = elementsByTagName(*strDetail); const QDomNodeList list = elementsByTagName(*strDetail);
for (int i=0; i < list.size(); ++i) for (int i = 0; i < list.size(); ++i)
{ {
QDomElement dom = list.at(i).toElement(); QDomElement dom = list.at(i).toElement();
@ -1689,7 +1653,7 @@ void VPatternConverter::TagDetailToV0_4_0()
{ {
switch (tags.indexOf(element.tagName())) switch (tags.indexOf(element.tagName()))
{ {
case 0://strNode case 0: // strNode
{ {
QDomElement tagNode = createElement(*strNode); QDomElement tagNode = createElement(*strNode);
@ -1716,13 +1680,13 @@ void VPatternConverter::TagDetailToV0_4_0()
break; break;
} }
case 1://strData case 1: // strData
tagData = element.cloneNode().toElement(); tagData = element.cloneNode().toElement();
break; break;
case 2://strPatternInfo case 2: // strPatternInfo
tagPatternInfo = element.cloneNode().toElement(); tagPatternInfo = element.cloneNode().toElement();
break; break;
case 3://strGrainline case 3: // strGrainline
tagGrainline = element.cloneNode().toElement(); tagGrainline = element.cloneNode().toElement();
break; break;
default: default:
@ -1799,20 +1763,21 @@ auto VPatternConverter::GetUnionChildrenNodesV0_4_0(const QDomElement &detail) -
void VPatternConverter::LabelTagToV0_4_4(const QString &tagName) void VPatternConverter::LabelTagToV0_4_4(const QString &tagName)
{ {
// TODO. Delete if minimal supported version is 0.4.4 // TODO. Delete if minimal supported version is 0.4.4
Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 4, 4), Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 4, 4), "Time to refactor the code.");
"Time to refactor the code.");
Unit unit = Unit::Cm; Unit unit = Unit::Cm;
const QStringList units = QStringList() << "mm" << "cm" << "inch"; const QStringList units = QStringList() << "mm"
<< "cm"
<< "inch";
switch (units.indexOf(UniqueTagText(*strUnit))) switch (units.indexOf(UniqueTagText(*strUnit)))
{ {
case 0:// mm case 0: // mm
unit = Unit::Mm; unit = Unit::Mm;
break; break;
case 1:// cm case 1: // cm
unit = Unit::Cm; unit = Unit::Cm;
break; break;
case 2:// in case 2: // in
unit = Unit::Inch; unit = Unit::Inch;
break; break;
default: default:
@ -1835,7 +1800,7 @@ void VPatternConverter::LabelTagToV0_4_4(const QString &tagName)
}; };
const QDomNodeList list = elementsByTagName(tagName); const QDomNodeList list = elementsByTagName(tagName);
for (int i=0; i < list.size(); ++i) for (int i = 0; i < list.size(); ++i)
{ {
QDomElement dom = list.at(i).toElement(); QDomElement dom = list.at(i).toElement();
@ -1851,27 +1816,18 @@ void VPatternConverter::LabelTagToV0_4_4(const QString &tagName)
auto VPatternConverter::AddTagPatternLabelV0_5_1() -> QDomElement auto VPatternConverter::AddTagPatternLabelV0_5_1() -> QDomElement
{ {
// TODO. Delete if minimal supported version is 0.6.0 // TODO. Delete if minimal supported version is 0.6.0
Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 6, 0), Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 6, 0), "Time to refactor the code.");
"Time to refactor the code.");
const QDomNodeList list = elementsByTagName(*strPatternLabel); const QDomNodeList list = elementsByTagName(*strPatternLabel);
if (list.isEmpty()) if (list.isEmpty())
{ {
const QStringList tags = QStringList() << *strUnit const QStringList tags = QStringList() << *strUnit << *strImage << *strAuthor << *strDescription << *strNotes
<< *strImage << *strGradation << *strPatternName << *strPatternNum << *strCompanyName
<< *strAuthor << *strCustomerName << *strPatternLabel;
<< *strDescription
<< *strNotes
<< *strGradation
<< *strPatternName
<< *strPatternNum
<< *strCompanyName
<< *strCustomerName
<< *strPatternLabel;
QDomElement element = createElement(*strPatternLabel); QDomElement element = createElement(*strPatternLabel);
QDomElement pattern = documentElement(); QDomElement pattern = documentElement();
for (vsizetype i = tags.indexOf(element.tagName())-1; i >= 0; --i) for (vsizetype i = tags.indexOf(element.tagName()) - 1; i >= 0; --i)
{ {
const QDomNodeList list = elementsByTagName(tags.at(i)); const QDomNodeList list = elementsByTagName(tags.at(i));
if (not list.isEmpty()) if (not list.isEmpty())
@ -1889,8 +1845,7 @@ auto VPatternConverter::AddTagPatternLabelV0_5_1() -> QDomElement
void VPatternConverter::PortPatternLabeltoV0_6_0(QDomElement &label) void VPatternConverter::PortPatternLabeltoV0_6_0(QDomElement &label)
{ {
// TODO. Delete if minimal supported version is 0.6.0 // TODO. Delete if minimal supported version is 0.6.0
Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 6, 0), Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 6, 0), "Time to refactor the code.");
"Time to refactor the code.");
if (not UniqueTagText(*strCompanyName).isEmpty()) if (not UniqueTagText(*strCompanyName).isEmpty())
{ {
@ -1942,8 +1897,7 @@ void VPatternConverter::AddLabelTemplateLineV0_6_0(QDomElement &label, const QSt
int alignment, int fontSizeIncrement) int alignment, int fontSizeIncrement)
{ {
// TODO. Delete if minimal supported version is 0.6.0 // TODO. Delete if minimal supported version is 0.6.0
Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 6, 0), Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 6, 0), "Time to refactor the code.");
"Time to refactor the code.");
QDomElement tagLine = createElement(*strLine); QDomElement tagLine = createElement(*strLine);
@ -1960,8 +1914,7 @@ void VPatternConverter::AddLabelTemplateLineV0_6_0(QDomElement &label, const QSt
void VPatternConverter::PortPieceLabelstoV0_6_0() void VPatternConverter::PortPieceLabelstoV0_6_0()
{ {
// TODO. Delete if minimal supported version is 0.6.0 // TODO. Delete if minimal supported version is 0.6.0
Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 6, 0), Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 6, 0), "Time to refactor the code.");
"Time to refactor the code.");
const QDomNodeList nodeList = elementsByTagName(*strData); const QDomNodeList nodeList = elementsByTagName(*strData);
for (int i = 0; i < nodeList.size(); ++i) for (int i = 0; i < nodeList.size(); ++i)
@ -1976,8 +1929,9 @@ void VPatternConverter::PortPieceLabelstoV0_6_0()
AddLabelTemplateLineV0_6_0(dataTag, "%pLetter%", true, false, Qt::AlignHCenter, 6); AddLabelTemplateLineV0_6_0(dataTag, "%pLetter%", true, false, Qt::AlignHCenter, 6);
} }
} }
catch(const VExceptionEmptyParameter &) catch (const VExceptionEmptyParameter &)
{} {
}
AddLabelTemplateLineV0_6_0(dataTag, "%pName%", true, false, Qt::AlignHCenter, 2); AddLabelTemplateLineV0_6_0(dataTag, "%pName%", true, false, Qt::AlignHCenter, 2);
@ -1991,7 +1945,7 @@ void VPatternConverter::PortPieceLabelstoV0_6_0()
QString line; QString line;
const int material = static_cast<int>(GetParametrUInt(domMCP, *strMaterial, QChar('0'))); const int material = static_cast<int>(GetParametrUInt(domMCP, *strMaterial, QChar('0')));
switch(material) switch (material)
{ {
case 0: case 0:
line.append("%mFabric%"); line.append("%mFabric%");
@ -2048,8 +2002,7 @@ void VPatternConverter::PortPieceLabelstoV0_6_0()
void VPatternConverter::RemoveUnusedTagsV0_6_0() void VPatternConverter::RemoveUnusedTagsV0_6_0()
{ {
// TODO. Delete if minimal supported version is 0.6.0 // TODO. Delete if minimal supported version is 0.6.0
Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 6, 0), Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 6, 0), "Time to refactor the code.");
"Time to refactor the code.");
RemoveUniqueTagV0_6_0(*strAuthor); RemoveUniqueTagV0_6_0(*strAuthor);
RemoveUniqueTagV0_6_0(*strSize); RemoveUniqueTagV0_6_0(*strSize);
@ -2072,8 +2025,7 @@ void VPatternConverter::RemoveUnusedTagsV0_6_0()
void VPatternConverter::RemoveUniqueTagV0_6_0(const QString &tag) void VPatternConverter::RemoveUniqueTagV0_6_0(const QString &tag)
{ {
// TODO. Delete if minimal supported version is 0.6.0 // TODO. Delete if minimal supported version is 0.6.0
Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 6, 0), Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 6, 0), "Time to refactor the code.");
"Time to refactor the code.");
const QDomNodeList nodeList = elementsByTagName(tag); const QDomNodeList nodeList = elementsByTagName(tag);
if (nodeList.isEmpty()) if (nodeList.isEmpty())
@ -2089,8 +2041,7 @@ void VPatternConverter::RemoveUniqueTagV0_6_0(const QString &tag)
void VPatternConverter::AddTagPreviewCalculationsV0_6_2() void VPatternConverter::AddTagPreviewCalculationsV0_6_2()
{ {
// TODO. Delete if minimal supported version is 0.6.2 // TODO. Delete if minimal supported version is 0.6.2
Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 6, 2), Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 6, 2), "Time to refactor the code.");
"Time to refactor the code.");
const QDomNodeList list = elementsByTagName(*strIncrements); const QDomNodeList list = elementsByTagName(*strIncrements);
if (not list.isEmpty()) if (not list.isEmpty())
@ -2118,11 +2069,10 @@ void VPatternConverter::RemoveGradationV0_8_8()
void VPatternConverter::AddPieceUUIDV0_8_8() void VPatternConverter::AddPieceUUIDV0_8_8()
{ {
// TODO. Delete if minimal supported version is 0.8.8 // TODO. Delete if minimal supported version is 0.8.8
Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 8, 8), Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 8, 8), "Time to refactor the code.");
"Time to refactor the code.");
const QDomNodeList list = elementsByTagName(*strDetail); const QDomNodeList list = elementsByTagName(*strDetail);
for (int i=0; i < list.size(); ++i) for (int i = 0; i < list.size(); ++i)
{ {
QDomElement dom = list.at(i).toElement(); QDomElement dom = list.at(i).toElement();
@ -2137,8 +2087,7 @@ void VPatternConverter::AddPieceUUIDV0_8_8()
void VPatternConverter::ConvertImageToV0_9_0() void VPatternConverter::ConvertImageToV0_9_0()
{ {
// TODO. Delete if minimal supported version is 0.9.0 // TODO. Delete if minimal supported version is 0.9.0
Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 9, 0), Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 9, 0), "Time to refactor the code.");
"Time to refactor the code.");
const QDomNodeList list = elementsByTagName(*strImage); const QDomNodeList list = elementsByTagName(*strImage);
if (not list.isEmpty()) if (not list.isEmpty())
@ -2151,11 +2100,7 @@ void VPatternConverter::ConvertImageToV0_9_0()
if (not extension.isEmpty()) if (not extension.isEmpty())
{ {
QMap<QString, QString> mimeTypes{ QMap<QString, QString> mimeTypes{{"BMP", "image/bmp"}, {"JPG", "image/jpeg"}, {"PNG", "image/png"}};
{"BMP", "image/bmp"},
{"JPG", "image/jpeg"},
{"PNG", "image/png"}
};
if (mimeTypes.contains(extension)) if (mimeTypes.contains(extension))
{ {
@ -2192,8 +2137,7 @@ void VPatternConverter::ConvertImageToV0_9_0()
void VPatternConverter::ConvertMeasurementsPathToV0_9_1() void VPatternConverter::ConvertMeasurementsPathToV0_9_1()
{ {
// TODO. Delete if minimal supported version is 0.9.1 // TODO. Delete if minimal supported version is 0.9.1
Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 9, 1), Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 9, 1), "Time to refactor the code.");
"Time to refactor the code.");
const QDomNodeList nodeList = this->elementsByTagName(*strMeasurements); const QDomNodeList nodeList = this->elementsByTagName(*strMeasurements);
if (nodeList.isEmpty()) if (nodeList.isEmpty())
@ -2225,11 +2169,10 @@ void VPatternConverter::ConvertMeasurementsPathToV0_9_1()
void VPatternConverter::ConvertPathAttributesToV0_9_2() void VPatternConverter::ConvertPathAttributesToV0_9_2()
{ {
// TODO. Delete if minimal supported version is 0.9.2 // TODO. Delete if minimal supported version is 0.9.2
Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 9, 2), Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 9, 2), "Time to refactor the code.");
"Time to refactor the code.");
const QDomNodeList paths = this->elementsByTagName(*strPath); const QDomNodeList paths = this->elementsByTagName(*strPath);
for (int i=0; i < paths.size(); ++i) for (int i = 0; i < paths.size(); ++i)
{ {
QDomElement domElement = paths.at(i).toElement(); QDomElement domElement = paths.at(i).toElement();
@ -2256,11 +2199,10 @@ void VPatternConverter::ConvertPathAttributesToV0_9_2()
void VPatternConverter::TagUnionDetailsToV0_4_0() void VPatternConverter::TagUnionDetailsToV0_4_0()
{ {
// TODO. Delete if minimal supported version is 0.4.0 // TODO. Delete if minimal supported version is 0.4.0
Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 4, 0), Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 4, 0), "Time to refactor the code.");
"Time to refactor the code.");
const QDomNodeList list = elementsByTagName(*strTools); const QDomNodeList list = elementsByTagName(*strTools);
for (int i=0; i < list.size(); ++i) for (int i = 0; i < list.size(); ++i)
{ {
// Tag 'tools' used only for union details, so no need to check any additional attributes // Tag 'tools' used only for union details, so no need to check any additional attributes
QDomElement toolDOM = list.at(i).toElement(); QDomElement toolDOM = list.at(i).toElement();
@ -2279,10 +2221,10 @@ void VPatternConverter::TagUnionDetailsToV0_4_0()
{ {
switch (tags.indexOf(element.tagName())) switch (tags.indexOf(element.tagName()))
{ {
case 0://strDet case 0: // strDet
nodes.append(GetUnionDetailNodesV0_4_0(element)); nodes.append(GetUnionDetailNodesV0_4_0(element));
break; break;
case 1://strChildren case 1: // strChildren
tagChildrenNodes.appendChild(GetUnionChildrenNodesV0_4_0(element)); tagChildrenNodes.appendChild(GetUnionChildrenNodesV0_4_0(element));
break; break;
default: default:

View File

@ -32,16 +32,18 @@
#include <QDomNodeList> #include <QDomNodeList>
#include <QDomText> #include <QDomText>
#include <QFile> #include <QFile>
#include <QGlobalStatic>
#include <QLatin1String> #include <QLatin1String>
#include <QList> #include <QList>
#include <QMap> #include <QMap>
#include <QMultiMap> #include <QMultiMap>
#include <QGlobalStatic>
#include "../exception/vexception.h"
#include "../vmisc/def.h"
#include "vabstractmconverter.h" #include "vabstractmconverter.h"
#if QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
#include "../vmisc/diagnostic.h"
#endif // QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
/* /*
* Version rules: * Version rules:
* 1. Version have three parts "major.minor.patch"; * 1. Version have three parts "major.minor.patch";
@ -54,11 +56,14 @@ const QString VVITConverter::MeasurementMinVerStr = QStringLiteral("0.2.0");
const QString VVITConverter::MeasurementMaxVerStr = QStringLiteral("0.5.2"); const QString VVITConverter::MeasurementMaxVerStr = QStringLiteral("0.5.2");
const QString VVITConverter::CurrentSchema = QStringLiteral("://schema/individual_measurements/v0.5.2.xsd"); const QString VVITConverter::CurrentSchema = QStringLiteral("://schema/individual_measurements/v0.5.2.xsd");
//VVITConverter::MeasurementMinVer; // <== DON'T FORGET TO UPDATE TOO!!!! // VVITConverter::MeasurementMinVer; // <== DON'T FORGET TO UPDATE TOO!!!!
//VVITConverter::MeasurementMaxVer; // <== DON'T FORGET TO UPDATE TOO!!!! // VVITConverter::MeasurementMaxVer; // <== DON'T FORGET TO UPDATE TOO!!!!
namespace namespace
{ {
QT_WARNING_PUSH
QT_WARNING_DISABLE_CLANG("-Wunused-member-function")
// The list of all string we use for conversion // The list of all string we use for conversion
// Better to use global variables because repeating QStringLiteral blows up code size // Better to use global variables because repeating QStringLiteral blows up code size
Q_GLOBAL_STATIC_WITH_ARGS(const QString, strTagRead_Only, (QLatin1String("read-only"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, strTagRead_Only, (QLatin1String("read-only"))) // NOLINT
@ -66,11 +71,13 @@ Q_GLOBAL_STATIC_WITH_ARGS(const QString, strGivenName, (QLatin1String("given-nam
Q_GLOBAL_STATIC_WITH_ARGS(const QString, strFamilyName, (QLatin1String("family-name"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, strFamilyName, (QLatin1String("family-name"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, strCustomer, (QLatin1String("customer"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, strCustomer, (QLatin1String("customer"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, strPersonal, (QLatin1String("personal"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, strPersonal, (QLatin1String("personal"))) // NOLINT
}
QT_WARNING_POP
} // namespace
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VVITConverter::VVITConverter(const QString &fileName) VVITConverter::VVITConverter(const QString &fileName)
:VAbstractMConverter(fileName) : VAbstractMConverter(fileName)
{ {
ValidateInputFile(CurrentSchema); ValidateInputFile(CurrentSchema);
} }
@ -78,8 +85,7 @@ VVITConverter::VVITConverter(const QString &fileName)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VVITConverter::XSDSchemas() -> QHash<unsigned int, QString> auto VVITConverter::XSDSchemas() -> QHash<unsigned int, QString>
{ {
static auto schemas = QHash <unsigned, QString> static auto schemas = QHash<unsigned, QString>{
{
std::make_pair(FormatVersion(0, 2, 0), QStringLiteral("://schema/individual_measurements/v0.2.0.xsd")), std::make_pair(FormatVersion(0, 2, 0), QStringLiteral("://schema/individual_measurements/v0.2.0.xsd")),
std::make_pair(FormatVersion(0, 3, 0), QStringLiteral("://schema/individual_measurements/v0.3.0.xsd")), std::make_pair(FormatVersion(0, 3, 0), QStringLiteral("://schema/individual_measurements/v0.3.0.xsd")),
std::make_pair(FormatVersion(0, 3, 1), QStringLiteral("://schema/individual_measurements/v0.3.1.xsd")), std::make_pair(FormatVersion(0, 3, 1), QStringLiteral("://schema/individual_measurements/v0.3.1.xsd")),
@ -139,8 +145,7 @@ void VVITConverter::DowngradeToCurrentMaxVersion()
auto VVITConverter::IsReadOnly() const -> bool auto VVITConverter::IsReadOnly() const -> bool
{ {
// Check if attribute read-only was not changed in file format // Check if attribute read-only was not changed in file format
Q_STATIC_ASSERT_X(VVITConverter::MeasurementMaxVer == FormatVersion(0, 5, 2), Q_STATIC_ASSERT_X(VVITConverter::MeasurementMaxVer == FormatVersion(0, 5, 2), "Check attribute read-only.");
"Check attribute read-only.");
// Possibly in future attribute read-only will change position etc. // Possibly in future attribute read-only will change position etc.
// For now position is the same for all supported format versions. // For now position is the same for all supported format versions.
@ -159,8 +164,7 @@ auto VVITConverter::Schemas() const -> QHash<unsigned int, QString>
void VVITConverter::AddNewTagsForV0_3_0() void VVITConverter::AddNewTagsForV0_3_0()
{ {
// TODO. Delete if minimal supported version is 0.3.0 // TODO. Delete if minimal supported version is 0.3.0
Q_STATIC_ASSERT_X(VVITConverter::MeasurementMinVer < FormatVersion(0, 3, 0), Q_STATIC_ASSERT_X(VVITConverter::MeasurementMinVer < FormatVersion(0, 3, 0), "Time to refactor the code.");
"Time to refactor the code.");
QDomElement rootElement = this->documentElement(); QDomElement rootElement = this->documentElement();
QDomNode refChild = rootElement.firstChildElement(QStringLiteral("version")); QDomNode refChild = rootElement.firstChildElement(QStringLiteral("version"));
@ -175,8 +179,7 @@ void VVITConverter::AddNewTagsForV0_3_0()
auto VVITConverter::MUnitV0_2_0() -> QString auto VVITConverter::MUnitV0_2_0() -> QString
{ {
// TODO. Delete if minimal supported version is 0.3.0 // TODO. Delete if minimal supported version is 0.3.0
Q_STATIC_ASSERT_X(VVITConverter::MeasurementMinVer < FormatVersion(0, 3, 0), Q_STATIC_ASSERT_X(VVITConverter::MeasurementMinVer < FormatVersion(0, 3, 0), "Time to refactor the code.");
"Time to refactor the code.");
return UniqueTagText(QStringLiteral("unit"), QStringLiteral("cm")); return UniqueTagText(QStringLiteral("unit"), QStringLiteral("cm"));
} }
@ -185,8 +188,7 @@ auto VVITConverter::MUnitV0_2_0() -> QString
void VVITConverter::ConvertMeasurementsToV0_3_0() void VVITConverter::ConvertMeasurementsToV0_3_0()
{ {
// TODO. Delete if minimal supported version is 0.3.0 // TODO. Delete if minimal supported version is 0.3.0
Q_STATIC_ASSERT_X(VVITConverter::MeasurementMinVer < FormatVersion(0, 3, 0), Q_STATIC_ASSERT_X(VVITConverter::MeasurementMinVer < FormatVersion(0, 3, 0), "Time to refactor the code.");
"Time to refactor the code.");
const QString tagBM = QStringLiteral("body-measurements"); const QString tagBM = QStringLiteral("body-measurements");
@ -199,8 +201,8 @@ void VVITConverter::ConvertMeasurementsToV0_3_0()
qreal resValue = 0; qreal resValue = 0;
// This has the same effect as a .values(), just isn't as elegant // This has the same effect as a .values(), just isn't as elegant
const QList<QString> list = names.values( key ); const QList<QString> list = names.values(key);
for(const auto &val : list) for (const auto &val : list)
{ {
const QDomNodeList nodeList = this->elementsByTagName(val); const QDomNodeList nodeList = this->elementsByTagName(val);
if (nodeList.isEmpty()) if (nodeList.isEmpty())
@ -228,8 +230,7 @@ void VVITConverter::ConvertMeasurementsToV0_3_0()
auto VVITConverter::AddMV0_3_0(const QString &name, qreal value) -> QDomElement auto VVITConverter::AddMV0_3_0(const QString &name, qreal value) -> QDomElement
{ {
// TODO. Delete if minimal supported version is 0.3.0 // TODO. Delete if minimal supported version is 0.3.0
Q_STATIC_ASSERT_X(VVITConverter::MeasurementMinVer < FormatVersion(0, 3, 0), Q_STATIC_ASSERT_X(VVITConverter::MeasurementMinVer < FormatVersion(0, 3, 0), "Time to refactor the code.");
"Time to refactor the code.");
QDomElement element = createElement(QStringLiteral("m")); QDomElement element = createElement(QStringLiteral("m"));
@ -245,8 +246,7 @@ auto VVITConverter::AddMV0_3_0(const QString &name, qreal value) -> QDomElement
void VVITConverter::GenderV0_3_1() void VVITConverter::GenderV0_3_1()
{ {
// TODO. Delete if minimal supported version is 0.3.1 // TODO. Delete if minimal supported version is 0.3.1
Q_STATIC_ASSERT_X(VVITConverter::MeasurementMinVer < FormatVersion(0, 3, 1), Q_STATIC_ASSERT_X(VVITConverter::MeasurementMinVer < FormatVersion(0, 3, 1), "Time to refactor the code.");
"Time to refactor the code.");
const QDomNodeList nodeList = this->elementsByTagName(QStringLiteral("sex")); const QDomNodeList nodeList = this->elementsByTagName(QStringLiteral("sex"));
QDomElement sex = nodeList.at(0).toElement(); QDomElement sex = nodeList.at(0).toElement();
@ -258,8 +258,7 @@ void VVITConverter::GenderV0_3_1()
void VVITConverter::PM_SystemV0_3_2() void VVITConverter::PM_SystemV0_3_2()
{ {
// TODO. Delete if minimal supported version is 0.3.2 // TODO. Delete if minimal supported version is 0.3.2
Q_STATIC_ASSERT_X(VVITConverter::MeasurementMinVer < FormatVersion(0, 3, 2), Q_STATIC_ASSERT_X(VVITConverter::MeasurementMinVer < FormatVersion(0, 3, 2), "Time to refactor the code.");
"Time to refactor the code.");
const QDomNodeList nodeList = this->elementsByTagName(QStringLiteral("personal")); const QDomNodeList nodeList = this->elementsByTagName(QStringLiteral("personal"));
QDomElement personal = nodeList.at(0).toElement(); QDomElement personal = nodeList.at(0).toElement();
@ -272,8 +271,7 @@ void VVITConverter::PM_SystemV0_3_2()
void VVITConverter::ConvertMeasurementsToV0_3_3() void VVITConverter::ConvertMeasurementsToV0_3_3()
{ {
// TODO. Delete if minimal supported version is 0.3.3 // TODO. Delete if minimal supported version is 0.3.3
Q_STATIC_ASSERT_X(VVITConverter::MeasurementMinVer < FormatVersion(0, 3, 3), Q_STATIC_ASSERT_X(VVITConverter::MeasurementMinVer < FormatVersion(0, 3, 3), "Time to refactor the code.");
"Time to refactor the code.");
const QMap<QString, QString> names = OldNamesToNewNames_InV0_3_3(); const QMap<QString, QString> names = OldNamesToNewNames_InV0_3_3();
auto i = names.constBegin(); auto i = names.constBegin();
@ -355,8 +353,7 @@ void VVITConverter::ConverCustomerNameToV0_4_0()
void VVITConverter::ToV0_3_0() void VVITConverter::ToV0_3_0()
{ {
// TODO. Delete if minimal supported version is 0.3.0 // TODO. Delete if minimal supported version is 0.3.0
Q_STATIC_ASSERT_X(VVITConverter::MeasurementMinVer < FormatVersion(0, 3, 0), Q_STATIC_ASSERT_X(VVITConverter::MeasurementMinVer < FormatVersion(0, 3, 0), "Time to refactor the code.");
"Time to refactor the code.");
AddRootComment(); AddRootComment();
SetVersion(QStringLiteral("0.3.0")); SetVersion(QStringLiteral("0.3.0"));
@ -369,8 +366,7 @@ void VVITConverter::ToV0_3_0()
void VVITConverter::ToV0_3_1() void VVITConverter::ToV0_3_1()
{ {
// TODO. Delete if minimal supported version is 0.3.1 // TODO. Delete if minimal supported version is 0.3.1
Q_STATIC_ASSERT_X(VVITConverter::MeasurementMinVer < FormatVersion(0, 3, 1), Q_STATIC_ASSERT_X(VVITConverter::MeasurementMinVer < FormatVersion(0, 3, 1), "Time to refactor the code.");
"Time to refactor the code.");
SetVersion(QStringLiteral("0.3.1")); SetVersion(QStringLiteral("0.3.1"));
GenderV0_3_1(); GenderV0_3_1();
@ -381,8 +377,7 @@ void VVITConverter::ToV0_3_1()
void VVITConverter::ToV0_3_2() void VVITConverter::ToV0_3_2()
{ {
// TODO. Delete if minimal supported version is 0.3.2 // TODO. Delete if minimal supported version is 0.3.2
Q_STATIC_ASSERT_X(VVITConverter::MeasurementMinVer < FormatVersion(0, 3, 2), Q_STATIC_ASSERT_X(VVITConverter::MeasurementMinVer < FormatVersion(0, 3, 2), "Time to refactor the code.");
"Time to refactor the code.");
SetVersion(QStringLiteral("0.3.2")); SetVersion(QStringLiteral("0.3.2"));
PM_SystemV0_3_2(); PM_SystemV0_3_2();
@ -393,8 +388,7 @@ void VVITConverter::ToV0_3_2()
void VVITConverter::ToV0_3_3() void VVITConverter::ToV0_3_3()
{ {
// TODO. Delete if minimal supported version is 0.3.3 // TODO. Delete if minimal supported version is 0.3.3
Q_STATIC_ASSERT_X(VVITConverter::MeasurementMinVer < FormatVersion(0, 3, 3), Q_STATIC_ASSERT_X(VVITConverter::MeasurementMinVer < FormatVersion(0, 3, 3), "Time to refactor the code.");
"Time to refactor the code.");
SetVersion(QStringLiteral("0.3.3")); SetVersion(QStringLiteral("0.3.3"));
ConvertMeasurementsToV0_3_3(); ConvertMeasurementsToV0_3_3();
@ -405,8 +399,7 @@ void VVITConverter::ToV0_3_3()
void VVITConverter::ToV0_4_0() void VVITConverter::ToV0_4_0()
{ {
// TODO. Delete if minimal supported version is 0.4.0 // TODO. Delete if minimal supported version is 0.4.0
Q_STATIC_ASSERT_X(VVITConverter::MeasurementMinVer < FormatVersion(0, 4, 0), Q_STATIC_ASSERT_X(VVITConverter::MeasurementMinVer < FormatVersion(0, 4, 0), "Time to refactor the code.");
"Time to refactor the code.");
SetVersion(QStringLiteral("0.4.0")); SetVersion(QStringLiteral("0.4.0"));
ConverCustomerNameToV0_4_0(); ConverCustomerNameToV0_4_0();
@ -417,8 +410,7 @@ void VVITConverter::ToV0_4_0()
void VVITConverter::ToV0_5_2() void VVITConverter::ToV0_5_2()
{ {
// TODO. Delete if minimal supported version is 0.5.2 // TODO. Delete if minimal supported version is 0.5.2
Q_STATIC_ASSERT_X(VVITConverter::MeasurementMinVer < FormatVersion(0, 5, 2), Q_STATIC_ASSERT_X(VVITConverter::MeasurementMinVer < FormatVersion(0, 5, 2), "Time to refactor the code.");
"Time to refactor the code.");
SetVersion(QStringLiteral("0.5.2")); SetVersion(QStringLiteral("0.5.2"));
Save(); Save();

View File

@ -32,16 +32,19 @@
#include <QDomNodeList> #include <QDomNodeList>
#include <QDomText> #include <QDomText>
#include <QFile> #include <QFile>
#include <QGlobalStatic>
#include <QLatin1String> #include <QLatin1String>
#include <QList> #include <QList>
#include <QMap> #include <QMap>
#include <QMultiMap> #include <QMultiMap>
#include <QGlobalStatic>
#include "../exception/vexception.h"
#include "../vmisc/def.h" #include "../vmisc/def.h"
#include "vabstractmconverter.h" #include "vabstractmconverter.h"
#if QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
#include "../vmisc/diagnostic.h"
#endif // QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
/* /*
* Version rules: * Version rules:
* 1. Version have three parts "major.minor.patch"; * 1. Version have three parts "major.minor.patch";
@ -54,20 +57,25 @@ const QString VVSTConverter::MeasurementMinVerStr = QStringLiteral("0.3.0");
const QString VVSTConverter::MeasurementMaxVerStr = QStringLiteral("0.5.4"); const QString VVSTConverter::MeasurementMaxVerStr = QStringLiteral("0.5.4");
const QString VVSTConverter::CurrentSchema = QStringLiteral("://schema/multisize_measurements/v0.5.4.xsd"); const QString VVSTConverter::CurrentSchema = QStringLiteral("://schema/multisize_measurements/v0.5.4.xsd");
//VVSTConverter::MeasurementMinVer; // <== DON'T FORGET TO UPDATE TOO!!!! // VVSTConverter::MeasurementMinVer; // <== DON'T FORGET TO UPDATE TOO!!!!
//VVSTConverter::MeasurementMaxVer; // <== DON'T FORGET TO UPDATE TOO!!!! // VVSTConverter::MeasurementMaxVer; // <== DON'T FORGET TO UPDATE TOO!!!!
namespace namespace
{ {
QT_WARNING_PUSH
QT_WARNING_DISABLE_CLANG("-Wunused-member-function")
Q_GLOBAL_STATIC_WITH_ARGS(const QString, strTagRead_Only, (QLatin1String("read-only"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, strTagRead_Only, (QLatin1String("read-only"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, strAttrCircumference, (QLatin1String("circumference"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, strAttrCircumference, (QLatin1String("circumference"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, strAttrMeasurement, (QLatin1String("measurement"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, strAttrMeasurement, (QLatin1String("measurement"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, strTagDimension, (QLatin1String("dimension"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, strTagDimension, (QLatin1String("dimension"))) // NOLINT
}
QT_WARNING_POP
} // namespace
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VVSTConverter::VVSTConverter(const QString &fileName) VVSTConverter::VVSTConverter(const QString &fileName)
:VAbstractMConverter(fileName) : VAbstractMConverter(fileName)
{ {
ValidateInputFile(CurrentSchema); ValidateInputFile(CurrentSchema);
} }
@ -75,8 +83,7 @@ VVSTConverter::VVSTConverter(const QString &fileName)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VVSTConverter::XSDSchemas() -> QHash<unsigned int, QString> auto VVSTConverter::XSDSchemas() -> QHash<unsigned int, QString>
{ {
static auto schemas = QHash <unsigned, QString> static auto schemas = QHash<unsigned, QString>{
{
std::make_pair(FormatVersion(0, 3, 0), QStringLiteral("://schema/multisize_measurements/v0.3.0.xsd")), std::make_pair(FormatVersion(0, 3, 0), QStringLiteral("://schema/multisize_measurements/v0.3.0.xsd")),
std::make_pair(FormatVersion(0, 4, 0), QStringLiteral("://schema/multisize_measurements/v0.4.0.xsd")), std::make_pair(FormatVersion(0, 4, 0), QStringLiteral("://schema/multisize_measurements/v0.4.0.xsd")),
std::make_pair(FormatVersion(0, 4, 1), QStringLiteral("://schema/multisize_measurements/v0.4.1.xsd")), std::make_pair(FormatVersion(0, 4, 1), QStringLiteral("://schema/multisize_measurements/v0.4.1.xsd")),
@ -138,8 +145,7 @@ void VVSTConverter::DowngradeToCurrentMaxVersion()
auto VVSTConverter::IsReadOnly() const -> bool auto VVSTConverter::IsReadOnly() const -> bool
{ {
// Check if attribute read-only was not changed in file format // Check if attribute read-only was not changed in file format
Q_STATIC_ASSERT_X(VVSTConverter::MeasurementMaxVer == FormatVersion(0, 5, 4), Q_STATIC_ASSERT_X(VVSTConverter::MeasurementMaxVer == FormatVersion(0, 5, 4), "Check attribute read-only.");
"Check attribute read-only.");
// Possibly in future attribute read-only will change position etc. // Possibly in future attribute read-only will change position etc.
// For now position is the same for all supported format versions. // For now position is the same for all supported format versions.
@ -158,24 +164,22 @@ auto VVSTConverter::Schemas() const -> QHash<unsigned int, QString>
void VVSTConverter::AddNewTagsForV0_4_0() void VVSTConverter::AddNewTagsForV0_4_0()
{ {
// TODO. Delete if minimal supported version is 0.4.0 // TODO. Delete if minimal supported version is 0.4.0
Q_STATIC_ASSERT_X(VVSTConverter::MeasurementMinVer < FormatVersion(0, 4, 0), Q_STATIC_ASSERT_X(VVSTConverter::MeasurementMinVer < FormatVersion(0, 4, 0), "Time to refactor the code.");
"Time to refactor the code.");
QDomElement rootElement = this->documentElement(); QDomElement rootElement = this->documentElement();
QDomNode refChild = rootElement.firstChildElement(QStringLiteral("version")); QDomNode refChild = rootElement.firstChildElement(QStringLiteral("version"));
refChild = rootElement.insertAfter(CreateElementWithText(QStringLiteral("read-only"), falseStr), refChild); refChild = rootElement.insertAfter(CreateElementWithText(QStringLiteral("read-only"), falseStr), refChild);
rootElement.insertAfter(CreateElementWithText(QStringLiteral("notes"), rootElement.insertAfter(
UniqueTagText(QStringLiteral("description"))), refChild); CreateElementWithText(QStringLiteral("notes"), UniqueTagText(QStringLiteral("description"))), refChild);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VVSTConverter::RemoveTagsForV0_4_0() void VVSTConverter::RemoveTagsForV0_4_0()
{ {
// TODO. Delete if minimal supported version is 0.4.0 // TODO. Delete if minimal supported version is 0.4.0
Q_STATIC_ASSERT_X(VVSTConverter::MeasurementMinVer < FormatVersion(0, 4, 0), Q_STATIC_ASSERT_X(VVSTConverter::MeasurementMinVer < FormatVersion(0, 4, 0), "Time to refactor the code.");
"Time to refactor the code.");
QDomElement rootElement = this->documentElement(); QDomElement rootElement = this->documentElement();
@ -200,8 +204,7 @@ void VVSTConverter::RemoveTagsForV0_4_0()
void VVSTConverter::ConvertMeasurementsToV0_4_0() void VVSTConverter::ConvertMeasurementsToV0_4_0()
{ {
// TODO. Delete if minimal supported version is 0.4.0 // TODO. Delete if minimal supported version is 0.4.0
Q_STATIC_ASSERT_X(VVSTConverter::MeasurementMinVer < FormatVersion(0, 4, 0), Q_STATIC_ASSERT_X(VVSTConverter::MeasurementMinVer < FormatVersion(0, 4, 0), "Time to refactor the code.");
"Time to refactor the code.");
const QString tagBM = QStringLiteral("body-measurements"); const QString tagBM = QStringLiteral("body-measurements");
@ -216,8 +219,8 @@ void VVSTConverter::ConvertMeasurementsToV0_4_0()
qreal resHeightIncrease = 0; qreal resHeightIncrease = 0;
// This has the same effect as a .values(), just isn't as elegant // This has the same effect as a .values(), just isn't as elegant
const QList<QString> list = names.values( key ); const QList<QString> list = names.values(key);
for(const auto &val : list) for (const auto &val : list)
{ {
const QDomNodeList nodeList = this->elementsByTagName(val); const QDomNodeList nodeList = this->elementsByTagName(val);
if (nodeList.isEmpty()) if (nodeList.isEmpty())
@ -251,8 +254,7 @@ auto VVSTConverter::AddMV0_4_0(const QString &name, qreal value, qreal sizeIncre
-> QDomElement -> QDomElement
{ {
// TODO. Delete if minimal supported version is 0.4.0 // TODO. Delete if minimal supported version is 0.4.0
Q_STATIC_ASSERT_X(VVSTConverter::MeasurementMinVer < FormatVersion(0, 4, 0), Q_STATIC_ASSERT_X(VVSTConverter::MeasurementMinVer < FormatVersion(0, 4, 0), "Time to refactor the code.");
"Time to refactor the code.");
QDomElement element = createElement(QStringLiteral("m")); QDomElement element = createElement(QStringLiteral("m"));
@ -260,7 +262,7 @@ auto VVSTConverter::AddMV0_4_0(const QString &name, qreal value, qreal sizeIncre
SetAttribute(element, QStringLiteral("base"), QString().setNum(value)); SetAttribute(element, QStringLiteral("base"), QString().setNum(value));
SetAttribute(element, QStringLiteral("size_increase"), QString().setNum(sizeIncrease)); SetAttribute(element, QStringLiteral("size_increase"), QString().setNum(sizeIncrease));
SetAttribute(element, QStringLiteral("height_increase"), QString().setNum(heightIncrease)); SetAttribute(element, QStringLiteral("height_increase"), QString().setNum(heightIncrease));
SetAttribute(element, QStringLiteral("description"),QString()); SetAttribute(element, QStringLiteral("description"), QString());
SetAttribute(element, QStringLiteral("full_name"), QString()); SetAttribute(element, QStringLiteral("full_name"), QString());
return element; return element;
@ -270,8 +272,7 @@ auto VVSTConverter::AddMV0_4_0(const QString &name, qreal value, qreal sizeIncre
void VVSTConverter::PM_SystemV0_4_1() void VVSTConverter::PM_SystemV0_4_1()
{ {
// TODO. Delete if minimal supported version is 0.4.1 // TODO. Delete if minimal supported version is 0.4.1
Q_STATIC_ASSERT_X(VVSTConverter::MeasurementMinVer < FormatVersion(0, 4, 1), Q_STATIC_ASSERT_X(VVSTConverter::MeasurementMinVer < FormatVersion(0, 4, 1), "Time to refactor the code.");
"Time to refactor the code.");
const QDomNodeList nodeList = this->elementsByTagName(QStringLiteral("size")); const QDomNodeList nodeList = this->elementsByTagName(QStringLiteral("size"));
QDomElement personal = nodeList.at(0).toElement(); QDomElement personal = nodeList.at(0).toElement();
@ -284,8 +285,7 @@ void VVSTConverter::PM_SystemV0_4_1()
void VVSTConverter::ConvertMeasurementsToV0_4_2() void VVSTConverter::ConvertMeasurementsToV0_4_2()
{ {
// TODO. Delete if minimal supported version is 0.4.2 // TODO. Delete if minimal supported version is 0.4.2
Q_STATIC_ASSERT_X(VVSTConverter::MeasurementMinVer < FormatVersion(0, 4, 2), Q_STATIC_ASSERT_X(VVSTConverter::MeasurementMinVer < FormatVersion(0, 4, 2), "Time to refactor the code.");
"Time to refactor the code.");
const QMap<QString, QString> names = OldNamesToNewNames_InV0_3_3(); const QMap<QString, QString> names = OldNamesToNewNames_InV0_3_3();
auto i = names.constBegin(); auto i = names.constBegin();
@ -317,8 +317,7 @@ void VVSTConverter::ConvertMeasurementsToV0_4_2()
void VVSTConverter::AddNewTagsForV0_5_0() void VVSTConverter::AddNewTagsForV0_5_0()
{ {
// TODO. Delete if minimal supported version is 0.5.0 // TODO. Delete if minimal supported version is 0.5.0
Q_STATIC_ASSERT_X(VVSTConverter::MeasurementMinVer < FormatVersion(0, 5, 0), Q_STATIC_ASSERT_X(VVSTConverter::MeasurementMinVer < FormatVersion(0, 5, 0), "Time to refactor the code.");
"Time to refactor the code.");
QDomElement root = documentElement(); QDomElement root = documentElement();
const QDomElement pmSystemTag = root.firstChildElement(QStringLiteral("pm_system")); const QDomElement pmSystemTag = root.firstChildElement(QStringLiteral("pm_system"));
@ -381,8 +380,7 @@ void VVSTConverter::AddNewTagsForV0_5_0()
void VVSTConverter::RemoveTagsForV0_5_0() void VVSTConverter::RemoveTagsForV0_5_0()
{ {
// TODO. Delete if minimal supported version is 0.5.0 // TODO. Delete if minimal supported version is 0.5.0
Q_STATIC_ASSERT_X(VVSTConverter::MeasurementMinVer < FormatVersion(0, 5, 0), Q_STATIC_ASSERT_X(VVSTConverter::MeasurementMinVer < FormatVersion(0, 5, 0), "Time to refactor the code.");
"Time to refactor the code.");
QDomElement root = documentElement(); QDomElement root = documentElement();
@ -403,8 +401,7 @@ void VVSTConverter::RemoveTagsForV0_5_0()
void VVSTConverter::ConvertMeasurementsToV0_5_0() void VVSTConverter::ConvertMeasurementsToV0_5_0()
{ {
// TODO. Delete if minimal supported version is 0.5.0 // TODO. Delete if minimal supported version is 0.5.0
Q_STATIC_ASSERT_X(VVSTConverter::MeasurementMinVer < FormatVersion(0, 5, 0), Q_STATIC_ASSERT_X(VVSTConverter::MeasurementMinVer < FormatVersion(0, 5, 0), "Time to refactor the code.");
"Time to refactor the code.");
const QDomNodeList measurements = elementsByTagName(QStringLiteral("m")); const QDomNodeList measurements = elementsByTagName(QStringLiteral("m"));
for (int i = 0; i < measurements.size(); ++i) for (int i = 0; i < measurements.size(); ++i)
@ -423,7 +420,7 @@ void VVSTConverter::ConvertMeasurementsToV0_5_0()
void VVSTConverter::ConvertCircumferenceAttreibuteToV0_5_4() void VVSTConverter::ConvertCircumferenceAttreibuteToV0_5_4()
{ {
const QDomNodeList list = elementsByTagName(*strTagDimension); const QDomNodeList list = elementsByTagName(*strTagDimension);
for (int i=0; i < list.size(); ++i) for (int i = 0; i < list.size(); ++i)
{ {
QDomElement dom = list.at(i).toElement(); QDomElement dom = list.at(i).toElement();
if (dom.hasAttribute(*strAttrCircumference)) if (dom.hasAttribute(*strAttrCircumference))
@ -439,8 +436,7 @@ void VVSTConverter::ConvertCircumferenceAttreibuteToV0_5_4()
void VVSTConverter::ToV0_4_0() void VVSTConverter::ToV0_4_0()
{ {
// TODO. Delete if minimal supported version is 0.4.0 // TODO. Delete if minimal supported version is 0.4.0
Q_STATIC_ASSERT_X(VVSTConverter::MeasurementMinVer < FormatVersion(0, 4, 0), Q_STATIC_ASSERT_X(VVSTConverter::MeasurementMinVer < FormatVersion(0, 4, 0), "Time to refactor the code.");
"Time to refactor the code.");
AddRootComment(); AddRootComment();
SetVersion(QStringLiteral("0.4.0")); SetVersion(QStringLiteral("0.4.0"));
@ -454,8 +450,7 @@ void VVSTConverter::ToV0_4_0()
void VVSTConverter::ToV0_4_1() void VVSTConverter::ToV0_4_1()
{ {
// TODO. Delete if minimal supported version is 0.4.1 // TODO. Delete if minimal supported version is 0.4.1
Q_STATIC_ASSERT_X(VVSTConverter::MeasurementMinVer < FormatVersion(0, 4, 1), Q_STATIC_ASSERT_X(VVSTConverter::MeasurementMinVer < FormatVersion(0, 4, 1), "Time to refactor the code.");
"Time to refactor the code.");
SetVersion(QStringLiteral("0.4.1")); SetVersion(QStringLiteral("0.4.1"));
PM_SystemV0_4_1(); PM_SystemV0_4_1();
@ -466,8 +461,7 @@ void VVSTConverter::ToV0_4_1()
void VVSTConverter::ToV0_4_2() void VVSTConverter::ToV0_4_2()
{ {
// TODO. Delete if minimal supported version is 0.4.2 // TODO. Delete if minimal supported version is 0.4.2
Q_STATIC_ASSERT_X(VVSTConverter::MeasurementMinVer < FormatVersion(0, 4, 2), Q_STATIC_ASSERT_X(VVSTConverter::MeasurementMinVer < FormatVersion(0, 4, 2), "Time to refactor the code.");
"Time to refactor the code.");
SetVersion(QStringLiteral("0.4.2")); SetVersion(QStringLiteral("0.4.2"));
ConvertMeasurementsToV0_4_2(); ConvertMeasurementsToV0_4_2();
@ -478,8 +472,7 @@ void VVSTConverter::ToV0_4_2()
void VVSTConverter::ToV0_5_0() void VVSTConverter::ToV0_5_0()
{ {
// TODO. Delete if minimal supported version is 0.5.0 // TODO. Delete if minimal supported version is 0.5.0
Q_STATIC_ASSERT_X(VVSTConverter::MeasurementMinVer < FormatVersion(0, 5, 0), Q_STATIC_ASSERT_X(VVSTConverter::MeasurementMinVer < FormatVersion(0, 5, 0), "Time to refactor the code.");
"Time to refactor the code.");
SetVersion(QStringLiteral("0.5.0")); SetVersion(QStringLiteral("0.5.0"));
AddNewTagsForV0_5_0(); AddNewTagsForV0_5_0();
@ -492,8 +485,7 @@ void VVSTConverter::ToV0_5_0()
void VVSTConverter::ToV0_5_4() void VVSTConverter::ToV0_5_4()
{ {
// TODO. Delete if minimal supported version is 0.5.4 // TODO. Delete if minimal supported version is 0.5.4
Q_STATIC_ASSERT_X(VVSTConverter::MeasurementMinVer < FormatVersion(0, 5, 4), Q_STATIC_ASSERT_X(VVSTConverter::MeasurementMinVer < FormatVersion(0, 5, 4), "Time to refactor the code.");
"Time to refactor the code.");
SetVersion(QStringLiteral("0.5.4")); SetVersion(QStringLiteral("0.5.4"));
ConvertCircumferenceAttreibuteToV0_5_4(); ConvertCircumferenceAttreibuteToV0_5_4();

View File

@ -1,30 +1,30 @@
/************************************************************************ /************************************************************************
** **
** @file vdxfengine.cpp ** @file vdxfengine.cpp
** @author Valentina Zhuravska <zhuravska19(at)gmail.com> ** @author Valentina Zhuravska <zhuravska19(at)gmail.com>
** @date 12 8, 2015 ** @date 12 8, 2015
** **
** @brief ** @brief
** @copyright ** @copyright
** This source code is part of the Valentina project, a pattern making ** This source code is part of the Valentina project, a pattern making
** program, whose allow create and modeling patterns of clothing. ** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2013-2015 Valentina project ** Copyright (C) 2013-2015 Valentina project
** <https://gitlab.com/smart-pattern/valentina> All Rights Reserved. ** <https://gitlab.com/smart-pattern/valentina> All Rights Reserved.
** **
** Valentina is free software: you can redistribute it and/or modify ** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by ** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or ** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version. ** (at your option) any later version.
** **
** Valentina is distributed in the hope that it will be useful, ** Valentina is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of ** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details. ** GNU General Public License for more details.
** **
** You should have received a copy of the GNU General Public License ** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>. ** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
** **
*************************************************************************/ *************************************************************************/
#include "vdxfengine.h" #include "vdxfengine.h"
#include <QLineF> #include <QLineF>
@ -54,50 +54,56 @@
#include <QTextCodec> #include <QTextCodec>
#endif #endif
#include "../vmisc/def.h"
#if QT_VERSION < QT_VERSION_CHECK(5, 5, 0) #if QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
#include "../vmisc/diagnostic.h" #include "../vmisc/diagnostic.h"
#endif // QT_VERSION < QT_VERSION_CHECK(5, 5, 0) #endif // QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
#include "../vgeometry/vgeometrydef.h" #include "../vgeometry/vgeometrydef.h"
#include "../vgeometry/vlayoutplacelabel.h" #include "../vgeometry/vlayoutplacelabel.h"
#include "../vlayout/vlayoutpiece.h" #include "../vlayout/vlayoutpiece.h"
#include "../vlayout/vlayoutpoint.h" #include "../vlayout/vlayoutpoint.h"
#include "../vmisc/def.h"
#include "dxiface.h" #include "dxiface.h"
namespace namespace
{ {
static const qreal AAMATextHeight = 2.5; const qreal AAMATextHeight = 2.5;
Q_GLOBAL_STATIC_WITH_ARGS(const UTF8STRING, layer0, (UTF8STRING("0"))) // NOLINT QT_WARNING_PUSH
Q_GLOBAL_STATIC_WITH_ARGS(const UTF8STRING, layer1, (UTF8STRING("1"))) // NOLINT QT_WARNING_DISABLE_CLANG("-Wunused-member-function")
Q_GLOBAL_STATIC_WITH_ARGS(const UTF8STRING, layer2, (UTF8STRING("2"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const UTF8STRING, layer3, (UTF8STRING("3"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const UTF8STRING, layer4, (UTF8STRING("4"))) // NOLINT
// Q_GLOBAL_STATIC_WITH_ARGS(const UTF8STRING, layer5, (UTF8STRING("5"))) // NOLINT
// Q_GLOBAL_STATIC_WITH_ARGS(const UTF8STRING, layer6, (UTF8STRING("6"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const UTF8STRING, layer7, (UTF8STRING("7"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const UTF8STRING, layer8, (UTF8STRING("8"))) // NOLINT
// Q_GLOBAL_STATIC_WITH_ARGS(const UTF8STRING, layer9, (UTF8STRING("9"))) // NOLINT
// Q_GLOBAL_STATIC_WITH_ARGS(const UTF8STRING, layer10, (UTF8STRING("10"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const UTF8STRING, layer11, (UTF8STRING("11"))) // NOLINT
// Q_GLOBAL_STATIC_WITH_ARGS(const UTF8STRING, layer12, (UTF8STRING("12"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const UTF8STRING, layer13, (UTF8STRING("13"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const UTF8STRING, layer14, (UTF8STRING("14"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const UTF8STRING, layer15, (UTF8STRING("15"))) // NOLINT
// Q_GLOBAL_STATIC_WITH_ARGS(const UTF8STRING, layer19, (UTF8STRING("19"))) // NOLINT
// Q_GLOBAL_STATIC_WITH_ARGS(const UTF8STRING, layer26, (UTF8STRING("26"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const UTF8STRING, layer80, (UTF8STRING("80"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const UTF8STRING, layer81, (UTF8STRING("81"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const UTF8STRING, layer82, (UTF8STRING("82"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const UTF8STRING, layer83, (UTF8STRING("83"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const UTF8STRING, layer84, (UTF8STRING("84"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const UTF8STRING, layer85, (UTF8STRING("85"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const UTF8STRING, layer86, (UTF8STRING("86"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const UTF8STRING, layer87, (UTF8STRING("87"))) // NOLINT
//--------------------------------------------------------------------------------------------------------------------- Q_GLOBAL_STATIC_WITH_ARGS(const UTF8STRING, layer0, (UTF8STRING("0"))) // NOLINT
auto PieceOutline(const VLayoutPiece &detail) -> QVector<VLayoutPoint> Q_GLOBAL_STATIC_WITH_ARGS(const UTF8STRING, layer1, (UTF8STRING("1"))) // NOLINT
{ Q_GLOBAL_STATIC_WITH_ARGS(const UTF8STRING, layer2, (UTF8STRING("2"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const UTF8STRING, layer3, (UTF8STRING("3"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const UTF8STRING, layer4, (UTF8STRING("4"))) // NOLINT
// Q_GLOBAL_STATIC_WITH_ARGS(const UTF8STRING, layer5, (UTF8STRING("5"))) // NOLINT
// Q_GLOBAL_STATIC_WITH_ARGS(const UTF8STRING, layer6, (UTF8STRING("6"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const UTF8STRING, layer7, (UTF8STRING("7"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const UTF8STRING, layer8, (UTF8STRING("8"))) // NOLINT
// Q_GLOBAL_STATIC_WITH_ARGS(const UTF8STRING, layer9, (UTF8STRING("9"))) // NOLINT
// Q_GLOBAL_STATIC_WITH_ARGS(const UTF8STRING, layer10, (UTF8STRING("10"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const UTF8STRING, layer11, (UTF8STRING("11"))) // NOLINT
// Q_GLOBAL_STATIC_WITH_ARGS(const UTF8STRING, layer12, (UTF8STRING("12"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const UTF8STRING, layer13, (UTF8STRING("13"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const UTF8STRING, layer14, (UTF8STRING("14"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const UTF8STRING, layer15, (UTF8STRING("15"))) // NOLINT
// Q_GLOBAL_STATIC_WITH_ARGS(const UTF8STRING, layer19, (UTF8STRING("19"))) // NOLINT
// Q_GLOBAL_STATIC_WITH_ARGS(const UTF8STRING, layer26, (UTF8STRING("26"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const UTF8STRING, layer80, (UTF8STRING("80"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const UTF8STRING, layer81, (UTF8STRING("81"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const UTF8STRING, layer82, (UTF8STRING("82"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const UTF8STRING, layer83, (UTF8STRING("83"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const UTF8STRING, layer84, (UTF8STRING("84"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const UTF8STRING, layer85, (UTF8STRING("85"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const UTF8STRING, layer86, (UTF8STRING("86"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const UTF8STRING, layer87, (UTF8STRING("87"))) // NOLINT
QT_WARNING_POP
//---------------------------------------------------------------------------------------------------------------------
auto PieceOutline(const VLayoutPiece &detail) -> QVector<VLayoutPoint>
{
QVector<VLayoutPoint> outline; QVector<VLayoutPoint> outline;
if (detail.IsSeamAllowance() && not detail.IsSeamAllowanceBuiltIn()) if (detail.IsSeamAllowance() && not detail.IsSeamAllowanceBuiltIn())
{ {
@ -108,28 +114,25 @@
outline = detail.GetMappedContourPoints(); outline = detail.GetMappedContourPoints();
} }
return outline; return outline;
} }
} // namespace } // namespace
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
static inline auto svgEngineFeatures() -> QPaintEngine::PaintEngineFeatures static inline auto svgEngineFeatures() -> QPaintEngine::PaintEngineFeatures
{ {
QT_WARNING_PUSH QT_WARNING_PUSH
QT_WARNING_DISABLE_CLANG("-Wsign-conversion") QT_WARNING_DISABLE_CLANG("-Wsign-conversion")
QT_WARNING_DISABLE_INTEL(68) QT_WARNING_DISABLE_INTEL(68)
return {QPaintEngine::AllFeatures return {QPaintEngine::AllFeatures & ~QPaintEngine::PatternBrush & ~QPaintEngine::PerspectiveTransform &
& ~QPaintEngine::PatternBrush ~QPaintEngine::ConicalGradientFill & ~QPaintEngine::PorterDuff};
& ~QPaintEngine::PerspectiveTransform
& ~QPaintEngine::ConicalGradientFill
& ~QPaintEngine::PorterDuff};
QT_WARNING_POP QT_WARNING_POP
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VDxfEngine::VDxfEngine() VDxfEngine::VDxfEngine()
:QPaintEngine(svgEngineFeatures()), : QPaintEngine(svgEngineFeatures()),
m_textBuffer(new DRW_Text()) m_textBuffer(new DRW_Text())
{ {
} }
@ -153,12 +156,12 @@ auto VDxfEngine::begin(QPaintDevice *pdev) -> bool
if (not m_size.isValid()) if (not m_size.isValid())
{ {
qWarning()<<"VDxfEngine::begin(), size is not valid"; qWarning() << "VDxfEngine::begin(), size is not valid";
return false; return false;
} }
m_input = QSharedPointer<dx_iface>(new dx_iface(GetFileNameForLocale(), m_version, m_varMeasurement, m_input =
m_varInsunits)); QSharedPointer<dx_iface>(new dx_iface(GetFileNameForLocale(), m_version, m_varMeasurement, m_varInsunits));
m_input->AddDefHeaderData(); m_input->AddDefHeaderData();
m_input->AddQtLTypes(); m_input->AddQtLTypes();
m_input->AddDefLayers(); m_input->AddDefLayers();
@ -180,7 +183,6 @@ void VDxfEngine::updateState(const QPaintEngineState &state)
// always stream full gstate, which is not required, but... // always stream full gstate, which is not required, but...
flags |= QPaintEngine::AllDirty; flags |= QPaintEngine::AllDirty;
if (flags & QPaintEngine::DirtyTransform) if (flags & QPaintEngine::DirtyTransform)
{ {
m_matrix = state.transform(); // Save new matrix for moving paths m_matrix = state.transform(); // Save new matrix for moving paths
@ -192,7 +194,7 @@ void VDxfEngine::drawPath(const QPainterPath &path)
{ {
const QList<QPolygonF> subpaths = path.toSubpathPolygons(m_matrix); const QList<QPolygonF> subpaths = path.toSubpathPolygons(m_matrix);
for (const auto& polygon : subpaths) for (const auto &polygon : subpaths)
{ {
if (polygon.isEmpty()) if (polygon.isEmpty())
{ {
@ -256,10 +258,10 @@ void VDxfEngine::drawLines(const QLineF *lines, int lineCount)
const QPointF p2 = m_matrix.map(lines[i].p2()); // NOLINT(cppcoreguidelines-pro-bounds-pointer-arithmetic) const QPointF p2 = m_matrix.map(lines[i].p2()); // NOLINT(cppcoreguidelines-pro-bounds-pointer-arithmetic)
auto *line = new DRW_Line(); auto *line = new DRW_Line();
line->basePoint = DRW_Coord(FromPixel(p1.x(), m_varInsunits), line->basePoint =
FromPixel(GetSize().height() - p1.y(), m_varInsunits), 0); DRW_Coord(FromPixel(p1.x(), m_varInsunits), FromPixel(GetSize().height() - p1.y(), m_varInsunits), 0);
line->secPoint = DRW_Coord(FromPixel(p2.x(), m_varInsunits), line->secPoint =
FromPixel(GetSize().height() - p2.y(), m_varInsunits), 0); DRW_Coord(FromPixel(p2.x(), m_varInsunits), FromPixel(GetSize().height() - p2.y(), m_varInsunits), 0);
line->layer = *layer0; line->layer = *layer0;
line->color = GetPenColor(); line->color = GetPenColor();
line->lWeight = DRW_LW_Conv::widthByLayer; line->lWeight = DRW_LW_Conv::widthByLayer;
@ -270,7 +272,7 @@ void VDxfEngine::drawLines(const QLineF *lines, int lineCount)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VDxfEngine::drawLines(const QLine * lines, int lineCount) void VDxfEngine::drawLines(const QLine *lines, int lineCount)
{ {
QPaintEngine::drawLines(lines, lineCount); QPaintEngine::drawLines(lines, lineCount);
} }
@ -293,7 +295,8 @@ void VDxfEngine::drawPolygon(const QPointF *points, int pointCount, PolygonDrawM
poly->lWeight = DRW_LW_Conv::widthByLayer; poly->lWeight = DRW_LW_Conv::widthByLayer;
poly->lineType = GetPenStyle(); poly->lineType = GetPenStyle();
if (pointCount > 1 && points[0] == points[pointCount]) // NOLINT(cppcoreguidelines-pro-bounds-pointer-arithmetic) if (pointCount > 1 &&
points[0] == points[pointCount]) // NOLINT(cppcoreguidelines-pro-bounds-pointer-arithmetic)
{ {
poly->flags |= 0x1; // closed NOLINT(hicpp-signed-bitwise) poly->flags |= 0x1; // closed NOLINT(hicpp-signed-bitwise)
} }
@ -303,8 +306,8 @@ void VDxfEngine::drawPolygon(const QPointF *points, int pointCount, PolygonDrawM
for (int i = 0; i < pointCount; ++i) for (int i = 0; i < pointCount; ++i)
{ {
const QPointF p = m_matrix.map(points[i]); // NOLINT(cppcoreguidelines-pro-bounds-pointer-arithmetic) const QPointF p = m_matrix.map(points[i]); // NOLINT(cppcoreguidelines-pro-bounds-pointer-arithmetic)
poly->addVertex(DRW_Vertex2D(FromPixel(p.x(), m_varInsunits), poly->addVertex(
FromPixel(GetSize().height() - p.y(), m_varInsunits), 0)); DRW_Vertex2D(FromPixel(p.x(), m_varInsunits), FromPixel(GetSize().height() - p.y(), m_varInsunits), 0));
} }
m_input->AddEntity(poly); m_input->AddEntity(poly);
@ -317,7 +320,8 @@ void VDxfEngine::drawPolygon(const QPointF *points, int pointCount, PolygonDrawM
poly->lWeight = DRW_LW_Conv::widthByLayer; poly->lWeight = DRW_LW_Conv::widthByLayer;
poly->lineType = GetPenStyle(); poly->lineType = GetPenStyle();
if (pointCount > 1 && points[0] == points[pointCount]) // NOLINT(cppcoreguidelines-pro-bounds-pointer-arithmetic) if (pointCount > 1 &&
points[0] == points[pointCount]) // NOLINT(cppcoreguidelines-pro-bounds-pointer-arithmetic)
{ {
poly->flags |= 0x1; // closed NOLINT(hicpp-signed-bitwise) poly->flags |= 0x1; // closed NOLINT(hicpp-signed-bitwise)
} }
@ -342,28 +346,28 @@ void VDxfEngine::drawPolygon(const QPoint *points, int pointCount, QPaintEngine:
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VDxfEngine::drawEllipse(const QRectF & rect) void VDxfEngine::drawEllipse(const QRectF &rect)
{ {
const QRectF newRect = m_matrix.mapRect(rect); const QRectF newRect = m_matrix.mapRect(rect);
const double rotationAngle = atan(m_matrix.m12()/m_matrix.m11()); const double rotationAngle = atan(m_matrix.m12() / m_matrix.m11());
double majorX, majorY; // distanse between center and endpoint of the major axis double majorX, majorY; // distanse between center and endpoint of the major axis
double ratio; // ratio of minor axis to major axis double ratio; // ratio of minor axis to major axis
if(rect.width()<= rect.height()) if (rect.width() <= rect.height())
{ {
majorX = (rect.top() - rect.center().y())*sin(rotationAngle)*m_matrix.m11()/cos(rotationAngle); majorX = (rect.top() - rect.center().y()) * sin(rotationAngle) * m_matrix.m11() / cos(rotationAngle);
// major axis * sin(rotation angle) * x-scale-factor // major axis * sin(rotation angle) * x-scale-factor
majorY = (rect.top() - rect.center().y())*m_matrix.m22(); majorY = (rect.top() - rect.center().y()) * m_matrix.m22();
// major axis * cos(rotation angle) * y-scale-factor, where y-scale-factor = matrix.m22()/cos(rotationAngle) // major axis * cos(rotation angle) * y-scale-factor, where y-scale-factor = matrix.m22()/cos(rotationAngle)
ratio = rect.width()/rect.height(); ratio = rect.width() / rect.height();
} }
else else
{ {
majorX = (rect.right() - rect.center().x())*m_matrix.m11(); majorX = (rect.right() - rect.center().x()) * m_matrix.m11();
// major axis * cos(rotation angle) * x-scale-factor, where y-scale-factor = matrix.m22()/cos(rotationAngle) // major axis * cos(rotation angle) * x-scale-factor, where y-scale-factor = matrix.m22()/cos(rotationAngle)
majorY = (rect.right() - rect.center().x())*sin(rotationAngle)*m_matrix.m22()/cos(rotationAngle); majorY = (rect.right() - rect.center().x()) * sin(rotationAngle) * m_matrix.m22() / cos(rotationAngle);
// major axis * sin(rotation angle) * y-scale-factor // major axis * sin(rotation angle) * y-scale-factor
ratio = rect.height()/rect.width(); ratio = rect.height() / rect.width();
} }
auto *ellipse = new DRW_Ellipse(); auto *ellipse = new DRW_Ellipse();
@ -372,7 +376,7 @@ void VDxfEngine::drawEllipse(const QRectF & rect)
ellipse->secPoint = DRW_Coord(FromPixel(majorX, m_varInsunits), FromPixel(majorY, m_varInsunits), 0); ellipse->secPoint = DRW_Coord(FromPixel(majorX, m_varInsunits), FromPixel(majorY, m_varInsunits), 0);
ellipse->ratio = ratio; ellipse->ratio = ratio;
ellipse->staparam = 0; ellipse->staparam = 0;
ellipse->endparam = 2*M_PI; ellipse->endparam = 2 * M_PI;
ellipse->layer = *layer0; ellipse->layer = *layer0;
ellipse->color = GetPenColor(); ellipse->color = GetPenColor();
@ -383,13 +387,13 @@ void VDxfEngine::drawEllipse(const QRectF & rect)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VDxfEngine::drawEllipse(const QRect & rect) void VDxfEngine::drawEllipse(const QRect &rect)
{ {
QPaintEngine::drawEllipse(rect); QPaintEngine::drawEllipse(rect);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VDxfEngine::drawTextItem(const QPointF & p, const QTextItem & textItem) void VDxfEngine::drawTextItem(const QPointF &p, const QTextItem &textItem)
{ {
if (m_textBuffer->text.empty()) if (m_textBuffer->text.empty())
{ {
@ -448,20 +452,20 @@ void VDxfEngine::drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr
Q_UNUSED(sr) Q_UNUSED(sr)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VDxfEngine::GetSize() const -> QSize auto VDxfEngine::GetSize() const -> QSize
{ {
return m_size; return m_size;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VDxfEngine::SetSize(const QSize &value) void VDxfEngine::SetSize(const QSize &value)
{ {
Q_ASSERT(not isActive()); Q_ASSERT(not isActive());
m_size = value; m_size = value;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VDxfEngine::GetResolution() const -> double auto VDxfEngine::GetResolution() const -> double
{ {
return m_resolution; return m_resolution;
@ -536,77 +540,77 @@ auto VDxfEngine::GetPenColor() -> int
{ {
QColor color = state->pen().color(); QColor color = state->pen().color();
if(color == Qt::black) if (color == Qt::black)
{ {
return DRW::black; return DRW::black;
} }
if(color == Qt::white) if (color == Qt::white)
{ {
return DRW::white; return DRW::white;
} }
if(color == Qt::darkGray) if (color == Qt::darkGray)
{ {
return DRW::gray; return DRW::gray;
} }
if(color == Qt::gray) if (color == Qt::gray)
{ {
return DRW::l_gray; return DRW::l_gray;
} }
if(color == Qt::darkMagenta) if (color == Qt::darkMagenta)
{ {
return DRW::magenta; return DRW::magenta;
} }
if(color == Qt::magenta) if (color == Qt::magenta)
{ {
return DRW::l_magenta; return DRW::l_magenta;
} }
if(color == Qt::cyan) if (color == Qt::cyan)
{ {
return DRW::l_cyan; return DRW::l_cyan;
} }
if(color == Qt::darkCyan) if (color == Qt::darkCyan)
{ {
return DRW::cyan; return DRW::cyan;
} }
if(color == Qt::blue) if (color == Qt::blue)
{ {
return DRW::l_blue; return DRW::l_blue;
} }
if(color == Qt::darkBlue) if (color == Qt::darkBlue)
{ {
return DRW::blue; return DRW::blue;
} }
if(color == Qt::darkGreen) if (color == Qt::darkGreen)
{ {
return DRW::green; return DRW::green;
} }
if(color == Qt::green) if (color == Qt::green)
{ {
return DRW::l_green; return DRW::l_green;
} }
if(color == Qt::darkRed) if (color == Qt::darkRed)
{ {
return DRW::red; return DRW::red;
} }
if(color == Qt::red) if (color == Qt::red)
{ {
return DRW::l_red; return DRW::l_red;
} }
if(color == Qt::yellow) if (color == Qt::yellow)
{ {
return DRW::yellow; return DRW::yellow;
} }
@ -698,7 +702,7 @@ auto VDxfEngine::ExportToAAMA(const QVector<VLayoutPiece> &details) -> bool
{ {
if (not m_size.isValid()) if (not m_size.isValid())
{ {
qWarning()<<"VDxfEngine::begin(), size is not valid"; qWarning() << "VDxfEngine::begin(), size is not valid";
return false; return false;
} }
@ -713,11 +717,11 @@ auto VDxfEngine::ExportToAAMA(const QVector<VLayoutPiece> &details) -> bool
ExportStyleSystemText(m_input, details); ExportStyleSystemText(m_input, details);
for(auto detail : details) for (auto detail : details)
{ {
// Use custom deleter function to lose ownership after adding the block // Use custom deleter function to lose ownership after adding the block
bool deleteBlock = true; bool deleteBlock = true;
auto NoOpDeleter =[&deleteBlock](dx_ifaceBlock* block) auto NoOpDeleter = [&deleteBlock](dx_ifaceBlock *block)
{ {
if (deleteBlock) if (deleteBlock)
{ {
@ -793,7 +797,7 @@ void VDxfEngine::ExportAAMADraw(const QSharedPointer<dx_ifaceBlock> &detailBlock
} }
const QVector<QVector<VLayoutPoint>> drawIntLine = detail.MappedInternalPathsForCut(false); const QVector<QVector<VLayoutPoint>> drawIntLine = detail.MappedInternalPathsForCut(false);
for(const auto &intLine : drawIntLine) for (const auto &intLine : drawIntLine)
{ {
if (DRW_Entity *e = AAMAPolygon(intLine, *layer8, false)) if (DRW_Entity *e = AAMAPolygon(intLine, *layer8, false))
{ {
@ -805,13 +809,13 @@ void VDxfEngine::ExportAAMADraw(const QSharedPointer<dx_ifaceBlock> &detailBlock
} }
const QVector<VLayoutPlaceLabel> labels = detail.GetPlaceLabels(); const QVector<VLayoutPlaceLabel> labels = detail.GetPlaceLabels();
for(const auto &label : labels) for (const auto &label : labels)
{ {
if (label.Type() != PlaceLabelType::Doubletree && label.Type() != PlaceLabelType::Button if (label.Type() != PlaceLabelType::Doubletree && label.Type() != PlaceLabelType::Button &&
&& label.Type() != PlaceLabelType::Circle) label.Type() != PlaceLabelType::Circle)
{ {
PlaceLabelImg shape = detail.MapPlaceLabelShape(VAbstractPiece::PlaceLabelShape(label)); PlaceLabelImg shape = detail.MapPlaceLabelShape(VAbstractPiece::PlaceLabelShape(label));
for(const auto &points : shape) for (const auto &points : shape)
{ {
if (DRW_Entity *e = AAMAPolygon(points, *layer8, false)) if (DRW_Entity *e = AAMAPolygon(points, *layer8, false))
{ {
@ -829,7 +833,7 @@ void VDxfEngine::ExportAAMADraw(const QSharedPointer<dx_ifaceBlock> &detailBlock
void VDxfEngine::ExportAAMAIntcut(const QSharedPointer<dx_ifaceBlock> &detailBlock, const VLayoutPiece &detail) void VDxfEngine::ExportAAMAIntcut(const QSharedPointer<dx_ifaceBlock> &detailBlock, const VLayoutPiece &detail)
{ {
QVector<QVector<VLayoutPoint>> drawIntCut = detail.MappedInternalPathsForCut(true); QVector<QVector<VLayoutPoint>> drawIntCut = detail.MappedInternalPathsForCut(true);
for(auto &intCut : drawIntCut) for (auto &intCut : drawIntCut)
{ {
if (DRW_Entity *e = AAMAPolygon(intCut, *layer11, false)) if (DRW_Entity *e = AAMAPolygon(intCut, *layer11, false))
{ {
@ -847,7 +851,7 @@ void VDxfEngine::ExportAAMANotch(const QSharedPointer<dx_ifaceBlock> &detailBloc
if (detail.IsSeamAllowance()) if (detail.IsSeamAllowance())
{ {
const QVector<VLayoutPassmark> passmarks = detail.GetMappedPassmarks(); const QVector<VLayoutPassmark> passmarks = detail.GetMappedPassmarks();
for(const auto &passmark : passmarks) for (const auto &passmark : passmarks)
{ {
std::unique_ptr<DRW_ASTMNotch> notch(new DRW_ASTMNotch()); std::unique_ptr<DRW_ASTMNotch> notch(new DRW_ASTMNotch());
const QPointF center = passmark.baseLine.p1(); const QPointF center = passmark.baseLine.p1();
@ -885,7 +889,7 @@ void VDxfEngine::ExportPieceText(const QSharedPointer<dx_ifaceBlock> &detailBloc
for (int i = 0; i < list.size(); ++i) for (int i = 0; i < list.size(); ++i)
{ {
const qreal height = ToPixel(AAMATextHeight * m_yscale, m_varInsunits); const qreal height = ToPixel(AAMATextHeight * m_yscale, m_varInsunits);
QPointF pos(startPos.x(), startPos.y() - height * (static_cast<int>(list.size()) - i-1)); QPointF pos(startPos.x(), startPos.y() - height * (static_cast<int>(list.size()) - i - 1));
detailBlock->ent.push_back(AAMAText(pos, list.at(i), *layer1)); detailBlock->ent.push_back(AAMAText(pos, list.at(i), *layer1));
} }
} }
@ -893,7 +897,7 @@ void VDxfEngine::ExportPieceText(const QSharedPointer<dx_ifaceBlock> &detailBloc
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VDxfEngine::ExportStyleSystemText(const QSharedPointer<dx_iface> &input, const QVector<VLayoutPiece> &details) void VDxfEngine::ExportStyleSystemText(const QSharedPointer<dx_iface> &input, const QVector<VLayoutPiece> &details)
{ {
for(const auto &detail : details) for (const auto &detail : details)
{ {
const QStringList strings = detail.GetPatternText(); const QStringList strings = detail.GetPatternText();
if (not strings.isEmpty()) if (not strings.isEmpty())
@ -901,7 +905,7 @@ void VDxfEngine::ExportStyleSystemText(const QSharedPointer<dx_iface> &input, co
for (int j = 0; j < strings.size(); ++j) for (int j = 0; j < strings.size(); ++j)
{ {
const qreal height = ToPixel(AAMATextHeight * m_yscale, m_varInsunits); const qreal height = ToPixel(AAMATextHeight * m_yscale, m_varInsunits);
QPointF pos(0, GetSize().height() - height * (static_cast<int>(strings.size()) - j-1)); QPointF pos(0, GetSize().height() - height * (static_cast<int>(strings.size()) - j - 1));
input->AddEntity(AAMAText(pos, strings.at(j), *layer1)); input->AddEntity(AAMAText(pos, strings.at(j), *layer1));
} }
return; return;
@ -914,10 +918,10 @@ void VDxfEngine::ExportAAMADrill(const QSharedPointer<dx_ifaceBlock> &detailBloc
{ {
const QVector<VLayoutPlaceLabel> labels = detail.GetPlaceLabels(); const QVector<VLayoutPlaceLabel> labels = detail.GetPlaceLabels();
for(const auto &label : labels) for (const auto &label : labels)
{ {
if (label.Type() == PlaceLabelType::Doubletree || label.Type() == PlaceLabelType::Button if (label.Type() == PlaceLabelType::Doubletree || label.Type() == PlaceLabelType::Button ||
|| label.Type() == PlaceLabelType::Circle) label.Type() == PlaceLabelType::Circle)
{ {
const QPointF center = detail.GetMatrix().map(label.Center()); const QPointF center = detail.GetMatrix().map(label.Center());
detailBlock->ent.push_back(AAMAPoint(center, *layer13)); detailBlock->ent.push_back(AAMAPoint(center, *layer13));
@ -930,12 +934,12 @@ auto VDxfEngine::ExportToASTM(const QVector<VLayoutPiece> &details) -> bool
{ {
if (not m_size.isValid()) if (not m_size.isValid())
{ {
qWarning()<<"VDxfEngine::begin(), size is not valid"; qWarning() << "VDxfEngine::begin(), size is not valid";
return false; return false;
} }
m_input = QSharedPointer<dx_iface>(new dx_iface(GetFileNameForLocale(), m_version, m_varMeasurement, m_input =
m_varInsunits)); QSharedPointer<dx_iface>(new dx_iface(GetFileNameForLocale(), m_version, m_varMeasurement, m_varInsunits));
m_input->AddXSpaceBlock(false); m_input->AddXSpaceBlock(false);
m_input->AddAAMAHeaderData(); m_input->AddAAMAHeaderData();
if (m_version > DRW::AC1009) if (m_version > DRW::AC1009)
@ -946,11 +950,11 @@ auto VDxfEngine::ExportToASTM(const QVector<VLayoutPiece> &details) -> bool
ExportStyleSystemText(m_input, details); ExportStyleSystemText(m_input, details);
for(auto detail : details) for (auto detail : details)
{ {
// Use custom deleter function to lose ownership after adding the block // Use custom deleter function to lose ownership after adding the block
bool deleteBlock = true; bool deleteBlock = true;
auto NoOpDeleter =[&deleteBlock](dx_ifaceBlock* block) auto NoOpDeleter = [&deleteBlock](dx_ifaceBlock *block)
{ {
if (deleteBlock) if (deleteBlock)
{ {
@ -1043,7 +1047,7 @@ void VDxfEngine::ExportASTMSewLine(const QSharedPointer<dx_ifaceBlock> &detailBl
void VDxfEngine::ExportASTMInternalLine(const QSharedPointer<dx_ifaceBlock> &detailBlock, const VLayoutPiece &detail) void VDxfEngine::ExportASTMInternalLine(const QSharedPointer<dx_ifaceBlock> &detailBlock, const VLayoutPiece &detail)
{ {
const QVector<QVector<VLayoutPoint>> drawIntLine = detail.MappedInternalPathsForCut(false); const QVector<QVector<VLayoutPoint>> drawIntLine = detail.MappedInternalPathsForCut(false);
for(const auto &intLine : drawIntLine) for (const auto &intLine : drawIntLine)
{ {
// Internal line // Internal line
if (DRW_Entity *e = AAMAPolygon(intLine, *layer8, false)) if (DRW_Entity *e = AAMAPolygon(intLine, *layer8, false))
@ -1062,13 +1066,13 @@ void VDxfEngine::ExportASTMInternalLine(const QSharedPointer<dx_ifaceBlock> &det
} }
const QVector<VLayoutPlaceLabel> labels = detail.GetPlaceLabels(); const QVector<VLayoutPlaceLabel> labels = detail.GetPlaceLabels();
for(const auto &label : labels) for (const auto &label : labels)
{ {
if (label.Type() != PlaceLabelType::Doubletree && label.Type() != PlaceLabelType::Button if (label.Type() != PlaceLabelType::Doubletree && label.Type() != PlaceLabelType::Button &&
&& label.Type() != PlaceLabelType::Circle) label.Type() != PlaceLabelType::Circle)
{ {
PlaceLabelImg shape = detail.MapPlaceLabelShape(VAbstractPiece::PlaceLabelShape(label)); PlaceLabelImg shape = detail.MapPlaceLabelShape(VAbstractPiece::PlaceLabelShape(label));
for(const auto &p : shape) for (const auto &p : shape)
{ {
// Internal line (placelabel) // Internal line (placelabel)
if (DRW_Entity *e = AAMAPolygon(p, *layer8, false)) if (DRW_Entity *e = AAMAPolygon(p, *layer8, false))
@ -1093,7 +1097,7 @@ void VDxfEngine::ExportASTMInternalLine(const QSharedPointer<dx_ifaceBlock> &det
void VDxfEngine::ExportASTMInternalCutout(const QSharedPointer<dx_ifaceBlock> &detailBlock, const VLayoutPiece &detail) void VDxfEngine::ExportASTMInternalCutout(const QSharedPointer<dx_ifaceBlock> &detailBlock, const VLayoutPiece &detail)
{ {
QVector<QVector<VLayoutPoint>> drawIntCut = detail.MappedInternalPathsForCut(true); QVector<QVector<VLayoutPoint>> drawIntCut = detail.MappedInternalPathsForCut(true);
for(auto &intCut : drawIntCut) for (auto &intCut : drawIntCut)
{ {
// Internal cutout // Internal cutout
if (DRW_Entity *e = AAMAPolygon(intCut, *layer11, false)) if (DRW_Entity *e = AAMAPolygon(intCut, *layer11, false))
@ -1127,10 +1131,10 @@ void VDxfEngine::ExportASTMDrill(const QSharedPointer<dx_ifaceBlock> &detailBloc
{ {
const QVector<VLayoutPlaceLabel> labels = detail.GetPlaceLabels(); const QVector<VLayoutPlaceLabel> labels = detail.GetPlaceLabels();
for(const auto &label : labels) for (const auto &label : labels)
{ {
if (label.Type() == PlaceLabelType::Doubletree || label.Type() == PlaceLabelType::Button if (label.Type() == PlaceLabelType::Doubletree || label.Type() == PlaceLabelType::Button ||
|| label.Type() == PlaceLabelType::Circle) label.Type() == PlaceLabelType::Circle)
{ {
const QPointF center = detail.GetMatrix().map(label.Center()); const QPointF center = detail.GetMatrix().map(label.Center());
QLineF diameter = detail.GetMatrix().map(QLineF(label.Box().bottomLeft(), label.Box().topRight())); QLineF diameter = detail.GetMatrix().map(QLineF(label.Box().bottomLeft(), label.Box().topRight()));
@ -1143,8 +1147,8 @@ void VDxfEngine::ExportASTMDrill(const QSharedPointer<dx_ifaceBlock> &detailBloc
detailBlock->ent.push_back(point.release()); detailBlock->ent.push_back(point.release());
// TODO. Investigate drill category // TODO. Investigate drill category
// QPointF pos(center.x(), center.y() - ToPixel(AAMATextHeight, m_varInsunits)); // QPointF pos(center.x(), center.y() - ToPixel(AAMATextHeight, m_varInsunits));
// detailBlock->ent.push_back(AAMAText(pos, category, *layer13)); // detailBlock->ent.push_back(AAMAText(pos, category, *layer13));
} }
} }
} }
@ -1155,7 +1159,7 @@ void VDxfEngine::ExportASTMNotch(const QSharedPointer<dx_ifaceBlock> &detailBloc
if (detail.IsSeamAllowance()) if (detail.IsSeamAllowance())
{ {
const QVector<VLayoutPassmark> passmarks = detail.GetMappedPassmarks(); const QVector<VLayoutPassmark> passmarks = detail.GetMappedPassmarks();
for(const auto &passmark : passmarks) for (const auto &passmark : passmarks)
{ {
auto *notch = new DRW_ASTMNotch(); auto *notch = new DRW_ASTMNotch();
const QPointF center = passmark.baseLine.p1(); const QPointF center = passmark.baseLine.p1();
@ -1238,7 +1242,7 @@ void VDxfEngine::ExportASTMNotch(const QSharedPointer<dx_ifaceBlock> &detailBloc
void VDxfEngine::ExportTurnPoints(const QSharedPointer<dx_ifaceBlock> &detailBlock, void VDxfEngine::ExportTurnPoints(const QSharedPointer<dx_ifaceBlock> &detailBlock,
const QVector<VLayoutPoint> &points) const const QVector<VLayoutPoint> &points) const
{ {
for(const auto &p : qAsConst(points)) for (const auto &p : qAsConst(points))
{ {
if (p.TurnPoint()) if (p.TurnPoint())
{ {
@ -1251,7 +1255,7 @@ void VDxfEngine::ExportTurnPoints(const QSharedPointer<dx_ifaceBlock> &detailBlo
void VDxfEngine::ExportCurvePoints(const QSharedPointer<dx_ifaceBlock> &detailBlock, void VDxfEngine::ExportCurvePoints(const QSharedPointer<dx_ifaceBlock> &detailBlock,
const QVector<VLayoutPoint> &points) const const QVector<VLayoutPoint> &points) const
{ {
for(const auto &p : qAsConst(points)) for (const auto &p : qAsConst(points))
{ {
if (p.CurvePoint() && not p.TurnPoint()) if (p.CurvePoint() && not p.TurnPoint())
{ {
@ -1261,8 +1265,8 @@ void VDxfEngine::ExportCurvePoints(const QSharedPointer<dx_ifaceBlock> &detailBl
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VDxfEngine::AAMAPolygon(const QVector<VLayoutPoint> &polygon, const UTF8STRING &layer, auto VDxfEngine::AAMAPolygon(const QVector<VLayoutPoint> &polygon, const UTF8STRING &layer, bool forceClosed)
bool forceClosed) -> DRW_Entity * -> DRW_Entity *
{ {
if (polygon.isEmpty()) if (polygon.isEmpty())
{ {
@ -1296,10 +1300,10 @@ auto VDxfEngine::AAMAText(const QPointF &pos, const QString &text, const UTF8STR
{ {
auto *textLine = new DRW_Text(); auto *textLine = new DRW_Text();
textLine->basePoint = DRW_Coord(FromPixel(pos.x(), m_varInsunits), textLine->basePoint =
FromPixel(GetSize().height() - pos.y(), m_varInsunits), 0); DRW_Coord(FromPixel(pos.x(), m_varInsunits), FromPixel(GetSize().height() - pos.y(), m_varInsunits), 0);
textLine->secPoint = DRW_Coord(FromPixel(pos.x(), m_varInsunits), textLine->secPoint =
FromPixel(GetSize().height() - pos.y(), m_varInsunits), 0); DRW_Coord(FromPixel(pos.x(), m_varInsunits), FromPixel(GetSize().height() - pos.y(), m_varInsunits), 0);
textLine->height = AAMATextHeight; textLine->height = AAMATextHeight;
textLine->layer = layer; textLine->layer = layer;
textLine->text = text.toStdString(); textLine->text = text.toStdString();
@ -1311,8 +1315,8 @@ auto VDxfEngine::AAMAText(const QPointF &pos, const QString &text, const UTF8STR
auto VDxfEngine::AAMAPoint(const QPointF &pos, const UTF8STRING &layer) const -> DRW_Point * auto VDxfEngine::AAMAPoint(const QPointF &pos, const UTF8STRING &layer) const -> DRW_Point *
{ {
auto *point = new DRW_Point(); auto *point = new DRW_Point();
point->basePoint = DRW_Coord(FromPixel(pos.x(), m_varInsunits), point->basePoint =
FromPixel(GetSize().height() - pos.y(), m_varInsunits), 0); DRW_Coord(FromPixel(pos.x(), m_varInsunits), FromPixel(GetSize().height() - pos.y(), m_varInsunits), 0);
point->layer = layer; point->layer = layer;
return point; return point;
} }
@ -1334,9 +1338,8 @@ auto VDxfEngine::GetFileNameForLocale() const -> std::string
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
template<class P, class V, class C> template <class P, class V, class C>
auto VDxfEngine::CreateAAMAPolygon(const QVector<C> &polygon, const UTF8STRING &layer, auto VDxfEngine::CreateAAMAPolygon(const QVector<C> &polygon, const UTF8STRING &layer, bool forceClosed) -> P *
bool forceClosed) -> P *
{ {
auto *poly = new P(); auto *poly = new P();
poly->layer = layer; poly->layer = layer;
@ -1355,8 +1358,7 @@ auto VDxfEngine::CreateAAMAPolygon(const QVector<C> &polygon, const UTF8STRING &
for (const auto &p : polygon) for (const auto &p : polygon)
{ {
poly->addVertex(V(FromPixel(p.x(), m_varInsunits), poly->addVertex(V(FromPixel(p.x(), m_varInsunits), FromPixel(GetSize().height() - p.y(), m_varInsunits)));
FromPixel(GetSize().height() - p.y(), m_varInsunits)));
} }
return poly; return poly;

View File

@ -29,13 +29,13 @@
#ifndef VDXFENGINE_H #ifndef VDXFENGINE_H
#define VDXFENGINE_H #define VDXFENGINE_H
#include <qcompilerdetection.h>
#include <QPaintEngine> #include <QPaintEngine>
#include <QPointF> #include <QPointF>
#include <QRectF> #include <QRectF>
#include <QSize> #include <QSize>
#include <QString> #include <QString>
#include <QtGlobal> #include <QtGlobal>
#include <qcompilerdetection.h>
#include <string> #include <string>
#include "../vmisc/def.h" #include "../vmisc/def.h"
@ -59,6 +59,7 @@ class VTextCodec;
class VDxfEngine final : public QPaintEngine class VDxfEngine final : public QPaintEngine
{ {
friend class VDxfPaintDevice; friend class VDxfPaintDevice;
public: public:
VDxfEngine(); VDxfEngine();
~VDxfEngine() override; ~VDxfEngine() override;
@ -71,13 +72,13 @@ public:
void updateState(const QPaintEngineState &state) override; void updateState(const QPaintEngineState &state) override;
void drawPath(const QPainterPath &path) override; void drawPath(const QPainterPath &path) override;
void drawLines(const QLineF * lines, int lineCount) override; void drawLines(const QLineF *lines, int lineCount) override;
void drawLines(const QLine * lines, int lineCount) override; void drawLines(const QLine *lines, int lineCount) override;
void drawPolygon(const QPointF *points, int pointCount, PolygonDrawMode mode) override; void drawPolygon(const QPointF *points, int pointCount, PolygonDrawMode mode) override;
void drawPolygon(const QPoint *points, int pointCount, PolygonDrawMode mode) override; void drawPolygon(const QPoint *points, int pointCount, PolygonDrawMode mode) override;
void drawEllipse(const QRectF & rect) override; void drawEllipse(const QRectF &rect) override;
void drawEllipse(const QRect & rect) override; void drawEllipse(const QRect &rect) override;
void drawTextItem(const QPointF & p, const QTextItem & textItem) override; void drawTextItem(const QPointF &p, const QTextItem &textItem) override;
void drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr) override; void drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr) override;
auto GetSize() const -> QSize; auto GetSize() const -> QSize;
@ -147,20 +148,18 @@ private:
void ExportASTMDrill(const QSharedPointer<dx_ifaceBlock> &detailBlock, const VLayoutPiece &detail); void ExportASTMDrill(const QSharedPointer<dx_ifaceBlock> &detailBlock, const VLayoutPiece &detail);
void ExportASTMNotch(const QSharedPointer<dx_ifaceBlock> &detailBlock, const VLayoutPiece &detail); void ExportASTMNotch(const QSharedPointer<dx_ifaceBlock> &detailBlock, const VLayoutPiece &detail);
void ExportTurnPoints(const QSharedPointer<dx_ifaceBlock> &detailBlock, void ExportTurnPoints(const QSharedPointer<dx_ifaceBlock> &detailBlock, const QVector<VLayoutPoint> &points) const;
const QVector<VLayoutPoint> &points) const; void ExportCurvePoints(const QSharedPointer<dx_ifaceBlock> &detailBlock, const QVector<VLayoutPoint> &points) const;
void ExportCurvePoints(const QSharedPointer<dx_ifaceBlock> &detailBlock,
const QVector<VLayoutPoint> &points) const;
Q_REQUIRED_RESULT auto AAMAPolygon(const QVector<VLayoutPoint> &polygon, const UTF8STRING &layer, Q_REQUIRED_RESULT auto AAMAPolygon(const QVector<VLayoutPoint> &polygon, const UTF8STRING &layer, bool forceClosed)
bool forceClosed) -> DRW_Entity *; -> DRW_Entity *;
Q_REQUIRED_RESULT auto AAMALine(const QLineF &line, const UTF8STRING &layer) -> DRW_Entity *; Q_REQUIRED_RESULT auto AAMALine(const QLineF &line, const UTF8STRING &layer) -> DRW_Entity *;
Q_REQUIRED_RESULT auto AAMAText(const QPointF &pos, const QString &text, const UTF8STRING &layer) -> DRW_Entity *; Q_REQUIRED_RESULT auto AAMAText(const QPointF &pos, const QString &text, const UTF8STRING &layer) -> DRW_Entity *;
Q_REQUIRED_RESULT auto AAMAPoint(const QPointF &pos, const UTF8STRING &layer) const -> DRW_Point *; Q_REQUIRED_RESULT auto AAMAPoint(const QPointF &pos, const UTF8STRING &layer) const -> DRW_Point *;
template<class P, class V, class C> template <class P, class V, class C>
Q_REQUIRED_RESULT auto CreateAAMAPolygon(const QVector<C> &polygon, const UTF8STRING &layer, Q_REQUIRED_RESULT auto CreateAAMAPolygon(const QVector<C> &polygon, const UTF8STRING &layer, bool forceClosed)
bool forceClosed) -> P *; -> P *;
static auto FromUnicodeToCodec(const QString &str, VTextCodec *codec) -> std::string; static auto FromUnicodeToCodec(const QString &str, VTextCodec *codec) -> std::string;
auto GetFileNameForLocale() const -> std::string; auto GetFileNameForLocale() const -> std::string;

View File

@ -33,32 +33,33 @@
#include "vdxfengine.h" #include "vdxfengine.h"
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VDxfPaintDevice::VDxfPaintDevice() VDxfPaintDevice::VDxfPaintDevice()
:m_engine(new VDxfEngine()) : m_engine(new VDxfEngine())
{} {
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VDxfPaintDevice::~VDxfPaintDevice() VDxfPaintDevice::~VDxfPaintDevice()
{ {
delete m_engine; delete m_engine;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
// cppcheck-suppress unusedFunction // cppcheck-suppress unusedFunction
auto VDxfPaintDevice::paintEngine() const -> QPaintEngine * auto VDxfPaintDevice::paintEngine() const -> QPaintEngine *
{ {
return m_engine; return m_engine;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
// cppcheck-suppress unusedFunction // cppcheck-suppress unusedFunction
auto VDxfPaintDevice::GetFileName() const -> QString auto VDxfPaintDevice::GetFileName() const -> QString
{ {
return m_fileName; return m_fileName;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VDxfPaintDevice::SetFileName(const QString &value) void VDxfPaintDevice::SetFileName(const QString &value)
{ {
if (m_engine->isActive()) if (m_engine->isActive())
@ -71,13 +72,13 @@ void VDxfPaintDevice::SetFileName(const QString &value)
m_engine->SetFileName(m_fileName); m_engine->SetFileName(m_fileName);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VDxfPaintDevice::GetSize() -> QSize auto VDxfPaintDevice::GetSize() -> QSize
{ {
return m_engine->GetSize(); return m_engine->GetSize();
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VDxfPaintDevice::SetSize(const QSize &size) void VDxfPaintDevice::SetSize(const QSize &size)
{ {
if (m_engine->isActive()) if (m_engine->isActive())
@ -88,13 +89,13 @@ void VDxfPaintDevice::SetSize(const QSize &size)
m_engine->SetSize(size); m_engine->SetSize(size);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VDxfPaintDevice::GetResolution() const -> double auto VDxfPaintDevice::GetResolution() const -> double
{ {
return m_engine->GetResolution(); return m_engine->GetResolution();
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VDxfPaintDevice::SetResolution(double dpi) void VDxfPaintDevice::SetResolution(double dpi)
{ {
if (m_engine->isActive()) if (m_engine->isActive())

View File

@ -29,11 +29,11 @@
#ifndef VDXFPAINTDEVICE_H #ifndef VDXFPAINTDEVICE_H
#define VDXFPAINTDEVICE_H #define VDXFPAINTDEVICE_H
#include <qcompilerdetection.h>
#include <QPaintDevice> #include <QPaintDevice>
#include <QSize> #include <QSize>
#include <QString> #include <QString>
#include <QtGlobal> #include <QtGlobal>
#include <qcompilerdetection.h>
#include "dxfdef.h" #include "dxfdef.h"
#include "libdxfrw/drw_base.h" #include "libdxfrw/drw_base.h"
@ -80,6 +80,7 @@ public:
protected: protected:
auto metric(PaintDeviceMetric metric) const -> int override; auto metric(PaintDeviceMetric metric) const -> int override;
private: private:
// cppcheck-suppress unknownMacro // cppcheck-suppress unknownMacro
Q_DISABLE_COPY_MOVE(VDxfPaintDevice) // NOLINT Q_DISABLE_COPY_MOVE(VDxfPaintDevice) // NOLINT

View File

@ -28,33 +28,36 @@
#include "vmeasurements.h" #include "vmeasurements.h"
#include <qnumeric.h>
#include <QDate> #include <QDate>
#include <QDomNode> #include <QDomNode>
#include <QDomNodeList> #include <QDomNodeList>
#include <QDomText> #include <QDomText>
#include <QGlobalStatic>
#include <QLatin1Char> #include <QLatin1Char>
#include <QMessageLogger> #include <QMessageLogger>
#include <QScopedPointer> #include <QScopedPointer>
#include <QSet> #include <QSet>
#include <QtDebug> #include <QtDebug>
#include <QGlobalStatic> #include <qnumeric.h>
#include "../ifc/exception/vexceptionemptyparameter.h"
#include "../ifc/exception/vexceptionobjecterror.h" #include "../ifc/exception/vexceptionobjecterror.h"
#include "../ifc/ifcdef.h"
#include "../ifc/xml/vvitconverter.h" #include "../ifc/xml/vvitconverter.h"
#include "../ifc/xml/vvstconverter.h" #include "../ifc/xml/vvstconverter.h"
#include "../ifc/ifcdef.h"
#include "../qmuparser/qmutokenparser.h"
#include "../qmuparser/qmuparsererror.h" #include "../qmuparser/qmuparsererror.h"
#include "../qmuparser/qmutokenparser.h"
#include "../vmisc/projectversion.h"
#include "../vpatterndb/calculator.h" #include "../vpatterndb/calculator.h"
#include "../vpatterndb/variables/vmeasurement.h"
#include "../vpatterndb/vcontainer.h"
#include "../vpatterndb/measurements.h" #include "../vpatterndb/measurements.h"
#include "../vpatterndb/pmsystems.h" #include "../vpatterndb/pmsystems.h"
#include "../vmisc/projectversion.h" #include "../vpatterndb/variables/vmeasurement.h"
#include "../vpatterndb/vcontainer.h"
#include "def.h" #include "def.h"
#if QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
#include "../vmisc/diagnostic.h"
#endif // QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
const QString VMeasurements::TagVST = QStringLiteral("vst"); const QString VMeasurements::TagVST = QStringLiteral("vst");
const QString VMeasurements::TagVIT = QStringLiteral("vit"); const QString VMeasurements::TagVIT = QStringLiteral("vit");
const QString VMeasurements::TagBodyMeasurements = QStringLiteral("body-measurements"); const QString VMeasurements::TagBodyMeasurements = QStringLiteral("body-measurements");
@ -109,26 +112,27 @@ const QString VMeasurements::DimensionZ = QStringLiteral("z");
namespace namespace
{ {
QT_WARNING_PUSH
QT_WARNING_DISABLE_CLANG("-Wunused-member-function")
Q_GLOBAL_STATIC_WITH_ARGS(const QString, defBirthDate, (QLatin1String("1800-01-01"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, defBirthDate, (QLatin1String("1800-01-01"))) // NOLINT
QT_WARNING_POP
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto FileComment() -> QString auto FileComment() -> QString
{ {
return QString("Measurements created with Valentina v%1 (https://smart-pattern.com.ua/).") return QString("Measurements created with Valentina v%1 (https://smart-pattern.com.ua/).").arg(APP_VERSION_STR);
.arg(APP_VERSION_STR);
}
} }
} // namespace
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VMeasurements::VMeasurements(VContainer *data) VMeasurements::VMeasurements(VContainer *data)
: data(data), : data(data),
type(MeasurementsType::Unknown) type(MeasurementsType::Unknown){SCASSERT(data != nullptr)}
{
SCASSERT(data != nullptr)
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VMeasurements::VMeasurements(Unit unit, VContainer *data) VMeasurements::VMeasurements(Unit unit, VContainer * data)
: data(data), : data(data),
type(MeasurementsType::Individual) type(MeasurementsType::Individual)
{ {
@ -138,8 +142,7 @@ VMeasurements::VMeasurements(Unit unit, VContainer *data)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VMeasurements::VMeasurements(Unit unit, const QVector<MeasurementDimension_p > &dimensions, VMeasurements::VMeasurements(Unit unit, const QVector<MeasurementDimension_p> &dimensions, VContainer *data)
VContainer *data)
: data(data), : data(data),
type(MeasurementsType::Multisize) type(MeasurementsType::Multisize)
{ {
@ -295,7 +298,7 @@ void VMeasurements::MoveBottom(const QString &name)
const QDomNodeList mList = elementsByTagName(TagMeasurement); const QDomNodeList mList = elementsByTagName(TagMeasurement);
if (mList.size() >= 2) if (mList.size() >= 2)
{ {
const QDomNode bottom = mList.at(mList.size()-1); const QDomNode bottom = mList.at(mList.size() - 1);
if (not bottom.isNull()) if (not bottom.isNull())
{ {
const QDomNodeList list = elementsByTagName(TagBodyMeasurements); const QDomNodeList list = elementsByTagName(TagBodyMeasurements);
@ -333,7 +336,7 @@ void VMeasurements::ReadMeasurements(qreal baseA, qreal baseB, qreal baseC) cons
} }
const QDomNodeList list = elementsByTagName(TagMeasurement); const QDomNodeList list = elementsByTagName(TagMeasurement);
for (int i=0; i < list.size(); ++i) for (int i = 0; i < list.size(); ++i)
{ {
const QDomElement dom = list.at(i).toElement(); const QDomElement dom = list.at(i).toElement();
@ -387,8 +390,8 @@ void VMeasurements::ReadMeasurements(qreal baseA, qreal baseB, qreal baseC) cons
convertedStepC = UnitConvertor(convertedStepC, Units(), *data->GetPatternUnit()); convertedStepC = UnitConvertor(convertedStepC, Units(), *data->GetPatternUnit());
} }
meash = QSharedPointer<VMeasurement>::create(static_cast<quint32>(i), name, meash = QSharedPointer<VMeasurement>::create(static_cast<quint32>(i), name, convertedBaseA,
convertedBaseA, convertedBaseB, convertedBaseC, base); convertedBaseB, convertedBaseC, base);
meash->SetBaseA(baseA); meash->SetBaseA(baseA);
meash->SetBaseB(baseB); meash->SetBaseB(baseB);
meash->SetBaseC(baseC); meash->SetBaseC(baseC);
@ -459,7 +462,7 @@ void VMeasurements::ClearForExport()
{ {
const QDomNodeList list = elementsByTagName(TagMeasurement); const QDomNodeList list = elementsByTagName(TagMeasurement);
for (int i=0; i < list.size(); ++i) for (int i = 0; i < list.size(); ++i)
{ {
QDomElement domElement = list.at(i).toElement(); QDomElement domElement = list.at(i).toElement();
if (not domElement.isNull()) if (not domElement.isNull())
@ -701,11 +704,12 @@ void VMeasurements::SetFullCircumference(bool fc)
QDomElement dimenstionsTag = documentElement().firstChildElement(TagDimensions); QDomElement dimenstionsTag = documentElement().firstChildElement(TagDimensions);
if (not dimenstionsTag.isNull()) if (not dimenstionsTag.isNull())
{ {
SetAttributeOrRemoveIf<bool>(dimenstionsTag, AttrFullCircumference, fc, [](bool fc) noexcept {return not fc;}); SetAttributeOrRemoveIf<bool>(dimenstionsTag, AttrFullCircumference, fc,
[](bool fc) noexcept { return not fc; });
} }
else else
{ {
qDebug()<<"Can't save full circumference "<<Q_FUNC_INFO; qDebug() << "Can't save full circumference " << Q_FUNC_INFO;
} }
} }
@ -799,7 +803,8 @@ void VMeasurements::SetMSpecialUnits(const QString &name, bool special)
QDomElement node = FindM(name); QDomElement node = FindM(name);
if (not node.isNull()) if (not node.isNull())
{ {
SetAttributeOrRemoveIf<bool>(node, AttrSpecialUnits, special, [](bool special) noexcept {return not special;}); SetAttributeOrRemoveIf<bool>(node, AttrSpecialUnits, special,
[](bool special) noexcept { return not special; });
} }
else else
{ {
@ -873,7 +878,7 @@ void VMeasurements::SetMDimension(const QString &name, IMD type)
{ {
SetAttributeOrRemoveIf<QString>(node, AttrDimension, VMeasurements::IMDToStr(type), SetAttributeOrRemoveIf<QString>(node, AttrDimension, VMeasurements::IMDToStr(type),
[](const QString &type) noexcept [](const QString &type) noexcept
{return type == VMeasurements::IMDToStr(IMD::N);}); { return type == VMeasurements::IMDToStr(IMD::N); });
} }
else else
{ {
@ -887,7 +892,7 @@ auto VMeasurements::MeasurementForDimension(IMD type) const -> QString
const QString d = VMeasurements::IMDToStr(type); const QString d = VMeasurements::IMDToStr(type);
QDomNodeList list = elementsByTagName(TagMeasurement); QDomNodeList list = elementsByTagName(TagMeasurement);
for (int i=0; i < list.size(); ++i) for (int i = 0; i < list.size(); ++i)
{ {
const QDomElement domElement = list.at(i).toElement(); const QDomElement domElement = list.at(i).toElement();
if (domElement.isNull() == false) if (domElement.isNull() == false)
@ -908,12 +913,12 @@ auto VMeasurements::Dimensions() const -> VDimensions
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VMeasurements::GetRestrictions() const -> QMap<QString, VDimensionRestriction > auto VMeasurements::GetRestrictions() const -> QMap<QString, VDimensionRestriction>
{ {
QMap<QString, VDimensionRestriction > restrictions; QMap<QString, VDimensionRestriction> restrictions;
const QDomNodeList list = elementsByTagName(TagRestriction); const QDomNodeList list = elementsByTagName(TagRestriction);
for (int i=0; i < list.size(); ++i) for (int i = 0; i < list.size(); ++i)
{ {
const QDomElement res = list.at(i).toElement(); const QDomElement res = list.at(i).toElement();
@ -948,11 +953,11 @@ void VMeasurements::SetRestrictions(const QMap<QString, VDimensionRestriction> &
SetAttribute(restrictionTag, AttrCoordinates, i.key()); SetAttribute(restrictionTag, AttrCoordinates, i.key());
SetAttributeOrRemoveIf<qreal>(restrictionTag, AttrMin, i.value().GetMin(), SetAttributeOrRemoveIf<qreal>(restrictionTag, AttrMin, i.value().GetMin(),
[](qreal min) noexcept {return qFuzzyIsNull(min);}); [](qreal min) noexcept { return qFuzzyIsNull(min); });
SetAttributeOrRemoveIf<qreal>(restrictionTag, AttrMax, i.value().GetMax(), SetAttributeOrRemoveIf<qreal>(restrictionTag, AttrMax, i.value().GetMax(),
[](qreal max) noexcept {return qFuzzyIsNull(max);}); [](qreal max) noexcept { return qFuzzyIsNull(max); });
SetAttributeOrRemoveIf<QString>(restrictionTag, AttrExclude, i.value().GetExcludeString(), SetAttributeOrRemoveIf<QString>(restrictionTag, AttrExclude, i.value().GetExcludeString(),
[](const QString &exlcuded) noexcept {return exlcuded.isEmpty();}); [](const QString &exlcuded) noexcept { return exlcuded.isEmpty(); });
restrictionsTag.appendChild(restrictionTag); restrictionsTag.appendChild(restrictionTag);
++i; ++i;
@ -962,7 +967,7 @@ void VMeasurements::SetRestrictions(const QMap<QString, VDimensionRestriction> &
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VMeasurements::Restriction(qreal base, qreal base2) const -> VDimensionRestriction auto VMeasurements::Restriction(qreal base, qreal base2) const -> VDimensionRestriction
{ {
const QMap<QString, VDimensionRestriction > restrictions = GetRestrictions(); const QMap<QString, VDimensionRestriction> restrictions = GetRestrictions();
const QString hash = VMeasurement::CorrectionHash(base, base2, 0); const QString hash = VMeasurement::CorrectionHash(base, base2, 0);
return restrictions.value(hash); return restrictions.value(hash);
} }
@ -971,7 +976,7 @@ auto VMeasurements::Restriction(qreal base, qreal base2) const -> VDimensionRest
void VMeasurements::SetDimensionLabels(const QMap<MeasurementDimension, DimesionLabels> &labels) void VMeasurements::SetDimensionLabels(const QMap<MeasurementDimension, DimesionLabels> &labels)
{ {
const QDomNodeList list = elementsByTagName(TagDimension); const QDomNodeList list = elementsByTagName(TagDimension);
for (int i=0; i < list.size(); ++i) for (int i = 0; i < list.size(); ++i)
{ {
QDomElement dom = list.at(i).toElement(); QDomElement dom = list.at(i).toElement();
const MeasurementDimension type = StrToDimensionType(GetParametrString(dom, AttrType)); const MeasurementDimension type = StrToDimensionType(GetParametrString(dom, AttrType));
@ -989,7 +994,7 @@ void VMeasurements::SetDimensionLabels(const QMap<MeasurementDimension, Dimesion
void VMeasurements::SetDimensionCustomNames(const QMap<MeasurementDimension, QString> &names) void VMeasurements::SetDimensionCustomNames(const QMap<MeasurementDimension, QString> &names)
{ {
const QDomNodeList list = elementsByTagName(TagDimension); const QDomNodeList list = elementsByTagName(TagDimension);
for (int i=0; i < list.size(); ++i) for (int i = 0; i < list.size(); ++i)
{ {
QDomElement dom = list.at(i).toElement(); QDomElement dom = list.at(i).toElement();
const MeasurementDimension type = StrToDimensionType(GetParametrString(dom, AttrType)); const MeasurementDimension type = StrToDimensionType(GetParametrString(dom, AttrType));
@ -997,7 +1002,7 @@ void VMeasurements::SetDimensionCustomNames(const QMap<MeasurementDimension, QSt
if (names.contains(type)) if (names.contains(type))
{ {
SetAttributeOrRemoveIf<QString>(dom, AttrCustomName, names.value(type), SetAttributeOrRemoveIf<QString>(dom, AttrCustomName, names.value(type),
[](const QString &name) noexcept {return name.isEmpty();}); [](const QString &name) noexcept { return name.isEmpty(); });
} }
} }
@ -1112,7 +1117,7 @@ auto VMeasurements::StrToIMD(const QString &type) -> IMD
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VMeasurements::IMDName(IMD type) -> QString auto VMeasurements::IMDName(IMD type) -> QString
{ {
switch(type) switch (type)
{ {
case IMD::N: case IMD::N:
return tr("None"); return tr("None");
@ -1135,7 +1140,7 @@ auto VMeasurements::ListAll() const -> QStringList
QStringList listNames; QStringList listNames;
const QDomNodeList list = elementsByTagName(TagMeasurement); const QDomNodeList list = elementsByTagName(TagMeasurement);
for (int i=0; i < list.size(); ++i) for (int i = 0; i < list.size(); ++i)
{ {
const QDomElement domElement = list.at(i).toElement(); const QDomElement domElement = list.at(i).toElement();
if (domElement.isNull() == false) if (domElement.isNull() == false)
@ -1152,7 +1157,7 @@ auto VMeasurements::ListKnown() const -> QStringList
{ {
QStringList listNames; QStringList listNames;
const QStringList list = ListAll(); const QStringList list = ListAll();
for (int i=0; i < list.size(); ++i) for (int i = 0; i < list.size(); ++i)
{ {
if (list.at(i).indexOf(CustomMSign) != 0) if (list.at(i).indexOf(CustomMSign) != 0)
{ {
@ -1193,8 +1198,7 @@ auto VMeasurements::GetData() const -> VContainer *
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VMeasurements::CreateEmptyMultisizeFile(Unit unit, void VMeasurements::CreateEmptyMultisizeFile(Unit unit, const QVector<MeasurementDimension_p> &dimensions)
const QVector<MeasurementDimension_p > &dimensions)
{ {
this->clear(); this->clear();
QDomElement mElement = this->createElement(TagVST); QDomElement mElement = this->createElement(TagVST);
@ -1210,8 +1214,9 @@ void VMeasurements::CreateEmptyMultisizeFile(Unit unit,
mElement.appendChild(createElement(TagBodyMeasurements)); mElement.appendChild(createElement(TagBodyMeasurements));
this->appendChild(mElement); this->appendChild(mElement);
insertBefore(createProcessingInstruction(QStringLiteral("xml"), insertBefore(
QStringLiteral("version=\"1.0\" encoding=\"UTF-8\"")), this->firstChild()); createProcessingInstruction(QStringLiteral("xml"), QStringLiteral("version=\"1.0\" encoding=\"UTF-8\"")),
this->firstChild());
// Cache data // Cache data
m_units = unit; m_units = unit;
@ -1242,8 +1247,9 @@ void VMeasurements::CreateEmptyIndividualFile(Unit unit)
mElement.appendChild(createElement(TagBodyMeasurements)); mElement.appendChild(createElement(TagBodyMeasurements));
this->appendChild(mElement); this->appendChild(mElement);
insertBefore(createProcessingInstruction(QStringLiteral("xml"), insertBefore(
QStringLiteral("version=\"1.0\" encoding=\"UTF-8\"")), this->firstChild()); createProcessingInstruction(QStringLiteral("xml"), QStringLiteral("version=\"1.0\" encoding=\"UTF-8\"")),
this->firstChild());
// Cache data // Cache data
m_units = unit; m_units = unit;
@ -1251,11 +1257,11 @@ void VMeasurements::CreateEmptyIndividualFile(Unit unit)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VMeasurements::CreateDimensions(const QVector<MeasurementDimension_p > &dimensions) -> QDomElement auto VMeasurements::CreateDimensions(const QVector<MeasurementDimension_p> &dimensions) -> QDomElement
{ {
QDomElement dimensionsTag = createElement(TagDimensions); QDomElement dimensionsTag = createElement(TagDimensions);
for(const auto &dimension : dimensions) for (const auto &dimension : dimensions)
{ {
QDomElement dimensionTag = createElement(TagDimension); QDomElement dimensionTag = createElement(TagDimension);
@ -1265,9 +1271,9 @@ auto VMeasurements::CreateDimensions(const QVector<MeasurementDimension_p > &dim
SetAttribute(dimensionTag, AttrMax, dimension->MaxValue()); SetAttribute(dimensionTag, AttrMax, dimension->MaxValue());
SetAttribute(dimensionTag, AttrStep, dimension->Step()); SetAttribute(dimensionTag, AttrStep, dimension->Step());
SetAttributeOrRemoveIf<bool>(dimensionTag, AttrMeasurement, dimension->IsBodyMeasurement(), SetAttributeOrRemoveIf<bool>(dimensionTag, AttrMeasurement, dimension->IsBodyMeasurement(),
[](bool m) noexcept {return m;}); [](bool m) noexcept { return m; });
SetAttributeOrRemoveIf<QString>(dimensionTag, AttrCustomName, dimension->CustomName(), SetAttributeOrRemoveIf<QString>(dimensionTag, AttrCustomName, dimension->CustomName(),
[](const QString &name) noexcept {return name.isEmpty();}); [](const QString &name) noexcept { return name.isEmpty(); });
dimensionsTag.appendChild(dimensionTag); dimensionsTag.appendChild(dimensionTag);
} }
@ -1337,7 +1343,7 @@ auto VMeasurements::FindM(const QString &name) const -> QDomElement
QDomNodeList list = elementsByTagName(TagMeasurement); QDomNodeList list = elementsByTagName(TagMeasurement);
for (int i=0; i < list.size(); ++i) for (int i = 0; i < list.size(); ++i)
{ {
const QDomElement domElement = list.at(i).toElement(); const QDomElement domElement = list.at(i).toElement();
if (domElement.isNull() == false) if (domElement.isNull() == false)
@ -1396,7 +1402,7 @@ auto VMeasurements::ReadDimensions() const -> VDimensions
const Unit units = Units(); const Unit units = Units();
const QDomNodeList list = elementsByTagName(TagDimension); const QDomNodeList list = elementsByTagName(TagDimension);
for (int i=0; i < list.size(); ++i) for (int i = 0; i < list.size(); ++i)
{ {
const QDomElement dom = list.at(i).toElement(); const QDomElement dom = list.at(i).toElement();
const MeasurementDimension type = StrToDimensionType(GetParametrString(dom, AttrType)); const MeasurementDimension type = StrToDimensionType(GetParametrString(dom, AttrType));
@ -1639,7 +1645,7 @@ void VMeasurements::ClearDimension(IMD type)
const QString d = VMeasurements::IMDToStr(type); const QString d = VMeasurements::IMDToStr(type);
QDomNodeList list = elementsByTagName(TagMeasurement); QDomNodeList list = elementsByTagName(TagMeasurement);
for (int i=0; i < list.size(); ++i) for (int i = 0; i < list.size(); ++i)
{ {
QDomElement domElement = list.at(i).toElement(); QDomElement domElement = list.at(i).toElement();
if (domElement.isNull() == false) if (domElement.isNull() == false)

View File

@ -51,14 +51,23 @@
#include "vprintlayout.h" #include "vprintlayout.h"
#include "vrawlayout.h" #include "vrawlayout.h"
#if QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
#include "../vmisc/diagnostic.h"
#endif // QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
namespace namespace
{ {
QT_WARNING_PUSH
QT_WARNING_DISABLE_CLANG("-Wunused-member-function")
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
Q_GLOBAL_STATIC_WITH_ARGS(const QString, PDFTOPS, (QLatin1String("pdftops.exe"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, PDFTOPS, (QLatin1String("pdftops.exe"))) // NOLINT
#else #else
Q_GLOBAL_STATIC_WITH_ARGS(const QString, PDFTOPS, (QLatin1String("pdftops"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, PDFTOPS, (QLatin1String("pdftops"))) // NOLINT
#endif #endif
QT_WARNING_POP
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief PrepareTextForDXF prepare QGraphicsSimpleTextItem items for export to flat dxf. * @brief PrepareTextForDXF prepare QGraphicsSimpleTextItem items for export to flat dxf.
@ -77,7 +86,7 @@ void PrepareDetailsForDXF(const QString &placeholder, const QList<QGraphicsItem
{ {
if (child->type() == QGraphicsSimpleTextItem::Type) if (child->type() == QGraphicsSimpleTextItem::Type)
{ {
if(auto *textItem = qgraphicsitem_cast<QGraphicsSimpleTextItem *>(child)) if (auto *textItem = qgraphicsitem_cast<QGraphicsSimpleTextItem *>(child))
{ {
textItem->setText(textItem->text() + placeholder); textItem->setText(textItem->text() + placeholder);
} }
@ -104,7 +113,7 @@ void RestoreDetailsAfterDXF(const QString &placeholder, const QList<QGraphicsIte
{ {
if (child->type() == QGraphicsSimpleTextItem::Type) if (child->type() == QGraphicsSimpleTextItem::Type)
{ {
if(auto *textItem = qgraphicsitem_cast<QGraphicsSimpleTextItem *>(child)) if (auto *textItem = qgraphicsitem_cast<QGraphicsSimpleTextItem *>(child))
{ {
QString text = textItem->text(); QString text = textItem->text();
text.replace(placeholder, QString()); text.replace(placeholder, QString());
@ -283,7 +292,7 @@ void VLayoutExporter::ExportToFlatDXF(QGraphicsScene *scene, const QList<QGraphi
generator.SetResolution(PrintDPI); generator.SetResolution(PrintDPI);
generator.SetVersion(static_cast<DRW::Version>(m_dxfVersion)); generator.SetVersion(static_cast<DRW::Version>(m_dxfVersion));
generator.SetBinaryFormat(m_binaryDxfFormat); generator.SetBinaryFormat(m_binaryDxfFormat);
generator.SetInsunits(VarInsunits::Millimeters);// Decided to always use mm. See issue #745 generator.SetInsunits(VarInsunits::Millimeters); // Decided to always use mm. See issue #745
QPainter painter; QPainter painter;
if (painter.begin(&generator)) if (painter.begin(&generator))
@ -292,8 +301,7 @@ void VLayoutExporter::ExportToFlatDXF(QGraphicsScene *scene, const QList<QGraphi
scene->render(&painter, m_imageRect, m_imageRect, Qt::IgnoreAspectRatio); scene->render(&painter, m_imageRect, m_imageRect, Qt::IgnoreAspectRatio);
if (not painter.end()) if (not painter.end())
{ {
qCritical() << tr("Can't create a flat dxf file.") qCritical() << tr("Can't create a flat dxf file.") << generator.ErrorString();
<< generator.ErrorString();
} }
} }
@ -310,13 +318,12 @@ void VLayoutExporter::ExportToAAMADXF(const QVector<VLayoutPiece> &details) cons
generator.SetResolution(PrintDPI); generator.SetResolution(PrintDPI);
generator.SetVersion(static_cast<DRW::Version>(m_dxfVersion)); generator.SetVersion(static_cast<DRW::Version>(m_dxfVersion));
generator.SetBinaryFormat(m_binaryDxfFormat); generator.SetBinaryFormat(m_binaryDxfFormat);
generator.SetInsunits(VarInsunits::Millimeters);// Decided to always use mm. See issue #745 generator.SetInsunits(VarInsunits::Millimeters); // Decided to always use mm. See issue #745
generator.SetXScale(m_xScale); generator.SetXScale(m_xScale);
generator.SetYScale(m_yScale); generator.SetYScale(m_yScale);
if (not generator.ExportToAAMA(details)) if (not generator.ExportToAAMA(details))
{ {
qCritical() << tr("Can't create an AAMA dxf file.") qCritical() << tr("Can't create an AAMA dxf file.") << generator.ErrorString();
<< generator.ErrorString();
} }
} }
@ -329,13 +336,12 @@ void VLayoutExporter::ExportToASTMDXF(const QVector<VLayoutPiece> &details) cons
generator.SetResolution(PrintDPI); generator.SetResolution(PrintDPI);
generator.SetVersion(static_cast<DRW::Version>(m_dxfVersion)); generator.SetVersion(static_cast<DRW::Version>(m_dxfVersion));
generator.SetBinaryFormat(m_binaryDxfFormat); generator.SetBinaryFormat(m_binaryDxfFormat);
generator.SetInsunits(VarInsunits::Millimeters);// Decided to always use mm. See issue #745 generator.SetInsunits(VarInsunits::Millimeters); // Decided to always use mm. See issue #745
generator.SetXScale(m_xScale); generator.SetXScale(m_xScale);
generator.SetYScale(m_yScale); generator.SetYScale(m_yScale);
if (not generator.ExportToASTM(details)) if (not generator.ExportToASTM(details))
{ {
qCritical() << tr("Can't create an ASTM dxf file.") qCritical() << tr("Can't create an ASTM dxf file.") << generator.ErrorString();
<< generator.ErrorString();
} }
} }
@ -345,7 +351,7 @@ void VLayoutExporter::ExportToRLD(const QVector<VLayoutPiece> &details) const
QVector<VLayoutPiece> scaledPieces; QVector<VLayoutPiece> scaledPieces;
scaledPieces.reserve(details.size()); scaledPieces.reserve(details.size());
for(auto detail : details) for (auto detail : details)
{ {
detail.Scale(m_xScale, m_yScale); detail.Scale(m_xScale, m_yScale);
scaledPieces.append(detail); scaledPieces.append(detail);
@ -370,7 +376,7 @@ auto VLayoutExporter::SupportPDFConversion() -> bool
QProcess proc; QProcess proc;
#if defined(Q_OS_WIN) || defined(Q_OS_OSX) #if defined(Q_OS_WIN) || defined(Q_OS_OSX)
// Seek pdftops in app bundle or near valentina.exe // Seek pdftops in app bundle or near valentina.exe
proc.start(qApp->applicationDirPath() + QLatin1String("/")+ *PDFTOPS, QStringList()); proc.start(qApp->applicationDirPath() + QLatin1String("/") + *PDFTOPS, QStringList());
#else #else
proc.start(*PDFTOPS, QStringList()); // Seek pdftops in standard path proc.start(*PDFTOPS, QStringList()); // Seek pdftops in standard path
#endif #endif
@ -433,8 +439,8 @@ void VLayoutExporter::PdfToPs(const QStringList &params)
QFile f(ConstLast<QString>(params)); QFile f(ConstLast<QString>(params));
if (not f.exists()) if (not f.exists())
{ {
qCritical() << qUtf8Printable(tr("Creating file '%1' failed! %2") qCritical() << qUtf8Printable(
.arg(ConstLast<QString>(params), proc.errorString())); tr("Creating file '%1' failed! %2").arg(ConstLast<QString>(params), proc.errorString()));
} }
} }
@ -453,8 +459,8 @@ void VLayoutExporter::ExportToPDF(QGraphicsScene *scene, const QList<QGraphicsIt
printer.setResolution(static_cast<int>(PrintDPI)); printer.setResolution(static_cast<int>(PrintDPI));
printer.setFullPage(m_ignorePrinterMargins); printer.setFullPage(m_ignorePrinterMargins);
QPageLayout::Orientation imageOrientation = m_imageRect.height() >= m_imageRect.width() ? QPageLayout::Portrait QPageLayout::Orientation imageOrientation =
: QPageLayout::Landscape; m_imageRect.height() >= m_imageRect.width() ? QPageLayout::Portrait : QPageLayout::Landscape;
qreal width = FromPixel(m_imageRect.width() * m_xScale + m_margins.left() + m_margins.right(), Unit::Mm); qreal width = FromPixel(m_imageRect.width() * m_xScale + m_margins.left() + m_margins.right(), Unit::Mm);
qreal height = FromPixel(m_imageRect.height() * m_yScale + m_margins.top() + m_margins.bottom(), Unit::Mm); qreal height = FromPixel(m_imageRect.height() * m_yScale + m_margins.top() + m_margins.bottom(), Unit::Mm);
@ -504,7 +510,7 @@ auto VLayoutExporter::ExportFormatDescription(LayoutExportFormats format) -> QSt
const QString dxfFlatFilesStr = tr("(flat) files"); const QString dxfFlatFilesStr = tr("(flat) files");
const QString filesStr = tr("files"); const QString filesStr = tr("files");
switch(format) switch (format)
{ {
case LayoutExportFormats::SVG: case LayoutExportFormats::SVG:
return QStringLiteral("Svg %1 (*.svg)").arg(filesStr); return QStringLiteral("Svg %1 (*.svg)").arg(filesStr);
@ -556,7 +562,7 @@ auto VLayoutExporter::ExportFormatDescription(LayoutExportFormats format) -> QSt
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VLayoutExporter::ExportFormatSuffix(LayoutExportFormats format) -> QString auto VLayoutExporter::ExportFormatSuffix(LayoutExportFormats format) -> QString
{ {
switch(format) switch (format)
{ {
case LayoutExportFormats::SVG: case LayoutExportFormats::SVG:
return QStringLiteral(".svg"); return QStringLiteral(".svg");

View File

@ -28,11 +28,11 @@
#ifndef VLAYOUTEXPORTER_H #ifndef VLAYOUTEXPORTER_H
#define VLAYOUTEXPORTER_H #define VLAYOUTEXPORTER_H
#include <QCoreApplication>
#include <QMargins> #include <QMargins>
#include <QPen> #include <QPen>
#include <QRectF> #include <QRectF>
#include <QString> #include <QString>
#include <QCoreApplication>
#include "../vlayout/vlayoutdef.h" #include "../vlayout/vlayoutdef.h"
@ -43,6 +43,7 @@ class VLayoutPiece;
class VLayoutExporter class VLayoutExporter
{ {
Q_DECLARE_TR_FUNCTIONS(VLayoutExporter) // NOLINT Q_DECLARE_TR_FUNCTIONS(VLayoutExporter) // NOLINT
public: public:
VLayoutExporter() = default; VLayoutExporter() = default;

View File

@ -333,7 +333,7 @@ auto VLayoutPaper::GetPaperItem(bool autoCropLength, bool autoCropWidth, bool te
{ {
QScopedPointer<QGraphicsScene> scene(new QGraphicsScene()); QScopedPointer<QGraphicsScene> scene(new QGraphicsScene());
QList<QGraphicsItem *> list = GetItemDetails(textAsPaths); QList<QGraphicsItem *> list = GetItemDetails(textAsPaths);
for (auto item : list) for (auto *item : list)
{ {
scene->addItem(item); scene->addItem(item);
} }
@ -411,7 +411,7 @@ auto VLayoutPaper::GetGlobalContour() const -> QGraphicsPathItem *
path.lineTo(side2.p2()); path.lineTo(side2.p2());
} }
QGraphicsPathItem *item = new QGraphicsPathItem(path); auto *item = new QGraphicsPathItem(path);
QPen pen = item->pen(); QPen pen = item->pen();
pen.setWidthF(0.25); pen.setWidthF(0.25);
item->setPen(pen); item->setPen(pen);
@ -424,7 +424,7 @@ auto VLayoutPaper::GetItemDetails(bool textAsPaths) const -> QList<QGraphicsItem
{ {
QList<QGraphicsItem *> list; QList<QGraphicsItem *> list;
list.reserve(d->details.count()); list.reserve(d->details.count());
for (auto &detail : d->details) for (const auto &detail : d->details)
{ {
list.append(detail.GetItem(textAsPaths)); list.append(detail.GetItem(textAsPaths));
} }

View File

@ -60,13 +60,13 @@
#include "../vpatterndb/vcontainer.h" #include "../vpatterndb/vcontainer.h"
#include "../vpatterndb/vpassmark.h" #include "../vpatterndb/vpassmark.h"
#include "../vpatterndb/vpiecenode.h" #include "../vpatterndb/vpiecenode.h"
#include "qline.h"
#include "qpainterpath.h"
#include "vgobject.h" #include "vgobject.h"
#include "vgraphicsfillitem.h" #include "vgraphicsfillitem.h"
#include "vlayoutpiece_p.h" #include "vlayoutpiece_p.h"
#include "vpiecegrainline.h" #include "vpiecegrainline.h"
#include "vtextmanager.h" #include "vtextmanager.h"
#include <QLine>
#include <QPainterPath>
namespace namespace
{ {
@ -195,16 +195,19 @@ auto RotatePoint(const QPointF &ptCenter, const QPointF &pt, qreal dAng) -> QPoi
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto PieceLabelText(const QVector<QPointF> &labelShape, const VTextManager &tm) -> QStringList auto PieceLabelText(const QVector<QPointF> &labelShape, const VTextManager &tm) -> QStringList
{ {
QStringList text; if (labelShape.count() <= 2)
if (labelShape.count() > 2)
{ {
return {};
}
QStringList text;
auto sourceCount = tm.GetSourceLinesCount(); auto sourceCount = tm.GetSourceLinesCount();
text.reserve(sourceCount); text.reserve(sourceCount);
for (int i = 0; i < sourceCount; ++i) for (int i = 0; i < sourceCount; ++i)
{ {
text.append(tm.GetSourceLine(i).m_qsText); text.append(tm.GetSourceLine(i).m_qsText);
} }
}
return text; return text;
} }
@ -616,7 +619,8 @@ VLayoutPiece::VLayoutPiece(VLayoutPiece &&detail) Q_DECL_NOTHROW : VAbstractPiec
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VLayoutPiece::operator=(VLayoutPiece &&detail) Q_DECL_NOTHROW->VLayoutPiece & auto VLayoutPiece::operator=(VLayoutPiece &&detail) Q_DECL_NOTHROW
->VLayoutPiece &
{ {
VAbstractPiece::operator=(detail); VAbstractPiece::operator=(detail);
std::swap(d, detail.d); std::swap(d, detail.d);

View File

@ -29,7 +29,7 @@
#ifndef VLAYOUTDETAIL_H #ifndef VLAYOUTDETAIL_H
#define VLAYOUTDETAIL_H #define VLAYOUTDETAIL_H
#include <qcompilerdetection.h> #include <QCoreApplication>
#include <QDate> #include <QDate>
#include <QLineF> #include <QLineF>
#include <QPointF> #include <QPointF>
@ -39,7 +39,6 @@
#include <QTypeInfo> #include <QTypeInfo>
#include <QVector> #include <QVector>
#include <QtGlobal> #include <QtGlobal>
#include <QCoreApplication>
#include "../vmisc/typedef.h" #include "../vmisc/typedef.h"
#include "../vpatterndb/floatItemData/floatitemdef.h" #include "../vpatterndb/floatItemData/floatitemdef.h"
@ -70,9 +69,10 @@ QT_WARNING_PUSH
QT_WARNING_DISABLE_GCC("-Wsuggest-final-types") QT_WARNING_DISABLE_GCC("-Wsuggest-final-types")
QT_WARNING_DISABLE_GCC("-Wsuggest-final-methods") QT_WARNING_DISABLE_GCC("-Wsuggest-final-methods")
class VLayoutPiece :public VAbstractPiece class VLayoutPiece : public VAbstractPiece
{ {
Q_DECLARE_TR_FUNCTIONS(VLayoutPiece) // NOLINT Q_DECLARE_TR_FUNCTIONS(VLayoutPiece) // NOLINT
public: public:
VLayoutPiece(); VLayoutPiece();
VLayoutPiece(const VLayoutPiece &detail); VLayoutPiece(const VLayoutPiece &detail);
@ -82,7 +82,8 @@ public:
auto operator=(const VLayoutPiece &detail) -> VLayoutPiece &; auto operator=(const VLayoutPiece &detail) -> VLayoutPiece &;
#ifdef Q_COMPILER_RVALUE_REFS #ifdef Q_COMPILER_RVALUE_REFS
VLayoutPiece(VLayoutPiece &&detail) Q_DECL_NOTHROW; VLayoutPiece(VLayoutPiece &&detail) Q_DECL_NOTHROW;
auto operator=(VLayoutPiece &&detail) Q_DECL_NOTHROW -> VLayoutPiece &; auto operator=(VLayoutPiece &&detail) Q_DECL_NOTHROW
->VLayoutPiece &;
#endif #endif
static auto Create(const VPiece &piece, vidtype id, const VContainer *pattern) -> VLayoutPiece; static auto Create(const VPiece &piece, vidtype id, const VContainer *pattern) -> VLayoutPiece;
@ -112,20 +113,21 @@ public:
auto GetPlaceLabels() const -> QVector<VLayoutPlaceLabel>; auto GetPlaceLabels() const -> QVector<VLayoutPlaceLabel>;
void SetPlaceLabels(const QVector<VLayoutPlaceLabel> &labels); void SetPlaceLabels(const QVector<VLayoutPlaceLabel> &labels);
auto MappedInternalPathsForCut(bool cut) const -> QVector<QVector<VLayoutPoint> >; auto MappedInternalPathsForCut(bool cut) const -> QVector<QVector<VLayoutPoint>>;
auto GetInternalPaths() const -> QVector<VLayoutPiecePath>; auto GetInternalPaths() const -> QVector<VLayoutPiecePath>;
void SetInternalPaths(const QVector<VLayoutPiecePath> &internalPaths); void SetInternalPaths(const QVector<VLayoutPiecePath> &internalPaths);
auto GetPieceTextPosition() const -> QPointF; auto GetPieceTextPosition() const -> QPointF;
auto GetPieceText() const -> QStringList; auto GetPieceText() const -> QStringList;
void SetPieceText(const QString &qsName, const VPieceLabelData& data, const QFont& font, const VContainer *pattern); void SetPieceText(const QString &qsName, const VPieceLabelData &data, const QFont &font,
const VContainer *pattern);
auto GetPatternTextPosition() const -> QPointF; auto GetPatternTextPosition() const -> QPointF;
auto GetPatternText() const -> QStringList; auto GetPatternText() const -> QStringList;
void SetPatternInfo(VAbstractPattern *pDoc, const VPatternLabelData& geom, const QFont& font, void SetPatternInfo(VAbstractPattern *pDoc, const VPatternLabelData &geom, const QFont &font,
const VContainer *pattern); const VContainer *pattern);
void SetGrainline(const VGrainlineData& geom, const VContainer *pattern); void SetGrainline(const VGrainlineData &geom, const VContainer *pattern);
auto GetGrainline() const -> VPieceGrainline; auto GetGrainline() const -> VPieceGrainline;
auto GetMappedGrainlineShape() const -> GrainlineShape; auto GetMappedGrainlineShape() const -> GrainlineShape;
auto GetGrainlineShape() const -> GrainlineShape; auto GetGrainlineShape() const -> GrainlineShape;
@ -194,8 +196,8 @@ public:
auto BiggestEdge() const -> qreal; auto BiggestEdge() const -> qreal;
friend auto operator<< (QDataStream& dataStream, const VLayoutPiece& piece) -> QDataStream&; friend auto operator<<(QDataStream &dataStream, const VLayoutPiece &piece) -> QDataStream &;
friend auto operator>> (QDataStream& dataStream, VLayoutPiece& piece) -> QDataStream&; friend auto operator>>(QDataStream &dataStream, VLayoutPiece &piece) -> QDataStream &;
auto MapPlaceLabelShape(PlaceLabelImg shape) const -> PlaceLabelImg; auto MapPlaceLabelShape(PlaceLabelImg shape) const -> PlaceLabelImg;
@ -205,13 +207,13 @@ protected:
auto GetPieceLabelRect() const -> QVector<QPointF>; auto GetPieceLabelRect() const -> QVector<QPointF>;
void SetPieceLabelRect(const QVector<QPointF> &rect); void SetPieceLabelRect(const QVector<QPointF> &rect);
auto GetPieceLabelData() const ->VTextManager; auto GetPieceLabelData() const -> VTextManager;
void SetPieceLabelData(const VTextManager &data); void SetPieceLabelData(const VTextManager &data);
auto GetPatternLabelRect() const -> QVector<QPointF>; auto GetPatternLabelRect() const -> QVector<QPointF>;
void SetPatternLabelRect(const QVector<QPointF> &rect); void SetPatternLabelRect(const QVector<QPointF> &rect);
auto GetPatternLabelData() const ->VTextManager; auto GetPatternLabelData() const -> VTextManager;
void SetPatternLabelData(const VTextManager &data); void SetPatternLabelData(const VTextManager &data);
private: private:
@ -226,8 +228,7 @@ private:
bool textAsPaths) const; bool textAsPaths) const;
void CreateGrainlineItem(QGraphicsItem *parent) const; void CreateGrainlineItem(QGraphicsItem *parent) const;
template <class T> template <class T> auto Map(QVector<T> points) const -> QVector<T>;
auto Map(QVector<T> points) const -> QVector<T>;
auto Map(const GrainlineShape &shape) const -> GrainlineShape; auto Map(const GrainlineShape &shape) const -> GrainlineShape;
auto Edge(const QVector<QPointF> &path, int i) const -> QLineF; auto Edge(const QVector<QPointF> &path, int i) const -> QLineF;

View File

@ -52,8 +52,19 @@
#include "../vpatterndb/vcontainer.h" #include "../vpatterndb/vcontainer.h"
#include "vtextmanager.h" #include "vtextmanager.h"
#if QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
#include "../vmisc/diagnostic.h"
#endif // QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
namespace namespace
{ {
QT_WARNING_PUSH
QT_WARNING_DISABLE_CLANG("-Wunused-member-function")
Q_GLOBAL_STATIC(QVector<TextLine>, m_patternLabelLinesCache) // NOLINT
QT_WARNING_POP
auto SplitTextByWidth(const QString &text, const QFont &font, int maxWidth) -> QStringList auto SplitTextByWidth(const QString &text, const QFont &font, int maxWidth) -> QStringList
{ {
QFontMetrics fontMetrics(font); QFontMetrics fontMetrics(font);
@ -160,11 +171,6 @@ auto operator>>(QDataStream &dataStream, TextLine &data) -> QDataStream &
const quint32 VTextManager::streamHeader = 0x47E6A9EE; // CRC-32Q string "VTextManager" const quint32 VTextManager::streamHeader = 0x47E6A9EE; // CRC-32Q string "VTextManager"
const quint16 VTextManager::classVersion = 1; const quint16 VTextManager::classVersion = 1;
namespace
{
Q_GLOBAL_STATIC(QVector<TextLine>, m_patternLabelLinesCache) // NOLINT
}
// Friend functions // Friend functions
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto operator<<(QDataStream &dataStream, const VTextManager &data) -> QDataStream & auto operator<<(QDataStream &dataStream, const VTextManager &data) -> QDataStream &

View File

@ -62,7 +62,7 @@
#include "literals.h" #include "literals.h"
#if QT_VERSION < QT_VERSION_CHECK(5, 5, 0) #if QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
#include "../vmisc/diagnostic.h" #include "diagnostic.h"
#endif // QT_VERSION < QT_VERSION_CHECK(5, 5, 0) #endif // QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
namespace namespace
@ -374,6 +374,9 @@ void MacosEnableLayerBacking()
#endif // MACOS_LAYER_BACKING_AFFECTED #endif // MACOS_LAYER_BACKING_AFFECTED
#endif // Q_OS_MAC #endif // Q_OS_MAC
QT_WARNING_PUSH
QT_WARNING_DISABLE_CLANG("-Wunused-member-function")
Q_GLOBAL_STATIC_WITH_ARGS(const QString, strTMark, (QLatin1String("tMark"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, strTMark, (QLatin1String("tMark"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, strVMark, (QLatin1String("vMark"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, strVMark, (QLatin1String("vMark"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, strVMark2, (QLatin1String("vMark2"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, strVMark2, (QLatin1String("vMark2"))) // NOLINT
@ -381,6 +384,8 @@ Q_GLOBAL_STATIC_WITH_ARGS(const QString, strUMark, (QLatin1String("uMark")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, strBoxMark, (QLatin1String("boxMark"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, strBoxMark, (QLatin1String("boxMark"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, strCheckMark, (QLatin1String("checkMark"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, strCheckMark, (QLatin1String("checkMark"))) // NOLINT
QT_WARNING_POP
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto PassmarkLineTypeToString(PassmarkLineType type) -> QString auto PassmarkLineTypeToString(PassmarkLineType type) -> QString
{ {

View File

@ -27,6 +27,7 @@
*************************************************************************/ *************************************************************************/
#include "vcommonsettings.h" #include "vcommonsettings.h"
#include <QVariant>
#include <QApplication> #include <QApplication>
#include <QColor> #include <QColor>
@ -52,6 +53,10 @@
#include "defglobal.h" #include "defglobal.h"
#include "literals.h" #include "literals.h"
#if QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
#include "diagnostic.h"
#endif // QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
const int VCommonSettings::defaultScrollingDuration = 300; const int VCommonSettings::defaultScrollingDuration = 300;
const int VCommonSettings::scrollingDurationMin = 100; const int VCommonSettings::scrollingDurationMin = 100;
const int VCommonSettings::scrollingDurationMax = 1000; const int VCommonSettings::scrollingDurationMax = 1000;
@ -78,98 +83,119 @@ const QString VCommonSettings::defaultPieceLabelLocale = QStringLiteral("default
Q_DECLARE_METATYPE(QMarginsF) // NOLINT Q_DECLARE_METATYPE(QMarginsF) // NOLINT
#endif #endif
QT_WARNING_PUSH
QT_WARNING_DISABLE_CLANG("-Wunused-member-function")
namespace namespace
{ {
// NOLINTNEXTLINE
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPathsIndividualMeasurements, Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPathsIndividualMeasurements,
(QLatin1String("paths/individual_measurements"))) // NOLINT (QLatin1String("paths/individual_measurements")))
// NOLINTNEXTLINE
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPathsMultisizeMeasurements, Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPathsMultisizeMeasurements,
(QLatin1String("paths/standard_measurements"))) // NOLINT (QLatin1String("paths/standard_measurements")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPathsPattern, (QLatin1String("paths/pattern"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPathsPattern, (QLatin1String("paths/pattern"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPathsTemplates, (QLatin1String("paths/templates"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPathsTemplates, (QLatin1String("paths/templates"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPathsLabelTemplate, (QLatin1String("paths/labels"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPathsLabelTemplate, (QLatin1String("paths/labels"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPathsManualLayouts, (QLatin1String("paths/manualLayouts"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPathsManualLayouts, (QLatin1String("paths/manualLayouts"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationOsSeparator, // NOLINTNEXTLINE
(QLatin1String("configuration/osSeparator"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationOsSeparator, (QLatin1String("configuration/osSeparator")))
// NOLINTNEXTLINE
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationAutosaveState, Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationAutosaveState,
(QLatin1String("configuration/autosave/state"))) // NOLINT (QLatin1String("configuration/autosave/state")))
// NOLINTNEXTLINE
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationAutosaveTime, Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationAutosaveTime,
(QLatin1String("configuration/autosave/time"))) // NOLINT (QLatin1String("configuration/autosave/time")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationLocale, (QLatin1String("configuration/locale"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationLocale, (QLatin1String("configuration/locale"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationPieceLabelLocale, // NOLINT // NOLINTNEXTLINE
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationPieceLabelLocale,
(QLatin1String("configuration/pieceLabelLocale"))) (QLatin1String("configuration/pieceLabelLocale")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPMSystemCode, (QLatin1String("configuration/pmscode"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPMSystemCode, (QLatin1String("configuration/pmscode"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationUnit, (QLatin1String("configuration/unit"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationUnit, (QLatin1String("configuration/unit"))) // NOLINT
// NOLINTNEXTLINE
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationConfirmItemDeletion, Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationConfirmItemDeletion,
(QLatin1String("configuration/confirm_item_deletion"))) // NOLINT (QLatin1String("configuration/confirm_item_deletion")))
// NOLINTNEXTLINE
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationConfirmFormatRewriting, Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationConfirmFormatRewriting,
(QLatin1String("configuration/confirm_format_rewriting"))) // NOLINT (QLatin1String("configuration/confirm_format_rewriting")))
// NOLINTNEXTLINE
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationAskContinueIfLayoutStale, Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationAskContinueIfLayoutStale,
(QLatin1String("configuration/askContinueIfLayoutStale"))) // NOLINT (QLatin1String("configuration/askContinueIfLayoutStale")))
// NOLINTNEXTLINE
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationToolBarStyle, Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationToolBarStyle,
(QLatin1String("configuration/tool_bar_style"))) // NOLINT (QLatin1String("configuration/tool_bar_style")))
// NOLINTNEXTLINE
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationFreeCurveMode, Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationFreeCurveMode,
(QLatin1String("configuration/freeCurveMode"))) // NOLINT (QLatin1String("configuration/freeCurveMode")))
// NOLINTNEXTLINE
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationDoubleClickZoomFitBestCurrentPP, Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationDoubleClickZoomFitBestCurrentPP,
(QLatin1String("configuration/doubleClickZoomFitBestCurrentPP"))) // NOLINT (QLatin1String("configuration/doubleClickZoomFitBestCurrentPP")))
// NOLINTNEXTLINE
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationInteractiveTools, Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationInteractiveTools,
(QLatin1String("configuration/interactiveTools"))) // NOLINT (QLatin1String("configuration/interactiveTools")))
// NOLINTNEXTLINE
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationDontUseNativeDialog, Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationDontUseNativeDialog,
(QLatin1String("configuration/dontUseNativeDialog"))) // NOLINT (QLatin1String("configuration/dontUseNativeDialog")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternUndo, (QLatin1String("pattern/undo"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternUndo, (QLatin1String("pattern/undo"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternForbidFlipping, // NOLINTNEXTLINE
(QLatin1String("pattern/forbidFlipping"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternForbidFlipping, (QLatin1String("pattern/forbidFlipping")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternForceFlipping, // NOLINTNEXTLINE
(QLatin1String("pattern/forceFlipping"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternForceFlipping, (QLatin1String("pattern/forceFlipping")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternSewLineOnDrawing, // NOLINTNEXTLINE
(QLatin1String("pattern/sewLineOnDrawing"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternSewLineOnDrawing, (QLatin1String("pattern/sewLineOnDrawing")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternHideMainPath, (QLatin1String("pattern/hideMainPath"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternHideMainPath, (QLatin1String("pattern/hideMainPath"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingDoublePassmark, (QLatin1String("pattern/doublePassmark"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingDoublePassmark, (QLatin1String("pattern/doublePassmark"))) // NOLINT
// NOLINTNEXTLINE
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternDefaultSeamAllowance, Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternDefaultSeamAllowance,
(QLatin1String("pattern/defaultSeamAllowance"))) // NOLINT (QLatin1String("pattern/defaultSeamAllowance")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternLabelFont, (QLatin1String("pattern/labelFont"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternLabelFont, (QLatin1String("pattern/labelFont"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPieceLabelFontPointSize, // NOLINT // NOLINTNEXTLINE
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPieceLabelFontPointSize,
(QLatin1String("pattern/pieceLabelFontPointSize"))) (QLatin1String("pattern/pieceLabelFontPointSize")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternLineWidth, (QLatin1String("pattern/lineWidth"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternLineWidth, (QLatin1String("pattern/lineWidth"))) // NOLINT
// NOLINTNEXTLINE
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternCurveApproximationScale, Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternCurveApproximationScale,
(QLatin1String("pattern/curveApproximationScale"))) // NOLINT (QLatin1String("pattern/curveApproximationScale")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternShowCurveDetails, // NOLINTNEXTLINE
(QLatin1String("pattern/showCurveDetails"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternShowCurveDetails, (QLatin1String("pattern/showCurveDetails")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternPieceShowMainPath, // NOLINTNEXTLINE
(QLatin1String("pattern/pieceShowMainPath"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternPieceShowMainPath, (QLatin1String("pattern/pieceShowMainPath")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternLabelFontSize, // NOLINTNEXTLINE
(QLatin1String("pattern/labelFontSize"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternLabelFontSize, (QLatin1String("pattern/labelFontSize")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternHideLabels, (QLatin1String("pattern/hideLabels"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternHideLabels, (QLatin1String("pattern/hideLabels"))) // NOLINT
// NOLINTNEXTLINE
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternShowAccuracyRadius, Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternShowAccuracyRadius,
(QLatin1String("pattern/showAccuracyRadius"))) // NOLINT (QLatin1String("pattern/showAccuracyRadius")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternUseOpenGLRender, // NOLINTNEXTLINE
(QLatin1String("pattern/useOpenGLRender"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternUseOpenGLRender, (QLatin1String("pattern/useOpenGLRender")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternGraphicalOutput, // NOLINTNEXTLINE
(QLatin1String("pattern/graphicalOutput"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternGraphicalOutput, (QLatin1String("pattern/graphicalOutput")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingGeneralRecentFileList, (QLatin1String("recentFileList"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingGeneralRecentFileList, (QLatin1String("recentFileList"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingGeneralRestoreFileList, (QLatin1String("restoreFileList"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingGeneralRestoreFileList, (QLatin1String("restoreFileList"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingGeneralGeometry, (QLatin1String("geometry"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingGeneralGeometry, (QLatin1String("geometry"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingGeneralToolbarsState, (QLatin1String("toolbarsState"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingGeneralToolbarsState, (QLatin1String("toolbarsState"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationDarkMode, // NOLINTNEXTLINE
(QLatin1String("configuration/dark_mode"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationDarkMode, (QLatin1String("configuration/dark_mode")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPreferenceDialogSize, (QLatin1String("preferenceDialogSize"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPreferenceDialogSize, (QLatin1String("preferenceDialogSize"))) // NOLINT
// NOLINTNEXTLINE
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingToolSeamAllowanceDialogSize, Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingToolSeamAllowanceDialogSize,
(QLatin1String("toolSeamAllowanceDialogSize"))) // NOLINT (QLatin1String("toolSeamAllowanceDialogSize")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingIncrementsDialogSize, // NOLINTNEXTLINE
(QLatin1String("toolIncrementsDialogSize"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingIncrementsDialogSize, (QLatin1String("toolIncrementsDialogSize")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingFormulaWizardDialogSize, // NOLINTNEXTLINE
(QLatin1String("formulaWizardDialogSize"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingFormulaWizardDialogSize, (QLatin1String("formulaWizardDialogSize")))
// NOLINTNEXTLINE
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingFinalMeasurementsDialogSize, Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingFinalMeasurementsDialogSize,
(QLatin1String("finalMeasurementsDialogSize"))) // NOLINT (QLatin1String("finalMeasurementsDialogSize")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutSettingsDialogSize, // NOLINTNEXTLINE
(QLatin1String("layoutSettingsDialogSize"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutSettingsDialogSize, (QLatin1String("layoutSettingsDialogSize")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingDialogSplinePathSize, (QLatin1String("splinePathDialogSize"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingDialogSplinePathSize, (QLatin1String("splinePathDialogSize"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingAutomaticallyCheckUpdates, // NOLINTNEXTLINE
(QLatin1String("automaticallyCheckUpdates"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingAutomaticallyCheckUpdates, (QLatin1String("automaticallyCheckUpdates")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLatestSkippedVersion, // NOLINTNEXTLINE
(QLatin1String("lastestSkippedVersion"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLatestSkippedVersion, (QLatin1String("lastestSkippedVersion")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingDateOfLastRemind, (QLatin1String("dateOfLastRemind"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingDateOfLastRemind, (QLatin1String("dateOfLastRemind"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingCSVWithHeader, (QLatin1String("csv/withHeader"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingCSVWithHeader, (QLatin1String("csv/withHeader"))) // NOLINT
@ -177,28 +203,29 @@ Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingCSVCodec, (QLatin1String("csv/wi
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingCSVSeparator, (QLatin1String("csv/withSeparator"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingCSVSeparator, (QLatin1String("csv/withSeparator"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLabelDateFormat, (QLatin1String("label/dateFormat"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLabelDateFormat, (QLatin1String("label/dateFormat"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLabelUserDateFormats, // NOLINTNEXTLINE
(QLatin1String("label/userDateFormats"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLabelUserDateFormats, (QLatin1String("label/userDateFormats")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLabelTimeFormat, (QLatin1String("label/timeFormat"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLabelTimeFormat, (QLatin1String("label/timeFormat"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLabelUserTimeFormats, // NOLINTNEXTLINE
(QLatin1String("label/userTimeFormats"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLabelUserTimeFormats, (QLatin1String("label/userTimeFormats")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingScrollingDuration, (QLatin1String("scrolling/duration"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingScrollingDuration, (QLatin1String("scrolling/duration"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingScrollingUpdateInterval, // NOLINTNEXTLINE
(QLatin1String("scrolling/updateInterval"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingScrollingUpdateInterval, (QLatin1String("scrolling/updateInterval")))
// NOLINTNEXTLINE
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingScrollingSensorMouseScale, Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingScrollingSensorMouseScale,
(QLatin1String("scrolling/sensorMouseScale"))) // NOLINT (QLatin1String("scrolling/sensorMouseScale")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingScrollingWheelMouseScale, // NOLINTNEXTLINE
(QLatin1String("scrolling/wheelMouseScale"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingScrollingWheelMouseScale, (QLatin1String("scrolling/wheelMouseScale")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingScrollingAcceleration, // NOLINTNEXTLINE
(QLatin1String("scrolling/acceleration"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingScrollingAcceleration, (QLatin1String("scrolling/acceleration")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingTiledPDFMargins, (QLatin1String("tiledPDF/margins"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingTiledPDFMargins, (QLatin1String("tiledPDF/margins"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingTiledPDFOrientation, (QLatin1String("tiledPDF/orientation"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingTiledPDFOrientation, (QLatin1String("tiledPDF/orientation"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingWatermarkEditorSize, (QLatin1String("watermarkEditorSize"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingWatermarkEditorSize, (QLatin1String("watermarkEditorSize"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingWatermarkCustomColors, // NOLINTNEXTLINE
(QLatin1String("watermarkCustomColors"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingWatermarkCustomColors, (QLatin1String("watermarkCustomColors")))
// Reading settings file is very expensive, cache curve approximation to speed up getting value // Reading settings file is very expensive, cache curve approximation to speed up getting value
qreal curveApproximationCached = -1; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables) qreal curveApproximationCached = -1; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)
@ -329,6 +356,8 @@ auto PrepareStandardFiles(const QString &currentPath, const QString &standardPat
} }
} // namespace } // namespace
QT_WARNING_POP
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VCommonSettings::VCommonSettings(Format format, Scope scope, const QString &organization, const QString &application, VCommonSettings::VCommonSettings(Format format, Scope scope, const QString &organization, const QString &application,
QObject *parent) QObject *parent)
@ -353,8 +382,7 @@ auto VCommonSettings::SharePath(const QString &shareItem) -> QString
{ {
return dirBundle.absolutePath(); return dirBundle.absolutePath();
} }
else
{
QDir appDir = QDir(qApp->applicationDirPath()); QDir appDir = QDir(qApp->applicationDirPath());
appDir.cdUp(); appDir.cdUp();
appDir.cdUp(); appDir.cdUp();
@ -364,25 +392,16 @@ auto VCommonSettings::SharePath(const QString &shareItem) -> QString
{ {
return dir.absolutePath(); return dir.absolutePath();
} }
else
{
return VCommonSettings::unixStandardSharePath + shareItem; return VCommonSettings::unixStandardSharePath + shareItem;
}
}
#else // Unix #else // Unix
#ifdef QT_DEBUG
return QCoreApplication::applicationDirPath() + shareItem;
#else
QDir dir(QCoreApplication::applicationDirPath() + shareItem); QDir dir(QCoreApplication::applicationDirPath() + shareItem);
if (dir.exists()) if (dir.exists())
{ {
return dir.absolutePath(); return dir.absolutePath();
} }
else
{
return VCommonSettings::unixStandardSharePath + shareItem; return VCommonSettings::unixStandardSharePath + shareItem;
}
#endif
#endif #endif
} }
@ -1109,20 +1128,20 @@ auto VCommonSettings::GetCSVSeparator() const -> QChar
switch (separator) switch (separator)
{ {
case 0: case 0:
return QChar('\t'); return {'\t'};
case 1: case 1:
return QChar(';'); return {';'};
case 2: case 2:
return QChar(' '); return {' '};
default: default:
return QChar(','); return {','};
} }
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VCommonSettings::GetDefCSVSeparator() -> QChar auto VCommonSettings::GetDefCSVSeparator() -> QChar
{ {
return QChar(','); return {','};
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View File

@ -29,132 +29,175 @@
#include "vvalentinasettings.h" #include "vvalentinasettings.h"
#include <QDir> #include <QDir>
#include <QLocale>
#include <QMetaType>
#include <QPrinter>
#include <QSharedPointer>
#include <QVariant>
#include <QPrinterInfo>
#include <QtDebug>
#include <QGlobalStatic> #include <QGlobalStatic>
#include <QLocale>
#include <QMargins> #include <QMargins>
#include <QMetaType> #include <QMetaType>
#include <QPrinter>
#include <QPrinterInfo>
#include <QSharedPointer>
#include <QVariant>
#include <QtDebug>
#include "../vmisc/def.h" #include "compatibility.h"
#include "../vmisc/compatibility.h" #include "def.h"
#include "qglobal.h" #include "qglobal.h"
#if QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
#include "diagnostic.h"
#endif // QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
#ifndef QPRINTENGINE_H #ifndef QPRINTENGINE_H
Q_DECLARE_METATYPE(QMarginsF) // NOLINT Q_DECLARE_METATYPE(QMarginsF) // NOLINT
#endif #endif
namespace namespace
{ {
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationLabelLanguage, // NOLINT QT_WARNING_PUSH
QT_WARNING_DISABLE_CLANG("-Wunused-member-function")
// NOLINTNEXTLINE
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationLabelLanguage,
(QLatin1String("configuration/label_language"))) (QLatin1String("configuration/label_language")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingAutoRefreshPatternMessage, // NOLINT // NOLINTNEXTLINE
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingAutoRefreshPatternMessage,
(QLatin1String("configuration/autoRefreshPatternMessage"))) (QLatin1String("configuration/autoRefreshPatternMessage")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingToolPanelScaling, // NOLINT // NOLINTNEXTLINE
(QLatin1String("configuration/toolPanelScaling"))) Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingToolPanelScaling, (QLatin1String("configuration/toolPanelScaling")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPathsLayout, (QLatin1String("paths/layout"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPathsLayout, (QLatin1String("paths/layout"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternKnownMaterials, (QLatin1String("pattern/knownMaterials"))) // NOLINT // NOLINTNEXTLINE
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternRememberMaterials, (QLatin1String("pattern/rememberMaterials"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternKnownMaterials, (QLatin1String("pattern/knownMaterials")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternBackgroundImageDefOpacity, // NOLINT // NOLINTNEXTLINE
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternRememberMaterials, (QLatin1String("pattern/rememberMaterials")))
// NOLINTNEXTLINE
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternBackgroundImageDefOpacity,
(QLatin1String("pattern/backgroundImageDefOpacity"))) (QLatin1String("pattern/backgroundImageDefOpacity")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutWidth, (QLatin1String("layout/width"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutWidth, (QLatin1String("layout/width"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutSorting, (QLatin1String("layout/sorting"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutSorting, (QLatin1String("layout/sorting"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutPaperHeight, (QLatin1String("layout/paperHeight"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutPaperHeight, (QLatin1String("layout/paperHeight"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutPaperWidth, (QLatin1String("layout/paperWidth"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutPaperWidth, (QLatin1String("layout/paperWidth"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutFollowGrainline, (QLatin1String("layout/followGrainline"))) // NOLINT // NOLINTNEXTLINE
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutManualPriority, (QLatin1String("layout/manualPriority"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutFollowGrainline, (QLatin1String("layout/followGrainline")))
// NOLINTNEXTLINE
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutManualPriority, (QLatin1String("layout/manualPriority")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutNestQuantity, (QLatin1String("layout/nestQuantity"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutNestQuantity, (QLatin1String("layout/nestQuantity"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutAutoCropLength, (QLatin1String("layout/autoCropLength"))) // NOLINT // NOLINTNEXTLINE
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutAutoCropLength, (QLatin1String("layout/autoCropLength")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutAutoCropWidth, (QLatin1String("layout/autoCropWidth"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutAutoCropWidth, (QLatin1String("layout/autoCropWidth"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutSaveLength, (QLatin1String("layout/saveLength"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutSaveLength, (QLatin1String("layout/saveLength"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutPreferOneSheetSolution, // NOLINT // NOLINTNEXTLINE
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutPreferOneSheetSolution,
(QLatin1String("layout/preferOneSheetSolution"))) (QLatin1String("layout/preferOneSheetSolution")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutUnitePages, (QLatin1String("layout/unitePages"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutUnitePages, (QLatin1String("layout/unitePages"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutShowGrainline, (QLatin1String("layout/showGrainline"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutShowGrainline, (QLatin1String("layout/showGrainline"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingFields, (QLatin1String("layout/fields"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingFields, (QLatin1String("layout/fields"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingIgnoreFields, (QLatin1String("layout/ignoreFields"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingIgnoreFields, (QLatin1String("layout/ignoreFields"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingStripOptimization, (QLatin1String("layout/stripOptimization"))) // NOLINT // NOLINTNEXTLINE
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingStripOptimization, (QLatin1String("layout/stripOptimization")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingMultiplier, (QLatin1String("layout/multiplier"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingMultiplier, (QLatin1String("layout/multiplier"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingTextAsPaths, (QLatin1String("layout/textAsPaths"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingTextAsPaths, (QLatin1String("layout/textAsPaths"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingNestingTime, (QLatin1String("layout/time"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingNestingTime, (QLatin1String("layout/time"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingEfficiencyCoefficient, (QLatin1String("layout/efficiencyCoefficient"))) // NOLINT // NOLINTNEXTLINE
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingEfficiencyCoefficient, (QLatin1String("layout/efficiencyCoefficient")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutExportFormat, (QLatin1String("layout/exportFormat"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutExportFormat, (QLatin1String("layout/exportFormat"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingDetailExportFormat, (QLatin1String("detail/exportFormat"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingDetailExportFormat, (QLatin1String("detail/exportFormat"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingTiledPDFPaperHeight, (QLatin1String("tiledPDF/paperHeight"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingTiledPDFPaperHeight, (QLatin1String("tiledPDF/paperHeight"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingTiledPDFPaperWidth, (QLatin1String("tiledPDF/paperWidth"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingTiledPDFPaperWidth, (QLatin1String("tiledPDF/paperWidth"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingdockWidgetGroupsActive, (QLatin1String("dockWidget/groupsActive"))) // NOLINT // NOLINTNEXTLINE
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingDockWidgetToolOptionsActive, // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingdockWidgetGroupsActive, (QLatin1String("dockWidget/groupsActive")))
// NOLINTNEXTLINE
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingDockWidgetToolOptionsActive,
(QLatin1String("dockWidget/toolOptionsActive"))) (QLatin1String("dockWidget/toolOptionsActive")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingDockWidgetPatternMessagesActive, // NOLINT // NOLINTNEXTLINE
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingDockWidgetPatternMessagesActive,
(QLatin1String("dockWidget/patternMessagesActive"))) (QLatin1String("dockWidget/patternMessagesActive")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingDockWidgetBackgroundImagesActive, // NOLINT // NOLINTNEXTLINE
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingDockWidgetBackgroundImagesActive,
(QLatin1String("dockWidget/backgroundImagesActive"))) (QLatin1String("dockWidget/backgroundImagesActive")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternMessagesFontSize, (QLatin1String("font/patternMessagesSize"))) // NOLINT // NOLINTNEXTLINE
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternMessagesFontSize, (QLatin1String("font/patternMessagesSize")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchHistoryHistory, (QLatin1String("searchHistory/history"))) // NOLINT // NOLINTNEXTLINE
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchHistoryIncrements, (QLatin1String("searchHistory/increments"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchHistoryHistory, (QLatin1String("searchHistory/history")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchHistoryPreviewCalculations, // NOLINT // NOLINTNEXTLINE
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchHistoryIncrements, (QLatin1String("searchHistory/increments")))
// NOLINTNEXTLINE
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchHistoryPreviewCalculations,
(QLatin1String("searchHistory/previewCalculations"))) (QLatin1String("searchHistory/previewCalculations")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchHistoryFinalMeasurements, // NOLINT // NOLINTNEXTLINE
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchHistoryFinalMeasurements,
(QLatin1String("searchHistory/finalMeasurements"))) (QLatin1String("searchHistory/finalMeasurements")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsHistoryUseUnicodeProperties, // NOLINT // NOLINTNEXTLINE
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsHistoryUseUnicodeProperties,
(QLatin1String("searchOptions/historyUseUnicodeProperties"))) (QLatin1String("searchOptions/historyUseUnicodeProperties")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsHistoryWholeWord, // NOLINT // NOLINTNEXTLINE
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsHistoryWholeWord,
(QLatin1String("searchOptions/historyWholeWord"))) (QLatin1String("searchOptions/historyWholeWord")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsHistoryRegexp, // NOLINT // NOLINTNEXTLINE
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsHistoryRegexp,
(QLatin1String("searchOptions/historyRegexp"))) (QLatin1String("searchOptions/historyRegexp")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsHistoryMatchCase, // NOLINT // NOLINTNEXTLINE
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsHistoryMatchCase,
(QLatin1String("searchOptions/historyMatchCase"))) (QLatin1String("searchOptions/historyMatchCase")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsIncrementsUseUnicodeProperties, // NOLINT // NOLINTNEXTLINE
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsIncrementsUseUnicodeProperties,
(QLatin1String("searchOptions/incrementsUseUnicodeProperties"))) (QLatin1String("searchOptions/incrementsUseUnicodeProperties")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsIncrementsWholeWord, // NOLINT // NOLINTNEXTLINE
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsIncrementsWholeWord,
(QLatin1String("searchOptions/incrementsWholeWord"))) (QLatin1String("searchOptions/incrementsWholeWord")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsIncrementsRegexp, // NOLINT // NOLINTNEXTLINE
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsIncrementsRegexp,
(QLatin1String("searchOptions/incrementsRegexp"))) (QLatin1String("searchOptions/incrementsRegexp")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsIncrementsMatchCase, // NOLINT // NOLINTNEXTLINE
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsIncrementsMatchCase,
(QLatin1String("searchOptions/incrementsMatchCase"))) (QLatin1String("searchOptions/incrementsMatchCase")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsPreviewCalculationsUseUnicodeProperties, // NOLINT // NOLINTNEXTLINE
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsPreviewCalculationsUseUnicodeProperties,
(QLatin1String("searchOptions/previewCalculationsUseUnicodeProperties"))) (QLatin1String("searchOptions/previewCalculationsUseUnicodeProperties")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsPreviewCalculationsWholeWord, // NOLINT // NOLINTNEXTLINE
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsPreviewCalculationsWholeWord,
(QLatin1String("searchOptions/previewCalculationsWholeWord"))) (QLatin1String("searchOptions/previewCalculationsWholeWord")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsPreviewCalculationsRegexp, // NOLINT // NOLINTNEXTLINE
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsPreviewCalculationsRegexp,
(QLatin1String("searchOptions/previewCalculationsRegexp"))) (QLatin1String("searchOptions/previewCalculationsRegexp")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsPreviewCalculationsMatchCase, // NOLINT // NOLINTNEXTLINE
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsPreviewCalculationsMatchCase,
(QLatin1String("searchOptions/previewCalculationsMatchCase"))) (QLatin1String("searchOptions/previewCalculationsMatchCase")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsFinalMeasurementsUseUnicodeProperties, // NOLINT // NOLINTNEXTLINE
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsFinalMeasurementsUseUnicodeProperties,
(QLatin1String("searchOptions/finalMeasurementsUseUnicodeProperties"))) (QLatin1String("searchOptions/finalMeasurementsUseUnicodeProperties")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsFinalMeasurementsWholeWord, // NOLINT // NOLINTNEXTLINE
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsFinalMeasurementsWholeWord,
(QLatin1String("searchOptions/finalMeasurementsWholeWord"))) (QLatin1String("searchOptions/finalMeasurementsWholeWord")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsFinalMeasurementsRegexp, // NOLINT // NOLINTNEXTLINE
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsFinalMeasurementsRegexp,
(QLatin1String("searchOptions/finalMeasurementsRegexp"))) (QLatin1String("searchOptions/finalMeasurementsRegexp")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsFinalMeasurementsMatchCase, // NOLINT // NOLINTNEXTLINE
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsFinalMeasurementsMatchCase,
(QLatin1String("searchOptions/finalMeasurementsMatchCase"))) (QLatin1String("searchOptions/finalMeasurementsMatchCase")))
QT_WARNING_POP
} // namespace } // namespace
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VValentinaSettings::VValentinaSettings(Format format, Scope scope, const QString &organization, const QString &application, VValentinaSettings::VValentinaSettings(Format format, Scope scope, const QString &organization,
QObject *parent) const QString &application, QObject *parent)
:VCommonSettings(format, scope, organization, application, parent) : VCommonSettings(format, scope, organization, application, parent)
{ {
REGISTER_META_TYPE_STREAM_OPERATORS(QMarginsF); REGISTER_META_TYPE_STREAM_OPERATORS(QMarginsF);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VValentinaSettings::VValentinaSettings(const QString &fileName, QSettings::Format format, QObject *parent) VValentinaSettings::VValentinaSettings(const QString &fileName, QSettings::Format format, QObject *parent)
:VCommonSettings(fileName, format, parent) : VCommonSettings(fileName, format, parent)
{ {
REGISTER_META_TYPE_STREAM_OPERATORS(QMarginsF); REGISTER_META_TYPE_STREAM_OPERATORS(QMarginsF);
} }
@ -195,7 +238,7 @@ void VValentinaSettings::SetPathLayout(const QString &value)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VValentinaSettings::GetLayoutPaperHeight() const -> qreal auto VValentinaSettings::GetLayoutPaperHeight() const -> qreal
{ {
return ValueOrDef<qreal>(*this, *settingLayoutPaperHeight, UnitConvertor(1189/*A0*/, Unit::Mm, Unit::Px)); return ValueOrDef<qreal>(*this, *settingLayoutPaperHeight, UnitConvertor(1189 /*A0*/, Unit::Mm, Unit::Px));
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -207,7 +250,7 @@ void VValentinaSettings::SetLayoutPaperHeight(qreal value)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VValentinaSettings::GetLayoutPaperWidth() const -> qreal auto VValentinaSettings::GetLayoutPaperWidth() const -> qreal
{ {
return ValueOrDef<qreal>(*this, *settingLayoutPaperWidth, UnitConvertor(841/*A0*/, Unit::Mm, Unit::Px)); return ValueOrDef<qreal>(*this, *settingLayoutPaperWidth, UnitConvertor(841 /*A0*/, Unit::Mm, Unit::Px));
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -569,10 +612,9 @@ auto VValentinaSettings::GetTiledPDFPaperWidth(const Unit &unit) const -> qreal
*/ */
void VValentinaSettings::SetTiledPDFPaperWidth(qreal value, const Unit &unit) void VValentinaSettings::SetTiledPDFPaperWidth(qreal value, const Unit &unit)
{ {
setValue(*settingTiledPDFPaperWidth, UnitConvertor(value,unit, Unit::Mm)); setValue(*settingTiledPDFPaperWidth, UnitConvertor(value, unit, Unit::Mm));
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VValentinaSettings::IsDockWidgetGroupsActive() const -> bool auto VValentinaSettings::IsDockWidgetGroupsActive() const -> bool
{ {
@ -668,8 +710,8 @@ auto VValentinaSettings::GetDefMaxPatternMessageFontSize() -> int
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VValentinaSettings::SetPatternMessageFontSize(int size) void VValentinaSettings::SetPatternMessageFontSize(int size)
{ {
setValue(*settingPatternMessagesFontSize, qBound(GetDefMinPatternMessageFontSize(), size, setValue(*settingPatternMessagesFontSize,
GetDefMaxPatternMessageFontSize())); qBound(GetDefMinPatternMessageFontSize(), size, GetDefMaxPatternMessageFontSize()));
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View File

@ -40,6 +40,7 @@
class VValentinaSettings : public VCommonSettings class VValentinaSettings : public VCommonSettings
{ {
Q_OBJECT // NOLINT Q_OBJECT // NOLINT
public: public:
VValentinaSettings(Format format, Scope scope, const QString &organization, const QString &application = QString(), VValentinaSettings(Format format, Scope scope, const QString &organization, const QString &application = QString(),
QObject *parent = nullptr); QObject *parent = nullptr);
@ -193,7 +194,7 @@ public:
auto GetHistorySearchOptionRegexp() const -> bool; auto GetHistorySearchOptionRegexp() const -> bool;
void SetHistorySearchOptionRegexp(bool value); void SetHistorySearchOptionRegexp(bool value);
auto GetHistorySearchOptionMatchCase() const ->bool; auto GetHistorySearchOptionMatchCase() const -> bool;
void SetHistorySearchOptionMatchCase(bool value); void SetHistorySearchOptionMatchCase(bool value);
auto GetIncrementsSearchOptionUseUnicodeProperties() const -> bool; auto GetIncrementsSearchOptionUseUnicodeProperties() const -> bool;
@ -205,7 +206,7 @@ public:
auto GetIncrementsSearchOptionRegexp() const -> bool; auto GetIncrementsSearchOptionRegexp() const -> bool;
void SetIncrementsSearchOptionRegexp(bool value); void SetIncrementsSearchOptionRegexp(bool value);
auto GetIncrementsSearchOptionMatchCase() const ->bool; auto GetIncrementsSearchOptionMatchCase() const -> bool;
void SetIncrementsSearchOptionMatchCase(bool value); void SetIncrementsSearchOptionMatchCase(bool value);
auto GetPreviewCalculationsSearchOptionUseUnicodeProperties() const -> bool; auto GetPreviewCalculationsSearchOptionUseUnicodeProperties() const -> bool;
@ -217,7 +218,7 @@ public:
auto GetPreviewCalculationsSearchOptionRegexp() const -> bool; auto GetPreviewCalculationsSearchOptionRegexp() const -> bool;
void SetPreviewCalculationsSearchOptionRegexp(bool value); void SetPreviewCalculationsSearchOptionRegexp(bool value);
auto GetPreviewCalculationsSearchOptionMatchCase() const ->bool; auto GetPreviewCalculationsSearchOptionMatchCase() const -> bool;
void SetPreviewCalculationsSearchOptionMatchCase(bool value); void SetPreviewCalculationsSearchOptionMatchCase(bool value);
auto GetFinalMeasurementsSearchOptionUseUnicodeProperties() const -> bool; auto GetFinalMeasurementsSearchOptionUseUnicodeProperties() const -> bool;
@ -229,7 +230,7 @@ public:
auto GetFinalMeasurementsSearchOptionRegexp() const -> bool; auto GetFinalMeasurementsSearchOptionRegexp() const -> bool;
void SetFinalMeasurementsSearchOptionRegexp(bool value); void SetFinalMeasurementsSearchOptionRegexp(bool value);
auto GetFinalMeasurementsSearchOptionMatchCase() const ->bool; auto GetFinalMeasurementsSearchOptionMatchCase() const -> bool;
void SetFinalMeasurementsSearchOptionMatchCase(bool value); void SetFinalMeasurementsSearchOptionMatchCase(bool value);
auto GetBackgroundImageDefOpacity() const -> int; auto GetBackgroundImageDefOpacity() const -> int;

View File

@ -28,7 +28,6 @@
#include "abstracttest.h" #include "abstracttest.h"
#include <qtestcase.h>
#include <QApplication> #include <QApplication>
#include <QByteArray> #include <QByteArray>
#include <QDir> #include <QDir>
@ -36,15 +35,16 @@
#include <QFileInfo> #include <QFileInfo>
#include <QFlags> #include <QFlags>
#include <QIODevice> #include <QIODevice>
#include <QJsonArray>
#include <QJsonObject>
#include <QLineF>
#include <QPointF> #include <QPointF>
#include <QProcess> #include <QProcess>
#include <QScopedPointer> #include <QScopedPointer>
#include <QStringList> #include <QStringList>
#include <QVector> #include <QVector>
#include <QtGlobal> #include <QtGlobal>
#include <QLineF> #include <qtestcase.h>
#include <QJsonObject>
#include <QJsonArray>
#include "../vgeometry/vgobject.h" #include "../vgeometry/vgobject.h"
#include "../vgeometry/vpointf.h" #include "../vgeometry/vpointf.h"
@ -52,9 +52,9 @@
#include "../vgeometry/vsplinepath.h" #include "../vgeometry/vsplinepath.h"
#include "../vlayout/vabstractpiece.h" #include "../vlayout/vabstractpiece.h"
#include "../vpatterndb/vcontainer.h" #include "../vpatterndb/vcontainer.h"
#include "../vpatterndb/vpassmark.h"
#include "../vpatterndb/vpiece.h" #include "../vpatterndb/vpiece.h"
#include "../vpatterndb/vpiecenode.h" #include "../vpatterndb/vpiecenode.h"
#include "../vpatterndb/vpassmark.h"
namespace namespace
{ {
@ -63,11 +63,11 @@ auto FillPath(const QVector<QPointF> &path, qreal accuracy) -> QVector<QPointF>
QVector<QPointF> pathFilled; QVector<QPointF> pathFilled;
pathFilled.reserve(path.size()); pathFilled.reserve(path.size());
for (int i=0; i < path.size()-1; ++i) for (int i = 0; i < path.size() - 1; ++i)
{ {
pathFilled.append(path.at(i)); pathFilled.append(path.at(i));
QLineF line(path.at(i), path.at(i+1)); QLineF line(path.at(i), path.at(i + 1));
if (line.length() > accuracy) if (line.length() > accuracy)
{ {
qreal len = accuracy; qreal len = accuracy;
@ -77,8 +77,7 @@ auto FillPath(const QVector<QPointF> &path, qreal accuracy) -> QVector<QPointF>
l.setLength(len); l.setLength(len);
pathFilled.append(l.p2()); pathFilled.append(l.p2());
len += accuracy; len += accuracy;
} } while (line.length() > len);
while(line.length() > len);
} }
} }
@ -89,8 +88,8 @@ auto FillPath(const QVector<QPointF> &path, qreal accuracy) -> QVector<QPointF>
} // namespace } // namespace
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
AbstractTest::AbstractTest(QObject *parent) : AbstractTest::AbstractTest(QObject *parent)
QObject(parent) : QObject(parent)
{ {
} }
@ -252,18 +251,18 @@ void AbstractTest::ComparePaths(const QVector<QPointF> &actual, const QVector<QP
QVERIFY2(actual.size() >= 2, "Not enough points"); QVERIFY2(actual.size() >= 2, "Not enough points");
QVERIFY2(expected.size() >= 2, "Not enough points"); QVERIFY2(expected.size() >= 2, "Not enough points");
const qreal accuracy = accuracyPointOnLine*4.; const qreal accuracy = accuracyPointOnLine * 4.;
QVector<QPointF> actualFilled = FillPath(actual, accuracy); QVector<QPointF> actualFilled = FillPath(actual, accuracy);
bool onLine = false; bool onLine = false;
QSet<int> usedEdges; QSet<int> usedEdges;
for (auto p : actualFilled) for (auto p : actualFilled)
{ {
for(int i = 0; i < expected.size()-1; ++i) for (int i = 0; i < expected.size() - 1; ++i)
{ {
if (VGObject::IsPointOnLineSegment(p, expected.at(i), expected.at(i+1), accuracyPointOnLine*2.)) if (VGObject::IsPointOnLineSegment(p, expected.at(i), expected.at(i + 1), accuracyPointOnLine * 2.))
{ {
usedEdges.insert(i+1); usedEdges.insert(i + 1);
onLine = true; onLine = true;
} }
} }
@ -282,10 +281,10 @@ void AbstractTest::ComparePaths(const QVector<QPointF> &actual, const QVector<QP
void AbstractTest::ComparePathsDistance(const QVector<QPointF> &ekv, const QVector<QPointF> &ekvOrig) const void AbstractTest::ComparePathsDistance(const QVector<QPointF> &ekv, const QVector<QPointF> &ekvOrig) const
{ {
// Begin comparison // Begin comparison
QCOMPARE(ekv.size(), ekvOrig.size());// First check if sizes are equal QCOMPARE(ekv.size(), ekvOrig.size()); // First check if sizes are equal
const qreal testAccuracy = MmToPixel(1.); const qreal testAccuracy = MmToPixel(1.);
for (int i=0; i < ekv.size(); i++) for (int i = 0; i < ekv.size(); i++)
{ {
ComparePointsDistance(ekv.at(i), ekvOrig.at(i), testAccuracy); ComparePointsDistance(ekv.at(i), ekvOrig.at(i), testAccuracy);
} }
@ -295,27 +294,29 @@ void AbstractTest::ComparePathsDistance(const QVector<QPointF> &ekv, const QVect
void AbstractTest::ComparePointsDistance(const QPointF &result, const QPointF &expected, qreal testAccuracy) const void AbstractTest::ComparePointsDistance(const QPointF &result, const QPointF &expected, qreal testAccuracy) const
{ {
const QString msg = QStringLiteral("Actual '%2;%3', Expected '%4;%5'. Distance between points %6 mm.") const QString msg = QStringLiteral("Actual '%2;%3', Expected '%4;%5'. Distance between points %6 mm.")
.arg(result.x()).arg(result.y()).arg(expected.x()).arg(expected.y()) .arg(result.x())
.arg(result.y())
.arg(expected.x())
.arg(expected.y())
.arg(UnitConvertor(QLineF(result, expected).length(), Unit::Px, Unit::Mm)); .arg(UnitConvertor(QLineF(result, expected).length(), Unit::Px, Unit::Mm));
// Check each point. Don't use comparison float values // Check each point. Don't use comparison float values
QVERIFY2(VFuzzyComparePoints(result, expected, testAccuracy), qUtf8Printable(msg)); QVERIFY2(VFuzzyComparePoints(result, expected, testAccuracy), qUtf8Printable(msg));
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void AbstractTest::CompareLinesDistance(const QVector<QLineF> &result, const QVector<QLineF> &expected) const void AbstractTest::CompareLinesDistance(const QVector<QLineF> &result, const QVector<QLineF> &expected) const
{ {
// Begin comparison // Begin comparison
QCOMPARE(result.size(), expected.size());// First check if sizes equal QCOMPARE(result.size(), expected.size()); // First check if sizes equal
for (int i=0; i < result.size(); i++) for (int i = 0; i < result.size(); i++)
{ {
const QLineF &line1 = result.at(i); const QLineF &line1 = result.at(i);
const QLineF &line2 = expected.at(i); const QLineF &line2 = expected.at(i);
// Check each point. Don't use comparison float values // Check each point. Don't use comparison float values
QVERIFY2(VFuzzyComparePoints(line1.p1(), line2.p1()) && VFuzzyComparePoints(line1.p2(), line2.p2()), QVERIFY2(
qUtf8Printable( VFuzzyComparePoints(line1.p1(), line2.p1()) && VFuzzyComparePoints(line1.p2(), line2.p2()),
QStringLiteral("Index: %1. Got line '(%2;%3):(%4;%5)', Expected line '(%6;%7):(%8;%9)'.") qUtf8Printable(QStringLiteral("Index: %1. Got line '(%2;%3):(%4;%5)', Expected line '(%6;%7):(%8;%9)'.")
.arg(i) .arg(i)
.arg(line1.p1().x()) .arg(line1.p1().x())
.arg(line1.p1().y()) .arg(line1.p1().y())
@ -324,9 +325,7 @@ void AbstractTest::CompareLinesDistance(const QVector<QLineF> &result, const QVe
.arg(line2.p1().x()) .arg(line2.p1().x())
.arg(line2.p1().y()) .arg(line2.p1().y())
.arg(line2.p2().x()) .arg(line2.p2().x())
.arg(line2.p2().y()) .arg(line2.p2().y())));
)
);
} }
} }
@ -408,8 +407,8 @@ auto AbstractTest::Run(int exit, const QString &program, const QStringList &argu
{ {
msecs = AbstractTest::RunTimeout(msecs); msecs = AbstractTest::RunTimeout(msecs);
const QString parameters = QStringLiteral("Program: %1 \nArguments: %2.") const QString parameters =
.arg(program, arguments.join(QStringLiteral(", "))); QStringLiteral("Program: %1 \nArguments: %2.").arg(program, arguments.join(QStringLiteral(", ")));
QFileInfo info(program); QFileInfo info(program);
if (not info.exists()) if (not info.exists())
@ -446,7 +445,8 @@ auto AbstractTest::Run(int exit, const QString &program, const QStringList &argu
if (process->exitCode() != exit) if (process->exitCode() != exit)
{ {
error = QStringLiteral("Unexpected finish. Exit code: %1\n%2").arg(process->exitCode()) error = QStringLiteral("Unexpected finish. Exit code: %1\n%2")
.arg(process->exitCode())
.arg(QString(process->readAllStandardError())); .arg(QString(process->readAllStandardError()));
return process->exitCode(); return process->exitCode();
} }
@ -470,8 +470,8 @@ auto AbstractTest::CopyRecursively(const QString &srcFilePath, const QString &tg
return false; return false;
} }
QDir sourceDir(srcFilePath); QDir sourceDir(srcFilePath);
const QStringList fileNames = sourceDir.entryList(QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot | const QStringList fileNames =
QDir::Hidden | QDir::System); sourceDir.entryList(QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot | QDir::Hidden | QDir::System);
for (auto &fileName : fileNames) for (auto &fileName : fileNames)
{ {
const QString newSrcFilePath = srcFilePath + QDir::separator() + fileName; const QString newSrcFilePath = srcFilePath + QDir::separator() + fileName;
@ -504,8 +504,8 @@ auto AbstractTest::CopyRecursively(const QString &srcFilePath, const QString &tg
QFile srcFile(srcFilePath); QFile srcFile(srcFilePath);
if (not srcFile.open(QFile::ReadOnly)) if (not srcFile.open(QFile::ReadOnly))
{ {
const QString msg = QStringLiteral("Can't copy file '%1'. Error: %2") const QString msg =
.arg(srcFilePath, srcFile.errorString()); QStringLiteral("Can't copy file '%1'. Error: %2").arg(srcFilePath, srcFile.errorString());
QWARN(qUtf8Printable(msg)); QWARN(qUtf8Printable(msg));
return false; return false;
} }
@ -589,8 +589,8 @@ void AbstractTest::ReadBooleanValue(const QJsonObject &itemObject, const QString
} }
else else
{ {
const QString error = QStringLiteral("%1 is not boolean value '%2'.").arg(attribute, const QString error =
attributeValue.toString()); QStringLiteral("%1 is not boolean value '%2'.").arg(attribute, attributeValue.toString());
QFAIL(qUtf8Printable(error)); QFAIL(qUtf8Printable(error));
} }
} }
@ -703,9 +703,8 @@ void AbstractTest::ReadPieceNodeValue(const QJsonObject &itemObject, VPieceNode
node = VPieceNode(id, typeTool, reverse); node = VPieceNode(id, typeTool, reverse);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
template<typename T, typename std::enable_if<std::is_floating_point<T>::value>::type*> template <typename T, typename std::enable_if<std::is_floating_point<T>::value>::type *>
void AbstractTest::ReadDoubleValue(const QJsonObject &itemObject, const QString &attribute, T &value, void AbstractTest::ReadDoubleValue(const QJsonObject &itemObject, const QString &attribute, T &value,
const QString &defaultValue) const QString &defaultValue)
{ {
@ -744,7 +743,7 @@ void AbstractTest::ReadDoubleValue(const QJsonObject &itemObject, const QString
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
template<typename T, typename std::enable_if<std::is_enum<T>::value>::type*> template <typename T, typename std::enable_if<std::is_enum<T>::value>::type *>
void AbstractTest::ReadDoubleValue(const QJsonObject &itemObject, const QString &attribute, T &value, void AbstractTest::ReadDoubleValue(const QJsonObject &itemObject, const QString &attribute, T &value,
const QString &defaultValue) const QString &defaultValue)
{ {
@ -783,7 +782,7 @@ void AbstractTest::ReadDoubleValue(const QJsonObject &itemObject, const QString
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
template<typename T, typename std::enable_if<std::is_integral<T>::value>::type*> template <typename T, typename std::enable_if<std::is_integral<T>::value>::type *>
void AbstractTest::ReadDoubleValue(const QJsonObject &itemObject, const QString &attribute, T &value, void AbstractTest::ReadDoubleValue(const QJsonObject &itemObject, const QString &attribute, T &value,
const QString &defaultValue) const QString &defaultValue)
{ {
@ -913,7 +912,7 @@ void AbstractTest::DBFromJson(const QJsonObject &dbObject, QSharedPointer<VConta
GOType objectType; GOType objectType;
AbstractTest::ReadDoubleValue(itemObject, QStringLiteral("type"), objectType); AbstractTest::ReadDoubleValue(itemObject, QStringLiteral("type"), objectType);
switch(objectType) switch (objectType)
{ {
case GOType::Point: case GOType::Point:
{ {
@ -930,8 +929,8 @@ void AbstractTest::DBFromJson(const QJsonObject &dbObject, QSharedPointer<VConta
break; break;
default: default:
{ {
const QString error = QStringLiteral("Not supported item type '%1'.") const QString error =
.arg(static_cast<int>(objectType)); QStringLiteral("Not supported item type '%1'.").arg(static_cast<int>(objectType));
QFAIL(qUtf8Printable(error)); QFAIL(qUtf8Printable(error));
} }
} }

View File

@ -31,11 +31,13 @@
#include <QDialog> #include <QDialog>
#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0)
#include "../vmisc/defglobal.h" #include "../vmisc/defglobal.h"
#endif
namespace Ui namespace Ui
{ {
class DialogPatternMaterials; class DialogPatternMaterials;
} }
class VComboBoxDelegate; class VComboBoxDelegate;

View File

@ -27,9 +27,9 @@
*************************************************************************/ *************************************************************************/
#include "global.h" #include "global.h"
#include "../vmisc/compatibility.h"
#include "../vmisc/def.h" #include "../vmisc/def.h"
#include "../vmisc/vabstractapplication.h" #include "../vmisc/vabstractapplication.h"
#include "../vmisc/compatibility.h"
#include <QBitmap> #include <QBitmap>
#include <QGraphicsItem> #include <QGraphicsItem>
@ -79,7 +79,7 @@ auto CorrectColor(const QGraphicsItem *item, const QColor &color) -> QColor
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto PointRect(qreal radius) -> QRectF auto PointRect(qreal radius) -> QRectF
{ {
QRectF rec = QRectF(0, 0, radius*2, radius*2); QRectF rec = QRectF(0, 0, radius * 2, radius * 2);
rec.translate(-rec.center().x(), -rec.center().y()); rec.translate(-rec.center().x(), -rec.center().y());
return rec; return rec;
} }
@ -90,7 +90,7 @@ auto ScaledRadius(qreal scale) -> qreal
qreal scaledRadius = DefPointRadiusPixel(); qreal scaledRadius = DefPointRadiusPixel();
if (scale > 1) if (scale > 1)
{ {
scaledRadius = qMax(DefPointRadiusPixel()/96, DefPointRadiusPixel()/scale); scaledRadius = qMax(DefPointRadiusPixel() / 96, DefPointRadiusPixel() / scale);
} }
return scaledRadius; return scaledRadius;
} }
@ -108,7 +108,7 @@ auto ScaleWidth(qreal width, qreal scale) -> qreal
{ {
if (scale > 1) if (scale > 1)
{ {
width = qMax(0.01, width/scale); width = qMax(0.01, width / scale);
} }
return width; return width;
} }
@ -178,9 +178,7 @@ void GraphicsItemHighlightSelected(const QRectF &boundingRect, qreal itemPenWidt
const QColor fgcolor = option->palette.windowText().color(); const QColor fgcolor = option->palette.windowText().color();
const QColor bgcolor( // ensure good contrast against fgcolor const QColor bgcolor( // ensure good contrast against fgcolor
fgcolor.red() > 127 ? 0 : 255, fgcolor.red() > 127 ? 0 : 255, fgcolor.green() > 127 ? 0 : 255, fgcolor.blue() > 127 ? 0 : 255);
fgcolor.green() > 127 ? 0 : 255,
fgcolor.blue() > 127 ? 0 : 255);
painter->setPen(QPen(bgcolor, penWidth, Qt::SolidLine)); painter->setPen(QPen(bgcolor, penWidth, Qt::SolidLine));
painter->setBrush(Qt::NoBrush); painter->setBrush(Qt::NoBrush);
@ -195,6 +193,6 @@ void GraphicsItemHighlightSelected(const QRectF &boundingRect, qreal itemPenWidt
auto IsSelectedByReleaseEvent(QGraphicsItem *item, QGraphicsSceneMouseEvent *event) -> bool auto IsSelectedByReleaseEvent(QGraphicsItem *item, QGraphicsSceneMouseEvent *event) -> bool
{ {
SCASSERT(item != nullptr) SCASSERT(item != nullptr)
return event->button() == Qt::LeftButton && event->type() != QEvent::GraphicsSceneMouseDoubleClick return event->button() == Qt::LeftButton && event->type() != QEvent::GraphicsSceneMouseDoubleClick &&
&& item->contains(event->pos()); item->contains(event->pos());
} }

View File

@ -29,8 +29,8 @@
#ifndef GLOBAL_H #ifndef GLOBAL_H
#define GLOBAL_H #define GLOBAL_H
#include <QtGlobal>
#include <QStyleOptionGraphicsItem> #include <QStyleOptionGraphicsItem>
#include <QtGlobal>
extern const qreal minVisibleFontSize; extern const qreal minVisibleFontSize;
@ -66,7 +66,7 @@ void GraphicsItemHighlightSelected(const QRectF &boundingRect, qreal itemPenWidt
* Unfortunatelly qt_graphicsItem_highlightSelected was designed in way that doesn't support custom QGraphicsItem * Unfortunatelly qt_graphicsItem_highlightSelected was designed in way that doesn't support custom QGraphicsItem
* classes. Such classes always get pen width 1.0. This make imposible to draw selection rect around very small objects. * classes. Such classes always get pen width 1.0. This make imposible to draw selection rect around very small objects.
*/ */
template<class Parent, class Item> template <class Parent, class Item>
void PaintWithFixItemHighlightSelected(Item *item, QPainter *painter, const QStyleOptionGraphicsItem *option, void PaintWithFixItemHighlightSelected(Item *item, QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget) QWidget *widget)
{ {

View File

@ -30,22 +30,25 @@
#include <QItemDelegate> #include <QItemDelegate>
#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0)
#include "../vmisc/defglobal.h" #include "../vmisc/defglobal.h"
#endif
class VComboBoxDelegate : public QItemDelegate class VComboBoxDelegate : public QItemDelegate
{ {
Q_OBJECT // NOLINT Q_OBJECT // NOLINT
public: public:
explicit VComboBoxDelegate(const QStringList &items, QObject *parent = nullptr); explicit VComboBoxDelegate(const QStringList &items, QObject *parent = nullptr);
virtual auto createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const virtual auto createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const
-> QWidget * override; -> QWidget * override;
virtual void setEditorData(QWidget *editor, const QModelIndex &index) const override; virtual void setEditorData(QWidget *editor, const QModelIndex &index) const override;
virtual void setModelData(QWidget *editor, QAbstractItemModel *model, virtual void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const override;
const QModelIndex &index) const override;
virtual void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, virtual void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option,
const QModelIndex &index) const override; const QModelIndex &index) const override;
private: private:
// cppcheck-suppress unknownMacro // cppcheck-suppress unknownMacro
Q_DISABLE_COPY_MOVE(VComboBoxDelegate) // NOLINT Q_DISABLE_COPY_MOVE(VComboBoxDelegate) // NOLINT

View File

@ -31,13 +31,16 @@
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VDecorationAligningDelegate::VDecorationAligningDelegate(Qt::Alignment alignment, QObject *parent) VDecorationAligningDelegate::VDecorationAligningDelegate(Qt::Alignment alignment, QObject *parent)
: QStyledItemDelegate(parent), m_alignment(alignment) : QStyledItemDelegate(parent),
{} m_alignment(alignment)
{
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VDecorationAligningDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const void VDecorationAligningDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option,
const QModelIndex &index) const
{ {
QIcon icon = QIcon(qvariant_cast<QIcon>(index.data(Qt::DecorationRole))); auto icon(qvariant_cast<QIcon>(index.data(Qt::DecorationRole)));
if ((option.state & QStyle::State_Selected) != 0U) if ((option.state & QStyle::State_Selected) != 0U)
{ {

View File

@ -30,7 +30,9 @@
#include <QStyledItemDelegate> #include <QStyledItemDelegate>
#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0)
#include "../vmisc/defglobal.h" #include "../vmisc/defglobal.h"
#endif
class VDecorationAligningDelegate : public QStyledItemDelegate class VDecorationAligningDelegate : public QStyledItemDelegate
{ {

View File

@ -29,17 +29,26 @@
#include "tst_tapecommandline.h" #include "tst_tapecommandline.h"
#include "../vmisc/vsysexits.h" #include "../vmisc/vsysexits.h"
#include <QtTest> #if QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
#include "../vmisc/diagnostic.h"
#endif // QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
#include <QGlobalStatic> #include <QGlobalStatic>
#include <QtTest>
namespace namespace
{ {
QT_WARNING_PUSH
QT_WARNING_DISABLE_CLANG("-Wunused-member-function")
Q_GLOBAL_STATIC_WITH_ARGS(const QString, tmpTestFolder, (QLatin1String("tst_tape_tmp"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, tmpTestFolder, (QLatin1String("tst_tape_tmp"))) // NOLINT
}
QT_WARNING_POP
} // namespace
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
TST_TapeCommandLine::TST_TapeCommandLine(QObject *parent) TST_TapeCommandLine::TST_TapeCommandLine(QObject *parent)
:AbstractTest(parent) : AbstractTest(parent)
{ {
} }
@ -66,50 +75,35 @@ void TST_TapeCommandLine::OpenMeasurements_data() const
QTest::addColumn<int>("exitCode"); QTest::addColumn<int>("exitCode");
// The file doesn't exist! // The file doesn't exist!
QTest::newRow("Send wrong path to a file") << "wrongPath.vit" QTest::newRow("Send wrong path to a file") << "wrongPath.vit" << V_EX_NOINPUT;
<< V_EX_NOINPUT;
QTest::newRow("Old individual format to new version") << "keiko.vit" QTest::newRow("Old individual format to new version") << "keiko.vit" << V_EX_OK;
<< V_EX_OK;
QTest::newRow("Open empty file") << "empty.vit" QTest::newRow("Open empty file") << "empty.vit" << V_EX_OK;
<< V_EX_OK;
QTest::newRow("Open the VIT file with all know measurements (v0.3.0)") << "all_measurements_v0.3.0.vit" QTest::newRow("Open the VIT file with all know measurements (v0.3.0)") << "all_measurements_v0.3.0.vit" << V_EX_OK;
<< V_EX_OK;
QTest::newRow("Open the VST file with all know measurements (v0.4.0)") << "all_measurements_v0.4.0.vst" QTest::newRow("Open the VST file with all know measurements (v0.4.0)") << "all_measurements_v0.4.0.vst" << V_EX_OK;
<< V_EX_OK;
QTest::newRow("Open the VST file for man ru GOST (v0.3.0).") << "GOST_man_ru_v0.3.0.vst" QTest::newRow("Open the VST file for man ru GOST (v0.3.0).") << "GOST_man_ru_v0.3.0.vst" << V_EX_OK;
<< V_EX_OK;
QTest::newRow("Open the VIT file with all know measurements (v0.3.3)") << "all_measurements_v0.3.3.vit" QTest::newRow("Open the VIT file with all know measurements (v0.3.3)") << "all_measurements_v0.3.3.vit" << V_EX_OK;
<< V_EX_OK;
QTest::newRow("Open the VST file with all know measurements (v0.4.2)") << "all_measurements_v0.4.2.vst" QTest::newRow("Open the VST file with all know measurements (v0.4.2)") << "all_measurements_v0.4.2.vst" << V_EX_OK;
<< V_EX_OK;
QTest::newRow("Open the VST file for man ru GOST (v0.4.2).") << "GOST_man_ru_v0.4.2.vst" QTest::newRow("Open the VST file for man ru GOST (v0.4.2).") << "GOST_man_ru_v0.4.2.vst" << V_EX_OK;
<< V_EX_OK;
QTest::newRow("Broken file. Not unique name.") << "broken1.vit" QTest::newRow("Broken file. Not unique name.") << "broken1.vit" << V_EX_NOINPUT;
<< V_EX_NOINPUT;
QTest::newRow("Broken file. Measurement name can't be empty.") << "broken1.vit" QTest::newRow("Broken file. Measurement name can't be empty.") << "broken1.vit" << V_EX_NOINPUT;
<< V_EX_NOINPUT;
QTest::newRow("Broken file. An empty value shouldn't break a file.") << "broken3.vit" QTest::newRow("Broken file. An empty value shouldn't break a file.") << "broken3.vit" << V_EX_OK;
<< V_EX_OK;
QTest::newRow("Broken file. Invalid measurement name.") << "broken4.vit" QTest::newRow("Broken file. Invalid measurement name.") << "broken4.vit" << V_EX_NOINPUT;
<< V_EX_NOINPUT;
QTest::newRow("Empty text VIT file.") << "text.vit" QTest::newRow("Empty text VIT file.") << "text.vit" << V_EX_NOINPUT;
<< V_EX_NOINPUT;
QTest::newRow("Empty text VST file.") << "text.vst" QTest::newRow("Empty text VST file.") << "text.vst" << V_EX_NOINPUT;
<< V_EX_NOINPUT;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -119,9 +113,11 @@ void TST_TapeCommandLine::OpenMeasurements()
QFETCH(int, exitCode); QFETCH(int, exitCode);
QString error; QString error;
const int exit = Run(exitCode, TapePath(), QStringList() << "--test" const int exit = Run(exitCode, TapePath(),
QStringList() << "--test"
<< QCoreApplication::applicationDirPath() + QDir::separator() + *tmpTestFolder + << QCoreApplication::applicationDirPath() + QDir::separator() + *tmpTestFolder +
QDir::separator() + file, error); QDir::separator() + file,
error);
QVERIFY2(exit == exitCode, qUtf8Printable(error.right(350))); QVERIFY2(exit == exitCode, qUtf8Printable(error.right(350)));
} }

View File

@ -29,17 +29,27 @@
#include "tst_valentinacommandline.h" #include "tst_valentinacommandline.h"
#include "../vmisc/vsysexits.h" #include "../vmisc/vsysexits.h"
#include <QtTest> #if QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
#include "../vmisc/diagnostic.h"
#endif // QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
#include <QGlobalStatic> #include <QGlobalStatic>
#include <QtTest>
namespace namespace
{ {
QT_WARNING_PUSH
QT_WARNING_DISABLE_CLANG("-Wunused-member-function")
Q_GLOBAL_STATIC_WITH_ARGS(const QString, tmpTestFolder, (QLatin1String("tst_valentina_tmp"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, tmpTestFolder, (QLatin1String("tst_valentina_tmp"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, tmpTestCollectionFolder, (QLatin1String("tst_valentina_collection_tmp"))) // NOLINT // NOLINTNEXTLINE
} Q_GLOBAL_STATIC_WITH_ARGS(const QString, tmpTestCollectionFolder, (QLatin1String("tst_valentina_collection_tmp")))
QT_WARNING_POP
} // namespace
TST_ValentinaCommandLine::TST_ValentinaCommandLine(QObject *parent) TST_ValentinaCommandLine::TST_ValentinaCommandLine(QObject *parent)
:AbstractTest(parent) : AbstractTest(parent)
{ {
} }
@ -47,7 +57,7 @@ TST_ValentinaCommandLine::TST_ValentinaCommandLine(QObject *parent)
// cppcheck-suppress unusedFunction // cppcheck-suppress unusedFunction
void TST_ValentinaCommandLine::initTestCase() void TST_ValentinaCommandLine::initTestCase()
{ {
{// Test files { // Test files
QDir tmpDir(*tmpTestFolder); QDir tmpDir(*tmpTestFolder);
if (not tmpDir.removeRecursively()) if (not tmpDir.removeRecursively())
{ {
@ -62,7 +72,7 @@ void TST_ValentinaCommandLine::initTestCase()
} }
} }
{// Collection { // Collection
QDir tmpDir(*tmpTestCollectionFolder); QDir tmpDir(*tmpTestCollectionFolder);
if (not tmpDir.removeRecursively()) if (not tmpDir.removeRecursively())
{ {
@ -88,24 +98,19 @@ void TST_ValentinaCommandLine::OpenPatterns_data() const
// The file doesn't exist! // The file doesn't exist!
QTest::newRow("Send wrong path to a file") << "wrongPath.val" QTest::newRow("Send wrong path to a file") << "wrongPath.val"
<< "--test" << "--test" << V_EX_NOINPUT;
<< V_EX_NOINPUT;
QTest::newRow("Measurement independent empty file") << "empty.val" QTest::newRow("Measurement independent empty file") << "empty.val"
<< "--test" << "--test" << V_EX_OK;
<< V_EX_OK;
QTest::newRow("File with invalid object type") << "wrong_obj_type.val" QTest::newRow("File with invalid object type") << "wrong_obj_type.val"
<< "--test" << "--test" << V_EX_NOINPUT;
<< V_EX_NOINPUT;
QTest::newRow("Empty text VAL file") << "txt.val" QTest::newRow("Empty text VAL file") << "txt.val"
<< "--test" << "--test" << V_EX_NOINPUT;
<< V_EX_NOINPUT;
QTest::newRow("Pattern with a warning") << "test_pedantic.val" QTest::newRow("Pattern with a warning") << "test_pedantic.val"
<< "--test;;--pedantic" << "--test;;--pedantic" << V_EX_DATAERR;
<< V_EX_DATAERR;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -118,8 +123,8 @@ void TST_ValentinaCommandLine::OpenPatterns()
QString error; QString error;
const QString tmp = QCoreApplication::applicationDirPath() + QDir::separator() + *tmpTestFolder; const QString tmp = QCoreApplication::applicationDirPath() + QDir::separator() + *tmpTestFolder;
const int exit = Run(exitCode, ValentinaPath(), QStringList() << arguments.split(";;") const int exit =
<< tmp + QDir::separator() + file, error); Run(exitCode, ValentinaPath(), QStringList() << arguments.split(";;") << tmp + QDir::separator() + file, error);
QVERIFY2(exit == exitCode, qUtf8Printable(error.right(350))); QVERIFY2(exit == exitCode, qUtf8Printable(error.right(350)));
} }
@ -134,8 +139,7 @@ void TST_ValentinaCommandLine::ExportMode_data() const
const QString tmp = QCoreApplication::applicationDirPath() + QDir::separator() + *tmpTestFolder; const QString tmp = QCoreApplication::applicationDirPath() + QDir::separator() + *tmpTestFolder;
QTest::newRow("Issue #372")<< "issue_372.val" QTest::newRow("Issue #372") << "issue_372.val" << QString("-p;;0;;-d;;%1;;-b;;output;;--coefficient;;1").arg(tmp)
<< QString("-p;;0;;-d;;%1;;-b;;output;;--coefficient;;1").arg(tmp)
<< V_EX_OK; << V_EX_OK;
} }
@ -149,8 +153,7 @@ void TST_ValentinaCommandLine::ExportMode()
QString error; QString error;
const QString tmp = QCoreApplication::applicationDirPath() + QDir::separator() + *tmpTestFolder; const QString tmp = QCoreApplication::applicationDirPath() + QDir::separator() + *tmpTestFolder;
const QStringList arg = QStringList() << tmp + QDir::separator() + file const QStringList arg = QStringList() << tmp + QDir::separator() + file << arguments.split(";;");
<< arguments.split(";;");
const int exit = Run(exitCode, ValentinaPath(), arg, error); const int exit = Run(exitCode, ValentinaPath(), arg, error);
QVERIFY2(exit == exitCode, qUtf8Printable(error.right(350))); QVERIFY2(exit == exitCode, qUtf8Printable(error.right(350)));
@ -165,37 +168,29 @@ void TST_ValentinaCommandLine::TestMode_data() const
const QString tmp = QCoreApplication::applicationDirPath() + QDir::separator() + *tmpTestFolder; const QString tmp = QCoreApplication::applicationDirPath() + QDir::separator() + *tmpTestFolder;
QTest::newRow("Issue #256. Correct path.")<< "issue_256.val" QTest::newRow("Issue #256. Correct path.") << "issue_256.val" << QString("--test") << V_EX_OK;
<< QString("--test")
<< V_EX_OK;
QTest::newRow("Issue #256. Wrong path.")<< "issue_256_wrong_path.vit" QTest::newRow("Issue #256. Wrong path.") << "issue_256_wrong_path.vit" << QString("--test") << V_EX_NOINPUT;
<< QString("--test")
QTest::newRow("Issue #256. Correct individual measurements.")
<< "issue_256.val"
<< QString("--test;;-m;;%1").arg(tmp + QDir::separator() + QLatin1String("issue_256_correct.vit")) << V_EX_OK;
QTest::newRow("Issue #256. Wrong individual measurements.")
<< "issue_256.val"
<< QString("--test;;-m;;%1").arg(tmp + QDir::separator() + QLatin1String("issue_256_wrong.vit"))
<< V_EX_NOINPUT; << V_EX_NOINPUT;
QTest::newRow("Issue #256. Correct individual measurements.")<< "issue_256.val" QTest::newRow("Issue #256. Correct multisize measurements.")
<< QString("--test;;-m;;%1").arg(tmp + QDir::separator() + << "issue_256.val"
QLatin1String("issue_256_correct.vit")) << QString("--test;;-m;;%1").arg(tmp + QDir::separator() + QLatin1String("issue_256_correct.vst")) << V_EX_OK;
<< V_EX_OK;
QTest::newRow("Issue #256. Wrong individual measurements.")<< "issue_256.val" QTest::newRow("Issue #256. Wrong multisize measurements.")
<< QString("--test;;-m;;%1").arg(tmp + QDir::separator() + << "issue_256.val"
QLatin1String("issue_256_wrong.vit")) << QString("--test;;-m;;%1").arg(tmp + QDir::separator() + QLatin1String("issue_256_wrong.vst"))
<< V_EX_NOINPUT; << V_EX_NOINPUT;
QTest::newRow("Issue #256. Correct multisize measurements.")<< "issue_256.val" QTest::newRow("Wrong formula.") << "wrong_formula.val" << QString("--test") << V_EX_DATAERR;
<< QString("--test;;-m;;%1").arg(tmp + QDir::separator() +
QLatin1String("issue_256_correct.vst"))
<< V_EX_OK;
QTest::newRow("Issue #256. Wrong multisize measurements.")<< "issue_256.val"
<< QString("--test;;-m;;%1").arg(tmp + QDir::separator() +
QLatin1String("issue_256_wrong.vst"))
<< V_EX_NOINPUT;
QTest::newRow("Wrong formula.")<< "wrong_formula.val"
<< QString("--test")
<< V_EX_DATAERR;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -207,8 +202,7 @@ void TST_ValentinaCommandLine::TestMode()
QString error; QString error;
const QString tmp = QCoreApplication::applicationDirPath() + QDir::separator() + *tmpTestFolder; const QString tmp = QCoreApplication::applicationDirPath() + QDir::separator() + *tmpTestFolder;
const QStringList arg = QStringList() << tmp + QDir::separator() + file const QStringList arg = QStringList() << tmp + QDir::separator() + file << arguments.split(";;");
<< arguments.split(";;");
const int exit = Run(exitCode, ValentinaPath(), arg, error); const int exit = Run(exitCode, ValentinaPath(), arg, error);
QVERIFY2(exit == exitCode, qUtf8Printable(error.right(350))); QVERIFY2(exit == exitCode, qUtf8Printable(error.right(350)));
@ -268,8 +262,7 @@ void TST_ValentinaCommandLine::TestOpenCollection()
QString error; QString error;
const QString tmp = QCoreApplication::applicationDirPath() + QDir::separator() + *tmpTestCollectionFolder; const QString tmp = QCoreApplication::applicationDirPath() + QDir::separator() + *tmpTestCollectionFolder;
const QStringList arg = QStringList() << tmp + QDir::separator() + file const QStringList arg = QStringList() << tmp + QDir::separator() + file << arguments.split(";;");
<< arguments.split(";;");
const int exit = Run(exitCode, ValentinaPath(), arg, error); const int exit = Run(exitCode, ValentinaPath(), arg, error);
QVERIFY2(exit == exitCode, qUtf8Printable(error.right(350))); QVERIFY2(exit == exitCode, qUtf8Printable(error.right(350)));

View File

@ -32,34 +32,35 @@
#include <xercesc/util/PlatformUtils.hpp> #include <xercesc/util/PlatformUtils.hpp>
#endif #endif
#include "tst_vposter.h"
#include "tst_vabstractpiece.h"
#include "tst_vspline.h"
#include "tst_nameregexp.h"
#include "tst_vlayoutdetail.h"
#include "tst_varc.h"
#include "tst_vellipticalarc.h"
#include "tst_qmutokenparser.h"
#include "tst_vmeasurements.h"
#include "tst_vlockguard.h"
#include "tst_misc.h"
#include "tst_vcommandline.h"
#include "tst_vpiece.h"
#include "tst_findpoint.h"
#include "tst_vabstractcurve.h"
#include "tst_vcubicbezierpath.h"
#include "tst_vgobject.h"
#include "tst_vsplinepath.h"
#include "tst_vpointf.h"
#include "tst_readval.h"
#include "tst_vtranslatevars.h"
#include "tst_vtooluniondetails.h"
#include "tst_vdomdocument.h"
#include "tst_dxf.h" #include "tst_dxf.h"
#include "tst_findpoint.h"
#include "tst_misc.h"
#include "tst_nameregexp.h"
#include "tst_qmutokenparser.h"
#include "tst_readval.h"
#include "tst_vabstractcurve.h"
#include "tst_vabstractpiece.h"
#include "tst_varc.h"
#include "tst_vcommandline.h"
#include "tst_vcubicbezierpath.h"
#include "tst_vdomdocument.h"
#include "tst_vellipticalarc.h"
#include "tst_vgobject.h"
#include "tst_vlayoutdetail.h"
#include "tst_vlockguard.h"
#include "tst_vmeasurements.h"
#include "tst_vpiece.h"
#include "tst_vpointf.h"
#include "tst_vposter.h"
#include "tst_vspline.h"
#include "tst_vsplinepath.h"
#include "tst_vsvgpathtokenizer.h"
#include "tst_vtooluniondetails.h"
#include "tst_vtranslatevars.h"
#include "tst_xsdschema.h" #include "tst_xsdschema.h"
#include "../vmisc/def.h"
#include "../qmuparser/qmudef.h" #include "../qmuparser/qmudef.h"
#include "../vmisc/def.h"
#include "../vmisc/testvapplication.h" #include "../vmisc/testvapplication.h"
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -70,10 +71,10 @@ auto main(int argc, char **argv) -> int
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
XERCES_CPP_NAMESPACE::XMLPlatformUtils::Initialize(); XERCES_CPP_NAMESPACE::XMLPlatformUtils::Initialize();
auto Terminate = qScopeGuard([](){ XERCES_CPP_NAMESPACE::XMLPlatformUtils::Terminate(); }); auto Terminate = qScopeGuard([]() { XERCES_CPP_NAMESPACE::XMLPlatformUtils::Terminate(); });
#endif #endif
TestVApplication app( argc, argv );// For QPrinter TestVApplication app(argc, argv); // For QPrinter
QResource::registerResource(QCoreApplication::applicationDirPath() + QStringLiteral("/test_data.rcc")); QResource::registerResource(QCoreApplication::applicationDirPath() + QStringLiteral("/test_data.rcc"));