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 {
Depends { name: "freedesktop2" }
Depends { name: "tenv" }
Depends { name: "windeployqt"; condition: qbs.targetOS.contains("windows") }
Depends { name: "i18nconfig"; }
Depends { name: "i18n"; }

View File

@ -27,24 +27,22 @@
*************************************************************************/
#include "puzzlepreferencesconfigurationpage.h"
#include "ui_puzzlepreferencesconfigurationpage.h"
#include "../../vpapplication.h"
#include "ui_puzzlepreferencesconfigurationpage.h"
#if QT_VERSION < QT_VERSION_CHECK(5, 7, 0)
#include "../vmisc/backport/qoverload.h"
#endif // QT_VERSION < QT_VERSION_CHECK(5, 7, 0)
//---------------------------------------------------------------------------------------------------------------------
PuzzlePreferencesConfigurationPage::PuzzlePreferencesConfigurationPage(QWidget *parent) :
QWidget(parent),
PuzzlePreferencesConfigurationPage::PuzzlePreferencesConfigurationPage(QWidget *parent)
: QWidget(parent),
ui(new Ui::PuzzlePreferencesConfigurationPage)
{
ui->setupUi(this);
InitLanguages(ui->langCombo);
connect(ui->langCombo, QOverload<int>::of(&QComboBox::currentIndexChanged), this, [this]()
{
m_langChanged = true;
});
connect(ui->langCombo, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
[this]() { m_langChanged = true; });
VPSettings *settings = VPApplication::VApp()->PuzzleSettings();
@ -60,7 +58,7 @@ PuzzlePreferencesConfigurationPage::PuzzlePreferencesConfigurationPage(QWidget *
// Undo
ui->undoCount->setValue(settings->GetUndoCount());
//Graphical output
// Graphical output
ui->graphOutputCheck->setChecked(settings->GetGraphicalOutput());
ui->checkBoxOpenGLRender->setChecked(settings->IsOpenGLRender());
@ -121,7 +119,7 @@ auto PuzzlePreferencesConfigurationPage::Apply() -> QStringList
m_langChanged = false;
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

View File

@ -26,10 +26,10 @@
**
*************************************************************************/
#include "dialogsavemanuallayout.h"
#include "ui_dialogsavemanuallayout.h"
#include "../vpapplication.h"
#include "../ifc/exception/vexception.h"
#include "../vlayout/vlayoutexporter.h"
#include "../vpapplication.h"
#include "ui_dialogsavemanuallayout.h"
#if QT_VERSION < QT_VERSION_CHECK(5, 7, 0)
#include "../vmisc/backport/qoverload.h"
#endif // QT_VERSION < QT_VERSION_CHECK(5, 7, 0)
@ -38,19 +38,31 @@
#include <QShowEvent>
#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
Q_GLOBAL_STATIC_WITH_ARGS(const QString, baseFilenameRegExp, (QLatin1String("^[^\\/]+$"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, baseFilenameRegExp, (QLatin1String("^[^\\/]+$"))) // NOLINT
#else
Q_GLOBAL_STATIC_WITH_ARGS(const QString, baseFilenameRegExp, (QLatin1String("^[^\\:?\"*|\\/<>]+$"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, baseFilenameRegExp, (QLatin1String("^[^\\:?\"*|\\/<>]+$"))) // NOLINT
#endif
QT_WARNING_POP
} // namespace
//---------------------------------------------------------------------------------------------------------------------
DialogSaveManualLayout::DialogSaveManualLayout(vsizetype count, bool consoleExport, const QString &fileName,
QWidget *parent)
: VAbstractLayoutDialog(parent),
ui(new Ui::DialogSaveManualLayout),
m_count(count),
m_consoleExport(consoleExport)
: VAbstractLayoutDialog(parent),
ui(new Ui::DialogSaveManualLayout),
m_count(count),
m_consoleExport(consoleExport)
{
ui->setupUi(this);
@ -64,7 +76,7 @@ DialogSaveManualLayout::DialogSaveManualLayout(vsizetype count, bool consoleExpo
SCASSERT(bOk != nullptr)
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;
if (not m_consoleExport)
@ -91,45 +103,46 @@ DialogSaveManualLayout::DialogSaveManualLayout(vsizetype count, bool consoleExpo
RemoveFormatFromList(LayoutExportFormats::OBJ);
#endif
// RemoveFormatFromList(LayoutExportFormats::NC); // No support for now
// RemoveFormatFromList(LayoutExportFormats::NC); // No support for now
connect(bOk, &QPushButton::clicked, this, &DialogSaveManualLayout::Save);
connect(ui->lineEditFileName, &QLineEdit::textChanged, this, &DialogSaveManualLayout::ShowExample);
connect(ui->comboBoxFormat, QOverload<int>::of(&QComboBox::currentIndexChanged),
this, &DialogSaveManualLayout::ShowExample);
connect(ui->comboBoxFormat, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
&DialogSaveManualLayout::ShowExample);
connect(ui->pushButtonBrowse, &QPushButton::clicked, this, [this]()
{
const QString dirPath = VPApplication::VApp()->PuzzleSettings()->GetPathManualLayouts();
bool usedNotExistedDir = false;
QDir directory(dirPath);
if (not directory.exists())
{
usedNotExistedDir = directory.mkpath(QChar('.'));
}
connect(ui->pushButtonBrowse, &QPushButton::clicked, this,
[this]()
{
const QString dirPath = VPApplication::VApp()->PuzzleSettings()->GetPathManualLayouts();
bool usedNotExistedDir = false;
QDir directory(dirPath);
if (not directory.exists())
{
usedNotExistedDir = directory.mkpath(QChar('.'));
}
const QString dir = QFileDialog::getExistingDirectory(
this, tr("Select folder"), dirPath,
VAbstractApplication::VApp()->NativeFileDialog(QFileDialog::ShowDirsOnly |
QFileDialog::DontResolveSymlinks));
if (not dir.isEmpty())
{// If paths equal the signal will not be called, we will do this manually
dir == ui->lineEditPath->text() ? PathChanged(dir) : ui->lineEditPath->setText(dir);
}
const QString dir = QFileDialog::getExistingDirectory(
this, tr("Select folder"), dirPath,
VAbstractApplication::VApp()->NativeFileDialog(QFileDialog::ShowDirsOnly |
QFileDialog::DontResolveSymlinks));
if (not dir.isEmpty())
{ // If paths equal the signal will not be called, we will do this manually
dir == ui->lineEditPath->text() ? PathChanged(dir) : ui->lineEditPath->setText(dir);
}
if (usedNotExistedDir)
{
QDir directory(dirPath);
directory.rmpath(QChar('.'));
}
});
if (usedNotExistedDir)
{
QDir directory(dirPath);
directory.rmpath(QChar('.'));
}
});
connect(ui->lineEditPath, &QLineEdit::textChanged, this, &DialogSaveManualLayout::PathChanged);
ui->lineEditPath->setText(VPApplication::VApp()->PuzzleSettings()->GetPathManualLayouts());
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)
{
switch(Format())
switch (Format())
{
case LayoutExportFormats::DXF_AC1006_Flat:
case LayoutExportFormats::DXF_AC1009_Flat:
@ -199,7 +212,7 @@ void DialogSaveManualLayout::SetBinaryDXFFormat(bool binary)
//---------------------------------------------------------------------------------------------------------------------
auto DialogSaveManualLayout::IsBinaryDXFFormat() const -> bool
{
switch(Format())
switch (Format())
{
case LayoutExportFormats::DXF_AC1006_Flat:
case LayoutExportFormats::DXF_AC1009_Flat:
@ -221,7 +234,7 @@ auto DialogSaveManualLayout::IsBinaryDXFFormat() const -> bool
//---------------------------------------------------------------------------------------------------------------------
void DialogSaveManualLayout::SetShowGrainline(bool show)
{
switch(Format())
switch (Format())
{
case LayoutExportFormats::SVG:
case LayoutExportFormats::PDF:
@ -250,7 +263,7 @@ void DialogSaveManualLayout::SetShowGrainline(bool show)
//---------------------------------------------------------------------------------------------------------------------
auto DialogSaveManualLayout::IsShowGrainline() const -> bool
{
switch(Format())
switch (Format())
{
case LayoutExportFormats::SVG:
case LayoutExportFormats::PDF:
@ -315,7 +328,7 @@ void DialogSaveManualLayout::SetTextAsPaths(bool textAsPaths)
//---------------------------------------------------------------------------------------------------------------------
void DialogSaveManualLayout::SetExportUnified(bool value)
{
switch(Format())
switch (Format())
{
case LayoutExportFormats::PDF:
case LayoutExportFormats::PDFTiled:
@ -332,7 +345,7 @@ void DialogSaveManualLayout::SetExportUnified(bool value)
//---------------------------------------------------------------------------------------------------------------------
auto DialogSaveManualLayout::IsExportUnified() const -> bool
{
switch(Format())
switch (Format())
{
case LayoutExportFormats::PDF:
case LayoutExportFormats::PDFTiled:
@ -347,7 +360,7 @@ auto DialogSaveManualLayout::IsExportUnified() const -> bool
//---------------------------------------------------------------------------------------------------------------------
void DialogSaveManualLayout::SetTilesScheme(bool value)
{
switch(Format())
switch (Format())
{
case LayoutExportFormats::PDFTiled:
ui->checkBoxTilesScheme->setChecked(value);
@ -361,7 +374,7 @@ void DialogSaveManualLayout::SetTilesScheme(bool value)
//---------------------------------------------------------------------------------------------------------------------
auto DialogSaveManualLayout::IsTilesScheme() const -> bool
{
switch(Format())
switch (Format())
{
case LayoutExportFormats::PDFTiled:
return ui->checkBoxTilesScheme->isChecked();
@ -373,8 +386,8 @@ auto DialogSaveManualLayout::IsTilesScheme() const -> bool
//---------------------------------------------------------------------------------------------------------------------
void DialogSaveManualLayout::showEvent(QShowEvent *event)
{
QDialog::showEvent( event );
if ( event->spontaneous() )
QDialog::showEvent(event);
if (event->spontaneous())
{
return;
}
@ -387,7 +400,7 @@ void DialogSaveManualLayout::showEvent(QShowEvent *event)
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();
for (int i=0; i < m_count; ++i)
for (int i = 0; i < m_count; ++i)
{
QString name;
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
{
@ -409,9 +422,10 @@ void DialogSaveManualLayout::Save()
if (QFile::exists(name))
{
QMessageBox::StandardButton res = QMessageBox::question(this, tr("Name conflict"),
tr("Folder already contain file with name %1. Rewrite all conflict file names?")
.arg(name), QMessageBox::Yes|QMessageBox::No, QMessageBox::Yes);
QMessageBox::StandardButton res = QMessageBox::question(
this, tr("Name conflict"),
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)
{
reject();
@ -470,7 +484,7 @@ void DialogSaveManualLayout::ShowExample()
ui->checkBoxTilesScheme->setEnabled(false);
ui->checkBoxShowGrainline->setEnabled(true);
switch(currentFormat)
switch (currentFormat)
{
case LayoutExportFormats::DXF_AAMA:
case LayoutExportFormats::DXF_ASTM:
@ -515,7 +529,7 @@ void DialogSaveManualLayout::ShowExample()
auto DialogSaveManualLayout::SupportPSTest() -> bool
{
static bool havePdf = false;
static bool tested = false;
static bool tested = false;
if (!tested)
{
havePdf = VLayoutExporter::SupportPDFConversion();
@ -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;
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::PDF);
@ -555,7 +567,7 @@ auto DialogSaveManualLayout::InitFormats() -> QVector<std::pair<QString, LayoutE
InitFormat(LayoutExportFormats::DXF_AAMA);
InitFormat(LayoutExportFormats::DXF_ASTM);
InitFormat(LayoutExportFormats::PDFTiled);
// InitFormat(LayoutExportFormats::NC);
// InitFormat(LayoutExportFormats::NC);
InitFormat(LayoutExportFormats::RLD);
InitFormat(LayoutExportFormats::TIF);

View File

@ -42,20 +42,24 @@
#include "../layout/vplayout.h"
#include "../layout/vppiece.h"
#include "../layout/vpsheet.h"
#include "../vlayout/vgraphicsfillitem.h"
#include "../vlayout/vtextmanager.h"
#include "../vpapplication.h"
#include "../vlayout/vlayoutpiecepath.h"
#include "compatibility.h"
#include "../vformat/vsinglelineoutlinechar.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/vpundopiecemove.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>
QT_WARNING_PUSH
@ -68,9 +72,14 @@ QT_WARNING_POP
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, errorColor, (Qt::red)) // NOLINT
QT_WARNING_POP
//---------------------------------------------------------------------------------------------------------------------
inline auto LineMatrix(const VPPiecePtr &piece, const QPointF &topLeft, qreal angle, const QPointF &linePos,
int maxLineWidth) -> QTransform

View File

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

View File

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

View File

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

File diff suppressed because it is too large Load Diff

View File

@ -28,36 +28,57 @@
#include "vpsettings.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>
namespace
{
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingDockWidgetPropertiesActive, (QLatin1String("dockWidget/properties"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingDockPropertiesContentsActive, (QLatin1String("dockWidget/contents"))) // NOLINT
QT_WARNING_PUSH
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, settingLayoutSheetPaperWidth, (QLatin1String("layout/sheetPaperWidth"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutSheetPaperHeight, (QLatin1String("layout/sheetPaperHeight"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutTilePaperWidth, (QLatin1String("layout/tilePaperWidth"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutTilePaperHeight, (QLatin1String("layout/tilePaperHeight"))) // NOLINT
// NOLINTNEXTLINE
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutSheetPaperWidth, (QLatin1String("layout/sheetPaperWidth")))
// NOLINTNEXTLINE
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, settingLayoutTileMargins, (QLatin1String("layout/tileMargins"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutSheetIgnoreMargins, (QLatin1String("layout/sheetIgnoreMargins"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutTileIgnoreMargins, (QLatin1String("layout/tileIgnoreMargins"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutTileMargins, (QLatin1String("layout/tileMargins"))) // NOLINT
// NOLINTNEXTLINE
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, settingLayoutTileShowWatermark, (QLatin1String("layout/tileShowWatermark"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutWarningPiecesSuperposition, // NOLINT
// NOLINTNEXTLINE
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutTileShowWatermark, (QLatin1String("layout/tileShowWatermark")))
// NOLINTNEXTLINE
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutWarningPiecesSuperposition,
(QLatin1String("layout/warningPiecesSuperposition")))
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")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutFollowGrainline, (QLatin1String("layout/followGrainline"))) // 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, settingLayoutLineWidth, (QLatin1String("layout/lineWidth"))) // 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, settingLayoutExportFormat, (QLatin1String("layout/exportFormat"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutLineWidth, (QLatin1String("layout/lineWidth"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutShowGrainline, (QLatin1String("layout/showGrainline"))) // NOLINT
QT_WARNING_POP
int cachedLineWidth = -1; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)
} // namespace
} // namespace
#ifndef QPRINTENGINE_H
Q_DECLARE_METATYPE(QMarginsF) // NOLINT
@ -65,15 +86,12 @@ Q_DECLARE_METATYPE(QMarginsF) // NOLINT
//---------------------------------------------------------------------------------------------------------------------
VPSettings::VPSettings(Format format, Scope scope, const QString &organization, const QString &application,
QObject *parent)
: VCommonSettings(format, scope, organization, application, parent)
{
REGISTER_META_TYPE_STREAM_OPERATORS(QMarginsF)
}
QObject *parent)
: VCommonSettings(format, scope, organization, application, parent){REGISTER_META_TYPE_STREAM_OPERATORS(QMarginsF)}
//---------------------------------------------------------------------------------------------------------------------
VPSettings::VPSettings(const QString &fileName, QSettings::Format format, QObject *parent)
: VCommonSettings(fileName, format, parent)
//---------------------------------------------------------------------------------------------------------------------
VPSettings::VPSettings(const QString &fileName, QSettings::Format format, QObject *parent)
: VCommonSettings(fileName, format, parent)
{
REGISTER_META_TYPE_STREAM_OPERATORS(QMarginsF)
}
@ -135,7 +153,7 @@ void VPSettings::SetLayoutSheetPaperWidth(qreal width)
//---------------------------------------------------------------------------------------------------------------------
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
{
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
{
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
{
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 "../vwidgets/vmaingraphicsscene.h"
#include "layout/vpsheet.h"
#include "qobject.h"
#include "scene/vpmaingraphicsview.h"
#include "../vlayout/vprintlayout.h"
#include "../vmisc/compatibility.h"
#include "../vmisc/def.h"
#include "../vmisc/literals.h"
#include "../vmisc/vcommonsettings.h"
#include "../vmisc/compatibility.h"
#include "../vlayout/vprintlayout.h"
#include "../vwidgets/vmaingraphicsscene.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
{
Q_GLOBAL_STATIC_WITH_ARGS(QColor, tileColor, (180, 180, 180)) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(QBrush, triangleBush, (QColor(200,200,200))) // NOLINT
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(QBrush, triangleBush, (QColor(200, 200, 200))) // NOLINT
QT_WARNING_POP
//---------------------------------------------------------------------------------------------------------------------
auto Grayscale(QImage image) -> QImage
{
for (int ii = 0; ii < image.height(); ii++)
{
uchar* scan = image.scanLine(ii);
uchar *scan = image.scanLine(ii);
int depth = 4;
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);
*rgbpixel = QColor(gray, gray, gray, qAlpha(*rgbpixel)).rgba();
}
@ -41,9 +49,11 @@ auto WatermarkImageFromCache(const VWatermarkData &watermarkData, const QString
{
QPixmap pixmap;
QString imagePath = AbsoluteMPath(watermarkPath, watermarkData.path);
QString imageCacheKey = QStringLiteral("puzzle=path%1+rotation%3+grayscale%4+xscale%5+yxcale%6")
.arg(imagePath, QString::number(watermarkData.imageRotation),
watermarkData.grayscale ? trueStr : falseStr ).arg(xScale).arg(yScale);
QString imageCacheKey =
QStringLiteral("puzzle=path%1+rotation%3+grayscale%4+xscale%5+yxcale%6")
.arg(imagePath, QString::number(watermarkData.imageRotation), watermarkData.grayscale ? trueStr : falseStr)
.arg(xScale)
.arg(yScale);
if (not QPixmapCache::find(imageCacheKey, &pixmap))
{
@ -65,9 +75,9 @@ auto WatermarkImageFromCache(const VWatermarkData &watermarkData, const QString
watermark = watermark.transformed(t);
t = QTransform();
t.translate(watermark.width()/2., watermark.height()/2.);
t.translate(watermark.width() / 2., watermark.height() / 2.);
t.rotate(-watermarkData.imageRotation);
t.translate(-watermark.width()/2., -watermark.height()/2.);
t.translate(-watermark.width() / 2., -watermark.height() / 2.);
watermark = watermark.transformed(t);
pixmap = QPixmap::fromImage(watermark);
@ -82,9 +92,7 @@ auto WatermarkImageFromCache(const VWatermarkData &watermarkData, const QString
auto TriangleBasic() -> QPainterPath
{
// ------------- prepare triangles for position marks
QRectF rectBasic = QRectF(-UnitConvertor(0.5, Unit::Cm, Unit::Px),
0,
UnitConvertor(1, Unit::Cm, Unit::Px),
QRectF rectBasic = QRectF(-UnitConvertor(0.5, Unit::Cm, Unit::Px), 0, UnitConvertor(1, Unit::Cm, Unit::Px),
UnitConvertor(0.5, Unit::Cm, Unit::Px));
QPainterPath triangleBasic;
triangleBasic.moveTo(rectBasic.topLeft());
@ -93,16 +101,16 @@ auto TriangleBasic() -> QPainterPath
triangleBasic.lineTo(rectBasic.topLeft());
return triangleBasic;
}
} // namespace
} // namespace
// See https://stackoverflow.com/a/46719572/3045403
#if __cplusplus < 201703L // C++17
constexpr qreal VPTileFactory::tileStripeWidth; // NOLINT(readability-redundant-declaration)
#if __cplusplus < 201703L // C++17
constexpr qreal VPTileFactory::tileStripeWidth; // NOLINT(readability-redundant-declaration)
#endif
//---------------------------------------------------------------------------------------------------------------------
VPTileFactory::VPTileFactory(const VPLayoutPtr &layout, VCommonSettings *commonSettings, QObject *parent):
QObject(parent),
VPTileFactory::VPTileFactory(const VPLayoutPtr &layout, VCommonSettings *commonSettings, QObject *parent)
: QObject(parent),
m_layout(layout),
m_commonSettings(commonSettings)
{
@ -112,7 +120,7 @@ VPTileFactory::VPTileFactory(const VPLayoutPtr &layout, VCommonSettings *commonS
void VPTileFactory::RefreshTileInfos()
{
VPLayoutPtr layout = m_layout.toStrongRef();
if(not layout.isNull())
if (not layout.isNull())
{
QSizeF tilesSize = layout->LayoutSettings().GetTilesSize();
QMarginsF tilesMargins = layout->LayoutSettings().GetTilesMargins();
@ -139,7 +147,7 @@ void VPTileFactory::RefreshTileInfos()
void VPTileFactory::RefreshWatermarkData()
{
VPLayoutPtr layout = m_layout.toStrongRef();
if(not layout.isNull())
if (not layout.isNull())
{
m_watermarkData = layout->WatermarkData();
}
@ -156,7 +164,7 @@ void VPTileFactory::drawTile(QPainter *painter, QPrinter *printer, const VPSheet
SCASSERT(printer != nullptr)
VPLayoutPtr layout = m_layout.toStrongRef();
if(layout.isNull())
if (layout.isNull())
{
return;
}
@ -184,7 +192,7 @@ void VPTileFactory::drawTile(QPainter *painter, QPrinter *printer, const VPSheet
const QPair<qreal, qreal> scale = VPrintLayout::PrinterScaleDiff(printer);
painter->scale(scale.first, scale.second);
if(row > 0)
if (row > 0)
{
// add top triangle
DrawTopTriangle(painter);
@ -199,7 +207,7 @@ void VPTileFactory::drawTile(QPainter *painter, QPrinter *printer, const VPSheet
DrawSolidTopLine(painter, col, nbCol);
}
if(col > 0)
if (col > 0)
{
// add left triangle
DrawLeftTriangle(painter);
@ -214,7 +222,7 @@ void VPTileFactory::drawTile(QPainter *painter, QPrinter *printer, const VPSheet
DrawSolidLeftLine(painter, row, nbRow);
}
if(row < nbRow-1)
if (row < nbRow - 1)
{
// add bottom triangle
DrawBottomTriangle(painter);
@ -230,7 +238,7 @@ void VPTileFactory::drawTile(QPainter *painter, QPrinter *printer, const VPSheet
DrawRuler(painter, scale.first);
DrawWatermark(painter);
if(col < nbCol-1)
if (col < nbCol - 1)
{
// add right triangle
DrawRightTriangle(painter);
@ -259,7 +267,7 @@ auto VPTileFactory::RowNb(const VPSheetPtr &sheet) const -> int
qreal yScale = 1;
VPLayoutPtr layout = m_layout.toStrongRef();
if(not layout.isNull())
if (not layout.isNull())
{
yScale = layout->LayoutSettings().VerticalScale();
}
@ -278,7 +286,7 @@ auto VPTileFactory::ColNb(const VPSheetPtr &sheet) const -> int
qreal xScale = 1;
VPLayoutPtr layout = m_layout.toStrongRef();
if(not layout.isNull())
if (not layout.isNull())
{
xScale = layout->LayoutSettings().HorizontalScale();
}
@ -309,7 +317,7 @@ auto VPTileFactory::WatermarkData() const -> const VWatermarkData &
void VPTileFactory::DrawRuler(QPainter *painter, qreal scale) const
{
VPLayoutPtr layout = m_layout.toStrongRef();
if(layout.isNull())
if (layout.isNull())
{
return;
}
@ -326,18 +334,18 @@ void VPTileFactory::DrawRuler(QPainter *painter, qreal scale) const
Unit rulerUnits = layoutUnits == Unit::Inch ? layoutUnits : Unit::Cm;
const qreal step = UnitConvertor(1, rulerUnits, Unit::Px);
double marksCount = (m_drawingAreaWidth-tileStripeWidth) / step;
double marksCount = (m_drawingAreaWidth - tileStripeWidth) / step;
int i = 0;
while (i < marksCount)
{
if (i != 0)
{ // don't need 0 notch
// 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));
// 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));
}
else
@ -345,7 +353,7 @@ void VPTileFactory::DrawRuler(QPainter *painter, qreal scale) const
painter->save();
QFont fnt = painter->font();
const int size = qRound(10/scale);
const int size = qRound(10 / scale);
size > 0 ? fnt.setPointSize(size) : fnt.setPointSize(10);
painter->setFont(fnt);
@ -353,8 +361,9 @@ void VPTileFactory::DrawRuler(QPainter *painter, qreal scale) const
QFontMetrics fm(fnt);
QString units = rulerUnits != Unit::Inch ? tr("cm", "unit") : tr("in", "unit");
unitsWidth = TextWidth(fm, units);
painter->drawText(QPointF(step*0.5-unitsWidth*0.6,
m_drawingAreaHeight - tileStripeWidth + notchHeight+shortNotchHeight), units);
painter->drawText(QPointF(step * 0.5 - unitsWidth * 0.6,
m_drawingAreaHeight - tileStripeWidth + notchHeight + shortNotchHeight),
units);
painter->restore();
}
@ -370,21 +379,18 @@ void VPTileFactory::DrawWatermark(QPainter *painter) const
SCASSERT(painter != nullptr)
VPLayoutPtr layout = m_layout.toStrongRef();
if(layout.isNull())
if (layout.isNull())
{
return;
}
if (m_watermarkData.opacity > 0)
{
QRectF img(0, 0,
m_drawingAreaWidth - tileStripeWidth,
m_drawingAreaHeight - tileStripeWidth);
QRectF img(0, 0, m_drawingAreaWidth - tileStripeWidth, m_drawingAreaHeight - tileStripeWidth);
if (m_watermarkData.showImage && not m_watermarkData.path.isEmpty())
{
PaintWatermarkImage(painter, img, m_watermarkData,
layout->LayoutSettings().WatermarkPath());
PaintWatermarkImage(painter, img, m_watermarkData, layout->LayoutSettings().WatermarkPath());
}
if (m_watermarkData.showText && not m_watermarkData.text.isEmpty())
@ -405,7 +411,7 @@ void VPTileFactory::DrawTilePageContent(QPainter *painter, const VPSheetPtr &she
QPrinter *printer) const
{
VPLayoutPtr layout = m_layout.toStrongRef();
if(layout.isNull())
if (layout.isNull())
{
return;
}
@ -416,23 +422,19 @@ void VPTileFactory::DrawTilePageContent(QPainter *painter, const VPSheetPtr &she
sheetMargins = sheet->GetSheetMargins();
}
QPen penTileDrawing = QPen(Qt::black, m_commonSettings->WidthMainLine(), Qt::SolidLine, Qt::RoundCap,
Qt::RoundJoin);
QPen penTileDrawing =
QPen(Qt::black, m_commonSettings->WidthMainLine(), Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
painter->setPen(penTileDrawing);
// paint the content of the page
const qreal xScale = layout->LayoutSettings().HorizontalScale();
const qreal yScale = layout->LayoutSettings().VerticalScale();
QRectF source = QRectF(sheetMargins.left() + col*(m_drawingAreaWidth - tileStripeWidth) / xScale,
sheetMargins.top() + row*(m_drawingAreaHeight - tileStripeWidth) / yScale,
m_drawingAreaWidth / xScale,
m_drawingAreaHeight / yScale);
QRectF source = QRectF(sheetMargins.left() + col * (m_drawingAreaWidth - tileStripeWidth) / xScale,
sheetMargins.top() + row * (m_drawingAreaHeight - tileStripeWidth) / yScale,
m_drawingAreaWidth / xScale, m_drawingAreaHeight / yScale);
QRectF target = QRectF(0,
0,
m_drawingAreaWidth,
m_drawingAreaHeight);
QRectF target = QRectF(0, 0, m_drawingAreaWidth, m_drawingAreaHeight);
sheet->SceneData()->Scene()->render(painter, VPrintLayout::SceneTargetRect(printer, target), source,
Qt::IgnoreAspectRatio);
}
@ -440,43 +442,34 @@ void VPTileFactory::DrawTilePageContent(QPainter *painter, const VPSheetPtr &she
//---------------------------------------------------------------------------------------------------------------------
void VPTileFactory::DrawTopTriangle(QPainter *painter) const
{
QPainterPath triangleTop =
QTransform()
.translate(m_drawingAreaWidth/2, 0)
.map(TriangleBasic());
QPainterPath triangleTop = QTransform().translate(m_drawingAreaWidth / 2, 0).map(TriangleBasic());
painter->fillPath(triangleTop, *triangleBush);
}
//---------------------------------------------------------------------------------------------------------------------
void VPTileFactory::DrawLeftTriangle(QPainter *painter) const
{
QPainterPath triangleLeft =
QTransform()
.translate(0, m_drawingAreaHeight/2)
.rotate(-90)
.map(TriangleBasic());
QPainterPath triangleLeft = QTransform().translate(0, m_drawingAreaHeight / 2).rotate(-90).map(TriangleBasic());
painter->fillPath(triangleLeft, *triangleBush);
}
//---------------------------------------------------------------------------------------------------------------------
void VPTileFactory::DrawBottomTriangle(QPainter *painter) const
{
QPainterPath triangleBottom =
QTransform()
.translate(m_drawingAreaWidth/2, m_drawingAreaHeight - tileStripeWidth)
.rotate(180)
.map(TriangleBasic());
QPainterPath triangleBottom = QTransform()
.translate(m_drawingAreaWidth / 2, m_drawingAreaHeight - tileStripeWidth)
.rotate(180)
.map(TriangleBasic());
painter->fillPath(triangleBottom, *triangleBush);
}
//---------------------------------------------------------------------------------------------------------------------
void VPTileFactory::DrawRightTriangle(QPainter *painter) const
{
QPainterPath triangleRight =
QTransform()
.translate(m_drawingAreaWidth - tileStripeWidth, m_drawingAreaHeight/2)
.rotate(90)
.map(TriangleBasic());
QPainterPath triangleRight = QTransform()
.translate(m_drawingAreaWidth - tileStripeWidth, m_drawingAreaHeight / 2)
.rotate(90)
.map(TriangleBasic());
painter->fillPath(triangleRight, *triangleBush);
}
@ -484,8 +477,7 @@ void VPTileFactory::DrawRightTriangle(QPainter *painter) const
void VPTileFactory::DrawTopLineScissors(QPainter *painter) const
{
QSvgRenderer svgRenderer(QStringLiteral("://puzzleicon/svg/icon_scissors_horizontal.svg"));
svgRenderer.render(painter, QRectF(m_drawingAreaWidth - tileStripeWidth, 0,
UnitConvertor(0.95, Unit::Cm, Unit::Px),
svgRenderer.render(painter, QRectF(m_drawingAreaWidth - tileStripeWidth, 0, UnitConvertor(0.95, Unit::Cm, Unit::Px),
UnitConvertor(0.56, Unit::Cm, Unit::Px)));
}
@ -493,9 +485,9 @@ void VPTileFactory::DrawTopLineScissors(QPainter *painter) const
void VPTileFactory::DrawLeftLineScissors(QPainter *painter) const
{
QSvgRenderer svgRenderer(QStringLiteral("://puzzleicon/svg/icon_scissors_vertical.svg"));
svgRenderer.render(painter, QRectF(0, m_drawingAreaHeight - tileStripeWidth,
UnitConvertor(0.56, Unit::Cm, Unit::Px),
UnitConvertor(0.95, Unit::Cm, Unit::Px)));
svgRenderer.render(painter,
QRectF(0, m_drawingAreaHeight - tileStripeWidth, UnitConvertor(0.56, 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);
painter->setPen(penTileInfos);
if(col < nbCol - 1)
if (col < nbCol - 1)
{
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);
painter->setPen(penTileInfos);
if(row < nbRow - 1)
if (row < nbRow - 1)
{
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);
painter->setPen(penTileInfos);
if(col < nbCol - 1)
if (col < nbCol - 1)
{
painter->drawLine(QPointF(0, m_drawingAreaHeight - tileStripeWidth),
QPointF(m_drawingAreaWidth, m_drawingAreaHeight - tileStripeWidth));
@ -585,7 +577,8 @@ void VPTileFactory::DrawSolidBottomLine(QPainter *painter, int col, int nbCol) c
else
{
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);
painter->setPen(penTileInfos);
if(row < nbRow - 1)
if (row < nbRow - 1)
{
painter->drawLine(QPointF(m_drawingAreaWidth - tileStripeWidth, 0),
QPointF(m_drawingAreaWidth - tileStripeWidth, m_drawingAreaHeight));
@ -617,18 +610,18 @@ void VPTileFactory::DrawTextInformation(QPainter *painter, int row, int col, int
// paint the grid information
const QString grid = tr("Grid ( %1 , %2 )").arg(row + 1).arg(col + 1);
const QString tileColorStr = QStringLiteral("%1,%2,%3")
.arg(tileColor->red()).arg(tileColor->green()).arg(tileColor->blue());
const QString tileColorStr =
QStringLiteral("%1,%2,%3").arg(tileColor->red()).arg(tileColor->green()).arg(tileColor->blue());
td.setHtml(QString("<table width='100%' style='color:rgb(%1);'>"
"<tr>"
"<td align='center'>%2</td>"
"</tr>"
"</table>")
.arg(tileColorStr, grid));
.arg(tileColorStr, grid));
painter->setPen(PenTileInfos());
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);
painter->restore();
@ -645,11 +638,12 @@ void VPTileFactory::DrawTextInformation(QPainter *painter, int row, int col, int
"<tr>"
"<td align='center'>%2 - %3</td>"
"</tr>"
"</table>").arg(tileColorStr, page, clippedSheetName));
"</table>")
.arg(tileColorStr, page, clippedSheetName));
painter->save();
painter->rotate(-90);
painter->translate(QPointF(-(m_drawingAreaHeight) + UnitConvertor(1, Unit::Cm, Unit::Px),
m_drawingAreaWidth - tileStripeWidth));
painter->translate(
QPointF(-(m_drawingAreaHeight) + UnitConvertor(1, Unit::Cm, Unit::Px), m_drawingAreaWidth - tileStripeWidth));
td.drawContents(painter);
painter->restore();
}
@ -662,7 +656,7 @@ void VPTileFactory::PaintWatermarkText(QPainter *painter, const QRectF &img, con
painter->save();
painter->setOpacity(watermarkData.opacity/100.);
painter->setOpacity(watermarkData.opacity / 100.);
QPen pen = painter->pen();
pen.setWidth(1);
@ -696,22 +690,22 @@ void VPTileFactory::PaintWatermarkText(QPainter *painter, const QRectF &img, con
//---------------------------------------------------------------------------------------------------------------------
void VPTileFactory::PaintWatermarkImage(QPainter *painter, const QRectF &img, const VWatermarkData &watermarkData,
const QString &watermarkPath, qreal xScale, qreal yScale)
const QString &watermarkPath, qreal xScale, qreal yScale)
{
SCASSERT(painter != nullptr)
const qreal opacity = watermarkData.opacity/100.;
const qreal opacity = watermarkData.opacity / 100.;
auto BrokenImage = [img, watermarkData, watermarkPath, opacity]()
{
QPixmap watermark;
QString imagePath = QStringLiteral("puzzle=path%1+opacity%2_broken")
.arg(AbsoluteMPath(watermarkPath, watermarkData.path), QString::number(opacity));
.arg(AbsoluteMPath(watermarkPath, watermarkData.path), QString::number(opacity));
if (not QPixmapCache::find(imagePath, &watermark))
{
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.fill(Qt::transparent);
@ -760,7 +754,7 @@ void VPTileFactory::PaintWatermarkImage(QPainter *painter, const QRectF &img, co
#endif
qint64 pixelSize = fileSize / watermarkImage.height() / watermarkImage.width();
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();
if (scaledImageSize > limit && (xScale < 1 || yScale < 1))
@ -781,7 +775,7 @@ void VPTileFactory::PaintWatermarkImage(QPainter *painter, const QRectF &img, co
QPixmap watermark;
if (f.suffix() == QLatin1String("png") || f.suffix() == QLatin1String("jpg") ||
f.suffix() == QLatin1String("jpeg") || f.suffix() == QLatin1String("bmp"))
f.suffix() == QLatin1String("jpeg") || f.suffix() == QLatin1String("bmp"))
{
QString error;
watermark = WatermarkImageFromCache(watermarkData, watermarkPath, xScale, yScale, error);
@ -797,7 +791,7 @@ void VPTileFactory::PaintWatermarkImage(QPainter *painter, const QRectF &img, co
}
painter->save();
painter->setOpacity(watermarkData.opacity/100.);
painter->setOpacity(watermarkData.opacity / 100.);
QRect imagePosition(0, 0, watermark.width(), watermark.height());
imagePosition.translate(img.center().toPoint() - imagePosition.center());

View File

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

View File

@ -29,91 +29,91 @@
namespace ML // Manual layout
{
const QString TagLayout = QStringLiteral("layout"); // NOLINT(cert-err58-cpp)
const QString TagProperties = QStringLiteral("properties"); // NOLINT(cert-err58-cpp)
const QString TagUnit = QStringLiteral("unit"); // NOLINT(cert-err58-cpp)
const QString TagTitle = QStringLiteral("title"); // NOLINT(cert-err58-cpp)
const QString TagDescription = QStringLiteral("description"); // NOLINT(cert-err58-cpp)
const QString TagSize = QStringLiteral("size"); // NOLINT(cert-err58-cpp)
const QString TagMargin = QStringLiteral("margin"); // NOLINT(cert-err58-cpp)
const QString TagControl = QStringLiteral("control"); // NOLINT(cert-err58-cpp)
const QString TagTiles = QStringLiteral("tiles"); // NOLINT(cert-err58-cpp)
const QString TagUnplacedPieces = QStringLiteral("unplacedPieces"); // NOLINT(cert-err58-cpp)
const QString TagPieces = QStringLiteral("pieces"); // NOLINT(cert-err58-cpp)
const QString TagPiece = QStringLiteral("piece"); // NOLINT(cert-err58-cpp)
const QString TagSheets = QStringLiteral("sheets"); // NOLINT(cert-err58-cpp)
const QString TagSheet = QStringLiteral("sheet"); // NOLINT(cert-err58-cpp)
const QString TagName = QStringLiteral("name"); // NOLINT(cert-err58-cpp)
const QString TagSeamLine = QStringLiteral("seamLine"); // NOLINT(cert-err58-cpp)
const QString TagSeamAllowance = QStringLiteral("seamAllowance"); // NOLINT(cert-err58-cpp)
const QString TagGrainline = QStringLiteral("grainline"); // NOLINT(cert-err58-cpp)
const QString TagNotches = QStringLiteral("notches"); // NOLINT(cert-err58-cpp)
const QString TagNotch = QStringLiteral("notch"); // NOLINT(cert-err58-cpp)
const QString TagInternalPaths = QStringLiteral("internalPaths"); // NOLINT(cert-err58-cpp)
const QString TagInternalPath = QStringLiteral("internalPath"); // NOLINT(cert-err58-cpp)
const QString TagMarkers = QStringLiteral("markers"); // NOLINT(cert-err58-cpp)
const QString TagMarker = QStringLiteral("marker"); // NOLINT(cert-err58-cpp)
const QString TagLabels = QStringLiteral("labels"); // NOLINT(cert-err58-cpp)
const QString TagPieceLabel = QStringLiteral("pieceLabel"); // NOLINT(cert-err58-cpp)
const QString TagPatternLabel = QStringLiteral("patternLabel"); // NOLINT(cert-err58-cpp)
const QString TagLines = QStringLiteral("lines"); // NOLINT(cert-err58-cpp)
const QString TagLine = QStringLiteral("line"); // NOLINT(cert-err58-cpp)
const QString TagScale = QStringLiteral("scale"); // NOLINT(cert-err58-cpp)
const QString TagWatermark = QStringLiteral("watermark"); // NOLINT(cert-err58-cpp)
const QString TagPoint = QStringLiteral("point"); // NOLINT(cert-err58-cpp)
const QString TagLayout = QStringLiteral("layout"); // NOLINT(cert-err58-cpp)
const QString TagProperties = QStringLiteral("properties"); // NOLINT(cert-err58-cpp)
const QString TagUnit = QStringLiteral("unit"); // NOLINT(cert-err58-cpp)
const QString TagTitle = QStringLiteral("title"); // NOLINT(cert-err58-cpp)
const QString TagDescription = QStringLiteral("description"); // NOLINT(cert-err58-cpp)
const QString TagSize = QStringLiteral("size"); // NOLINT(cert-err58-cpp)
const QString TagMargin = QStringLiteral("margin"); // NOLINT(cert-err58-cpp)
const QString TagControl = QStringLiteral("control"); // NOLINT(cert-err58-cpp)
const QString TagTiles = QStringLiteral("tiles"); // NOLINT(cert-err58-cpp)
const QString TagUnplacedPieces = QStringLiteral("unplacedPieces"); // NOLINT(cert-err58-cpp)
const QString TagPieces = QStringLiteral("pieces"); // NOLINT(cert-err58-cpp)
const QString TagPiece = QStringLiteral("piece"); // NOLINT(cert-err58-cpp)
const QString TagSheets = QStringLiteral("sheets"); // NOLINT(cert-err58-cpp)
const QString TagSheet = QStringLiteral("sheet"); // NOLINT(cert-err58-cpp)
const QString TagName = QStringLiteral("name"); // NOLINT(cert-err58-cpp)
const QString TagSeamLine = QStringLiteral("seamLine"); // NOLINT(cert-err58-cpp)
const QString TagSeamAllowance = QStringLiteral("seamAllowance"); // NOLINT(cert-err58-cpp)
const QString TagGrainline = QStringLiteral("grainline"); // NOLINT(cert-err58-cpp)
const QString TagNotches = QStringLiteral("notches"); // NOLINT(cert-err58-cpp)
const QString TagNotch = QStringLiteral("notch"); // NOLINT(cert-err58-cpp)
const QString TagInternalPaths = QStringLiteral("internalPaths"); // NOLINT(cert-err58-cpp)
const QString TagInternalPath = QStringLiteral("internalPath"); // NOLINT(cert-err58-cpp)
const QString TagMarkers = QStringLiteral("markers"); // NOLINT(cert-err58-cpp)
const QString TagMarker = QStringLiteral("marker"); // NOLINT(cert-err58-cpp)
const QString TagLabels = QStringLiteral("labels"); // NOLINT(cert-err58-cpp)
const QString TagPieceLabel = QStringLiteral("pieceLabel"); // NOLINT(cert-err58-cpp)
const QString TagPatternLabel = QStringLiteral("patternLabel"); // NOLINT(cert-err58-cpp)
const QString TagLines = QStringLiteral("lines"); // NOLINT(cert-err58-cpp)
const QString TagLine = QStringLiteral("line"); // NOLINT(cert-err58-cpp)
const QString TagScale = QStringLiteral("scale"); // NOLINT(cert-err58-cpp)
const QString TagWatermark = QStringLiteral("watermark"); // NOLINT(cert-err58-cpp)
const QString TagPoint = QStringLiteral("point"); // NOLINT(cert-err58-cpp)
const QString AttrWarningSuperposition = QStringLiteral("warningSuperposition"); // NOLINT(cert-err58-cpp)
const QString AttrWarningOutOfBound = QStringLiteral("warningOutOfBound"); // NOLINT(cert-err58-cpp)
const QString AttrStickyEdges = QStringLiteral("stickyEdges"); // NOLINT(cert-err58-cpp)
const QString AttrPiecesGap = QStringLiteral("piecesGap"); // NOLINT(cert-err58-cpp)
const QString AttrVisible = QStringLiteral("visible"); // NOLINT(cert-err58-cpp)
const QString AttrMatchingMarks = QStringLiteral("matchingMarks"); // NOLINT(cert-err58-cpp)
const QString AttrName = QStringLiteral("name"); // NOLINT(cert-err58-cpp)
const QString AttrLeft = QStringLiteral("left"); // NOLINT(cert-err58-cpp)
const QString AttrTop = QStringLiteral("top"); // NOLINT(cert-err58-cpp)
const QString AttrRight = QStringLiteral("right"); // NOLINT(cert-err58-cpp)
const QString AttrBottom = QStringLiteral("bottom"); // NOLINT(cert-err58-cpp)
const QString AttrWidth = QStringLiteral("width"); // NOLINT(cert-err58-cpp)
const QString AttrLength = QStringLiteral("length"); // NOLINT(cert-err58-cpp)
const QString AttrFollowGrainline = QStringLiteral("followGrainline"); // NOLINT(cert-err58-cpp)
const QString AttrUID = QStringLiteral("uid"); // NOLINT(cert-err58-cpp)
const QString AttrMirrored = QStringLiteral("mirrored"); // NOLINT(cert-err58-cpp)
const QString AttrForbidFlipping = QStringLiteral("forbidFlipping"); // NOLINT(cert-err58-cpp)
const QString AttrForceFlipping = QStringLiteral("forceFlipping"); // NOLINT(cert-err58-cpp)
const QString AttrSewLineOnDrawing = QStringLiteral("sewLineOnDrawing"); // NOLINT(cert-err58-cpp)
const QString AttrTransform = QStringLiteral("transform"); // NOLINT(cert-err58-cpp)
const QString AttrShowSeamline = QStringLiteral("showSeamline"); // NOLINT(cert-err58-cpp)
const QString AttrEnabled = QStringLiteral("enabled"); // NOLINT(cert-err58-cpp)
const QString AttrBuiltIn = QStringLiteral("builtIn"); // NOLINT(cert-err58-cpp)
const QString AttrArrowDirection = QStringLiteral("arrowDirection"); // NOLINT(cert-err58-cpp)
const QString AttrType = QStringLiteral("type"); // NOLINT(cert-err58-cpp)
const QString AttrBaseLine = QStringLiteral("baseLine"); // NOLINT(cert-err58-cpp)
const QString AttrPath = QStringLiteral("path"); // NOLINT(cert-err58-cpp)
const QString AttrCut = QStringLiteral("cut"); // NOLINT(cert-err58-cpp)
const QString AttrPenStyle = QStringLiteral("penStyle"); // NOLINT(cert-err58-cpp)
const QString AttrCenter = QStringLiteral("center"); // NOLINT(cert-err58-cpp)
const QString AttrBox = QStringLiteral("box"); // NOLINT(cert-err58-cpp)
const QString AttrShape = QStringLiteral("shape"); // NOLINT(cert-err58-cpp)
const QString AttrFont = QStringLiteral("font"); // NOLINT(cert-err58-cpp)
const QString AttrFontSize = QStringLiteral("fontSize"); // NOLINT(cert-err58-cpp)
const QString AttrBold = QStringLiteral("bold"); // NOLINT(cert-err58-cpp)
const QString AttrItalic = QStringLiteral("italic"); // NOLINT(cert-err58-cpp)
const QString AttrAlignment = QStringLiteral("alignment"); // NOLINT(cert-err58-cpp)
const QString AttrGradationLabel = QStringLiteral("gradationLabel"); // NOLINT(cert-err58-cpp)
const QString AttrCopyNumber = QStringLiteral("copyNumber"); // NOLINT(cert-err58-cpp)
const QString AttrGrainlineType = QStringLiteral("grainlineType"); // NOLINT(cert-err58-cpp)
const QString AttrXScale = QStringLiteral("xScale"); // NOLINT(cert-err58-cpp)
const QString AttrYScale = QStringLiteral("yScale"); // NOLINT(cert-err58-cpp)
const QString AttrIgnoreMargins = QStringLiteral("ignoreMargins"); // NOLINT(cert-err58-cpp)
const QString AttrShowPreview = QStringLiteral("showPreview"); // NOLINT(cert-err58-cpp)
const QString AttrPrintScheme = QStringLiteral("printScheme"); // NOLINT(cert-err58-cpp)
const QString AttrTileNumber = QStringLiteral("tileNumber"); // NOLINT(cert-err58-cpp)
const QString AttrZValue = QStringLiteral("zValue"); // NOLINT(cert-err58-cpp)
const QString AttrX = QStringLiteral("x"); // NOLINT(cert-err58-cpp)
const QString AttrY = QStringLiteral("y"); // NOLINT(cert-err58-cpp)
const QString AttrTurnPoint = QStringLiteral("turnPoint"); // NOLINT(cert-err58-cpp)
const QString AttrCurvePoint = QStringLiteral("curvePoint"); // NOLINT(cert-err58-cpp)
const QString AttrClockwiseOpening = QStringLiteral("clockwiseOpening"); // NOLINT(cert-err58-cpp)
const QString AttrWarningOutOfBound = QStringLiteral("warningOutOfBound"); // NOLINT(cert-err58-cpp)
const QString AttrStickyEdges = QStringLiteral("stickyEdges"); // NOLINT(cert-err58-cpp)
const QString AttrPiecesGap = QStringLiteral("piecesGap"); // NOLINT(cert-err58-cpp)
const QString AttrVisible = QStringLiteral("visible"); // NOLINT(cert-err58-cpp)
const QString AttrMatchingMarks = QStringLiteral("matchingMarks"); // NOLINT(cert-err58-cpp)
const QString AttrName = QStringLiteral("name"); // NOLINT(cert-err58-cpp)
const QString AttrLeft = QStringLiteral("left"); // NOLINT(cert-err58-cpp)
const QString AttrTop = QStringLiteral("top"); // NOLINT(cert-err58-cpp)
const QString AttrRight = QStringLiteral("right"); // NOLINT(cert-err58-cpp)
const QString AttrBottom = QStringLiteral("bottom"); // NOLINT(cert-err58-cpp)
const QString AttrWidth = QStringLiteral("width"); // NOLINT(cert-err58-cpp)
const QString AttrLength = QStringLiteral("length"); // NOLINT(cert-err58-cpp)
const QString AttrFollowGrainline = QStringLiteral("followGrainline"); // NOLINT(cert-err58-cpp)
const QString AttrUID = QStringLiteral("uid"); // NOLINT(cert-err58-cpp)
const QString AttrMirrored = QStringLiteral("mirrored"); // NOLINT(cert-err58-cpp)
const QString AttrForbidFlipping = QStringLiteral("forbidFlipping"); // NOLINT(cert-err58-cpp)
const QString AttrForceFlipping = QStringLiteral("forceFlipping"); // NOLINT(cert-err58-cpp)
const QString AttrSewLineOnDrawing = QStringLiteral("sewLineOnDrawing"); // NOLINT(cert-err58-cpp)
const QString AttrTransform = QStringLiteral("transform"); // NOLINT(cert-err58-cpp)
const QString AttrShowSeamline = QStringLiteral("showSeamline"); // NOLINT(cert-err58-cpp)
const QString AttrEnabled = QStringLiteral("enabled"); // NOLINT(cert-err58-cpp)
const QString AttrBuiltIn = QStringLiteral("builtIn"); // NOLINT(cert-err58-cpp)
const QString AttrArrowDirection = QStringLiteral("arrowDirection"); // NOLINT(cert-err58-cpp)
const QString AttrType = QStringLiteral("type"); // NOLINT(cert-err58-cpp)
const QString AttrBaseLine = QStringLiteral("baseLine"); // NOLINT(cert-err58-cpp)
const QString AttrPath = QStringLiteral("path"); // NOLINT(cert-err58-cpp)
const QString AttrCut = QStringLiteral("cut"); // NOLINT(cert-err58-cpp)
const QString AttrPenStyle = QStringLiteral("penStyle"); // NOLINT(cert-err58-cpp)
const QString AttrCenter = QStringLiteral("center"); // NOLINT(cert-err58-cpp)
const QString AttrBox = QStringLiteral("box"); // NOLINT(cert-err58-cpp)
const QString AttrShape = QStringLiteral("shape"); // NOLINT(cert-err58-cpp)
const QString AttrFont = QStringLiteral("font"); // NOLINT(cert-err58-cpp)
const QString AttrFontSize = QStringLiteral("fontSize"); // NOLINT(cert-err58-cpp)
const QString AttrBold = QStringLiteral("bold"); // NOLINT(cert-err58-cpp)
const QString AttrItalic = QStringLiteral("italic"); // NOLINT(cert-err58-cpp)
const QString AttrAlignment = QStringLiteral("alignment"); // NOLINT(cert-err58-cpp)
const QString AttrGradationLabel = QStringLiteral("gradationLabel"); // NOLINT(cert-err58-cpp)
const QString AttrCopyNumber = QStringLiteral("copyNumber"); // NOLINT(cert-err58-cpp)
const QString AttrGrainlineType = QStringLiteral("grainlineType"); // NOLINT(cert-err58-cpp)
const QString AttrXScale = QStringLiteral("xScale"); // NOLINT(cert-err58-cpp)
const QString AttrYScale = QStringLiteral("yScale"); // NOLINT(cert-err58-cpp)
const QString AttrIgnoreMargins = QStringLiteral("ignoreMargins"); // NOLINT(cert-err58-cpp)
const QString AttrShowPreview = QStringLiteral("showPreview"); // NOLINT(cert-err58-cpp)
const QString AttrPrintScheme = QStringLiteral("printScheme"); // NOLINT(cert-err58-cpp)
const QString AttrTileNumber = QStringLiteral("tileNumber"); // NOLINT(cert-err58-cpp)
const QString AttrZValue = QStringLiteral("zValue"); // NOLINT(cert-err58-cpp)
const QString AttrX = QStringLiteral("x"); // NOLINT(cert-err58-cpp)
const QString AttrY = QStringLiteral("y"); // NOLINT(cert-err58-cpp)
const QString AttrTurnPoint = QStringLiteral("turnPoint"); // NOLINT(cert-err58-cpp)
const QString AttrCurvePoint = QStringLiteral("curvePoint"); // NOLINT(cert-err58-cpp)
const QString AttrClockwiseOpening = QStringLiteral("clockwiseOpening"); // NOLINT(cert-err58-cpp)
const QString oneWayUpStr = QStringLiteral("oneWayUp"); // NOLINT(cert-err58-cpp)
const QString oneWayDownStr = QStringLiteral("oneWayDown"); // NOLINT(cert-err58-cpp)
@ -129,7 +129,7 @@ const QString threeWaysUpLeftRightStr = QStringLiteral("threeWaysUpLeftRight");
const QString threeWaysDownLeftRightStr = QStringLiteral("threeWaysDownLeftRight"); // NOLINT(cert-err58-cpp)
const QChar groupSep = QLatin1Char(';');
const QChar coordintatesSep = QLatin1Char(',');
const QChar pointsSep = QLatin1Char(' ');
const QChar itemsSep = QLatin1Char('*');
} // namespace ML
const QChar coordintatesSep = QLatin1Char(',');
const QChar pointsSep = QLatin1Char(' ');
const QChar itemsSep = QLatin1Char('*');
} // namespace ML

View File

@ -137,7 +137,6 @@ extern const QChar groupSep;
extern const QChar coordintatesSep;
extern const QChar pointsSep;
extern const QChar itemsSep;
} // namespace ML
} // namespace ML
#endif // VPLAYOUTLITERALS_H

View File

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

View File

@ -80,6 +80,9 @@ QT_WARNING_POP
namespace
{
QT_WARNING_PUSH
QT_WARNING_DISABLE_CLANG("-Wunused-member-function")
Q_GLOBAL_STATIC_WITH_ARGS(const QString, LONG_OPTION_DIMENSION_A, (QLatin1String("dimensionA"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, SINGLE_OPTION_DIMENSION_A, (QChar('a'))) // NOLINT
@ -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, LONG_OPTION_TEST, (QLatin1String("test"))) // NOLINT
QT_WARNING_POP
} // namespace
//---------------------------------------------------------------------------------------------------------------------

File diff suppressed because it is too large Load Diff

View File

@ -28,27 +28,40 @@
#include "vtapesettings.h"
#include <QVariant>
#include <QDir>
#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
{
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingDataBaseGeometry, (QLatin1String("database/geometry"))) // NOLINT
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, 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")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsTapeWholeWord, // NOLINT
// NOLINTNEXTLINE
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsTapeWholeWord,
(QLatin1String("searchOptions/tapeWholeWord")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsTapeRegexp, (QLatin1String("searchOptions/tapeRegexp"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsTapeMatchCase, // NOLINT
// NOLINTNEXTLINE
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsTapeRegexp, (QLatin1String("searchOptions/tapeRegexp")))
// NOLINTNEXTLINE
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsTapeMatchCase,
(QLatin1String("searchOptions/tapeMatchCase")))
} // namespace
QT_WARNING_POP
} // namespace
//---------------------------------------------------------------------------------------------------------------------
VTapeSettings::VTapeSettings(Format format, Scope scope, const QString &organization, const QString &application,
QObject *parent)
:VCommonSettings(format, scope, organization, application, parent)
: VCommonSettings(format, scope, organization, application, parent)
{
}

View File

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

File diff suppressed because it is too large Load Diff

View File

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

View File

@ -27,39 +27,43 @@
*************************************************************************/
#include "dialogincrements.h"
#include "ui_dialogincrements.h"
#include "../vmisc/vvalentinasettings.h"
#include "ui_dialogincrements.h"
#if QT_VERSION < QT_VERSION_CHECK(5, 7, 0)
#include "../vmisc/backport/qoverload.h"
#endif // QT_VERSION < QT_VERSION_CHECK(5, 7, 0)
#include "../qmuparser/qmudef.h"
#include "../qmuparser/qmutokenparser.h"
#include "../vpatterndb/vtranslatevars.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/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 <QFileDialog>
#include <QDir>
#include <QMessageBox>
#include <QCloseEvent>
#include <QTableWidget>
#include <QDir>
#include <QFileDialog>
#include <QMenu>
#include <QMessageBox>
#include <QSettings>
#include <QTableWidget>
#include <QTableWidgetItem>
#include <QtNumeric>
#include <QMenu>
constexpr int DIALOG_MAX_FORMULA_HEIGHT = 64;
namespace
{
enum class IncrUnits : qint8 {Pattern, Degrees};
enum class IncrUnits : qint8
{
Pattern,
Degrees
};
}
//---------------------------------------------------------------------------------------------------------------------
@ -70,13 +74,13 @@ enum class IncrUnits : qint8 {Pattern, Degrees};
* @param parent parent widget
*/
DialogIncrements::DialogIncrements(VContainer *data, VPattern *doc, QWidget *parent)
:DialogTool(data, NULL_ID, parent),
ui(new Ui::DialogIncrements),
m_data(data),
m_doc(doc),
m_completeData(doc->GetCompleteData()),
m_searchHistory(new QMenu(this)),
m_searchHistoryPC(new QMenu(this))
: DialogTool(data, NULL_ID, parent),
ui(new Ui::DialogIncrements),
m_data(data),
m_doc(doc),
m_completeData(doc->GetCompleteData()),
m_searchHistory(new QMenu(this)),
m_searchHistoryPC(new QMenu(this))
{
ui->setupUi(this);
@ -129,14 +133,13 @@ DialogIncrements::DialogIncrements(VContainer *data, VPattern *doc, QWidget *par
connect(this->m_doc, &VPattern::FullUpdateFromFile, this, &DialogIncrements::FullUpdateFromFile);
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->lineEditNamePC->setValidator(validator);
connect(ui->tableWidgetIncrement, &QTableWidget::itemSelectionChanged, this,
&DialogIncrements::ShowIncrementDetails);
connect(ui->tableWidgetPC, &QTableWidget::itemSelectionChanged, this,
&DialogIncrements::ShowIncrementDetails);
connect(ui->tableWidgetPC, &QTableWidget::itemSelectionChanged, this, &DialogIncrements::ShowIncrementDetails);
ui->toolButtonAdd->setMenu(InitVarTypeMenu(ui->toolButtonAdd->menu(), true /*increments tab*/));
ui->toolButtonAddPC->setMenu(InitVarTypeMenu(ui->toolButtonAddPC->menu(), false /*preview calculations tab*/));
@ -191,8 +194,7 @@ void DialogIncrements::FillPreviewCalculations()
}
//---------------------------------------------------------------------------------------------------------------------
template <typename T>
void DialogIncrements::FillTable(const QMap<QString, T> &varTable, QTableWidget *table)
template <typename T> void DialogIncrements::FillTable(const QMap<QString, T> &varTable, QTableWidget *table)
{
SCASSERT(table != nullptr)
@ -203,7 +205,7 @@ void DialogIncrements::FillTable(const QMap<QString, T> &varTable, QTableWidget
i.next();
qreal length = *i.value()->GetValue();
currentRow++;
table->setRowCount ( static_cast<int>(varTable.size()) );
table->setRowCount(static_cast<int>(varTable.size()));
auto *item = new QTableWidgetItem(i.key());
item->setTextAlignment(Qt::AlignLeft);
@ -268,17 +270,17 @@ void DialogIncrements::ShowUnits()
{
const QString unit = UnitsToStr(VAbstractValApplication::VApp()->patternUnits());
ShowHeaderUnits(ui->tableWidgetIncrement, 1, unit);// calculated value
ShowHeaderUnits(ui->tableWidgetIncrement, 2, unit);// formula
ShowHeaderUnits(ui->tableWidgetPC, 1, unit);// calculated value
ShowHeaderUnits(ui->tableWidgetPC, 2, unit);// formula
ShowHeaderUnits(ui->tableWidgetIncrement, 1, unit); // calculated value
ShowHeaderUnits(ui->tableWidgetIncrement, 2, unit); // formula
ShowHeaderUnits(ui->tableWidgetPC, 1, unit); // calculated value
ShowHeaderUnits(ui->tableWidgetPC, 2, unit); // formula
ShowHeaderUnits(ui->tableWidgetLines, 1, unit);// lengths
ShowHeaderUnits(ui->tableWidgetSplines, 1, unit);// lengths
ShowHeaderUnits(ui->tableWidgetCLength, 1, unit);// lengths
ShowHeaderUnits(ui->tableWidgetLinesAngles, 1, degreeSymbol);// angle
ShowHeaderUnits(ui->tableWidgetRadiusesArcs, 1, unit);// radius
ShowHeaderUnits(ui->tableWidgetAnglesCurves, 1, degreeSymbol);// angle
ShowHeaderUnits(ui->tableWidgetLines, 1, unit); // lengths
ShowHeaderUnits(ui->tableWidgetSplines, 1, unit); // lengths
ShowHeaderUnits(ui->tableWidgetCLength, 1, unit); // lengths
ShowHeaderUnits(ui->tableWidgetLinesAngles, 1, degreeSymbol); // angle
ShowHeaderUnits(ui->tableWidgetRadiusesArcs, 1, unit); // radius
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,
bool ok) -> QTableWidgetItem *
auto DialogIncrements::AddCell(QTableWidget *table, const QString &text, int row, int column, int aligment, bool ok)
-> QTableWidgetItem *
{
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,
bool ok) -> QTableWidgetItem*
bool ok) -> QTableWidgetItem *
{
QTableWidgetItem *item = AddCell(table, text, row, column, aligment, ok);
@ -368,7 +370,8 @@ auto DialogIncrements::EvalIncrementFormula(const QString &formula, bool fromUse
}
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())
{
@ -383,8 +386,8 @@ auto DialogIncrements::EvalIncrementFormula(const QString &formula, bool fromUse
// Replace line return character with spaces for calc if exist
if (fromUser)
{
f = VAbstractApplication::VApp()->TrVars()
->FormulaFromUser(formula, VAbstractApplication::VApp()->Settings()->GetOsSeparator());
f = VAbstractApplication::VApp()->TrVars()->FormulaFromUser(
formula, VAbstractApplication::VApp()->Settings()->GetOsSeparator());
}
else
{
@ -458,7 +461,7 @@ void DialogIncrements::Controls(QTableWidget *table)
ui->toolButtonDownPC->setEnabled(true);
}
}
else if (table->currentRow() == table->rowCount()-1)
else if (table->currentRow() == table->rowCount() - 1)
{
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)
{
for (auto & i : m_renameList)
for (auto &i : m_renameList)
{
if (i.second == name)
{
@ -739,7 +742,7 @@ void DialogIncrements::ShowTableIncrementDetails(QTableWidget *table)
{
incr = m_data->GetVariable<VIncrement>(nameField->text());
}
catch(const VExceptionBadId &e)
catch (const VExceptionBadId &e)
{
Q_UNUSED(e)
EnableDetails(table, false);
@ -762,9 +765,8 @@ void DialogIncrements::ShowTableIncrementDetails(QTableWidget *table)
EvalIncrementFormula(incr->GetFormula(), false, incr->GetData(), labelCalculatedValue, incr->IsSpecialUnits());
plainTextEditFormula->blockSignals(true);
QString formula =
VTranslateVars::TryFormulaToUser(incr->GetFormula(),
VAbstractApplication::VApp()->Settings()->GetOsSeparator());
QString formula = VTranslateVars::TryFormulaToUser(incr->GetFormula(),
VAbstractApplication::VApp()->Settings()->GetOsSeparator());
plainTextEditFormula->setPlainText(formula);
plainTextEditFormula->blockSignals(false);
@ -829,11 +831,11 @@ void DialogIncrements::AddNewIncrement(IncrementType type)
}
else
{
currentRow = table->currentRow()+1;
currentRow = table->currentRow() + 1;
const QTableWidgetItem *nameField = table->item(table->currentRow(), 0);
incrementMode ? m_doc->AddEmptyIncrementAfter(nameField->text(), name, type) :
m_doc->AddEmptyPreviewCalculationAfter(nameField->text(), name, type);
incrementMode ? m_doc->AddEmptyIncrementAfter(nameField->text(), name, type)
: m_doc->AddEmptyPreviewCalculationAfter(nameField->text(), name, type);
}
m_hasChanges = true;
@ -863,207 +865,225 @@ void DialogIncrements::InitSearch()
UpdateSearchControlsTooltips();
connect(ui->lineEditFind, &QLineEdit::textEdited, this, [this](const QString &term){m_search->Find(term);});
connect(ui->lineEditFind, &QLineEdit::editingFinished, this, [this]()
{
SaveIncrementsSearchRequest();
InitIncrementsSearchHistory();
m_search->Find(ui->lineEditFind->text());
});
connect(ui->lineEditFindPC, &QLineEdit::textEdited, this, [this](const QString &term){m_searchPC->Find(term);});
connect(ui->lineEditFindPC, &QLineEdit::editingFinished, this, [this]()
{
SavePreviewCalculationsSearchRequest();
InitPreviewCalculationsSearchHistory();
m_searchPC->Find(ui->lineEditFindPC->text());
});
connect(ui->lineEditFind, &QLineEdit::textEdited, this, [this](const QString &term) { m_search->Find(term); });
connect(ui->lineEditFind, &QLineEdit::editingFinished, this,
[this]()
{
SaveIncrementsSearchRequest();
InitIncrementsSearchHistory();
m_search->Find(ui->lineEditFind->text());
});
connect(ui->lineEditFindPC, &QLineEdit::textEdited, this, [this](const QString &term) { m_searchPC->Find(term); });
connect(ui->lineEditFindPC, &QLineEdit::editingFinished, this,
[this]()
{
SavePreviewCalculationsSearchRequest();
InitPreviewCalculationsSearchHistory();
m_searchPC->Find(ui->lineEditFindPC->text());
});
connect(ui->toolButtonFindPrevious, &QToolButton::clicked, this, [this]()
{
SaveIncrementsSearchRequest();
InitPreviewCalculationsSearchHistory();
m_search->FindPrevious();
ui->labelResults->setText(QStringLiteral("%1/%2").arg(m_search->MatchIndex()+1).arg(m_search->MatchCount()));
});
connect(ui->toolButtonFindPreviousPC, &QToolButton::clicked, this, [this]()
{
SavePreviewCalculationsSearchRequest();
InitPreviewCalculationsSearchHistory();
m_searchPC->FindPrevious();
ui->labelResultsPC->setText(
QStringLiteral("%1/%2").arg(m_searchPC->MatchIndex()+1).arg(m_searchPC->MatchCount()));
});
connect(ui->toolButtonFindNext, &QToolButton::clicked, this, [this]()
{
SaveIncrementsSearchRequest();
InitIncrementsSearchHistory();
m_search->FindNext();
ui->labelResults->setText(QStringLiteral("%1/%2").arg(m_search->MatchIndex()+1).arg(m_search->MatchCount()));
});
connect(ui->toolButtonFindNextPC, &QToolButton::clicked, this, [this]()
{
SavePreviewCalculationsSearchRequest();
InitPreviewCalculationsSearchHistory();
m_searchPC->FindNext();
ui->labelResultsPC->setText(
QStringLiteral("%1/%2").arg(m_searchPC->MatchIndex()+1).arg(m_searchPC->MatchCount()));
});
connect(ui->toolButtonFindPrevious, &QToolButton::clicked, this,
[this]()
{
SaveIncrementsSearchRequest();
InitPreviewCalculationsSearchHistory();
m_search->FindPrevious();
ui->labelResults->setText(
QStringLiteral("%1/%2").arg(m_search->MatchIndex() + 1).arg(m_search->MatchCount()));
});
connect(ui->toolButtonFindPreviousPC, &QToolButton::clicked, this,
[this]()
{
SavePreviewCalculationsSearchRequest();
InitPreviewCalculationsSearchHistory();
m_searchPC->FindPrevious();
ui->labelResultsPC->setText(
QStringLiteral("%1/%2").arg(m_searchPC->MatchIndex() + 1).arg(m_searchPC->MatchCount()));
});
connect(ui->toolButtonFindNext, &QToolButton::clicked, this,
[this]()
{
SaveIncrementsSearchRequest();
InitIncrementsSearchHistory();
m_search->FindNext();
ui->labelResults->setText(
QStringLiteral("%1/%2").arg(m_search->MatchIndex() + 1).arg(m_search->MatchCount()));
});
connect(ui->toolButtonFindNextPC, &QToolButton::clicked, this,
[this]()
{
SavePreviewCalculationsSearchRequest();
InitPreviewCalculationsSearchHistory();
m_searchPC->FindNext();
ui->labelResultsPC->setText(
QStringLiteral("%1/%2").arg(m_searchPC->MatchIndex() + 1).arg(m_searchPC->MatchCount()));
});
connect(m_search.data(), &VTableSearch::HasResult, this, [this] (bool state)
{
ui->toolButtonFindPrevious->setEnabled(state);
ui->toolButtonFindNext->setEnabled(state);
connect(m_search.data(), &VTableSearch::HasResult, this,
[this](bool state)
{
ui->toolButtonFindPrevious->setEnabled(state);
ui->toolButtonFindNext->setEnabled(state);
if (state)
{
ui->labelResults->setText(
QStringLiteral("%1/%2").arg(m_search->MatchIndex()+1).arg(m_search->MatchCount()));
}
else
{
ui->labelResults->setText(tr("0 results"));
}
if (state)
{
ui->labelResults->setText(
QStringLiteral("%1/%2").arg(m_search->MatchIndex() + 1).arg(m_search->MatchCount()));
}
else
{
ui->labelResults->setText(tr("0 results"));
}
QPalette palette;
QPalette palette;
if (not state && not ui->lineEditFind->text().isEmpty())
{
palette.setColor(QPalette::Text, Qt::red);
ui->lineEditFind->setPalette(palette);
if (not state && not ui->lineEditFind->text().isEmpty())
{
palette.setColor(QPalette::Text, Qt::red);
ui->lineEditFind->setPalette(palette);
palette.setColor(QPalette::Active, ui->labelResults->foregroundRole(), Qt::red);
palette.setColor(QPalette::Inactive, ui->labelResults->foregroundRole(), Qt::red);
ui->labelResults->setPalette(palette);
}
else
{
ui->lineEditFind->setPalette(palette);
ui->labelResults->setPalette(palette);
}
});
palette.setColor(QPalette::Active, ui->labelResults->foregroundRole(), Qt::red);
palette.setColor(QPalette::Inactive, ui->labelResults->foregroundRole(), Qt::red);
ui->labelResults->setPalette(palette);
}
else
{
ui->lineEditFind->setPalette(palette);
ui->labelResults->setPalette(palette);
}
});
connect(m_searchPC.data(), &VTableSearch::HasResult, this, [this] (bool state)
{
ui->toolButtonFindPreviousPC->setEnabled(state);
ui->toolButtonFindNextPC->setEnabled(state);
connect(m_searchPC.data(), &VTableSearch::HasResult, this,
[this](bool state)
{
ui->toolButtonFindPreviousPC->setEnabled(state);
ui->toolButtonFindNextPC->setEnabled(state);
if (state)
{
ui->labelResultsPC->setText(
QStringLiteral("%1/%2").arg(m_searchPC->MatchIndex()+1).arg(m_searchPC->MatchCount()));
}
else
{
ui->labelResultsPC->setText(tr("0 results"));
}
if (state)
{
ui->labelResultsPC->setText(
QStringLiteral("%1/%2").arg(m_searchPC->MatchIndex() + 1).arg(m_searchPC->MatchCount()));
}
else
{
ui->labelResultsPC->setText(tr("0 results"));
}
QPalette palette;
QPalette palette;
if (not state && not ui->lineEditFindPC->text().isEmpty())
{
palette.setColor(QPalette::Text, Qt::red);
ui->lineEditFindPC->setPalette(palette);
if (not state && not ui->lineEditFindPC->text().isEmpty())
{
palette.setColor(QPalette::Text, Qt::red);
ui->lineEditFindPC->setPalette(palette);
palette.setColor(QPalette::Active, ui->labelResultsPC->foregroundRole(), Qt::red);
palette.setColor(QPalette::Inactive, ui->labelResultsPC->foregroundRole(), Qt::red);
ui->labelResultsPC->setPalette(palette);
}
else
{
ui->lineEditFindPC->setPalette(palette);
ui->labelResultsPC->setPalette(palette);
}
});
palette.setColor(QPalette::Active, ui->labelResultsPC->foregroundRole(), Qt::red);
palette.setColor(QPalette::Inactive, ui->labelResultsPC->foregroundRole(), Qt::red);
ui->labelResultsPC->setPalette(palette);
}
else
{
ui->lineEditFindPC->setPalette(palette);
ui->labelResultsPC->setPalette(palette);
}
});
connect(ui->toolButtonCaseSensitive, &QToolButton::toggled, this, [this](bool checked)
{
m_search->SetMatchCase(checked);
m_search->Find(ui->lineEditFind->text());
ui->lineEditFind->setPlaceholderText(m_search->SearchPlaceholder());
});
connect(ui->toolButtonCaseSensitive, &QToolButton::toggled, this,
[this](bool checked)
{
m_search->SetMatchCase(checked);
m_search->Find(ui->lineEditFind->text());
ui->lineEditFind->setPlaceholderText(m_search->SearchPlaceholder());
});
connect(ui->toolButtonCaseSensitivePC, &QToolButton::toggled, this, [this](bool checked)
{
m_searchPC->SetMatchCase(checked);
m_searchPC->Find(ui->lineEditFindPC->text());
ui->lineEditFindPC->setPlaceholderText(m_searchPC->SearchPlaceholder());
});
connect(ui->toolButtonCaseSensitivePC, &QToolButton::toggled, this,
[this](bool checked)
{
m_searchPC->SetMatchCase(checked);
m_searchPC->Find(ui->lineEditFindPC->text());
ui->lineEditFindPC->setPlaceholderText(m_searchPC->SearchPlaceholder());
});
connect(ui->toolButtonWholeWord, &QToolButton::toggled, this, [this](bool checked)
{
m_search->SetMatchWord(checked);
m_search->Find(ui->lineEditFind->text());
ui->lineEditFind->setPlaceholderText(m_search->SearchPlaceholder());
});
connect(ui->toolButtonWholeWord, &QToolButton::toggled, this,
[this](bool checked)
{
m_search->SetMatchWord(checked);
m_search->Find(ui->lineEditFind->text());
ui->lineEditFind->setPlaceholderText(m_search->SearchPlaceholder());
});
connect(ui->toolButtonWholeWordPC, &QToolButton::toggled, this, [this](bool checked)
{
m_searchPC->SetMatchWord(checked);
m_searchPC->Find(ui->lineEditFindPC->text());
ui->lineEditFindPC->setPlaceholderText(m_searchPC->SearchPlaceholder());
});
connect(ui->toolButtonWholeWordPC, &QToolButton::toggled, this,
[this](bool checked)
{
m_searchPC->SetMatchWord(checked);
m_searchPC->Find(ui->lineEditFindPC->text());
ui->lineEditFindPC->setPlaceholderText(m_searchPC->SearchPlaceholder());
});
connect(ui->toolButtonRegexp, &QToolButton::toggled, this, [this](bool checked)
{
m_search->SetMatchRegexp(checked);
connect(ui->toolButtonRegexp, &QToolButton::toggled, this,
[this](bool checked)
{
m_search->SetMatchRegexp(checked);
if (checked)
{
ui->toolButtonWholeWord->blockSignals(true);
ui->toolButtonWholeWord->setChecked(false);
ui->toolButtonWholeWord->blockSignals(false);
ui->toolButtonWholeWord->setEnabled(false);
if (checked)
{
ui->toolButtonWholeWord->blockSignals(true);
ui->toolButtonWholeWord->setChecked(false);
ui->toolButtonWholeWord->blockSignals(false);
ui->toolButtonWholeWord->setEnabled(false);
ui->toolButtonUseUnicodeProperties->setEnabled(true);
}
else
{
ui->toolButtonWholeWord->setEnabled(true);
ui->toolButtonUseUnicodeProperties->blockSignals(true);
ui->toolButtonUseUnicodeProperties->setChecked(false);
ui->toolButtonUseUnicodeProperties->blockSignals(false);
ui->toolButtonUseUnicodeProperties->setEnabled(false);
}
m_search->Find(ui->lineEditFind->text());
ui->lineEditFind->setPlaceholderText(m_search->SearchPlaceholder());
});
ui->toolButtonUseUnicodeProperties->setEnabled(true);
}
else
{
ui->toolButtonWholeWord->setEnabled(true);
ui->toolButtonUseUnicodeProperties->blockSignals(true);
ui->toolButtonUseUnicodeProperties->setChecked(false);
ui->toolButtonUseUnicodeProperties->blockSignals(false);
ui->toolButtonUseUnicodeProperties->setEnabled(false);
}
m_search->Find(ui->lineEditFind->text());
ui->lineEditFind->setPlaceholderText(m_search->SearchPlaceholder());
});
connect(ui->toolButtonRegexpPC, &QToolButton::toggled, this, [this](bool checked)
{
m_searchPC->SetMatchRegexp(checked);
connect(ui->toolButtonRegexpPC, &QToolButton::toggled, this,
[this](bool checked)
{
m_searchPC->SetMatchRegexp(checked);
if (checked)
{
ui->toolButtonWholeWordPC->blockSignals(true);
ui->toolButtonWholeWordPC->setChecked(false);
ui->toolButtonWholeWordPC->blockSignals(false);
ui->toolButtonWholeWordPC->setEnabled(false);
if (checked)
{
ui->toolButtonWholeWordPC->blockSignals(true);
ui->toolButtonWholeWordPC->setChecked(false);
ui->toolButtonWholeWordPC->blockSignals(false);
ui->toolButtonWholeWordPC->setEnabled(false);
ui->toolButtonUseUnicodePropertiesPC->setEnabled(true);
}
else
{
ui->toolButtonWholeWordPC->setEnabled(true);
ui->toolButtonUseUnicodePropertiesPC->blockSignals(true);
ui->toolButtonUseUnicodePropertiesPC->setChecked(false);
ui->toolButtonUseUnicodePropertiesPC->blockSignals(false);
ui->toolButtonUseUnicodePropertiesPC->setEnabled(false);
}
m_searchPC->Find(ui->lineEditFindPC->text());
ui->lineEditFindPC->setPlaceholderText(m_searchPC->SearchPlaceholder());
});
ui->toolButtonUseUnicodePropertiesPC->setEnabled(true);
}
else
{
ui->toolButtonWholeWordPC->setEnabled(true);
ui->toolButtonUseUnicodePropertiesPC->blockSignals(true);
ui->toolButtonUseUnicodePropertiesPC->setChecked(false);
ui->toolButtonUseUnicodePropertiesPC->blockSignals(false);
ui->toolButtonUseUnicodePropertiesPC->setEnabled(false);
}
m_searchPC->Find(ui->lineEditFindPC->text());
ui->lineEditFindPC->setPlaceholderText(m_searchPC->SearchPlaceholder());
});
connect(ui->toolButtonUseUnicodeProperties, &QToolButton::toggled, this, [this](bool checked)
{
m_search->SetUseUnicodePreperties(checked);
m_search->Find(ui->lineEditFind->text());
});
connect(ui->toolButtonUseUnicodeProperties, &QToolButton::toggled, this,
[this](bool checked)
{
m_search->SetUseUnicodePreperties(checked);
m_search->Find(ui->lineEditFind->text());
});
connect(ui->toolButtonUseUnicodePropertiesPC, &QToolButton::toggled, this, [this](bool checked)
{
m_searchPC->SetUseUnicodePreperties(checked);
m_searchPC->Find(ui->lineEditFindPC->text());
});
connect(ui->toolButtonUseUnicodePropertiesPC, &QToolButton::toggled, this,
[this](bool checked)
{
m_searchPC->SetUseUnicodePreperties(checked);
m_searchPC->Find(ui->lineEditFindPC->text());
});
m_searchHistory->setStyleSheet(QStringLiteral("QMenu { menu-scrollable: 1; }"));
m_searchHistoryPC->setStyleSheet(QStringLiteral("QMenu { menu-scrollable: 1; }"));
@ -1080,21 +1100,22 @@ void DialogIncrements::InitIncrementsSearchHistory()
{
QStringList searchHistory = VAbstractValApplication::VApp()->ValentinaSettings()->GetIncrementsSearchHistory();
m_searchHistory->clear();
for (const auto& term : searchHistory)
for (const auto &term : searchHistory)
{
QAction *action = m_searchHistory->addAction(term);
action->setData(term);
connect(action, &QAction::triggered, this, [this]()
{
auto *action = qobject_cast<QAction *>(sender());
if (action != nullptr)
{
QString term = action->data().toString();
ui->lineEditFind->setText(term);
m_search->Find(term);
ui->lineEditFind->setFocus();
}
});
connect(action, &QAction::triggered, this,
[this]()
{
auto *action = qobject_cast<QAction *>(sender());
if (action != nullptr)
{
QString term = action->data().toString();
ui->lineEditFind->setText(term);
m_search->Find(term);
ui->lineEditFind->setFocus();
}
});
}
}
@ -1102,23 +1123,24 @@ void DialogIncrements::InitIncrementsSearchHistory()
void DialogIncrements::InitPreviewCalculationsSearchHistory()
{
QStringList searchHistory =
VAbstractValApplication::VApp()->ValentinaSettings()->GetPreviewCalculationsSearchHistory();
VAbstractValApplication::VApp()->ValentinaSettings()->GetPreviewCalculationsSearchHistory();
m_searchHistoryPC->clear();
for (const auto& term : searchHistory)
for (const auto &term : searchHistory)
{
QAction *action = m_searchHistoryPC->addAction(term);
action->setData(term);
connect(action, &QAction::triggered, this, [this]()
{
auto *action = qobject_cast<QAction *>(sender());
if (action != nullptr)
{
QString term = action->data().toString();
ui->lineEditFindPC->setText(term);
m_searchPC->Find(term);
ui->lineEditFindPC->setFocus();
}
});
connect(action, &QAction::triggered, this,
[this]()
{
auto *action = qobject_cast<QAction *>(sender());
if (action != nullptr)
{
QString term = action->data().toString();
ui->lineEditFindPC->setText(term);
m_searchPC->Find(term);
ui->lineEditFindPC->setFocus();
}
});
}
}
@ -1144,7 +1166,8 @@ void DialogIncrements::SaveIncrementsSearchRequest()
//---------------------------------------------------------------------------------------------------------------------
void DialogIncrements::SavePreviewCalculationsSearchRequest()
{
QStringList searchHistory = VAbstractValApplication::VApp()->ValentinaSettings()->GetPreviewCalculationsSearchHistory();
QStringList searchHistory =
VAbstractValApplication::VApp()->ValentinaSettings()->GetPreviewCalculationsSearchHistory();
QString term = ui->lineEditFindPC->text();
if (term.isEmpty())
{
@ -1297,7 +1320,7 @@ void DialogIncrements::RefreshPattern()
//---------------------------------------------------------------------------------------------------------------------
void DialogIncrements::FillIncrementsTable(QTableWidget *table,
const QMap<QString, QSharedPointer<VIncrement> > &increments,
const QMap<QString, QSharedPointer<VIncrement>> &increments,
bool takePreviewCalculations)
{
SCASSERT(table != nullptr)
@ -1305,12 +1328,12 @@ void DialogIncrements::FillIncrementsTable(QTableWidget *table,
table->blockSignals(true);
table->clearContents();
QMap<QString, QSharedPointer<VIncrement> >::const_iterator i;
QMap<QString, QSharedPointer<VIncrement>>::const_iterator i;
QMap<quint32, QString> map;
//Sorting QHash by id
// Sorting QHash by id
for (i = increments.constBegin(); i != increments.constEnd(); ++i)
{
const QSharedPointer<VIncrement>& incr = i.value();
const QSharedPointer<VIncrement> &incr = i.value();
if (takePreviewCalculations == incr->IsPreviewCalculation())
{
map.insert(incr->GetIndex(), i.key());
@ -1319,7 +1342,7 @@ void DialogIncrements::FillIncrementsTable(QTableWidget *table,
qint32 currentRow = -1;
QMapIterator<quint32, QString> iMap(map);
table->setRowCount ( static_cast<int>(map.size()) );
table->setRowCount(static_cast<int>(map.size()));
while (iMap.hasNext())
{
iMap.next();
@ -1337,9 +1360,8 @@ void DialogIncrements::FillIncrementsTable(QTableWidget *table,
}
AddCell(table, calculatedValue, currentRow, 1, Qt::AlignCenter, incr->IsFormulaOk()); // calculated value
QString formula =
VTranslateVars::TryFormulaToUser(incr->GetFormula(),
VAbstractApplication::VApp()->Settings()->GetOsSeparator());
QString formula = VTranslateVars::TryFormulaToUser(
incr->GetFormula(), VAbstractApplication::VApp()->Settings()->GetOsSeparator());
AddCell(table, formula, currentRow, 2, Qt::AlignVCenter); // formula
@ -1351,7 +1373,7 @@ void DialogIncrements::FillIncrementsTable(QTableWidget *table,
else if (incr->GetType() == VarType::IncrementSeparator)
{
AddSeparatorCell(table, incr->GetName(), currentRow, 0, Qt::AlignVCenter); // name
AddCell(table, incr->GetDescription(), currentRow, 1, Qt::AlignCenter); // description
AddCell(table, incr->GetDescription(), currentRow, 1, Qt::AlignCenter); // description
table->setSpan(currentRow, 1, 1, 2);
}
}
@ -1464,7 +1486,7 @@ void DialogIncrements::MoveUp()
m_hasChanges = true;
LocalUpdateTree();
table->selectRow(row-1);
table->selectRow(row - 1);
table->repaint(); // Force repain to fix paint artifacts on Mac OS X
}
@ -1509,7 +1531,7 @@ void DialogIncrements::MoveDown()
m_hasChanges = true;
LocalUpdateTree();
table->selectRow(row+1);
table->selectRow(row + 1);
table->repaint(); // Force repain to fix paint artifacts on Mac OS X
}
@ -1704,9 +1726,9 @@ void DialogIncrements::SaveIncrFormula()
}
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());
labelCalculatedValue->setText(result->text() + QChar(QChar::Space) +postfix);
labelCalculatedValue->setText(result->text() + QChar(QChar::Space) + postfix);
}
return;
}
@ -1719,7 +1741,7 @@ void DialogIncrements::SaveIncrFormula()
}
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());
labelCalculatedValue->setText(tr("Error") + " (" + postfix + "). " + tr("Empty field."));
}
@ -1738,8 +1760,8 @@ void DialogIncrements::SaveIncrFormula()
try
{
const QString formula = VAbstractApplication::VApp()->TrVars()
->FormulaFromUser(text, VAbstractApplication::VApp()->Settings()->GetOsSeparator());
const QString formula = VAbstractApplication::VApp()->TrVars()->FormulaFromUser(
text, VAbstractApplication::VApp()->Settings()->GetOsSeparator());
m_doc->SetIncrementFormula(nameField->text(), formula);
}
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)
{
plainTextEditFormula->setFixedHeight(DIALOG_MAX_FORMULA_HEIGHT);
//Set icon from theme (internal for Windows system)
pushButtonGrow->setIcon(QIcon::fromTheme(QStringLiteral("go-next"),
QIcon(":/icons/win.icon.theme/16x16/actions/go-next.png")));
// Set icon from theme (internal for Windows system)
pushButtonGrow->setIcon(
QIcon::fromTheme(QStringLiteral("go-next"), QIcon(":/icons/win.icon.theme/16x16/actions/go-next.png")));
}
else
{
plainTextEditFormula->setFixedHeight(baseHeight);
//Set icon from theme (internal for Windows system)
pushButtonGrow->setIcon(QIcon::fromTheme(QStringLiteral("go-down"),
QIcon(":/icons/win.icon.theme/16x16/actions/go-down.png")));
plainTextEditFormula->setFixedHeight(baseHeight);
// Set icon from theme (internal for Windows system)
pushButtonGrow->setIcon(
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.
@ -1860,7 +1882,7 @@ void DialogIncrements::Fx()
dialog->SetFormula(VTranslateVars::TryFormulaFromUser(plainTextEditFormula->toPlainText(),
VAbstractApplication::VApp()->Settings()->GetOsSeparator()));
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)
{
@ -1957,7 +1979,7 @@ void DialogIncrements::showEvent(QShowEvent *event)
{
// Skip DialogTool implementation
QDialog::showEvent(event); // NOLINT(bugprone-parent-virtual-call)
if ( event->spontaneous() )
if (event->spontaneous())
{
return;
}
@ -1974,7 +1996,7 @@ void DialogIncrements::showEvent(QShowEvent *event)
resize(sz);
}
isInitialized = true;//first show windows are held
isInitialized = true; // first show windows are held
}
//---------------------------------------------------------------------------------------------------------------------
@ -1999,7 +2021,7 @@ void DialogIncrements::ShowIncrementDetails()
//---------------------------------------------------------------------------------------------------------------------
DialogIncrements::~DialogIncrements()
{
ui->lineEditFind->blockSignals(true); // prevents crash
ui->lineEditFind->blockSignals(true); // prevents crash
ui->lineEditFindPC->blockSignals(true); // prevents crash
delete ui;
}

View File

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

View File

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

View File

@ -27,12 +27,16 @@
*************************************************************************/
#include "vwidgetdetails.h"
#include "ui_vwidgetdetails.h"
#include "../ifc/xml/vabstractpattern.h"
#include "../vpatterndb/vcontainer.h"
#include "../vmisc/vabstractapplication.h"
#include "../vtools/undocommands/togglepiecestate.h"
#include "../vpatterndb/vcontainer.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 <QTimer>
@ -58,17 +62,22 @@ enum PieceColumn
PieceName = 1
};
Q_GLOBAL_STATIC_WITH_ARGS(const QString, allowDetailIcon, (QLatin1String("://icon/16x16/allow_detail.png"))) // NOLINT
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, forbidDetailIcon, (QLatin1String("://icon/16x16/forbid_detail.png"))) // NOLINT
} // namespace
QT_WARNING_POP
} // namespace
//---------------------------------------------------------------------------------------------------------------------
VWidgetDetails::VWidgetDetails(VContainer *data, VAbstractPattern *doc, QWidget *parent)
: QWidget(parent),
ui(new Ui::VWidgetDetails),
m_doc(doc),
m_data(data),
m_updateListTimer(new QTimer(this))
: QWidget(parent),
ui(new Ui::VWidgetDetails),
m_doc(doc),
m_data(data),
m_updateListTimer(new QTimer(this))
{
ui->setupUi(this);
@ -82,10 +91,7 @@ VWidgetDetails::VWidgetDetails(VContainer *data, VAbstractPattern *doc, QWidget
connect(ui->tableWidget, &QTableWidget::customContextMenuRequested, this, &VWidgetDetails::ShowContextMenu);
m_updateListTimer->setSingleShot(true);
connect(m_updateListTimer, &QTimer::timeout, this, [this]()
{
FillTable(m_data->DataPieces());
});
connect(m_updateListTimer, &QTimer::timeout, this, [this]() { FillTable(m_data->DataPieces()); });
}
//---------------------------------------------------------------------------------------------------------------------
@ -203,12 +209,12 @@ void VWidgetDetails::ToggleSectionDetails(bool select)
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();
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);
connect(togglePrint, &TogglePieceInLayout::Toggled, this, &VWidgetDetails::ToggledPiece);
@ -229,13 +235,12 @@ void VWidgetDetails::ToggledPieceItem(QTableWidgetItem *item)
if (details->contains(id))
{
const bool inLayout = details->value(id).IsInLayout();
inLayout ? item->setIcon(QIcon(*allowDetailIcon))
: item->setIcon(QIcon(*forbidDetailIcon));
inLayout ? item->setIcon(QIcon(*allowDetailIcon)) : item->setIcon(QIcon(*forbidDetailIcon));
VToolSeamAllowance *tool = nullptr;
try
{
tool = qobject_cast<VToolSeamAllowance*>(VAbstractPattern::getTool(id));
tool = qobject_cast<VToolSeamAllowance *>(VAbstractPattern::getTool(id));
tool->setVisible(ui->checkBoxHideNotInLayout->isChecked() ? inLayout : true);
}
catch (VExceptionBadId &)
@ -309,11 +314,11 @@ void VWidgetDetails::ShowContextMenu(const QPoint &pos)
pieceMode = true;
menu->addSeparator();
actionPieceOptions = menu->addAction(QIcon::fromTheme(QStringLiteral("preferences-other")),
tr("Piece options"));
actionPieceOptions =
menu->addAction(QIcon::fromTheme(QStringLiteral("preferences-other")), tr("Piece options"));
actionDeletePiece = menu->addAction(QIcon::fromTheme(QStringLiteral("edit-delete")),
tr("Delete piece"));
actionDeletePiece =
menu->addAction(QIcon::fromTheme(QStringLiteral("edit-delete")), tr("Delete piece"));
actionDeletePiece->setDisabled(toolPiece->referens() > 0);
}
}
@ -335,7 +340,7 @@ void VWidgetDetails::ShowContextMenu(const QPoint &pos)
auto iter = allDetails->constBegin();
while (iter != allDetails->constEnd())
{
if(iter.value().IsInLayout())
if (iter.value().IsInLayout())
{
selectedDetails++;
}
@ -372,7 +377,7 @@ void VWidgetDetails::ShowContextMenu(const QPoint &pos)
{
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);
const quint32 id = item->data(Qt::UserRole).toUInt();
@ -398,12 +403,12 @@ void VWidgetDetails::ShowContextMenu(const QPoint &pos)
{
toolPiece->DeleteFromMenu();
}
catch(const VExceptionToolWasDeleted &e)
catch (const VExceptionToolWasDeleted &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
#define MAINWINDOW_H
#include "mainwindowsnogui.h"
#include "core/vcmdexport.h"
#include "../vmisc/vlockguard.h"
#include "../vformat/vdimensions.h"
#include "../vmisc/vlockguard.h"
#include "core/vcmdexport.h"
#include "mainwindowsnogui.h"
#include <QDoubleSpinBox>
#include <QPointer>
namespace Ui
{
class MainWindow;
class MainWindow;
}
class VToolOptionsPropertyBrowser;
@ -66,6 +66,7 @@ class VWidgetBackgroundImages;
class MainWindow : public MainWindowsNoGUI
{
Q_OBJECT // NOLINT
public:
explicit MainWindow(QWidget *parent = nullptr);
~MainWindow() override;
@ -109,12 +110,13 @@ signals:
void EnableNodePointHover(bool enable);
void EnableDetailHover(bool enable);
void EnableImageBackgroundHover(bool enable);
protected:
void keyPressEvent(QKeyEvent *event) override;
void showEvent(QShowEvent *event) override;
void changeEvent(QEvent* event) override;
void changeEvent(QEvent *event) override;
void closeEvent(QCloseEvent *event) override;
void customEvent(QEvent * event) override;
void customEvent(QEvent *event) override;
void CleanLayout() override;
void PrepareSceneList(PreviewQuatilty quality) override;
void ExportToCSVData(const QString &fileName, bool withHeader, int mib, const QChar &separator) final;
@ -192,7 +194,7 @@ private slots:
void on_actionNew_triggered();
bool on_actionSaveAs_triggered(); // NOLINT(modernize-use-trailing-return-type)
bool on_actionSave_triggered(); // NOLINT(modernize-use-trailing-return-type)
bool on_actionSave_triggered(); // NOLINT(modernize-use-trailing-return-type)
void on_actionOpen_triggered();
void on_actionOpenPuzzle_triggered();
@ -222,7 +224,7 @@ private slots:
void RemoveWatermark();
#if defined(Q_OS_MAC)
void OpenAt(QAction *where);
#endif //defined(Q_OS_MAC)
#endif // defined(Q_OS_MAC)
void DimensionABaseChanged();
void DimensionBBaseChanged();
@ -279,14 +281,14 @@ private:
bool m_patternReadOnly{false};
QPointer<DialogIncrements> m_dialogTable;
QPointer<DialogTool> m_dialogTool{};
QPointer<DialogHistory> m_dialogHistory;
QPointer<DialogIncrements> m_dialogTable;
QPointer<DialogTool> m_dialogTool{};
QPointer<DialogHistory> m_dialogHistory;
QPointer<DialogFinalMeasurements> m_dialogFMeasurements;
/** @brief comboBoxDraws comboc who show name of pattern peaces. */
QComboBox *m_comboBoxDraws{nullptr};
QLabel *m_patternPieceLabel{nullptr};
QLabel *m_patternPieceLabel{nullptr};
/** @brief currentDrawIndex save current selected pattern peace. */
qint32 m_currentDrawIndex{0};
@ -316,10 +318,10 @@ private:
VWidgetBackgroundImages *m_backgroundImagesWidget{nullptr};
QSharedPointer<VLockGuard<char>> m_lock{nullptr};
QList<QToolButton*> m_toolButtonPointerList{};
QList<QToolButton *> m_toolButtonPointerList{};
QProgressBar *m_progressBar;
QLabel *m_statusLabel;
QLabel *m_statusLabel;
QList<QPointer<WatermarkWindow>> m_watermarkEditors{};
@ -332,7 +334,7 @@ private:
QTimer *m_gradation;
QMap<QUuid, VBackgroundImageItem *> m_backgroundImages{};
VBackgroundImageControls* m_backgroudcontrols{nullptr};
VBackgroundImageControls *m_backgroudcontrols{nullptr};
bool m_groupsActive{false};
bool m_toolOptionsActive{false};
@ -366,21 +368,14 @@ private:
template <typename Dialog, typename Func, typename Func2>
void SetToolButtonWithApply(bool checked, Tool t, const QString &cursor, const QString &toolTip,
Func closeDialogSlot, Func2 applyDialogSlot);
template <typename DrawTool>
void ClosedDialog(int result);
template <typename DrawTool> void ClosedDialog(int result);
template <typename DrawTool>
void ClosedDialogWithApply(int result, VMainGraphicsScene *scene);
template <typename DrawTool>
void ApplyDialog(VMainGraphicsScene *scene);
template <typename DrawTool>
void ClosedDrawDialogWithApply(int result);
template <typename DrawTool>
void ApplyDrawDialog();
template <typename DrawTool>
void ClosedDetailsDialogWithApply(int result);
template <typename DrawTool>
void ApplyDetailsDialog();
template <typename DrawTool> void ClosedDialogWithApply(int result, VMainGraphicsScene *scene);
template <typename DrawTool> void ApplyDialog(VMainGraphicsScene *scene);
template <typename DrawTool> void ClosedDrawDialogWithApply(int result);
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;
void AutoSavePattern();
@ -404,7 +399,7 @@ private:
void AddDocks();
void InitDocksContain();
auto OpenNewValentina(const QString &fileName = QString())const -> bool;
auto OpenNewValentina(const QString &fileName = QString()) const -> bool;
void FileClosedCorrect();
static auto GetUnlokedRestoreFileList() -> QStringList;
@ -420,8 +415,8 @@ private:
void ReadMeasurements(qreal baseA, qreal baseB, qreal baseC);
void ReopenFilesAfterCrash(QStringList &args);
auto DoExport(const VCommandLinePtr& expParams) -> bool;
auto DoFMExport(const VCommandLinePtr& expParams) -> bool;
auto DoExport(const VCommandLinePtr &expParams) -> bool;
auto DoFMExport(const VCommandLinePtr &expParams) -> bool;
auto SetDimensionA(int value) -> bool;
auto SetDimensionB(int value) -> bool;
@ -454,7 +449,7 @@ private:
void StoreIndividualMDimensions();
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>;
void SetDimensionBases();

View File

@ -21,25 +21,25 @@
#include "fvupdater.h"
#include <qsystemdetection.h>
#include <qxmlstream.h>
#include <QApplication>
#include <QByteArray>
#include <QDate>
#include <QDesktopServices>
#include <QDir>
#include <QGlobalStatic>
#include <QLatin1String>
#include <QMessageBox>
#include <QMessageLogger>
#include <QMutex>
#include <QNetworkReply>
#include <QNetworkRequest>
#include <QSslConfiguration>
#include <QStringList>
#include <QVariant>
#include <QXmlStreamAttributes>
#include <QtDebug>
#include <QSslConfiguration>
#include <QDir>
#include <QGlobalStatic>
#include <qsystemdetection.h>
#include <qxmlstream.h>
#include "../ifc/exception/vexception.h"
#include "../ifc/xml/vabstractconverter.h"
@ -49,13 +49,24 @@
#include "fvavailableupdate.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
{
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")))
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")))
}
QT_WARNING_POP
} // namespace
QPointer<FvUpdater> FvUpdater::m_Instance;
@ -96,16 +107,16 @@ auto FvUpdater::IsTestBuild() -> bool
//---------------------------------------------------------------------------------------------------------------------
FvUpdater::FvUpdater()
: QObject(nullptr),
m_updaterWindow(nullptr),
m_proposedUpdate(nullptr),
m_silentAsMuchAsItCouldGet(true),
m_feedURL(),
m_qnam(),
m_reply(nullptr),
m_httpRequestAborted(false),
m_dropOnFinnish(true),
m_xml()
: QObject(nullptr),
m_updaterWindow(nullptr),
m_proposedUpdate(nullptr),
m_silentAsMuchAsItCouldGet(true),
m_feedURL(),
m_qnam(),
m_reply(nullptr),
m_httpRequestAborted(false),
m_dropOnFinnish(true),
m_xml()
{
// noop
}
@ -325,24 +336,26 @@ void FvUpdater::startDownloadFeed(const QUrl &url)
m_reply = m_qnam.get(request);
connect(m_reply.data(), &QNetworkReply::readyRead, this, [this]()
{
// this slot gets called every time the QNetworkReply has new data.
// We read all of its new data and write it into the file.
// That way we use less RAM than when reading it at the finished()
// signal of the QNetworkReply
m_xml.addData(m_reply->readAll());
});
connect(m_reply.data(), &QNetworkReply::downloadProgress, this, [this](qint64 bytesRead, qint64 totalBytes)
{
Q_UNUSED(bytesRead)
Q_UNUSED(totalBytes)
connect(m_reply.data(), &QNetworkReply::readyRead, this,
[this]()
{
// this slot gets called every time the QNetworkReply has new data.
// We read all of its new data and write it into the file.
// That way we use less RAM than when reading it at the finished()
// signal of the QNetworkReply
m_xml.addData(m_reply->readAll());
});
connect(m_reply.data(), &QNetworkReply::downloadProgress, this,
[this](qint64 bytesRead, qint64 totalBytes)
{
Q_UNUSED(bytesRead)
Q_UNUSED(totalBytes)
if (m_httpRequestAborted)
{
return;
}
});
if (m_httpRequestAborted)
{
return;
}
});
connect(m_reply.data(), &QNetworkReply::finished, this, &FvUpdater::httpFeedDownloadFinished);
}
@ -455,18 +468,15 @@ auto FvUpdater::xmlParseFeed() -> bool
// here (because the topmost is the most recent one, and thus
// the newest version.
return searchDownloadedFeedForUpdates(xmlEnclosureUrl,
xmlEnclosureVersion,
xmlEnclosurePlatform);
return searchDownloadedFeedForUpdates(xmlEnclosureUrl, xmlEnclosureVersion, xmlEnclosurePlatform);
}
}
if (m_xml.error() && m_xml.error() != QXmlStreamReader::PrematureEndOfDocumentError)
{
showErrorDialog(tr("Feed parsing failed: %1 %2.").arg(QString::number(m_xml.lineNumber()),
m_xml.errorString()), false);
showErrorDialog(
tr("Feed parsing failed: %1 %2.").arg(QString::number(m_xml.lineNumber()), m_xml.errorString()), false);
return false;
}
}
@ -499,7 +509,7 @@ auto FvUpdater::searchDownloadedFeedForUpdates(const QString &xmlEnclosureUrl, c
showInformationDialog(tr("No updates were found."), false);
return true; // Things have succeeded when you think of it.
return true; // Things have succeeded when you think of it.
}
//
@ -575,7 +585,7 @@ void FvUpdater::IgnoreVersion(const QString &version)
catch (const VException &e)
{
Q_UNUSED(e)
return ; // Ignore invalid version
return; // Ignore invalid version
}
if (decVersion == AppVersion())
@ -596,7 +606,7 @@ auto FvUpdater::CurrentlyRunningOnPlatform(const QString &platform) -> bool
switch (platforms.indexOf(platform.toUpper().trimmed()))
{
case 0: // Q_OS_LINUX
case 0: // Q_OS_LINUX
#ifdef Q_OS_LINUX // Defined on Linux.
return true;
#else
@ -608,7 +618,7 @@ auto FvUpdater::CurrentlyRunningOnPlatform(const QString &platform) -> bool
#else
return false;
#endif
case 2: // Q_OS_WIN32
case 2: // Q_OS_WIN32
#ifdef Q_OS_WIN32 // Defined on all supported versions of Windows.
return true;
#else

View File

@ -30,151 +30,160 @@
#include <QDomNode>
#include <QDomNodeList>
#include <QFuture>
#include <QLatin1String>
#include <QList>
#include <QMessageLogger>
#include <QSet>
#include <QtDebug>
#include <QtConcurrentMap>
#include <QFuture>
#include <QtConcurrentRun>
#include <QMimeDatabase>
#include <QSet>
#include <QtConcurrentMap>
#include <QtConcurrentRun>
#include <QtDebug>
#include "../exception/vexceptionconversionerror.h"
#include "../exception/vexceptionemptyparameter.h"
#include "../exception/vexceptionobjecterror.h"
#include "../exception/vexceptionconversionerror.h"
#include "../qmuparser/qmutokenparser.h"
#include "../ifc/exception/vexceptionbadid.h"
#include "../ifc/ifcdef.h"
#include "../qmuparser/qmutokenparser.h"
#include "../vmisc/compatibility.h"
#include "../vmisc/vabstractvalapplication.h"
#include "../vpatterndb/vcontainer.h"
#include "../vpatterndb/vpiecenode.h"
#include "../vtools/tools/vdatatool.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 "vdomdocument.h"
#include "vpatternconverter.h"
#include "vpatternimage.h"
#include "vtoolrecord.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;
const QString VAbstractPattern::TagPattern = QStringLiteral("pattern");
const QString VAbstractPattern::TagCalculation = QStringLiteral("calculation");
const QString VAbstractPattern::TagModeling = QStringLiteral("modeling");
const QString VAbstractPattern::TagDetails = QStringLiteral("details");
const QString VAbstractPattern::TagDetail = QStringLiteral("detail");
const QString VAbstractPattern::TagDescription = QStringLiteral("description");
const QString VAbstractPattern::TagNotes = QStringLiteral("notes");
const QString VAbstractPattern::TagImage = QStringLiteral("image");
const QString VAbstractPattern::TagMeasurements = QStringLiteral("measurements");
const QString VAbstractPattern::TagIncrements = QStringLiteral("increments");
const QString VAbstractPattern::TagPattern = QStringLiteral("pattern");
const QString VAbstractPattern::TagCalculation = QStringLiteral("calculation");
const QString VAbstractPattern::TagModeling = QStringLiteral("modeling");
const QString VAbstractPattern::TagDetails = QStringLiteral("details");
const QString VAbstractPattern::TagDetail = QStringLiteral("detail");
const QString VAbstractPattern::TagDescription = QStringLiteral("description");
const QString VAbstractPattern::TagNotes = QStringLiteral("notes");
const QString VAbstractPattern::TagImage = QStringLiteral("image");
const QString VAbstractPattern::TagMeasurements = QStringLiteral("measurements");
const QString VAbstractPattern::TagIncrements = QStringLiteral("increments");
const QString VAbstractPattern::TagPreviewCalculations = QStringLiteral("previewCalculations");
const QString VAbstractPattern::TagIncrement = QStringLiteral("increment");
const QString VAbstractPattern::TagDraw = QStringLiteral("draw");
const QString VAbstractPattern::TagGroups = QStringLiteral("groups");
const QString VAbstractPattern::TagGroup = QStringLiteral("group");
const QString VAbstractPattern::TagGroupItem = QStringLiteral("item");
const QString VAbstractPattern::TagPoint = QStringLiteral("point");
const QString VAbstractPattern::TagSpline = QStringLiteral("spline");
const QString VAbstractPattern::TagArc = QStringLiteral("arc");
const QString VAbstractPattern::TagElArc = QStringLiteral("elArc");
const QString VAbstractPattern::TagTools = QStringLiteral("tools");
const QString VAbstractPattern::TagOperation = QStringLiteral("operation");
const QString VAbstractPattern::TagData = QStringLiteral("data");
const QString VAbstractPattern::TagPatternInfo = QStringLiteral("patternInfo");
const QString VAbstractPattern::TagPatternName = QStringLiteral("patternName");
const QString VAbstractPattern::TagPatternNum = QStringLiteral("patternNumber");
const QString VAbstractPattern::TagCustomerName = QStringLiteral("customer");
const QString VAbstractPattern::TagIncrement = QStringLiteral("increment");
const QString VAbstractPattern::TagDraw = QStringLiteral("draw");
const QString VAbstractPattern::TagGroups = QStringLiteral("groups");
const QString VAbstractPattern::TagGroup = QStringLiteral("group");
const QString VAbstractPattern::TagGroupItem = QStringLiteral("item");
const QString VAbstractPattern::TagPoint = QStringLiteral("point");
const QString VAbstractPattern::TagSpline = QStringLiteral("spline");
const QString VAbstractPattern::TagArc = QStringLiteral("arc");
const QString VAbstractPattern::TagElArc = QStringLiteral("elArc");
const QString VAbstractPattern::TagTools = QStringLiteral("tools");
const QString VAbstractPattern::TagOperation = QStringLiteral("operation");
const QString VAbstractPattern::TagData = QStringLiteral("data");
const QString VAbstractPattern::TagPatternInfo = QStringLiteral("patternInfo");
const QString VAbstractPattern::TagPatternName = QStringLiteral("patternName");
const QString VAbstractPattern::TagPatternNum = QStringLiteral("patternNumber");
const QString VAbstractPattern::TagCustomerName = QStringLiteral("customer");
const QString VAbstractPattern::TagCustomerBirthDate = QStringLiteral("birthDate");
const QString VAbstractPattern::TagCustomerEmail = QStringLiteral("email");
const QString VAbstractPattern::TagCompanyName = QStringLiteral("company");
const QString VAbstractPattern::TagPatternLabel = QStringLiteral("patternLabel");
const QString VAbstractPattern::TagWatermark = QStringLiteral("watermark");
const QString VAbstractPattern::TagCustomerEmail = QStringLiteral("email");
const QString VAbstractPattern::TagCompanyName = QStringLiteral("company");
const QString VAbstractPattern::TagPatternLabel = QStringLiteral("patternLabel");
const QString VAbstractPattern::TagWatermark = QStringLiteral("watermark");
const QString VAbstractPattern::TagPatternMaterials = QStringLiteral("patternMaterials");
const QString VAbstractPattern::TagFinalMeasurements= QStringLiteral("finalMeasurements");
const QString VAbstractPattern::TagMaterial = QStringLiteral("material");
const QString VAbstractPattern::TagFMeasurement = QStringLiteral("finalMeasurment");
const QString VAbstractPattern::TagGrainline = QStringLiteral("grainline");
const QString VAbstractPattern::TagPath = QStringLiteral("path");
const QString VAbstractPattern::TagNodes = QStringLiteral("nodes");
const QString VAbstractPattern::TagNode = QStringLiteral("node");
const QString VAbstractPattern::TagFinalMeasurements = QStringLiteral("finalMeasurements");
const QString VAbstractPattern::TagMaterial = QStringLiteral("material");
const QString VAbstractPattern::TagFMeasurement = QStringLiteral("finalMeasurment");
const QString VAbstractPattern::TagGrainline = QStringLiteral("grainline");
const QString VAbstractPattern::TagPath = QStringLiteral("path");
const QString VAbstractPattern::TagNodes = QStringLiteral("nodes");
const QString VAbstractPattern::TagNode = QStringLiteral("node");
const QString VAbstractPattern::TagBackgroundImages = QStringLiteral("backgroudImages");
const QString VAbstractPattern::TagBackgroundImage = QStringLiteral("backgroudImage");
const QString VAbstractPattern::TagPieceLabel = QStringLiteral("pieceLabel");
const QString VAbstractPattern::TagBackgroundImage = QStringLiteral("backgroudImage");
const QString VAbstractPattern::TagPieceLabel = QStringLiteral("pieceLabel");
const QString VAbstractPattern::AttrName = QStringLiteral("name");
const QString VAbstractPattern::AttrVisible = QStringLiteral("visible");
const QString VAbstractPattern::AttrObject = QStringLiteral("object");
const QString VAbstractPattern::AttrTool = QStringLiteral("tool");
const QString VAbstractPattern::AttrType = QStringLiteral("type");
const QString VAbstractPattern::AttrLetter = QStringLiteral("letter");
const QString VAbstractPattern::AttrAnnotation = QStringLiteral("annotation");
const QString VAbstractPattern::AttrOrientation = QStringLiteral("orientation");
const QString VAbstractPattern::AttrRotationWay = QStringLiteral("rotationWay");
const QString VAbstractPattern::AttrTilt = QStringLiteral("tilt");
const QString VAbstractPattern::AttrFoldPosition = QStringLiteral("foldPosition");
const QString VAbstractPattern::AttrQuantity = QStringLiteral("quantity");
const QString VAbstractPattern::AttrOnFold = QStringLiteral("onFold");
const QString VAbstractPattern::AttrDateFormat = QStringLiteral("dateFormat");
const QString VAbstractPattern::AttrTimeFormat = QStringLiteral("timeFormat");
const QString VAbstractPattern::AttrArrows = QStringLiteral("arrows");
const QString VAbstractPattern::AttrNodeReverse = QStringLiteral("reverse");
const QString VAbstractPattern::AttrNodeExcluded = QStringLiteral("excluded");
const QString VAbstractPattern::AttrNodePassmark = QStringLiteral("passmark");
const QString VAbstractPattern::AttrNodePassmarkLine = QStringLiteral("passmarkLine");
const QString VAbstractPattern::AttrName = QStringLiteral("name");
const QString VAbstractPattern::AttrVisible = QStringLiteral("visible");
const QString VAbstractPattern::AttrObject = QStringLiteral("object");
const QString VAbstractPattern::AttrTool = QStringLiteral("tool");
const QString VAbstractPattern::AttrType = QStringLiteral("type");
const QString VAbstractPattern::AttrLetter = QStringLiteral("letter");
const QString VAbstractPattern::AttrAnnotation = QStringLiteral("annotation");
const QString VAbstractPattern::AttrOrientation = QStringLiteral("orientation");
const QString VAbstractPattern::AttrRotationWay = QStringLiteral("rotationWay");
const QString VAbstractPattern::AttrTilt = QStringLiteral("tilt");
const QString VAbstractPattern::AttrFoldPosition = QStringLiteral("foldPosition");
const QString VAbstractPattern::AttrQuantity = QStringLiteral("quantity");
const QString VAbstractPattern::AttrOnFold = QStringLiteral("onFold");
const QString VAbstractPattern::AttrDateFormat = QStringLiteral("dateFormat");
const QString VAbstractPattern::AttrTimeFormat = QStringLiteral("timeFormat");
const QString VAbstractPattern::AttrArrows = QStringLiteral("arrows");
const QString VAbstractPattern::AttrNodeReverse = QStringLiteral("reverse");
const QString VAbstractPattern::AttrNodeExcluded = QStringLiteral("excluded");
const QString VAbstractPattern::AttrNodePassmark = QStringLiteral("passmark");
const QString VAbstractPattern::AttrNodePassmarkLine = QStringLiteral("passmarkLine");
const QString VAbstractPattern::AttrNodePassmarkAngle = QStringLiteral("passmarkAngle");
const QString VAbstractPattern::AttrNodeShowSecondPassmark = QStringLiteral("showSecondPassmark");
const QString VAbstractPattern::AttrNodePassmarkOpening = QStringLiteral("passmarkClockwiseOpening");
const QString VAbstractPattern::AttrNodeTurnPoint = QStringLiteral("turnPoint");
const QString VAbstractPattern::AttrSABefore = QStringLiteral("before");
const QString VAbstractPattern::AttrSAAfter = QStringLiteral("after");
const QString VAbstractPattern::AttrStart = QStringLiteral("start");
const QString VAbstractPattern::AttrPath = QStringLiteral("path");
const QString VAbstractPattern::AttrEnd = QStringLiteral("end");
const QString VAbstractPattern::AttrIncludeAs = QStringLiteral("includeAs");
const QString VAbstractPattern::AttrRotation = QStringLiteral("rotation");
const QString VAbstractPattern::AttrNumber = QStringLiteral("number");
const QString VAbstractPattern::AttrCheckUniqueness = QStringLiteral("checkUniqueness");
const QString VAbstractPattern::AttrNodeTurnPoint = QStringLiteral("turnPoint");
const QString VAbstractPattern::AttrSABefore = QStringLiteral("before");
const QString VAbstractPattern::AttrSAAfter = QStringLiteral("after");
const QString VAbstractPattern::AttrStart = QStringLiteral("start");
const QString VAbstractPattern::AttrPath = QStringLiteral("path");
const QString VAbstractPattern::AttrEnd = QStringLiteral("end");
const QString VAbstractPattern::AttrIncludeAs = QStringLiteral("includeAs");
const QString VAbstractPattern::AttrRotation = QStringLiteral("rotation");
const QString VAbstractPattern::AttrNumber = QStringLiteral("number");
const QString VAbstractPattern::AttrCheckUniqueness = QStringLiteral("checkUniqueness");
const QString VAbstractPattern::AttrManualPassmarkLength = QStringLiteral("manualPassmarkLength");
const QString VAbstractPattern::AttrPassmarkLength = QStringLiteral("passmarkLength");
const QString VAbstractPattern::AttrPassmarkLength = QStringLiteral("passmarkLength");
const QString VAbstractPattern::AttrManualPassmarkWidth = QStringLiteral("manualPassmarkWidth");
const QString VAbstractPattern::AttrPassmarkWidth = QStringLiteral("passmarkWidth");
const QString VAbstractPattern::AttrManualPassmarkAngle = QStringLiteral("manualPassmarkAngle");
const QString VAbstractPattern::AttrPassmarkAngle = QStringLiteral("passmarkAngleFormula");
const QString VAbstractPattern::AttrOpacity = QStringLiteral("opacity");
const QString VAbstractPattern::AttrTags = QStringLiteral("tags");
const QString VAbstractPattern::AttrTransform = QStringLiteral("transform");
const QString VAbstractPattern::AttrHold = QStringLiteral("hold");
const QString VAbstractPattern::AttrZValue = QStringLiteral("zValue");
const QString VAbstractPattern::AttrImageId = QStringLiteral("imageId");
const QString VAbstractPattern::AttrDimensionA = QStringLiteral("dimensionA");
const QString VAbstractPattern::AttrDimensionB = QStringLiteral("dimensionB");
const QString VAbstractPattern::AttrDimensionC = QStringLiteral("dimensionC");
const QString VAbstractPattern::AttrOpacity = QStringLiteral("opacity");
const QString VAbstractPattern::AttrTags = QStringLiteral("tags");
const QString VAbstractPattern::AttrTransform = QStringLiteral("transform");
const QString VAbstractPattern::AttrHold = QStringLiteral("hold");
const QString VAbstractPattern::AttrZValue = QStringLiteral("zValue");
const QString VAbstractPattern::AttrImageId = QStringLiteral("imageId");
const QString VAbstractPattern::AttrDimensionA = QStringLiteral("dimensionA");
const QString VAbstractPattern::AttrDimensionB = QStringLiteral("dimensionB");
const QString VAbstractPattern::AttrDimensionC = QStringLiteral("dimensionC");
const QString VAbstractPattern::AttrContentType = QStringLiteral("contentType");
const QString VAbstractPattern::AttrContentType = QStringLiteral("contentType");
const QString VAbstractPattern::AttrFormula = QStringLiteral("formula");
const QString VAbstractPattern::AttrDescription = QStringLiteral("description");
const QString VAbstractPattern::AttrFormula = QStringLiteral("formula");
const QString VAbstractPattern::AttrDescription = QStringLiteral("description");
const QString VAbstractPattern::AttrSpecialUnits = QStringLiteral("specialUnits");
const QString VAbstractPattern::NodeArc = QStringLiteral("NodeArc");
const QString VAbstractPattern::NodeElArc = QStringLiteral("NodeElArc");
const QString VAbstractPattern::NodePoint = QStringLiteral("NodePoint");
const QString VAbstractPattern::NodeSpline = QStringLiteral("NodeSpline");
const QString VAbstractPattern::NodeArc = QStringLiteral("NodeArc");
const QString VAbstractPattern::NodeElArc = QStringLiteral("NodeElArc");
const QString VAbstractPattern::NodePoint = QStringLiteral("NodePoint");
const QString VAbstractPattern::NodeSpline = QStringLiteral("NodeSpline");
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>();
QMap<int, QString> VAbstractPattern::patternMaterials = QMap<int, QString>();
bool VAbstractPattern::patternLabelWasChanged = false;
namespace
{
QT_WARNING_PUSH
QT_WARNING_DISABLE_CLANG("-Wunused-member-function")
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)
{
VFormulaField formula;
@ -202,7 +211,7 @@ auto GetTokens(const VFormulaField &formula) -> QList<QString>
catch (const qmu::QmuParserError &e)
{
qWarning() << QObject::tr("Cannot get tokens from formula '%1'. Parser error: %2.")
.arg(formula.expression, e.GetMsg());
.arg(formula.expression, e.GetMsg());
return QList<QString>();
}
catch (const qmu::QmuParserWarning &e)
@ -276,8 +285,7 @@ auto StringToTransfrom(const QString &matrix) -> QTransform
}
//---------------------------------------------------------------------------------------------------------------------
template <class T>
auto NumberToString(T number) -> QString
template <class T> auto NumberToString(T number) -> QString
{
const QLocale locale = QLocale::c();
return locale.toString(number, 'g', 12).remove(LocaleGroupSeparator(locale));
@ -286,32 +294,24 @@ auto NumberToString(T number) -> QString
//---------------------------------------------------------------------------------------------------------------------
auto TransformToString(const QTransform &m) -> QString
{
QStringList matrix
{
NumberToString(m.m11()),
NumberToString(m.m12()),
NumberToString(m.m13()),
NumberToString(m.m21()),
NumberToString(m.m22()),
NumberToString(m.m23()),
NumberToString(m.m31()),
NumberToString(m.m32()),
NumberToString(m.m33())
};
QStringList matrix{NumberToString(m.m11()), NumberToString(m.m12()), NumberToString(m.m13()),
NumberToString(m.m21()), NumberToString(m.m22()), NumberToString(m.m23()),
NumberToString(m.m31()), NumberToString(m.m32()), NumberToString(m.m33())};
return matrix.join(QChar(';'));
}
} // namespace
} // namespace
//---------------------------------------------------------------------------------------------------------------------
VAbstractPattern::VAbstractPattern(QObject *parent)
: VDomDocument(parent),
nameActivPP(),
cursor(0),
toolsOnRemove(QVector<VDataTool*>()),
history(QVector<VToolRecord>()),
patternPieces(),
modified(false)
{}
: VDomDocument(parent),
nameActivPP(),
cursor(0),
toolsOnRemove(QVector<VDataTool *>()),
history(QVector<VToolRecord>()),
patternPieces(),
modified(false)
{
}
//---------------------------------------------------------------------------------------------------------------------
VAbstractPattern::~VAbstractPattern()
@ -329,9 +329,9 @@ auto VAbstractPattern::RequiresMeasurements() const -> bool
//---------------------------------------------------------------------------------------------------------------------
auto VAbstractPattern::ListMeasurements() const -> QStringList
{
const QFuture<QStringList> futureIncrements = QtConcurrent::run([this](){return ListIncrements();});
const QList<QString> tokens = ConvertToList(QtConcurrent::blockingMappedReduced(ListExpressions(), GetTokens,
GatherTokens));
const QFuture<QStringList> futureIncrements = QtConcurrent::run([this]() { return ListIncrements(); });
const QList<QString> tokens =
ConvertToList(QtConcurrent::blockingMappedReduced(ListExpressions(), GetTokens, GatherTokens));
QSet<QString> measurements;
QSet<QString> others = ConvertToSet<QString>(futureIncrements.result());
@ -378,18 +378,18 @@ auto VAbstractPattern::GetActivDrawElement(QDomElement &element) const -> bool
{
if (nameActivPP.isEmpty() == false)
{
const QDomNodeList elements = this->documentElement().elementsByTagName( TagDraw );
const QDomNodeList elements = this->documentElement().elementsByTagName(TagDraw);
if (elements.size() == 0)
{
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)
{
const QString fieldName = element.attribute( AttrName );
if ( fieldName == nameActivPP )
const QString fieldName = element.attribute(AttrName);
if (fieldName == nameActivPP)
{
return true;
}
@ -404,7 +404,7 @@ auto VAbstractPattern::GetActivDrawElement(QDomElement &element) const -> bool
auto VAbstractPattern::getLocalHistory(const QString &draw) const -> QVector<VToolRecord>
{
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);
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
{
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)
{
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 ( GetParametrString(elem, AttrName) == name )
if (GetParametrString(elem, AttrName) == name)
{
return true;
}
@ -461,7 +461,7 @@ auto VAbstractPattern::GetActivNodeElement(const QString &name, QDomElement &ele
{
return false;
}
element = listElement.at( 0 ).toElement();
element = listElement.at(0).toElement();
if (element.isNull() == false)
{
return true;
@ -494,7 +494,7 @@ void VAbstractPattern::ParseGroups(const QDomElement &domElement)
{
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;
auto i = group.constBegin();
while (i != group.constEnd())
@ -519,7 +519,7 @@ void VAbstractPattern::ParseGroups(const QDomElement &domElement)
{
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));
}
++i;
@ -535,7 +535,7 @@ auto VAbstractPattern::CountPP() const -> int
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())
{
const QDomNodeList elements = this->documentElement().elementsByTagName( TagDraw );
const QDomNodeList elements = this->documentElement().elementsByTagName(TagDraw);
if (elements.size() == 0)
{
return QDomElement();
}
for ( qint32 i = 0; i < elements.count(); i++ )
for (qint32 i = 0; i < elements.count(); i++)
{
QDomElement element = elements.at(i).toElement();
if (not element.isNull())
@ -578,13 +578,13 @@ auto VAbstractPattern::ChangeNamePP(const QString &oldName, const QString &newNa
if (CheckExistNamePP(oldName) == false)
{
qDebug()<<"Do not exist pattern piece with name"<<oldName;
qDebug() << "Do not exist pattern piece with name" << oldName;
return false;
}
if (CheckExistNamePP(newName))
{
qDebug()<<"Already exist pattern piece with name"<<newName;
qDebug() << "Already exist pattern piece with name" << newName;
return false;
}
@ -596,7 +596,7 @@ auto VAbstractPattern::ChangeNamePP(const QString &oldName, const QString &newNa
nameActivPP = 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);
return true;
}
@ -695,7 +695,7 @@ void VAbstractPattern::AddTool(quint32 id, VDataTool *tool)
{
Q_ASSERT_X(id != 0, Q_FUNC_INFO, "id == 0");
SCASSERT(tool != nullptr)
tools.insert(id, tool);
tools.insert(id, tool);
}
//---------------------------------------------------------------------------------------------------------------------
@ -735,9 +735,8 @@ auto VAbstractPattern::ParsePieceCSARecords(const QDomElement &domElement) -> QV
record.path = GetParametrUInt(element, VAbstractPattern::AttrPath, NULL_ID_STR);
record.endPoint = GetParametrUInt(element, VAbstractPattern::AttrEnd, NULL_ID_STR);
record.reverse = GetParametrBool(element, VAbstractPattern::AttrNodeReverse, falseStr);
record.includeType = static_cast<PiecePathIncludeType>(GetParametrUInt(element,
VAbstractPattern::AttrIncludeAs,
QChar('1')));
record.includeType = static_cast<PiecePathIncludeType>(
GetParametrUInt(element, VAbstractPattern::AttrIncludeAs, QChar('1')));
records.append(record);
}
}
@ -822,20 +821,13 @@ auto VAbstractPattern::ParseSANode(const QDomElement &domElement) -> VPieceNode
VDomDocument::GetParametrBool(domElement, VAbstractPattern::AttrManualPassmarkAngle, falseStr);
const QString passmarkAngle = VDomDocument::GetParametrEmptyString(domElement, VAbstractPattern::AttrPassmarkAngle);
const bool turnPoint =
VDomDocument::GetParametrBool(domElement, VAbstractPattern::AttrNodeTurnPoint, trueStr);
const bool turnPoint = VDomDocument::GetParametrBool(domElement, VAbstractPattern::AttrNodeTurnPoint, trueStr);
const QString t = VDomDocument::GetParametrString(domElement, AttrType, VAbstractPattern::NodePoint);
Tool tool;
const QStringList types
{
VAbstractPattern::NodePoint,
VAbstractPattern::NodeArc,
VAbstractPattern::NodeSpline,
VAbstractPattern::NodeSplinePath,
VAbstractPattern::NodeElArc
};
const QStringList types{VAbstractPattern::NodePoint, VAbstractPattern::NodeArc, VAbstractPattern::NodeSpline,
VAbstractPattern::NodeSplinePath, VAbstractPattern::NodeElArc};
switch (types.indexOf(t))
{
@ -932,7 +924,7 @@ void VAbstractPattern::SetMPath(const QString &path)
}
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)
{
const VToolRecord tool = history.at(j-1);
switch ( tool.getTypeTool() )
const VToolRecord tool = history.at(j - 1);
switch (tool.getTypeTool())
{
case Tool::Arrow:
case Tool::Piece:
@ -981,7 +973,7 @@ auto VAbstractPattern::SiblingNodeId(const quint32 &nodeId) const -> quint32
continue;
default:
siblingId = tool.getId();
j = 0;// break loop
j = 0; // break loop
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;
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;
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);
setTagText(TagCustomerName, qsName);
@ -1435,7 +1427,7 @@ void VAbstractPattern::SaveBackgroundImages(const QVector<VBackgroundPatternImag
QDomElement imagesElement = CheckTagExists(TagBackgroundImages);
RemoveAllChildren(imagesElement);
for (const auto& image : images)
for (const auto &image : images)
{
if (not image.Id().isNull())
{
@ -1622,35 +1614,34 @@ auto VAbstractPattern::CheckTagExists(const QString &tag) -> QDomElement
QDomElement element;
if (list.isEmpty())
{
const QStringList tags
{
TagUnit, // 0
TagImage, // 1
TagDescription, // 2
TagNotes, // 3
TagPatternName, // 4
TagPatternNum, // 5
TagCompanyName, // 6
TagCustomerName, // 7
const QStringList tags{
TagUnit, // 0
TagImage, // 1
TagDescription, // 2
TagNotes, // 3
TagPatternName, // 4
TagPatternNum, // 5
TagCompanyName, // 6
TagCustomerName, // 7
TagCustomerBirthDate, // 8
TagCustomerEmail, // 9
TagPatternLabel, // 10
TagPieceLabel, // 11
TagWatermark, // 12
TagPatternMaterials, // 13
TagCustomerEmail, // 9
TagPatternLabel, // 10
TagPieceLabel, // 11
TagWatermark, // 12
TagPatternMaterials, // 13
TagFinalMeasurements, // 14
TagBackgroundImages // 15
TagBackgroundImages // 15
};
switch (tags.indexOf(tag))
{
case 1: //TagImage
case 1: // TagImage
element = createElement(TagImage);
break;
case 2: //TagDescription
case 2: // TagDescription
element = createElement(TagDescription);
break;
case 3: //TagNotes
case 3: // TagNotes
element = createElement(TagNotes);
break;
case 4: // TagPatternName
@ -1689,7 +1680,7 @@ auto VAbstractPattern::CheckTagExists(const QString &tag) -> QDomElement
case 15: // TagBackgroundImages
element = createElement(TagBackgroundImages);
break;
case 0: //TagUnit (Mandatory tag)
case 0: // TagUnit (Mandatory tag)
default:
return {};
}
@ -1703,7 +1694,7 @@ auto VAbstractPattern::CheckTagExists(const QString &tag) -> QDomElement
void VAbstractPattern::InsertTag(const QStringList &tags, const QDomElement &element)
{
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));
if (not list.isEmpty())
@ -1745,7 +1736,7 @@ auto VAbstractPattern::ListIncrements() const -> QStringList
auto GetExpressions = [&increments, this](const QString &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);
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.
// 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.
auto futurePointExpressions = QtConcurrent::run([this](){return ListPointExpressions();});
auto futureArcExpressions = QtConcurrent::run([this](){return ListArcExpressions();});
auto futureElArcExpressions = QtConcurrent::run([this](){return ListElArcExpressions();});
auto futureSplineExpressions = QtConcurrent::run([this](){return ListSplineExpressions();});
auto futureIncrementExpressions = QtConcurrent::run([this](){return ListIncrementExpressions();});
auto futureOperationExpressions = QtConcurrent::run([this](){return ListOperationExpressions();});
auto futurePathExpressions = QtConcurrent::run([this](){return ListPathExpressions();});
auto futurePieceExpressions = QtConcurrent::run([this](){return ListPieceExpressions();});
auto futureFinalMeasurementsExpressions = QtConcurrent::run([this](){return ListFinalMeasurementsExpressions();});
auto futurePointExpressions = QtConcurrent::run([this]() { return ListPointExpressions(); });
auto futureArcExpressions = QtConcurrent::run([this]() { return ListArcExpressions(); });
auto futureElArcExpressions = QtConcurrent::run([this]() { return ListElArcExpressions(); });
auto futureSplineExpressions = QtConcurrent::run([this]() { return ListSplineExpressions(); });
auto futureIncrementExpressions = QtConcurrent::run([this]() { return ListIncrementExpressions(); });
auto futureOperationExpressions = QtConcurrent::run([this]() { return ListOperationExpressions(); });
auto futurePathExpressions = QtConcurrent::run([this]() { return ListPathExpressions(); });
auto futurePieceExpressions = QtConcurrent::run([this]() { return ListPieceExpressions(); });
auto futureFinalMeasurementsExpressions =
QtConcurrent::run([this]() { return ListFinalMeasurementsExpressions(); });
QVector<VFormulaField> list;
list << futurePointExpressions.result();
@ -1801,7 +1793,7 @@ auto VAbstractPattern::ListPointExpressions() const -> QVector<VFormulaField>
QVector<VFormulaField> expressions;
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();
@ -1829,7 +1821,7 @@ auto VAbstractPattern::ListArcExpressions() const -> QVector<VFormulaField>
QVector<VFormulaField> expressions;
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();
@ -1853,7 +1845,7 @@ auto VAbstractPattern::ListElArcExpressions() const -> QVector<VFormulaField>
QVector<VFormulaField> expressions;
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();
@ -1886,7 +1878,7 @@ auto VAbstractPattern::ListPathPointExpressions() const -> QVector<VFormulaField
QVector<VFormulaField> expressions;
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();
@ -1904,7 +1896,7 @@ auto VAbstractPattern::ListIncrementExpressions() const -> QVector<VFormulaField
{
QVector<VFormulaField> expressions;
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();
@ -1924,7 +1916,7 @@ auto VAbstractPattern::ListOperationExpressions() const -> QVector<VFormulaField
QVector<VFormulaField> expressions;
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();
@ -1970,7 +1962,7 @@ auto VAbstractPattern::ListPathExpressions() const -> QVector<VFormulaField>
QVector<VFormulaField> expressions;
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();
if (dom.isNull())
@ -2008,7 +2000,7 @@ auto VAbstractPattern::ListPieceExpressions() const -> QVector<VFormulaField>
QVector<VFormulaField> expressions;
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();
if (dom.isNull())
@ -2031,7 +2023,7 @@ auto VAbstractPattern::ListFinalMeasurementsExpressions() const -> QVector<VForm
{
QVector<VFormulaField> expressions;
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();
if (dom.isNull())
@ -2051,7 +2043,7 @@ auto VAbstractPattern::IsVariable(const QString &token) const -> bool
{
for (const auto &var : builInVariables)
{
if (token.indexOf( var ) == 0)
if (token.indexOf(var) == 0)
{
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.second = items;
@ -2210,7 +2202,7 @@ void VAbstractPattern::SetFMeasurements(QDomElement &element, const QVector<VFin
SetAttribute(tagFMeasurement, AttrName, m.name);
SetAttribute(tagFMeasurement, AttrFormula, m.formula);
SetAttributeOrRemoveIf<QString>(tagFMeasurement, AttrDescription, m.description,
[](const QString &description) noexcept {return description.isEmpty();});
[](const QString &description) noexcept { return description.isEmpty(); });
element.appendChild(tagFMeasurement);
}
@ -2241,8 +2233,8 @@ auto VAbstractPattern::GetBackgroundPatternImage(const QDomElement &element) con
image.SetVisible(GetParametrBool(element, AttrVisible, trueStr));
VValentinaSettings *settings = VAbstractValApplication::VApp()->ValentinaSettings();
image.SetOpacity(GetParametrDouble(element, AttrOpacity,
QString::number(settings->GetBackgroundImageDefOpacity()/100.)));
image.SetOpacity(
GetParametrDouble(element, AttrOpacity, QString::number(settings->GetBackgroundImageDefOpacity() / 100.)));
QString matrix = GetParametrEmptyString(element, AttrTransform);
image.SetMatrix(StringToTransfrom(matrix));
@ -2296,21 +2288,22 @@ void VAbstractPattern::WriteBackgroundImage(QDomElement &element, const VBackgro
else
{
SetAttributeOrRemoveIf<QString>(element, AttrContentType, image.ContentType(),
[](const QString &contentType) noexcept {return contentType.isEmpty();});
[](const QString &contentType) noexcept { return contentType.isEmpty(); });
setTagText(element, image.ContentData());
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(),
[](const QString &name) noexcept {return name.isEmpty();});
[](const QString &name) noexcept { return name.isEmpty(); });
SetAttribute(element, AttrTransform, TransformToString(image.Matrix()));
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<bool>(element, AttrVisible, image.Visible(), [](bool visible) noexcept {return visible;});
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<bool>(element, AttrVisible, image.Visible(), [](bool visible) noexcept { return visible; });
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
{
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();
if (draw.isNull())
@ -2396,17 +2389,17 @@ auto VAbstractPattern::CreateGroup(quint32 id, const QString &name, const QStrin
SetAttribute(group, AttrId, id);
SetAttribute(group, AttrName, name);
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,
[](const QString &preparedTags) noexcept {return preparedTags.isEmpty();});
[](const QString &preparedTags) noexcept { return preparedTags.isEmpty(); });
auto i = groupData.constBegin();
while (i != groupData.constEnd())
{
QDomElement item = createElement(TagGroupItem);
item.setAttribute(AttrTool, i.value());
SetAttributeOrRemoveIf<vidtype>(item, AttrObject, i.key(), [i](vidtype object) noexcept
{return object == i.value();});
SetAttributeOrRemoveIf<vidtype>(item, AttrObject, i.key(),
[i](vidtype object) noexcept { return object == i.value(); });
group.appendChild(item);
++i;
}
@ -2417,7 +2410,7 @@ auto VAbstractPattern::CreateGroup(quint32 id, const QString &name, const QStrin
auto VAbstractPattern::GroupLinkedToTool(vidtype toolId) const -> vidtype
{
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();
if (not group.isNull() && group.hasAttribute(AttrTool))
@ -2442,7 +2435,6 @@ auto VAbstractPattern::GetGroupName(quint32 id) -> QString
if (group.isElement())
{
name = GetParametrString(group, AttrName, name);
}
return name;
@ -2480,7 +2472,7 @@ void VAbstractPattern::SetGroupTags(quint32 id, const QStringList &tags)
if (group.isElement())
{
SetAttributeOrRemoveIf<QString>(group, AttrTags, tags.join(','),
[](const QString &rawTags) noexcept {return rawTags.isEmpty();});
[](const QString &rawTags) noexcept { return rawTags.isEmpty(); });
modified = true;
emit patternChanged(false);
}
@ -2495,7 +2487,7 @@ auto VAbstractPattern::GetDimensionAValue() -> double
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;
}
@ -2511,7 +2503,7 @@ void VAbstractPattern::SetDimensionAValue(double value)
}
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);
}
qDebug()<<"Can't save dimension B of measurements"<<Q_FUNC_INFO;
qDebug() << "Can't save dimension B of measurements" << Q_FUNC_INFO;
return -1;
}
@ -2540,7 +2532,7 @@ void VAbstractPattern::SetDimensionBValue(double value)
}
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);
}
qDebug()<<"Can't save dimension C of measurements"<<Q_FUNC_INFO;
qDebug() << "Can't save dimension C of measurements" << Q_FUNC_INFO;
return -1;
}
@ -2569,7 +2561,7 @@ void VAbstractPattern::SetDimensionCValue(double value)
}
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;
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();
if (not group.isNull() && group.hasAttribute(AttrTags))
@ -2615,9 +2607,8 @@ auto VAbstractPattern::GetGroups(const QString &patternPieceName) -> QMap<quint3
VGroupData groupData;
const quint32 id = GetParametrUInt(group, AttrId, QChar('0'));
groupData.visible = GetParametrBool(group, AttrVisible, trueStr);
groupData.name =
GetParametrString(group, AttrName,
QCoreApplication::translate("VAbstractPattern", "New group"));
groupData.name = GetParametrString(
group, AttrName, QCoreApplication::translate("VAbstractPattern", "New group"));
groupData.tags = FilterGroupTags(GetParametrEmptyString(group, AttrTags));
groupData.tool = GetParametrUInt(group, AttrTool, NULL_ID_STR);
@ -2672,7 +2663,7 @@ auto VAbstractPattern::GetGroupsContainingItem(quint32 toolId, quint32 objectId,
{
QMap<quint32, QString> data;
if(objectId == 0)
if (objectId == 0)
{
objectId = toolId;
}
@ -2693,7 +2684,7 @@ auto VAbstractPattern::GetGroupsContainingItem(quint32 toolId, quint32 objectId,
if (group.tagName() == TagGroup)
{
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 QString name = GetParametrString(
@ -2736,7 +2727,7 @@ auto VAbstractPattern::GroupHasItem(const QDomElement &groupDomElement, quint32
quint32 toolIdIterate = GetParametrUInt(item, AttrTool, QChar('0'));
quint32 objectIdIterate = GetParametrUInt(item, AttrObject, QString::number(toolIdIterate));
if(toolIdIterate == toolId && objectIdIterate == objectId)
if (toolIdIterate == toolId && objectIdIterate == objectId)
{
result = true;
break;
@ -2835,15 +2826,15 @@ auto VAbstractPattern::AddItemToGroup(quint32 toolId, quint32 objectId, quint32
if (not group.isNull())
{
if(objectId == 0)
if (objectId == 0)
{
objectId = toolId;
}
QDomElement item = createElement(TagGroupItem);
item.setAttribute(AttrTool, toolId);
SetAttributeOrRemoveIf<vidtype>(item, AttrObject, objectId, [toolId](vidtype object) noexcept
{return object == toolId;});
SetAttributeOrRemoveIf<vidtype>(item, AttrObject, objectId,
[toolId](vidtype object) noexcept { return object == toolId; });
group.appendChild(item);
// 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(objectId == 0)
if (objectId == 0)
{
objectId = toolId;
}
@ -2894,10 +2885,10 @@ auto VAbstractPattern::RemoveItemFromGroup(quint32 toolId, quint32 objectId, qui
const QDomElement item = itemNode.toElement();
if (not item.isNull())
{
quint32 toolIdIterate= GetParametrUInt(item, AttrTool, QChar('0'));
quint32 objectIdIterate= GetParametrUInt(item, AttrObject, QString::number(toolIdIterate));
quint32 toolIdIterate = GetParametrUInt(item, AttrTool, QChar('0'));
quint32 objectIdIterate = GetParametrUInt(item, AttrObject, QString::number(toolIdIterate));
if(toolIdIterate == toolId && objectIdIterate == objectId)
if (toolIdIterate == toolId && objectIdIterate == objectId)
{
group.removeChild(itemNode);
@ -2957,7 +2948,7 @@ auto VAbstractPattern::PieceDrawName(quint32 id) -> QString
return QString();
}
return draw.attribute(VAbstractPattern::AttrName);
return draw.attribute(VAbstractPattern::AttrName);
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -28,15 +28,15 @@
#include "vdomdocument.h"
#include <QSaveFile>
#include <qcompilerdetection.h>
#include <qdom.h>
#include <QSaveFile>
#include "../exception/vexception.h"
#include "../exception/vexceptionbadid.h"
#include "../exception/vexceptionconversionerror.h"
#include "../exception/vexceptionemptyparameter.h"
#include "../exception/vexceptionwrongid.h"
#include "../exception/vexception.h"
#include "../ifcdef.h"
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
@ -45,9 +45,12 @@
#endif
#include <QByteArray>
#include <QDir>
#include <QDomNodeList>
#include <QDomText>
#include <QFile>
#include <QFileInfo>
#include <QFutureWatcher>
#include <QIODevice>
#include <QMessageLogger>
#include <QObject>
@ -55,14 +58,12 @@
#include <QTemporaryFile>
#include <QTextDocument>
#include <QTextStream>
#include <QTimer>
#include <QUrl>
#include <QVector>
#include <QtDebug>
#include <QXmlStreamWriter>
#include <QTimer>
#include <QtConcurrentRun>
#include <QFutureWatcher>
#include <QRegularExpression>
#include <QtDebug>
namespace
{
@ -71,7 +72,7 @@ void SaveNodeCanonically(QXmlStreamWriter &stream, const QDomNode &domNode)
{
if (stream.hasError())
{
return;
return;
}
if (domNode.isElement())
@ -159,7 +160,7 @@ auto LessThen(const QDomNode &element1, const QDomNode &element2) -> bool
QString tag1 = element1.nodeName();
QString tag2 = element2.nodeName();
//qDebug() << tag1 <<tag2;
// qDebug() << tag1 <<tag2;
if (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> attributes2 = GetElementAttributes(element2);
if(attributes1.size() != attributes2.size())
if (attributes1.size() != attributes2.size())
{
return attributes1.size() < attributes2.size();
}
@ -179,22 +180,22 @@ auto LessThen(const QDomNode &element1, const QDomNode &element2) -> bool
*stop = false;
std::sort(list1.begin(), list1.end(), LessThen);
std::sort(list2.begin(), list2.end(), LessThen);
//qDebug() << "comparing sorted lists";
for(int k = 0; k < list1.size(); ++k)
// qDebug() << "comparing sorted lists";
for (int k = 0; k < list1.size(); ++k)
{
if (!LessThen(list1[k], list2[k]))
{
if (LessThen(list2[k], list1[k]))
{
*stop = true;
//qDebug() << "false!";
// qDebug() << "false!";
return false;
}
}
else
{
*stop = true;
//qDebug() << "true!";
// qDebug() << "true!";
return true;
}
}
@ -214,17 +215,17 @@ auto LessThen(const QDomNode &element1, const QDomNode &element2) -> bool
QString value1, value2;
if(elts1.size() != elts2.size())
if (elts1.size() != elts2.size())
{
return elts1.size() < elts2.size();
}
if(elts1.isEmpty())
if (elts1.isEmpty())
{
value1 = element1.nodeValue();
value2 = element2.nodeValue();
//qDebug() <<value1 << value2 << (value1 < value2);
// qDebug() <<value1 << value2 << (value1 < value2);
return value1 < value2;
}
@ -235,7 +236,7 @@ auto LessThen(const QDomNode &element1, const QDomNode &element2) -> bool
}
return false;
}
} // namespace
} // namespace
QT_WARNING_PUSH
QT_WARNING_DISABLE_CLANG("-Wmissing-prototypes")
@ -245,23 +246,23 @@ Q_LOGGING_CATEGORY(vXML, "v.xml") // NOLINT
QT_WARNING_POP
const QString VDomDocument::AttrId = QStringLiteral("id");
const QString VDomDocument::AttrText = QStringLiteral("text");
const QString VDomDocument::AttrBold = QStringLiteral("bold");
const QString VDomDocument::AttrItalic = QStringLiteral("italic");
const QString VDomDocument::AttrAlignment = QStringLiteral("alignment");
const QString VDomDocument::AttrId = QStringLiteral("id");
const QString VDomDocument::AttrText = QStringLiteral("text");
const QString VDomDocument::AttrBold = QStringLiteral("bold");
const QString VDomDocument::AttrItalic = QStringLiteral("italic");
const QString VDomDocument::AttrAlignment = QStringLiteral("alignment");
const QString VDomDocument::AttrFSIncrement = QStringLiteral("sfIncrement");
const QString VDomDocument::TagVersion = QStringLiteral("version");
const QString VDomDocument::TagUnit = QStringLiteral("unit");
const QString VDomDocument::TagLine = QStringLiteral("line");
const QString VDomDocument::TagUnit = QStringLiteral("unit");
const QString VDomDocument::TagLine = QStringLiteral("line");
//---------------------------------------------------------------------------------------------------------------------
VDomDocument::VDomDocument(QObject *parent)
: QObject(parent),
QDomDocument(),
m_elementIdCache(),
m_watcher(new QFutureWatcher<QHash<quint32, QDomElement>>(this))
: QObject(parent),
QDomDocument(),
m_elementIdCache(),
m_watcher(new QFutureWatcher<QHash<quint32, QDomElement>>(this))
{
connect(m_watcher, &QFutureWatcher<QHash<quint32, QDomElement>>::finished, this, &VDomDocument::CacheRefreshed);
}
@ -300,7 +301,7 @@ auto VDomDocument::elementById(quint32 id, const QString &tagName, bool updateCa
}
if (updateCache)
{ // Cached missed
{ // Cached missed
RefreshElementIdCache();
}
@ -316,7 +317,7 @@ auto VDomDocument::elementById(quint32 id, const QString &tagName, bool updateCa
else
{
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();
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);
if (n.isElement())
@ -381,7 +382,6 @@ auto VDomDocument::find(QHash<quint32, QDomElement> &cache, const QDomElement &n
return false;
}
//---------------------------------------------------------------------------------------------------------------------
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);
const QStringList bools {trueStr, falseStr, QChar('1'), QChar('0')};
const QStringList bools{trueStr, falseStr, QChar('1'), QChar('0')};
switch (bools.indexOf(parametr))
{
case 0: // true
@ -511,7 +511,7 @@ auto VDomDocument::GetParametrBool(const QDomElement &domElement, const QString
case 3: // 0
val = false;
break;
default:// others
default: // others
throw VExceptionConversionError(message, name);
}
}
@ -687,7 +687,7 @@ void VDomDocument::CollectId(const QDomElement &node, QVector<quint32> &vector)
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);
if (n.isElement())
@ -702,7 +702,7 @@ void VDomDocument::RefreshElementIdCache()
{
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();
VException e(errorMsg);
e.AddMoreInformation(tr("Parsing error file %3 in line %1 column %2").arg(errorLine).arg(errorColumn)
.arg(fileName));
e.AddMoreInformation(
tr("Parsing error file %3 in line %1 column %2").arg(errorLine).arg(errorColumn).arg(fileName));
throw e;
}
@ -748,7 +748,7 @@ void VDomDocument::setXMLContent(const QString &fileName)
auto VDomDocument::UnitsHelpString() -> QString
{
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));
if (i < last - 1)
@ -772,7 +772,7 @@ auto VDomDocument::SaveDocument(const QString &fileName, QString &error) -> bool
{
if (fileName.isEmpty())
{
qDebug()<<"Got empty file name.";
qDebug() << "Got empty file name.";
return false;
}
bool success = false;
@ -787,10 +787,10 @@ auto VDomDocument::SaveDocument(const QString &fileName, QString &error) -> bool
}
// Left these strings in case we will need them for testing purposes
// QTextStream out(&file);
//#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
// out.setCodec("UTF-8");
//#endif
// save(out, indent);
// #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
// out.setCodec("UTF-8");
// #endif
// save(out, indent);
success = file.commit();
}
@ -886,7 +886,7 @@ auto VDomDocument::GetFormatVersion(const QString &version) -> unsigned
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);
if (nodeList.isEmpty())
{
qDebug()<<"Can't save tag "<<tag<<Q_FUNC_INFO;
qDebug() << "Can't save tag " << tag << Q_FUNC_INFO;
}
else
{
@ -967,11 +967,11 @@ auto VDomDocument::UniqueTag(const QString &tagName) const -> QDomElement
*/
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;
//#ifdef Q_OS_WIN32
// qt_ntfs_permission_lookup++; // turn checking on
//#endif /*Q_OS_WIN32*/
// #ifdef Q_OS_WIN32
// qt_ntfs_permission_lookup++; // turn checking on
// #endif /*Q_OS_WIN32*/
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())
{
error = destFile.errorString();
@ -1060,9 +1060,9 @@ auto VDomDocument::SafeCopy(const QString &source, const QString &destination, Q
}
}
//#ifdef Q_OS_WIN32
// qt_ntfs_permission_lookup--; // turn off check permission again
//#endif /*Q_OS_WIN32*/
// #ifdef Q_OS_WIN32
// qt_ntfs_permission_lookup--; // turn off check permission again
// #endif /*Q_OS_WIN32*/
return result;
}

View File

@ -31,6 +31,10 @@
#include "../vlayout/vlayoutpoint.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:
* 1. Version have three parts "major.minor.patch";
@ -43,33 +47,38 @@ const QString VLayoutConverter::LayoutMinVerStr = QStringLiteral("0.1.0");
const QString VLayoutConverter::LayoutMaxVerStr = QStringLiteral("0.1.5");
const QString VLayoutConverter::CurrentSchema = QStringLiteral("://schema/layout/v0.1.5.xsd");
//VLayoutConverter::LayoutMinVer; // <== DON'T FORGET TO UPDATE TOO!!!!
//VLayoutConverter::LayoutMaxVer; // <== DON'T FORGET TO UPDATE TOO!!!!
// VLayoutConverter::LayoutMinVer; // <== DON'T FORGET TO UPDATE TOO!!!!
// VLayoutConverter::LayoutMaxVer; // <== DON'T FORGET TO UPDATE TOO!!!!
namespace
{
QT_WARNING_PUSH
QT_WARNING_DISABLE_CLANG("-Wunused-member-function")
// The list of all string we use for conversion
// Better to use global variables because repeating QStringLiteral blows up code size
Q_GLOBAL_STATIC_WITH_ARGS(const QString, strSeamLineTag, (QLatin1String("seamLine"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, strSeamAllowanceTag, (QLatin1String("seamAllowance"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, strInternalPathTag, (QLatin1String("internalPath"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, strMarkerTag, (QLatin1String("marker"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, strPointTag, (QLatin1String("point"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, strPieceTag, (QLatin1String("piece"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, strGrainlineTag, (QLatin1String("grainline"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, strAttrX, (QLatin1String("x"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, strAttrY, (QLatin1String("y"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, strAttrTurnPoint, (QLatin1String("turnPoint"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, strAttrCurvePoint, (QLatin1String("curvePoint"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, strAttrId, (QLatin1String("id"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, strAttrUId, (QLatin1String("uid"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, strSeamLineTag, (QLatin1String("seamLine"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, strSeamAllowanceTag, (QLatin1String("seamAllowance"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, strInternalPathTag, (QLatin1String("internalPath"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, strMarkerTag, (QLatin1String("marker"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, strPointTag, (QLatin1String("point"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, strPieceTag, (QLatin1String("piece"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, strGrainlineTag, (QLatin1String("grainline"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, strAttrX, (QLatin1String("x"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, strAttrY, (QLatin1String("y"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, strAttrTurnPoint, (QLatin1String("turnPoint"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, strAttrCurvePoint, (QLatin1String("curvePoint"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, strAttrId, (QLatin1String("id"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, strAttrUId, (QLatin1String("uid"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, strAttrAngle, (QLatin1String("angle"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, strAttrArrowDirection, (QLatin1String("arrowDirection"))) // NOLINT
QT_WARNING_POP
const QChar groupSep = QLatin1Char(';');
const QChar coordintatesSep = QLatin1Char(',');
const QChar pointsSep = QLatin1Char(' ');
//const QChar itemsSep = QLatin1Char('*');
const QChar pointsSep = QLatin1Char(' ');
// const QChar itemsSep = QLatin1Char('*');
//---------------------------------------------------------------------------------------------------------------------
auto StringV0_1_2ToPoint(const QString &point) -> QPointF
@ -89,7 +98,7 @@ auto StringV0_1_2ToPath(const QString &path) -> QVector<QPointF>
QVector<QPointF> p;
QStringList points = path.split(pointsSep);
p.reserve(points.size());
for (const auto& point : points)
for (const auto &point : points)
{
p.append(StringV0_1_2ToPoint(point));
}
@ -103,11 +112,11 @@ template <class T> auto NumberToString(T number) -> QString
const QLocale locale = QLocale::c();
return locale.toString(number, 'g', 12).remove(LocaleGroupSeparator(locale));
}
} // namespace
} // namespace
//---------------------------------------------------------------------------------------------------------------------
VLayoutConverter::VLayoutConverter(const QString &fileName)
: VAbstractConverter(fileName)
: VAbstractConverter(fileName)
{
m_ver = GetFormatVersion(VLayoutConverter::GetFormatVersionStr());
ValidateInputFile(CurrentSchema);
@ -204,20 +213,14 @@ auto VLayoutConverter::Schemas() const -> QHash<unsigned int, QString>
void VLayoutConverter::ConvertPiecesToV0_1_3()
{
// TODO. Delete if minimal supported version is 0.1.3
Q_STATIC_ASSERT_X(VLayoutConverter::LayoutMinVer < FormatVersion(0, 1, 3),
"Time to refactor the code.");
Q_STATIC_ASSERT_X(VLayoutConverter::LayoutMinVer < FormatVersion(0, 1, 3), "Time to refactor the code.");
const QStringList types
{
*strSeamLineTag,
*strSeamAllowanceTag,
*strInternalPathTag
};
const QStringList types{*strSeamLineTag, *strSeamAllowanceTag, *strInternalPathTag};
for (const auto &tagType : types)
{
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();
ConvertPathToV0_1_3(node);
@ -225,14 +228,14 @@ void VLayoutConverter::ConvertPiecesToV0_1_3()
}
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();
RemoveAllChildren(node);
}
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();
if (node.isElement() && node.hasAttribute(*strAttrId))
@ -374,8 +377,7 @@ void VLayoutConverter::ConvertPiecesToV0_1_5()
void VLayoutConverter::ToV0_1_3()
{
// TODO. Delete if minimal supported version is 0.1.3
Q_STATIC_ASSERT_X(VLayoutConverter::LayoutMinVer < FormatVersion(0, 1, 3),
"Time to refactor the code.");
Q_STATIC_ASSERT_X(VLayoutConverter::LayoutMinVer < FormatVersion(0, 1, 3), "Time to refactor the code.");
ConvertPiecesToV0_1_3();
SetVersion(QStringLiteral("0.1.3"));

File diff suppressed because it is too large Load Diff

View File

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

View File

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

View File

@ -1,30 +1,30 @@
/************************************************************************
**
** @file vdxfengine.cpp
** @author Valentina Zhuravska <zhuravska19(at)gmail.com>
** @date 12 8, 2015
**
** @brief
** @copyright
** This source code is part of the Valentina project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2013-2015 Valentina project
** <https://gitlab.com/smart-pattern/valentina> All Rights Reserved.
**
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Valentina is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
*************************************************************************/
/************************************************************************
**
** @file vdxfengine.cpp
** @author Valentina Zhuravska <zhuravska19(at)gmail.com>
** @date 12 8, 2015
**
** @brief
** @copyright
** This source code is part of the Valentina project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2013-2015 Valentina project
** <https://gitlab.com/smart-pattern/valentina> All Rights Reserved.
**
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Valentina is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
*************************************************************************/
#include "vdxfengine.h"
#include <QLineF>
@ -54,83 +54,86 @@
#include <QTextCodec>
#endif
#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)
#include "../vgeometry/vgeometrydef.h"
#include "../vgeometry/vlayoutplacelabel.h"
#include "../vlayout/vlayoutpiece.h"
#include "../vlayout/vlayoutpoint.h"
#include "../vmisc/def.h"
#include "dxiface.h"
namespace
{
static const qreal AAMATextHeight = 2.5;
namespace
{
const qreal AAMATextHeight = 2.5;
Q_GLOBAL_STATIC_WITH_ARGS(const UTF8STRING, layer0, (UTF8STRING("0"))) // NOLINT
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_PUSH
QT_WARNING_DISABLE_CLANG("-Wunused-member-function")
//---------------------------------------------------------------------------------------------------------------------
auto PieceOutline(const VLayoutPiece &detail) -> QVector<VLayoutPoint>
{
QVector<VLayoutPoint> outline;
if (detail.IsSeamAllowance() && not detail.IsSeamAllowanceBuiltIn())
{
outline = detail.GetMappedSeamAllowancePoints();
}
else
{
outline = detail.GetMappedContourPoints();
}
return outline;
}
} // namespace
Q_GLOBAL_STATIC_WITH_ARGS(const UTF8STRING, layer0, (UTF8STRING("0"))) // NOLINT
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;
if (detail.IsSeamAllowance() && not detail.IsSeamAllowanceBuiltIn())
{
outline = detail.GetMappedSeamAllowancePoints();
}
else
{
outline = detail.GetMappedContourPoints();
}
return outline;
}
} // namespace
//---------------------------------------------------------------------------------------------------------------------
static inline auto svgEngineFeatures() -> QPaintEngine::PaintEngineFeatures
{
QT_WARNING_PUSH
QT_WARNING_DISABLE_CLANG("-Wsign-conversion")
QT_WARNING_DISABLE_INTEL(68)
QT_WARNING_PUSH
QT_WARNING_DISABLE_CLANG("-Wsign-conversion")
QT_WARNING_DISABLE_INTEL(68)
return {QPaintEngine::AllFeatures
& ~QPaintEngine::PatternBrush
& ~QPaintEngine::PerspectiveTransform
& ~QPaintEngine::ConicalGradientFill
& ~QPaintEngine::PorterDuff};
return {QPaintEngine::AllFeatures & ~QPaintEngine::PatternBrush & ~QPaintEngine::PerspectiveTransform &
~QPaintEngine::ConicalGradientFill & ~QPaintEngine::PorterDuff};
QT_WARNING_POP
QT_WARNING_POP
}
//---------------------------------------------------------------------------------------------------------------------
VDxfEngine::VDxfEngine()
:QPaintEngine(svgEngineFeatures()),
m_textBuffer(new DRW_Text())
: QPaintEngine(svgEngineFeatures()),
m_textBuffer(new DRW_Text())
{
}
@ -153,12 +156,12 @@ auto VDxfEngine::begin(QPaintDevice *pdev) -> bool
if (not m_size.isValid())
{
qWarning()<<"VDxfEngine::begin(), size is not valid";
qWarning() << "VDxfEngine::begin(), size is not valid";
return false;
}
m_input = QSharedPointer<dx_iface>(new dx_iface(GetFileNameForLocale(), m_version, m_varMeasurement,
m_varInsunits));
m_input =
QSharedPointer<dx_iface>(new dx_iface(GetFileNameForLocale(), m_version, m_varMeasurement, m_varInsunits));
m_input->AddDefHeaderData();
m_input->AddQtLTypes();
m_input->AddDefLayers();
@ -180,7 +183,6 @@ void VDxfEngine::updateState(const QPaintEngineState &state)
// always stream full gstate, which is not required, but...
flags |= QPaintEngine::AllDirty;
if (flags & QPaintEngine::DirtyTransform)
{
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);
for (const auto& polygon : subpaths)
for (const auto &polygon : subpaths)
{
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)
auto *line = new DRW_Line();
line->basePoint = DRW_Coord(FromPixel(p1.x(), m_varInsunits),
FromPixel(GetSize().height() - p1.y(), m_varInsunits), 0);
line->secPoint = DRW_Coord(FromPixel(p2.x(), m_varInsunits),
FromPixel(GetSize().height() - p2.y(), m_varInsunits), 0);
line->basePoint =
DRW_Coord(FromPixel(p1.x(), m_varInsunits), FromPixel(GetSize().height() - p1.y(), m_varInsunits), 0);
line->secPoint =
DRW_Coord(FromPixel(p2.x(), m_varInsunits), FromPixel(GetSize().height() - p2.y(), m_varInsunits), 0);
line->layer = *layer0;
line->color = GetPenColor();
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);
}
@ -293,7 +295,8 @@ void VDxfEngine::drawPolygon(const QPointF *points, int pointCount, PolygonDrawM
poly->lWeight = DRW_LW_Conv::widthByLayer;
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)
}
@ -303,8 +306,8 @@ void VDxfEngine::drawPolygon(const QPointF *points, int pointCount, PolygonDrawM
for (int i = 0; i < pointCount; ++i)
{
const QPointF p = m_matrix.map(points[i]); // NOLINT(cppcoreguidelines-pro-bounds-pointer-arithmetic)
poly->addVertex(DRW_Vertex2D(FromPixel(p.x(), m_varInsunits),
FromPixel(GetSize().height() - p.y(), m_varInsunits), 0));
poly->addVertex(
DRW_Vertex2D(FromPixel(p.x(), m_varInsunits), FromPixel(GetSize().height() - p.y(), m_varInsunits), 0));
}
m_input->AddEntity(poly);
@ -317,7 +320,8 @@ void VDxfEngine::drawPolygon(const QPointF *points, int pointCount, PolygonDrawM
poly->lWeight = DRW_LW_Conv::widthByLayer;
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)
}
@ -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 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 ratio; // ratio of minor axis to major axis
if(rect.width()<= rect.height())
double ratio; // ratio of minor axis to major axis
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
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)
ratio = rect.width()/rect.height();
ratio = rect.width() / rect.height();
}
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)
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
ratio = rect.height()/rect.width();
ratio = rect.height() / rect.width();
}
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->ratio = ratio;
ellipse->staparam = 0;
ellipse->endparam = 2*M_PI;
ellipse->endparam = 2 * M_PI;
ellipse->layer = *layer0;
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);
}
//---------------------------------------------------------------------------------------------------------------------
void VDxfEngine::drawTextItem(const QPointF & p, const QTextItem & textItem)
void VDxfEngine::drawTextItem(const QPointF &p, const QTextItem &textItem)
{
if (m_textBuffer->text.empty())
{
@ -400,9 +404,9 @@ void VDxfEngine::drawTextItem(const QPointF & p, const QTextItem & textItem)
const UTF8STRING fontStyle = m_input->AddFont(f);
m_textBuffer->basePoint = DRW_Coord(FromPixel(startPoint.x(), m_varInsunits),
FromPixel(GetSize().height() - startPoint.y(), m_varInsunits), 0);
FromPixel(GetSize().height() - startPoint.y(), m_varInsunits), 0);
m_textBuffer->secPoint = DRW_Coord(FromPixel(startPoint.x(), m_varInsunits),
FromPixel(GetSize().height() - startPoint.y(), m_varInsunits), 0);
FromPixel(GetSize().height() - startPoint.y(), m_varInsunits), 0);
m_textBuffer->height = FromPixel(QFontMetrics(f).height(), m_varInsunits);
m_textBuffer->style = fontStyle;
@ -448,20 +452,20 @@ void VDxfEngine::drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr
Q_UNUSED(sr)
}
//---------------------------------------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------------------------------
auto VDxfEngine::GetSize() const -> QSize
{
return m_size;
}
//---------------------------------------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------------------------------
void VDxfEngine::SetSize(const QSize &value)
{
Q_ASSERT(not isActive());
m_size = value;
}
//---------------------------------------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------------------------------
auto VDxfEngine::GetResolution() const -> double
{
return m_resolution;
@ -536,77 +540,77 @@ auto VDxfEngine::GetPenColor() -> int
{
QColor color = state->pen().color();
if(color == Qt::black)
if (color == Qt::black)
{
return DRW::black;
}
if(color == Qt::white)
if (color == Qt::white)
{
return DRW::white;
}
if(color == Qt::darkGray)
if (color == Qt::darkGray)
{
return DRW::gray;
}
if(color == Qt::gray)
if (color == Qt::gray)
{
return DRW::l_gray;
}
if(color == Qt::darkMagenta)
if (color == Qt::darkMagenta)
{
return DRW::magenta;
}
if(color == Qt::magenta)
if (color == Qt::magenta)
{
return DRW::l_magenta;
}
if(color == Qt::cyan)
if (color == Qt::cyan)
{
return DRW::l_cyan;
}
if(color == Qt::darkCyan)
if (color == Qt::darkCyan)
{
return DRW::cyan;
}
if(color == Qt::blue)
if (color == Qt::blue)
{
return DRW::l_blue;
}
if(color == Qt::darkBlue)
if (color == Qt::darkBlue)
{
return DRW::blue;
}
if(color == Qt::darkGreen)
if (color == Qt::darkGreen)
{
return DRW::green;
}
if(color == Qt::green)
if (color == Qt::green)
{
return DRW::l_green;
}
if(color == Qt::darkRed)
if (color == Qt::darkRed)
{
return DRW::red;
}
if(color == Qt::red)
if (color == Qt::red)
{
return DRW::l_red;
}
if(color == Qt::yellow)
if (color == Qt::yellow)
{
return DRW::yellow;
}
@ -698,7 +702,7 @@ auto VDxfEngine::ExportToAAMA(const QVector<VLayoutPiece> &details) -> bool
{
if (not m_size.isValid())
{
qWarning()<<"VDxfEngine::begin(), size is not valid";
qWarning() << "VDxfEngine::begin(), size is not valid";
return false;
}
@ -713,11 +717,11 @@ auto VDxfEngine::ExportToAAMA(const QVector<VLayoutPiece> &details) -> bool
ExportStyleSystemText(m_input, details);
for(auto detail : details)
for (auto detail : details)
{
// Use custom deleter function to lose ownership after adding the block
bool deleteBlock = true;
auto NoOpDeleter =[&deleteBlock](dx_ifaceBlock* block)
auto NoOpDeleter = [&deleteBlock](dx_ifaceBlock *block)
{
if (deleteBlock)
{
@ -793,7 +797,7 @@ void VDxfEngine::ExportAAMADraw(const QSharedPointer<dx_ifaceBlock> &detailBlock
}
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))
{
@ -805,13 +809,13 @@ void VDxfEngine::ExportAAMADraw(const QSharedPointer<dx_ifaceBlock> &detailBlock
}
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
&& label.Type() != PlaceLabelType::Circle)
if (label.Type() != PlaceLabelType::Doubletree && label.Type() != PlaceLabelType::Button &&
label.Type() != PlaceLabelType::Circle)
{
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))
{
@ -829,7 +833,7 @@ void VDxfEngine::ExportAAMADraw(const QSharedPointer<dx_ifaceBlock> &detailBlock
void VDxfEngine::ExportAAMAIntcut(const QSharedPointer<dx_ifaceBlock> &detailBlock, const VLayoutPiece &detail)
{
QVector<QVector<VLayoutPoint>> drawIntCut = detail.MappedInternalPathsForCut(true);
for(auto &intCut : drawIntCut)
for (auto &intCut : drawIntCut)
{
if (DRW_Entity *e = AAMAPolygon(intCut, *layer11, false))
{
@ -847,7 +851,7 @@ void VDxfEngine::ExportAAMANotch(const QSharedPointer<dx_ifaceBlock> &detailBloc
if (detail.IsSeamAllowance())
{
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());
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)
{
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));
}
}
@ -893,7 +897,7 @@ void VDxfEngine::ExportPieceText(const QSharedPointer<dx_ifaceBlock> &detailBloc
//---------------------------------------------------------------------------------------------------------------------
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();
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)
{
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));
}
return;
@ -914,10 +918,10 @@ void VDxfEngine::ExportAAMADrill(const QSharedPointer<dx_ifaceBlock> &detailBloc
{
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
|| label.Type() == PlaceLabelType::Circle)
if (label.Type() == PlaceLabelType::Doubletree || label.Type() == PlaceLabelType::Button ||
label.Type() == PlaceLabelType::Circle)
{
const QPointF center = detail.GetMatrix().map(label.Center());
detailBlock->ent.push_back(AAMAPoint(center, *layer13));
@ -930,12 +934,12 @@ auto VDxfEngine::ExportToASTM(const QVector<VLayoutPiece> &details) -> bool
{
if (not m_size.isValid())
{
qWarning()<<"VDxfEngine::begin(), size is not valid";
qWarning() << "VDxfEngine::begin(), size is not valid";
return false;
}
m_input = QSharedPointer<dx_iface>(new dx_iface(GetFileNameForLocale(), m_version, m_varMeasurement,
m_varInsunits));
m_input =
QSharedPointer<dx_iface>(new dx_iface(GetFileNameForLocale(), m_version, m_varMeasurement, m_varInsunits));
m_input->AddXSpaceBlock(false);
m_input->AddAAMAHeaderData();
if (m_version > DRW::AC1009)
@ -946,11 +950,11 @@ auto VDxfEngine::ExportToASTM(const QVector<VLayoutPiece> &details) -> bool
ExportStyleSystemText(m_input, details);
for(auto detail : details)
for (auto detail : details)
{
// Use custom deleter function to lose ownership after adding the block
bool deleteBlock = true;
auto NoOpDeleter =[&deleteBlock](dx_ifaceBlock* block)
auto NoOpDeleter = [&deleteBlock](dx_ifaceBlock *block)
{
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)
{
const QVector<QVector<VLayoutPoint>> drawIntLine = detail.MappedInternalPathsForCut(false);
for(const auto &intLine : drawIntLine)
for (const auto &intLine : drawIntLine)
{
// Internal line
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();
for(const auto &label : labels)
for (const auto &label : labels)
{
if (label.Type() != PlaceLabelType::Doubletree && label.Type() != PlaceLabelType::Button
&& label.Type() != PlaceLabelType::Circle)
if (label.Type() != PlaceLabelType::Doubletree && label.Type() != PlaceLabelType::Button &&
label.Type() != PlaceLabelType::Circle)
{
PlaceLabelImg shape = detail.MapPlaceLabelShape(VAbstractPiece::PlaceLabelShape(label));
for(const auto &p : shape)
for (const auto &p : shape)
{
// Internal line (placelabel)
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)
{
QVector<QVector<VLayoutPoint>> drawIntCut = detail.MappedInternalPathsForCut(true);
for(auto &intCut : drawIntCut)
for (auto &intCut : drawIntCut)
{
// Internal cutout
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();
for(const auto &label : labels)
for (const auto &label : labels)
{
if (label.Type() == PlaceLabelType::Doubletree || label.Type() == PlaceLabelType::Button
|| label.Type() == PlaceLabelType::Circle)
if (label.Type() == PlaceLabelType::Doubletree || label.Type() == PlaceLabelType::Button ||
label.Type() == PlaceLabelType::Circle)
{
const QPointF center = detail.GetMatrix().map(label.Center());
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());
// TODO. Investigate drill category
// QPointF pos(center.x(), center.y() - ToPixel(AAMATextHeight, m_varInsunits));
// detailBlock->ent.push_back(AAMAText(pos, category, *layer13));
// QPointF pos(center.x(), center.y() - ToPixel(AAMATextHeight, m_varInsunits));
// detailBlock->ent.push_back(AAMAText(pos, category, *layer13));
}
}
}
@ -1155,7 +1159,7 @@ void VDxfEngine::ExportASTMNotch(const QSharedPointer<dx_ifaceBlock> &detailBloc
if (detail.IsSeamAllowance())
{
const QVector<VLayoutPassmark> passmarks = detail.GetMappedPassmarks();
for(const auto &passmark : passmarks)
for (const auto &passmark : passmarks)
{
auto *notch = new DRW_ASTMNotch();
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,
const QVector<VLayoutPoint> &points) const
{
for(const auto &p : qAsConst(points))
for (const auto &p : qAsConst(points))
{
if (p.TurnPoint())
{
@ -1251,7 +1255,7 @@ void VDxfEngine::ExportTurnPoints(const QSharedPointer<dx_ifaceBlock> &detailBlo
void VDxfEngine::ExportCurvePoints(const QSharedPointer<dx_ifaceBlock> &detailBlock,
const QVector<VLayoutPoint> &points) const
{
for(const auto &p : qAsConst(points))
for (const auto &p : qAsConst(points))
{
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,
bool forceClosed) -> DRW_Entity *
auto VDxfEngine::AAMAPolygon(const QVector<VLayoutPoint> &polygon, const UTF8STRING &layer, bool forceClosed)
-> DRW_Entity *
{
if (polygon.isEmpty())
{
@ -1284,8 +1288,8 @@ auto VDxfEngine::AAMALine(const QLineF &line, const UTF8STRING &layer) -> DRW_En
auto *lineEnt = new DRW_Line();
lineEnt->basePoint = DRW_Coord(FromPixel(line.p1().x(), m_varInsunits),
FromPixel(GetSize().height() - line.p1().y(), m_varInsunits), 0);
lineEnt->secPoint = DRW_Coord(FromPixel(line.p2().x(), m_varInsunits),
FromPixel(GetSize().height() - line.p2().y(), m_varInsunits), 0);
lineEnt->secPoint = DRW_Coord(FromPixel(line.p2().x(), m_varInsunits),
FromPixel(GetSize().height() - line.p2().y(), m_varInsunits), 0);
lineEnt->layer = layer;
return lineEnt;
@ -1296,10 +1300,10 @@ auto VDxfEngine::AAMAText(const QPointF &pos, const QString &text, const UTF8STR
{
auto *textLine = new DRW_Text();
textLine->basePoint = DRW_Coord(FromPixel(pos.x(), m_varInsunits),
FromPixel(GetSize().height() - pos.y(), m_varInsunits), 0);
textLine->secPoint = DRW_Coord(FromPixel(pos.x(), m_varInsunits),
FromPixel(GetSize().height() - pos.y(), m_varInsunits), 0);
textLine->basePoint =
DRW_Coord(FromPixel(pos.x(), m_varInsunits), FromPixel(GetSize().height() - pos.y(), m_varInsunits), 0);
textLine->secPoint =
DRW_Coord(FromPixel(pos.x(), m_varInsunits), FromPixel(GetSize().height() - pos.y(), m_varInsunits), 0);
textLine->height = AAMATextHeight;
textLine->layer = layer;
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 *point = new DRW_Point();
point->basePoint = DRW_Coord(FromPixel(pos.x(), m_varInsunits),
FromPixel(GetSize().height() - pos.y(), m_varInsunits), 0);
point->basePoint =
DRW_Coord(FromPixel(pos.x(), m_varInsunits), FromPixel(GetSize().height() - pos.y(), m_varInsunits), 0);
point->layer = layer;
return point;
}
@ -1334,9 +1338,8 @@ auto VDxfEngine::GetFileNameForLocale() const -> std::string
}
//---------------------------------------------------------------------------------------------------------------------
template<class P, class V, class C>
auto VDxfEngine::CreateAAMAPolygon(const QVector<C> &polygon, const UTF8STRING &layer,
bool forceClosed) -> P *
template <class P, class V, class C>
auto VDxfEngine::CreateAAMAPolygon(const QVector<C> &polygon, const UTF8STRING &layer, bool forceClosed) -> P *
{
auto *poly = new P();
poly->layer = layer;
@ -1355,8 +1358,7 @@ auto VDxfEngine::CreateAAMAPolygon(const QVector<C> &polygon, const UTF8STRING &
for (const auto &p : polygon)
{
poly->addVertex(V(FromPixel(p.x(), m_varInsunits),
FromPixel(GetSize().height() - p.y(), m_varInsunits)));
poly->addVertex(V(FromPixel(p.x(), m_varInsunits), FromPixel(GetSize().height() - p.y(), m_varInsunits)));
}
return poly;

View File

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

View File

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

View File

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

View File

@ -28,109 +28,113 @@
#include "vmeasurements.h"
#include <qnumeric.h>
#include <QDate>
#include <QDomNode>
#include <QDomNodeList>
#include <QDomText>
#include <QGlobalStatic>
#include <QLatin1Char>
#include <QMessageLogger>
#include <QScopedPointer>
#include <QSet>
#include <QtDebug>
#include <QGlobalStatic>
#include <qnumeric.h>
#include "../ifc/exception/vexceptionemptyparameter.h"
#include "../ifc/exception/vexceptionobjecterror.h"
#include "../ifc/ifcdef.h"
#include "../ifc/xml/vvitconverter.h"
#include "../ifc/xml/vvstconverter.h"
#include "../ifc/ifcdef.h"
#include "../qmuparser/qmutokenparser.h"
#include "../qmuparser/qmuparsererror.h"
#include "../qmuparser/qmutokenparser.h"
#include "../vmisc/projectversion.h"
#include "../vpatterndb/calculator.h"
#include "../vpatterndb/variables/vmeasurement.h"
#include "../vpatterndb/vcontainer.h"
#include "../vpatterndb/measurements.h"
#include "../vpatterndb/pmsystems.h"
#include "../vmisc/projectversion.h"
#include "../vpatterndb/variables/vmeasurement.h"
#include "../vpatterndb/vcontainer.h"
#include "def.h"
const QString VMeasurements::TagVST = QStringLiteral("vst");
const QString VMeasurements::TagVIT = QStringLiteral("vit");
#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::TagVIT = QStringLiteral("vit");
const QString VMeasurements::TagBodyMeasurements = QStringLiteral("body-measurements");
const QString VMeasurements::TagNotes = QStringLiteral("notes");
const QString VMeasurements::TagPersonal = QStringLiteral("personal");
const QString VMeasurements::TagCustomer = QStringLiteral("customer");
const QString VMeasurements::TagBirthDate = QStringLiteral("birth-date");
const QString VMeasurements::TagGender = QStringLiteral("gender");
const QString VMeasurements::TagPMSystem = QStringLiteral("pm_system");
const QString VMeasurements::TagEmail = QStringLiteral("email");
const QString VMeasurements::TagReadOnly = QStringLiteral("read-only");
const QString VMeasurements::TagMeasurement = QStringLiteral("m");
const QString VMeasurements::TagDimensions = QStringLiteral("dimensions");
const QString VMeasurements::TagDimension = QStringLiteral("dimension");
const QString VMeasurements::TagRestrictions = QStringLiteral("restrictions");
const QString VMeasurements::TagRestriction = QStringLiteral("restriction");
const QString VMeasurements::TagCorrections = QStringLiteral("corrections");
const QString VMeasurements::TagCorrection = QStringLiteral("correction");
const QString VMeasurements::TagLabels = QStringLiteral("labels");
const QString VMeasurements::TagLabel = QStringLiteral("label");
const QString VMeasurements::TagNotes = QStringLiteral("notes");
const QString VMeasurements::TagPersonal = QStringLiteral("personal");
const QString VMeasurements::TagCustomer = QStringLiteral("customer");
const QString VMeasurements::TagBirthDate = QStringLiteral("birth-date");
const QString VMeasurements::TagGender = QStringLiteral("gender");
const QString VMeasurements::TagPMSystem = QStringLiteral("pm_system");
const QString VMeasurements::TagEmail = QStringLiteral("email");
const QString VMeasurements::TagReadOnly = QStringLiteral("read-only");
const QString VMeasurements::TagMeasurement = QStringLiteral("m");
const QString VMeasurements::TagDimensions = QStringLiteral("dimensions");
const QString VMeasurements::TagDimension = QStringLiteral("dimension");
const QString VMeasurements::TagRestrictions = QStringLiteral("restrictions");
const QString VMeasurements::TagRestriction = QStringLiteral("restriction");
const QString VMeasurements::TagCorrections = QStringLiteral("corrections");
const QString VMeasurements::TagCorrection = QStringLiteral("correction");
const QString VMeasurements::TagLabels = QStringLiteral("labels");
const QString VMeasurements::TagLabel = QStringLiteral("label");
const QString VMeasurements::AttrBase = QStringLiteral("base");
const QString VMeasurements::AttrValue = QStringLiteral("value");
const QString VMeasurements::AttrShiftA = QStringLiteral("shiftA");
const QString VMeasurements::AttrShiftB = QStringLiteral("shiftB");
const QString VMeasurements::AttrShiftC = QStringLiteral("shiftC");
const QString VMeasurements::AttrCorrection = QStringLiteral("correction");
const QString VMeasurements::AttrCoordinates = QStringLiteral("coordinates");
const QString VMeasurements::AttrExclude = QStringLiteral("exclude");
const QString VMeasurements::AttrSpecialUnits = QStringLiteral("specialUnits");
const QString VMeasurements::AttrDescription = QStringLiteral("description");
const QString VMeasurements::AttrName = QStringLiteral("name");
const QString VMeasurements::AttrFullName = QStringLiteral("full_name");
const QString VMeasurements::AttrMin = QStringLiteral("min");
const QString VMeasurements::AttrMax = QStringLiteral("max");
const QString VMeasurements::AttrStep = QStringLiteral("step");
const QString VMeasurements::AttrMeasurement = QStringLiteral("measurement");
const QString VMeasurements::AttrBase = QStringLiteral("base");
const QString VMeasurements::AttrValue = QStringLiteral("value");
const QString VMeasurements::AttrShiftA = QStringLiteral("shiftA");
const QString VMeasurements::AttrShiftB = QStringLiteral("shiftB");
const QString VMeasurements::AttrShiftC = QStringLiteral("shiftC");
const QString VMeasurements::AttrCorrection = QStringLiteral("correction");
const QString VMeasurements::AttrCoordinates = QStringLiteral("coordinates");
const QString VMeasurements::AttrExclude = QStringLiteral("exclude");
const QString VMeasurements::AttrSpecialUnits = QStringLiteral("specialUnits");
const QString VMeasurements::AttrDescription = QStringLiteral("description");
const QString VMeasurements::AttrName = QStringLiteral("name");
const QString VMeasurements::AttrFullName = QStringLiteral("full_name");
const QString VMeasurements::AttrMin = QStringLiteral("min");
const QString VMeasurements::AttrMax = QStringLiteral("max");
const QString VMeasurements::AttrStep = QStringLiteral("step");
const QString VMeasurements::AttrMeasurement = QStringLiteral("measurement");
const QString VMeasurements::AttrFullCircumference = QStringLiteral("fullCircumference");
const QString VMeasurements::AttrLabel = QStringLiteral("label");
const QString VMeasurements::AttrDimension = QStringLiteral("dimension");
const QString VMeasurements::AttrCustomName = QStringLiteral("customName");
const QString VMeasurements::AttrLabel = QStringLiteral("label");
const QString VMeasurements::AttrDimension = QStringLiteral("dimension");
const QString VMeasurements::AttrCustomName = QStringLiteral("customName");
const QString VMeasurements::GenderMale = QStringLiteral("male");
const QString VMeasurements::GenderFemale = QStringLiteral("female");
const QString VMeasurements::GenderMale = QStringLiteral("male");
const QString VMeasurements::GenderFemale = QStringLiteral("female");
const QString VMeasurements::GenderUnknown = QStringLiteral("unknown");
const QString VMeasurements::DimensionN = QStringLiteral("n");
const QString VMeasurements::DimensionX = QStringLiteral("x");
const QString VMeasurements::DimensionY = QStringLiteral("y");
const QString VMeasurements::DimensionW = QStringLiteral("w");
const QString VMeasurements::DimensionZ = QStringLiteral("z");
const QString VMeasurements::DimensionN = QStringLiteral("n");
const QString VMeasurements::DimensionX = QStringLiteral("x");
const QString VMeasurements::DimensionY = QStringLiteral("y");
const QString VMeasurements::DimensionW = QStringLiteral("w");
const QString VMeasurements::DimensionZ = QStringLiteral("z");
namespace
{
QT_WARNING_PUSH
QT_WARNING_DISABLE_CLANG("-Wunused-member-function")
Q_GLOBAL_STATIC_WITH_ARGS(const QString, defBirthDate, (QLatin1String("1800-01-01"))) // NOLINT
QT_WARNING_POP
//---------------------------------------------------------------------------------------------------------------------
auto FileComment() -> QString
{
return QString("Measurements created with Valentina v%1 (https://smart-pattern.com.ua/).")
.arg(APP_VERSION_STR);
}
return QString("Measurements created with Valentina v%1 (https://smart-pattern.com.ua/).").arg(APP_VERSION_STR);
}
} // namespace
//---------------------------------------------------------------------------------------------------------------------
VMeasurements::VMeasurements(VContainer *data)
: data(data),
type(MeasurementsType::Unknown)
{
SCASSERT(data != nullptr)
}
: data(data),
type(MeasurementsType::Unknown){SCASSERT(data != nullptr)}
//---------------------------------------------------------------------------------------------------------------------
VMeasurements::VMeasurements(Unit unit, VContainer *data)
: data(data),
type(MeasurementsType::Individual)
//---------------------------------------------------------------------------------------------------------------------
VMeasurements::VMeasurements(Unit unit, VContainer * data)
: data(data),
type(MeasurementsType::Individual)
{
SCASSERT(data != nullptr)
@ -138,10 +142,9 @@ VMeasurements::VMeasurements(Unit unit, VContainer *data)
}
//---------------------------------------------------------------------------------------------------------------------
VMeasurements::VMeasurements(Unit unit, const QVector<MeasurementDimension_p > &dimensions,
VContainer *data)
: data(data),
type(MeasurementsType::Multisize)
VMeasurements::VMeasurements(Unit unit, const QVector<MeasurementDimension_p> &dimensions, VContainer *data)
: data(data),
type(MeasurementsType::Multisize)
{
SCASSERT(data != nullptr)
@ -295,7 +298,7 @@ void VMeasurements::MoveBottom(const QString &name)
const QDomNodeList mList = elementsByTagName(TagMeasurement);
if (mList.size() >= 2)
{
const QDomNode bottom = mList.at(mList.size()-1);
const QDomNode bottom = mList.at(mList.size() - 1);
if (not bottom.isNull())
{
const QDomNodeList list = elementsByTagName(TagBodyMeasurements);
@ -333,7 +336,7 @@ void VMeasurements::ReadMeasurements(qreal baseA, qreal baseB, qreal baseC) cons
}
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();
@ -387,8 +390,8 @@ void VMeasurements::ReadMeasurements(qreal baseA, qreal baseB, qreal baseC) cons
convertedStepC = UnitConvertor(convertedStepC, Units(), *data->GetPatternUnit());
}
meash = QSharedPointer<VMeasurement>::create(static_cast<quint32>(i), name,
convertedBaseA, convertedBaseB, convertedBaseC, base);
meash = QSharedPointer<VMeasurement>::create(static_cast<quint32>(i), name, convertedBaseA,
convertedBaseB, convertedBaseC, base);
meash->SetBaseA(baseA);
meash->SetBaseB(baseB);
meash->SetBaseC(baseC);
@ -459,7 +462,7 @@ void VMeasurements::ClearForExport()
{
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();
if (not domElement.isNull())
@ -701,11 +704,12 @@ void VMeasurements::SetFullCircumference(bool fc)
QDomElement dimenstionsTag = documentElement().firstChildElement(TagDimensions);
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
{
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);
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
{
@ -873,7 +878,7 @@ void VMeasurements::SetMDimension(const QString &name, IMD type)
{
SetAttributeOrRemoveIf<QString>(node, AttrDimension, VMeasurements::IMDToStr(type),
[](const QString &type) noexcept
{return type == VMeasurements::IMDToStr(IMD::N);});
{ return type == VMeasurements::IMDToStr(IMD::N); });
}
else
{
@ -887,7 +892,7 @@ auto VMeasurements::MeasurementForDimension(IMD type) const -> QString
const QString d = VMeasurements::IMDToStr(type);
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();
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);
for (int i=0; i < list.size(); ++i)
for (int i = 0; i < list.size(); ++i)
{
const QDomElement res = list.at(i).toElement();
@ -948,11 +953,11 @@ void VMeasurements::SetRestrictions(const QMap<QString, VDimensionRestriction> &
SetAttribute(restrictionTag, AttrCoordinates, i.key());
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(),
[](qreal max) noexcept {return qFuzzyIsNull(max);});
[](qreal max) noexcept { return qFuzzyIsNull(max); });
SetAttributeOrRemoveIf<QString>(restrictionTag, AttrExclude, i.value().GetExcludeString(),
[](const QString &exlcuded) noexcept {return exlcuded.isEmpty();});
[](const QString &exlcuded) noexcept { return exlcuded.isEmpty(); });
restrictionsTag.appendChild(restrictionTag);
++i;
@ -962,7 +967,7 @@ void VMeasurements::SetRestrictions(const QMap<QString, 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);
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)
{
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();
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)
{
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();
const MeasurementDimension type = StrToDimensionType(GetParametrString(dom, AttrType));
@ -997,7 +1002,7 @@ void VMeasurements::SetDimensionCustomNames(const QMap<MeasurementDimension, QSt
if (names.contains(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
{
switch(type)
switch (type)
{
case IMD::N:
return tr("None");
@ -1135,7 +1140,7 @@ auto VMeasurements::ListAll() const -> QStringList
QStringList listNames;
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();
if (domElement.isNull() == false)
@ -1152,7 +1157,7 @@ auto VMeasurements::ListKnown() const -> QStringList
{
QStringList listNames;
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)
{
@ -1193,8 +1198,7 @@ auto VMeasurements::GetData() const -> VContainer *
}
//---------------------------------------------------------------------------------------------------------------------
void VMeasurements::CreateEmptyMultisizeFile(Unit unit,
const QVector<MeasurementDimension_p > &dimensions)
void VMeasurements::CreateEmptyMultisizeFile(Unit unit, const QVector<MeasurementDimension_p> &dimensions)
{
this->clear();
QDomElement mElement = this->createElement(TagVST);
@ -1210,8 +1214,9 @@ void VMeasurements::CreateEmptyMultisizeFile(Unit unit,
mElement.appendChild(createElement(TagBodyMeasurements));
this->appendChild(mElement);
insertBefore(createProcessingInstruction(QStringLiteral("xml"),
QStringLiteral("version=\"1.0\" encoding=\"UTF-8\"")), this->firstChild());
insertBefore(
createProcessingInstruction(QStringLiteral("xml"), QStringLiteral("version=\"1.0\" encoding=\"UTF-8\"")),
this->firstChild());
// Cache data
m_units = unit;
@ -1242,8 +1247,9 @@ void VMeasurements::CreateEmptyIndividualFile(Unit unit)
mElement.appendChild(createElement(TagBodyMeasurements));
this->appendChild(mElement);
insertBefore(createProcessingInstruction(QStringLiteral("xml"),
QStringLiteral("version=\"1.0\" encoding=\"UTF-8\"")), this->firstChild());
insertBefore(
createProcessingInstruction(QStringLiteral("xml"), QStringLiteral("version=\"1.0\" encoding=\"UTF-8\"")),
this->firstChild());
// Cache data
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);
for(const auto &dimension : dimensions)
for (const auto &dimension : dimensions)
{
QDomElement dimensionTag = createElement(TagDimension);
@ -1265,9 +1271,9 @@ auto VMeasurements::CreateDimensions(const QVector<MeasurementDimension_p > &dim
SetAttribute(dimensionTag, AttrMax, dimension->MaxValue());
SetAttribute(dimensionTag, AttrStep, dimension->Step());
SetAttributeOrRemoveIf<bool>(dimensionTag, AttrMeasurement, dimension->IsBodyMeasurement(),
[](bool m) noexcept {return m;});
[](bool m) noexcept { return m; });
SetAttributeOrRemoveIf<QString>(dimensionTag, AttrCustomName, dimension->CustomName(),
[](const QString &name) noexcept {return name.isEmpty();});
[](const QString &name) noexcept { return name.isEmpty(); });
dimensionsTag.appendChild(dimensionTag);
}
@ -1337,7 +1343,7 @@ auto VMeasurements::FindM(const QString &name) const -> QDomElement
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();
if (domElement.isNull() == false)
@ -1396,7 +1402,7 @@ auto VMeasurements::ReadDimensions() const -> VDimensions
const Unit units = Units();
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 MeasurementDimension type = StrToDimensionType(GetParametrString(dom, AttrType));
@ -1639,7 +1645,7 @@ void VMeasurements::ClearDimension(IMD type)
const QString d = VMeasurements::IMDToStr(type);
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();
if (domElement.isNull() == false)

View File

@ -51,14 +51,23 @@
#include "vprintlayout.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
{
QT_WARNING_PUSH
QT_WARNING_DISABLE_CLANG("-Wunused-member-function")
#ifdef Q_OS_WIN
Q_GLOBAL_STATIC_WITH_ARGS(const QString, PDFTOPS, (QLatin1String("pdftops.exe"))) // NOLINT
#else
Q_GLOBAL_STATIC_WITH_ARGS(const QString, PDFTOPS, (QLatin1String("pdftops"))) // NOLINT
#endif
QT_WARNING_POP
//---------------------------------------------------------------------------------------------------------------------
/**
* @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(auto *textItem = qgraphicsitem_cast<QGraphicsSimpleTextItem *>(child))
if (auto *textItem = qgraphicsitem_cast<QGraphicsSimpleTextItem *>(child))
{
textItem->setText(textItem->text() + placeholder);
}
@ -104,7 +113,7 @@ void RestoreDetailsAfterDXF(const QString &placeholder, const QList<QGraphicsIte
{
if (child->type() == QGraphicsSimpleTextItem::Type)
{
if(auto *textItem = qgraphicsitem_cast<QGraphicsSimpleTextItem *>(child))
if (auto *textItem = qgraphicsitem_cast<QGraphicsSimpleTextItem *>(child))
{
QString text = textItem->text();
text.replace(placeholder, QString());
@ -114,7 +123,7 @@ void RestoreDetailsAfterDXF(const QString &placeholder, const QList<QGraphicsIte
}
}
}
} // namespace
} // namespace
//---------------------------------------------------------------------------------------------------------------------
auto VLayoutExporter::IsShowGrainline() const -> bool
@ -283,7 +292,7 @@ void VLayoutExporter::ExportToFlatDXF(QGraphicsScene *scene, const QList<QGraphi
generator.SetResolution(PrintDPI);
generator.SetVersion(static_cast<DRW::Version>(m_dxfVersion));
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;
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);
if (not painter.end())
{
qCritical() << tr("Can't create a flat dxf file.")
<< generator.ErrorString();
qCritical() << tr("Can't create a flat dxf file.") << generator.ErrorString();
}
}
@ -310,13 +318,12 @@ void VLayoutExporter::ExportToAAMADXF(const QVector<VLayoutPiece> &details) cons
generator.SetResolution(PrintDPI);
generator.SetVersion(static_cast<DRW::Version>(m_dxfVersion));
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.SetYScale(m_yScale);
if (not generator.ExportToAAMA(details))
{
qCritical() << tr("Can't create an AAMA dxf file.")
<< generator.ErrorString();
qCritical() << tr("Can't create an AAMA dxf file.") << generator.ErrorString();
}
}
@ -329,13 +336,12 @@ void VLayoutExporter::ExportToASTMDXF(const QVector<VLayoutPiece> &details) cons
generator.SetResolution(PrintDPI);
generator.SetVersion(static_cast<DRW::Version>(m_dxfVersion));
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.SetYScale(m_yScale);
if (not generator.ExportToASTM(details))
{
qCritical() << tr("Can't create an ASTM dxf file.")
<< generator.ErrorString();
qCritical() << tr("Can't create an ASTM dxf file.") << generator.ErrorString();
}
}
@ -345,7 +351,7 @@ void VLayoutExporter::ExportToRLD(const QVector<VLayoutPiece> &details) const
QVector<VLayoutPiece> scaledPieces;
scaledPieces.reserve(details.size());
for(auto detail : details)
for (auto detail : details)
{
detail.Scale(m_xScale, m_yScale);
scaledPieces.append(detail);
@ -370,9 +376,9 @@ auto VLayoutExporter::SupportPDFConversion() -> bool
QProcess proc;
#if defined(Q_OS_WIN) || defined(Q_OS_OSX)
// Seek pdftops in app bundle or near valentina.exe
proc.start(qApp->applicationDirPath() + QLatin1String("/")+ *PDFTOPS, QStringList());
proc.start(qApp->applicationDirPath() + QLatin1String("/") + *PDFTOPS, QStringList());
#else
proc.start(*PDFTOPS, QStringList()); // Seek pdftops in standard path
proc.start(*PDFTOPS, QStringList()); // Seek pdftops in standard path
#endif
const int timeout = 15000;
@ -433,8 +439,8 @@ void VLayoutExporter::PdfToPs(const QStringList &params)
QFile f(ConstLast<QString>(params));
if (not f.exists())
{
qCritical() << qUtf8Printable(tr("Creating file '%1' failed! %2")
.arg(ConstLast<QString>(params), proc.errorString()));
qCritical() << qUtf8Printable(
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.setFullPage(m_ignorePrinterMargins);
QPageLayout::Orientation imageOrientation = m_imageRect.height() >= m_imageRect.width() ? QPageLayout::Portrait
: QPageLayout::Landscape;
QPageLayout::Orientation imageOrientation =
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 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 filesStr = tr("files");
switch(format)
switch (format)
{
case LayoutExportFormats::SVG:
return QStringLiteral("Svg %1 (*.svg)").arg(filesStr);
@ -556,7 +562,7 @@ auto VLayoutExporter::ExportFormatDescription(LayoutExportFormats format) -> QSt
//---------------------------------------------------------------------------------------------------------------------
auto VLayoutExporter::ExportFormatSuffix(LayoutExportFormats format) -> QString
{
switch(format)
switch (format)
{
case LayoutExportFormats::SVG:
return QStringLiteral(".svg");

View File

@ -28,11 +28,11 @@
#ifndef VLAYOUTEXPORTER_H
#define VLAYOUTEXPORTER_H
#include <QCoreApplication>
#include <QMargins>
#include <QPen>
#include <QRectF>
#include <QString>
#include <QCoreApplication>
#include "../vlayout/vlayoutdef.h"
@ -43,6 +43,7 @@ class VLayoutPiece;
class VLayoutExporter
{
Q_DECLARE_TR_FUNCTIONS(VLayoutExporter) // NOLINT
public:
VLayoutExporter() = default;
@ -106,19 +107,19 @@ public:
void SetOffset(const QPointF &newOffset);
private:
QString m_fileName{};
QString m_fileName{};
QMarginsF m_margins{};
QRectF m_imageRect{};
qreal m_xScale{1.0};
qreal m_yScale{1.0};
QString m_title{};
QString m_description{};
QPen m_pen{};
bool m_ignorePrinterMargins{false};
bool m_binaryDxfFormat{false};
bool m_showGrainline{true};
int m_dxfVersion{0};
QPointF m_offset{};
QRectF m_imageRect{};
qreal m_xScale{1.0};
qreal m_yScale{1.0};
QString m_title{};
QString m_description{};
QPen m_pen{};
bool m_ignorePrinterMargins{false};
bool m_binaryDxfFormat{false};
bool m_showGrainline{true};
int m_dxfVersion{0};
QPointF m_offset{};
void ExportToPDF(QGraphicsScene *scene, const QList<QGraphicsItem *> &details, const QString &filename) const;
};

View File

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

View File

@ -60,13 +60,13 @@
#include "../vpatterndb/vcontainer.h"
#include "../vpatterndb/vpassmark.h"
#include "../vpatterndb/vpiecenode.h"
#include "qline.h"
#include "qpainterpath.h"
#include "vgobject.h"
#include "vgraphicsfillitem.h"
#include "vlayoutpiece_p.h"
#include "vpiecegrainline.h"
#include "vtextmanager.h"
#include <QLine>
#include <QPainterPath>
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
{
QStringList text;
if (labelShape.count() > 2)
if (labelShape.count() <= 2)
{
auto sourceCount = tm.GetSourceLinesCount();
text.reserve(sourceCount);
for (int i = 0; i < sourceCount; ++i)
{
text.append(tm.GetSourceLine(i).m_qsText);
}
return {};
}
QStringList text;
auto sourceCount = tm.GetSourceLinesCount();
text.reserve(sourceCount);
for (int i = 0; i < sourceCount; ++i)
{
text.append(tm.GetSourceLine(i).m_qsText);
}
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);
std::swap(d, detail.d);

View File

@ -29,7 +29,7 @@
#ifndef VLAYOUTDETAIL_H
#define VLAYOUTDETAIL_H
#include <qcompilerdetection.h>
#include <QCoreApplication>
#include <QDate>
#include <QLineF>
#include <QPointF>
@ -39,7 +39,6 @@
#include <QTypeInfo>
#include <QVector>
#include <QtGlobal>
#include <QCoreApplication>
#include "../vmisc/typedef.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-methods")
class VLayoutPiece :public VAbstractPiece
class VLayoutPiece : public VAbstractPiece
{
Q_DECLARE_TR_FUNCTIONS(VLayoutPiece) // NOLINT
public:
VLayoutPiece();
VLayoutPiece(const VLayoutPiece &detail);
@ -82,7 +82,8 @@ public:
auto operator=(const VLayoutPiece &detail) -> VLayoutPiece &;
#ifdef Q_COMPILER_RVALUE_REFS
VLayoutPiece(VLayoutPiece &&detail) Q_DECL_NOTHROW;
auto operator=(VLayoutPiece &&detail) Q_DECL_NOTHROW -> VLayoutPiece &;
auto operator=(VLayoutPiece &&detail) Q_DECL_NOTHROW
->VLayoutPiece &;
#endif
static auto Create(const VPiece &piece, vidtype id, const VContainer *pattern) -> VLayoutPiece;
@ -112,20 +113,21 @@ public:
auto GetPlaceLabels() const -> QVector<VLayoutPlaceLabel>;
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>;
void SetInternalPaths(const QVector<VLayoutPiecePath> &internalPaths);
auto GetPieceTextPosition() const -> QPointF;
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 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);
void SetGrainline(const VGrainlineData& geom, const VContainer *pattern);
void SetGrainline(const VGrainlineData &geom, const VContainer *pattern);
auto GetGrainline() const -> VPieceGrainline;
auto GetMappedGrainlineShape() const -> GrainlineShape;
auto GetGrainlineShape() const -> GrainlineShape;
@ -194,8 +196,8 @@ public:
auto BiggestEdge() const -> qreal;
friend auto operator<< (QDataStream& dataStream, const VLayoutPiece& piece) -> QDataStream&;
friend auto operator>> (QDataStream& dataStream, VLayoutPiece& piece) -> QDataStream&;
friend auto operator<<(QDataStream &dataStream, const VLayoutPiece &piece) -> QDataStream &;
friend auto operator>>(QDataStream &dataStream, VLayoutPiece &piece) -> QDataStream &;
auto MapPlaceLabelShape(PlaceLabelImg shape) const -> PlaceLabelImg;
@ -205,13 +207,13 @@ protected:
auto GetPieceLabelRect() const -> QVector<QPointF>;
void SetPieceLabelRect(const QVector<QPointF> &rect);
auto GetPieceLabelData() const ->VTextManager;
auto GetPieceLabelData() const -> VTextManager;
void SetPieceLabelData(const VTextManager &data);
auto GetPatternLabelRect() const -> QVector<QPointF>;
void SetPatternLabelRect(const QVector<QPointF> &rect);
auto GetPatternLabelData() const ->VTextManager;
auto GetPatternLabelData() const -> VTextManager;
void SetPatternLabelData(const VTextManager &data);
private:
@ -226,8 +228,7 @@ private:
bool textAsPaths) const;
void CreateGrainlineItem(QGraphicsItem *parent) const;
template <class T>
auto Map(QVector<T> points) const -> QVector<T>;
template <class T> auto Map(QVector<T> points) const -> QVector<T>;
auto Map(const GrainlineShape &shape) const -> GrainlineShape;
auto Edge(const QVector<QPointF> &path, int i) const -> QLineF;

View File

@ -52,8 +52,19 @@
#include "../vpatterndb/vcontainer.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
{
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
{
QFontMetrics fontMetrics(font);
@ -160,11 +171,6 @@ auto operator>>(QDataStream &dataStream, TextLine &data) -> QDataStream &
const quint32 VTextManager::streamHeader = 0x47E6A9EE; // CRC-32Q string "VTextManager"
const quint16 VTextManager::classVersion = 1;
namespace
{
Q_GLOBAL_STATIC(QVector<TextLine>, m_patternLabelLinesCache) // NOLINT
}
// Friend functions
//---------------------------------------------------------------------------------------------------------------------
auto operator<<(QDataStream &dataStream, const VTextManager &data) -> QDataStream &

View File

@ -62,7 +62,7 @@
#include "literals.h"
#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)
namespace
@ -374,6 +374,9 @@ void MacosEnableLayerBacking()
#endif // MACOS_LAYER_BACKING_AFFECTED
#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, strVMark, (QLatin1String("vMark"))) // 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, strCheckMark, (QLatin1String("checkMark"))) // NOLINT
QT_WARNING_POP
//---------------------------------------------------------------------------------------------------------------------
auto PassmarkLineTypeToString(PassmarkLineType type) -> QString
{

View File

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

View File

@ -29,132 +29,175 @@
#include "vvalentinasettings.h"
#include <QDir>
#include <QLocale>
#include <QMetaType>
#include <QPrinter>
#include <QSharedPointer>
#include <QVariant>
#include <QPrinterInfo>
#include <QtDebug>
#include <QGlobalStatic>
#include <QLocale>
#include <QMargins>
#include <QMetaType>
#include <QPrinter>
#include <QPrinterInfo>
#include <QSharedPointer>
#include <QVariant>
#include <QtDebug>
#include "../vmisc/def.h"
#include "../vmisc/compatibility.h"
#include "compatibility.h"
#include "def.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
Q_DECLARE_METATYPE(QMarginsF) // NOLINT
#endif
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")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingAutoRefreshPatternMessage, // NOLINT
// NOLINTNEXTLINE
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingAutoRefreshPatternMessage,
(QLatin1String("configuration/autoRefreshPatternMessage")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingToolPanelScaling, // NOLINT
(QLatin1String("configuration/toolPanelScaling")))
// NOLINTNEXTLINE
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, settingPatternKnownMaterials, (QLatin1String("pattern/knownMaterials"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternRememberMaterials, (QLatin1String("pattern/rememberMaterials"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternBackgroundImageDefOpacity, // NOLINT
// NOLINTNEXTLINE
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternKnownMaterials, (QLatin1String("pattern/knownMaterials")))
// NOLINTNEXTLINE
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternRememberMaterials, (QLatin1String("pattern/rememberMaterials")))
// NOLINTNEXTLINE
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternBackgroundImageDefOpacity,
(QLatin1String("pattern/backgroundImageDefOpacity")))
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, settingLayoutWidth, (QLatin1String("layout/width"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutSorting, (QLatin1String("layout/sorting"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutPaperHeight, (QLatin1String("layout/paperHeight"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutPaperWidth, (QLatin1String("layout/paperWidth"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutFollowGrainline, (QLatin1String("layout/followGrainline"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutManualPriority, (QLatin1String("layout/manualPriority"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutPaperWidth, (QLatin1String("layout/paperWidth"))) // NOLINT
// NOLINTNEXTLINE
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, 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, settingLayoutSaveLength, (QLatin1String("layout/saveLength"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutPreferOneSheetSolution, // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutSaveLength, (QLatin1String("layout/saveLength"))) // NOLINT
// NOLINTNEXTLINE
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutPreferOneSheetSolution,
(QLatin1String("layout/preferOneSheetSolution")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutUnitePages, (QLatin1String("layout/unitePages"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutUnitePages, (QLatin1String("layout/unitePages"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutShowGrainline, (QLatin1String("layout/showGrainline"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingFields, (QLatin1String("layout/fields"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingIgnoreFields, (QLatin1String("layout/ignoreFields"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingStripOptimization, (QLatin1String("layout/stripOptimization"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingMultiplier, (QLatin1String("layout/multiplier"))) // 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
// NOLINTNEXTLINE
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingStripOptimization, (QLatin1String("layout/stripOptimization")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingMultiplier, (QLatin1String("layout/multiplier"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingTextAsPaths, (QLatin1String("layout/textAsPaths"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingNestingTime, (QLatin1String("layout/time"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingEfficiencyCoefficient, (QLatin1String("layout/efficiencyCoefficient"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingNestingTime, (QLatin1String("layout/time"))) // NOLINT
// NOLINTNEXTLINE
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingEfficiencyCoefficient, (QLatin1String("layout/efficiencyCoefficient")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutExportFormat, (QLatin1String("layout/exportFormat"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingDetailExportFormat, (QLatin1String("detail/exportFormat"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, 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
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingDockWidgetToolOptionsActive, // NOLINT
// NOLINTNEXTLINE
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingdockWidgetGroupsActive, (QLatin1String("dockWidget/groupsActive")))
// NOLINTNEXTLINE
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingDockWidgetToolOptionsActive,
(QLatin1String("dockWidget/toolOptionsActive")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingDockWidgetPatternMessagesActive, // NOLINT
// NOLINTNEXTLINE
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingDockWidgetPatternMessagesActive,
(QLatin1String("dockWidget/patternMessagesActive")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingDockWidgetBackgroundImagesActive, // NOLINT
// NOLINTNEXTLINE
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingDockWidgetBackgroundImagesActive,
(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
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchHistoryIncrements, (QLatin1String("searchHistory/increments"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchHistoryPreviewCalculations, // NOLINT
// NOLINTNEXTLINE
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchHistoryHistory, (QLatin1String("searchHistory/history")))
// NOLINTNEXTLINE
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchHistoryIncrements, (QLatin1String("searchHistory/increments")))
// NOLINTNEXTLINE
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchHistoryPreviewCalculations,
(QLatin1String("searchHistory/previewCalculations")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchHistoryFinalMeasurements, // NOLINT
// NOLINTNEXTLINE
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchHistoryFinalMeasurements,
(QLatin1String("searchHistory/finalMeasurements")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsHistoryUseUnicodeProperties, // NOLINT
// NOLINTNEXTLINE
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsHistoryUseUnicodeProperties,
(QLatin1String("searchOptions/historyUseUnicodeProperties")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsHistoryWholeWord, // NOLINT
// NOLINTNEXTLINE
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsHistoryWholeWord,
(QLatin1String("searchOptions/historyWholeWord")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsHistoryRegexp, // NOLINT
// NOLINTNEXTLINE
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsHistoryRegexp,
(QLatin1String("searchOptions/historyRegexp")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsHistoryMatchCase, // NOLINT
// NOLINTNEXTLINE
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsHistoryMatchCase,
(QLatin1String("searchOptions/historyMatchCase")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsIncrementsUseUnicodeProperties, // NOLINT
// NOLINTNEXTLINE
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsIncrementsUseUnicodeProperties,
(QLatin1String("searchOptions/incrementsUseUnicodeProperties")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsIncrementsWholeWord, // NOLINT
// NOLINTNEXTLINE
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsIncrementsWholeWord,
(QLatin1String("searchOptions/incrementsWholeWord")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsIncrementsRegexp, // NOLINT
// NOLINTNEXTLINE
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsIncrementsRegexp,
(QLatin1String("searchOptions/incrementsRegexp")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsIncrementsMatchCase, // NOLINT
// NOLINTNEXTLINE
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsIncrementsMatchCase,
(QLatin1String("searchOptions/incrementsMatchCase")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsPreviewCalculationsUseUnicodeProperties, // NOLINT
// NOLINTNEXTLINE
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsPreviewCalculationsUseUnicodeProperties,
(QLatin1String("searchOptions/previewCalculationsUseUnicodeProperties")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsPreviewCalculationsWholeWord, // NOLINT
// NOLINTNEXTLINE
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsPreviewCalculationsWholeWord,
(QLatin1String("searchOptions/previewCalculationsWholeWord")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsPreviewCalculationsRegexp, // NOLINT
// NOLINTNEXTLINE
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsPreviewCalculationsRegexp,
(QLatin1String("searchOptions/previewCalculationsRegexp")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsPreviewCalculationsMatchCase, // NOLINT
// NOLINTNEXTLINE
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsPreviewCalculationsMatchCase,
(QLatin1String("searchOptions/previewCalculationsMatchCase")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsFinalMeasurementsUseUnicodeProperties, // NOLINT
// NOLINTNEXTLINE
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsFinalMeasurementsUseUnicodeProperties,
(QLatin1String("searchOptions/finalMeasurementsUseUnicodeProperties")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsFinalMeasurementsWholeWord, // NOLINT
// NOLINTNEXTLINE
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsFinalMeasurementsWholeWord,
(QLatin1String("searchOptions/finalMeasurementsWholeWord")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsFinalMeasurementsRegexp, // NOLINT
// NOLINTNEXTLINE
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsFinalMeasurementsRegexp,
(QLatin1String("searchOptions/finalMeasurementsRegexp")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsFinalMeasurementsMatchCase, // NOLINT
// NOLINTNEXTLINE
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsFinalMeasurementsMatchCase,
(QLatin1String("searchOptions/finalMeasurementsMatchCase")))
} // namespace
QT_WARNING_POP
} // namespace
//---------------------------------------------------------------------------------------------------------------------
VValentinaSettings::VValentinaSettings(Format format, Scope scope, const QString &organization, const QString &application,
QObject *parent)
:VCommonSettings(format, scope, organization, application, parent)
VValentinaSettings::VValentinaSettings(Format format, Scope scope, const QString &organization,
const QString &application, QObject *parent)
: VCommonSettings(format, scope, organization, application, parent)
{
REGISTER_META_TYPE_STREAM_OPERATORS(QMarginsF);
}
//---------------------------------------------------------------------------------------------------------------------
VValentinaSettings::VValentinaSettings(const QString &fileName, QSettings::Format format, QObject *parent)
:VCommonSettings(fileName, format, parent)
: VCommonSettings(fileName, format, parent)
{
REGISTER_META_TYPE_STREAM_OPERATORS(QMarginsF);
}
@ -195,7 +238,7 @@ void VValentinaSettings::SetPathLayout(const QString &value)
//---------------------------------------------------------------------------------------------------------------------
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
{
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)
{
setValue(*settingTiledPDFPaperWidth, UnitConvertor(value,unit, Unit::Mm));
setValue(*settingTiledPDFPaperWidth, UnitConvertor(value, unit, Unit::Mm));
}
//---------------------------------------------------------------------------------------------------------------------
auto VValentinaSettings::IsDockWidgetGroupsActive() const -> bool
{
@ -668,8 +710,8 @@ auto VValentinaSettings::GetDefMaxPatternMessageFontSize() -> int
//---------------------------------------------------------------------------------------------------------------------
void VValentinaSettings::SetPatternMessageFontSize(int size)
{
setValue(*settingPatternMessagesFontSize, qBound(GetDefMinPatternMessageFontSize(), size,
GetDefMaxPatternMessageFontSize()));
setValue(*settingPatternMessagesFontSize,
qBound(GetDefMinPatternMessageFontSize(), size, GetDefMaxPatternMessageFontSize()));
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -40,9 +40,10 @@
class VValentinaSettings : public VCommonSettings
{
Q_OBJECT // NOLINT
public:
VValentinaSettings(Format format, Scope scope, const QString &organization, const QString &application = QString(),
QObject *parent = nullptr);
QObject *parent = nullptr);
VValentinaSettings(const QString &fileName, Format format, QObject *parent = nullptr);
auto GetLabelLanguage() const -> QString;
@ -127,17 +128,17 @@ public:
void SetTextAsPaths(bool value);
auto GetKnownMaterials() const -> QStringList;
void SetKnownMaterials(const QStringList &list);
void SetKnownMaterials(const QStringList &list);
auto IsRememberPatternMaterials() const -> bool;
void SetRememberPatternMaterials(bool value);
// settings for the tiled PDFs
auto GetTiledPDFPaperHeight(const Unit &unit) const -> qreal;
void SetTiledPDFPaperHeight(qreal value, const Unit &unit);
void SetTiledPDFPaperHeight(qreal value, const Unit &unit);
auto GetTiledPDFPaperWidth(const Unit &unit) const -> qreal;
void SetTiledPDFPaperWidth(qreal value, const Unit &unit);
void SetTiledPDFPaperWidth(qreal value, const Unit &unit);
auto IsDockWidgetGroupsActive() const -> bool;
static auto GetDefDockWidgetGroupsActive() -> bool;
@ -193,7 +194,7 @@ public:
auto GetHistorySearchOptionRegexp() const -> bool;
void SetHistorySearchOptionRegexp(bool value);
auto GetHistorySearchOptionMatchCase() const ->bool;
auto GetHistorySearchOptionMatchCase() const -> bool;
void SetHistorySearchOptionMatchCase(bool value);
auto GetIncrementsSearchOptionUseUnicodeProperties() const -> bool;
@ -205,7 +206,7 @@ public:
auto GetIncrementsSearchOptionRegexp() const -> bool;
void SetIncrementsSearchOptionRegexp(bool value);
auto GetIncrementsSearchOptionMatchCase() const ->bool;
auto GetIncrementsSearchOptionMatchCase() const -> bool;
void SetIncrementsSearchOptionMatchCase(bool value);
auto GetPreviewCalculationsSearchOptionUseUnicodeProperties() const -> bool;
@ -217,7 +218,7 @@ public:
auto GetPreviewCalculationsSearchOptionRegexp() const -> bool;
void SetPreviewCalculationsSearchOptionRegexp(bool value);
auto GetPreviewCalculationsSearchOptionMatchCase() const ->bool;
auto GetPreviewCalculationsSearchOptionMatchCase() const -> bool;
void SetPreviewCalculationsSearchOptionMatchCase(bool value);
auto GetFinalMeasurementsSearchOptionUseUnicodeProperties() const -> bool;
@ -229,7 +230,7 @@ public:
auto GetFinalMeasurementsSearchOptionRegexp() const -> bool;
void SetFinalMeasurementsSearchOptionRegexp(bool value);
auto GetFinalMeasurementsSearchOptionMatchCase() const ->bool;
auto GetFinalMeasurementsSearchOptionMatchCase() const -> bool;
void SetFinalMeasurementsSearchOptionMatchCase(bool value);
auto GetBackgroundImageDefOpacity() const -> int;

View File

@ -28,7 +28,6 @@
#include "abstracttest.h"
#include <qtestcase.h>
#include <QApplication>
#include <QByteArray>
#include <QDir>
@ -36,15 +35,16 @@
#include <QFileInfo>
#include <QFlags>
#include <QIODevice>
#include <QJsonArray>
#include <QJsonObject>
#include <QLineF>
#include <QPointF>
#include <QProcess>
#include <QScopedPointer>
#include <QStringList>
#include <QVector>
#include <QtGlobal>
#include <QLineF>
#include <QJsonObject>
#include <QJsonArray>
#include <qtestcase.h>
#include "../vgeometry/vgobject.h"
#include "../vgeometry/vpointf.h"
@ -52,9 +52,9 @@
#include "../vgeometry/vsplinepath.h"
#include "../vlayout/vabstractpiece.h"
#include "../vpatterndb/vcontainer.h"
#include "../vpatterndb/vpassmark.h"
#include "../vpatterndb/vpiece.h"
#include "../vpatterndb/vpiecenode.h"
#include "../vpatterndb/vpassmark.h"
namespace
{
@ -63,11 +63,11 @@ auto FillPath(const QVector<QPointF> &path, qreal accuracy) -> QVector<QPointF>
QVector<QPointF> pathFilled;
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));
QLineF line(path.at(i), path.at(i+1));
QLineF line(path.at(i), path.at(i + 1));
if (line.length() > accuracy)
{
qreal len = accuracy;
@ -77,8 +77,7 @@ auto FillPath(const QVector<QPointF> &path, qreal accuracy) -> QVector<QPointF>
l.setLength(len);
pathFilled.append(l.p2());
len += accuracy;
}
while(line.length() > len);
} while (line.length() > len);
}
}
@ -86,11 +85,11 @@ auto FillPath(const QVector<QPointF> &path, qreal accuracy) -> QVector<QPointF>
return pathFilled;
}
} // namespace
} // namespace
//---------------------------------------------------------------------------------------------------------------------
AbstractTest::AbstractTest(QObject *parent) :
QObject(parent)
AbstractTest::AbstractTest(QObject *parent)
: QObject(parent)
{
}
@ -238,7 +237,7 @@ void AbstractTest::PassmarkShapeFromJson(const QString &json, QVector<QLineF> &s
if (type != QLatin1String("QLineF"))
{
const QString error = QStringLiteral("Invalid json file '%1'. Unexpected class '%2'.")
.arg(json, lineObject[typeKey].toString());
.arg(json, lineObject[typeKey].toString());
QFAIL(qUtf8Printable(error));
}
@ -252,18 +251,18 @@ void AbstractTest::ComparePaths(const QVector<QPointF> &actual, const QVector<QP
QVERIFY2(actual.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);
bool onLine = false;
QSet<int> usedEdges;
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;
}
}
@ -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
{
// 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.);
for (int i=0; i < ekv.size(); i++)
for (int i = 0; i < ekv.size(); i++)
{
ComparePointsDistance(ekv.at(i), ekvOrig.at(i), testAccuracy);
}
@ -295,38 +294,38 @@ void AbstractTest::ComparePathsDistance(const QVector<QPointF> &ekv, const QVect
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.")
.arg(result.x()).arg(result.y()).arg(expected.x()).arg(expected.y())
.arg(UnitConvertor(QLineF(result, expected).length(), Unit::Px, Unit::Mm));
.arg(result.x())
.arg(result.y())
.arg(expected.x())
.arg(expected.y())
.arg(UnitConvertor(QLineF(result, expected).length(), Unit::Px, Unit::Mm));
// Check each point. Don't use comparison float values
QVERIFY2(VFuzzyComparePoints(result, expected, testAccuracy), qUtf8Printable(msg));
}
//---------------------------------------------------------------------------------------------------------------------
void AbstractTest::CompareLinesDistance(const QVector<QLineF> &result, const QVector<QLineF> &expected) const
{
// 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 &line2 = expected.at(i);
// Check each point. Don't use comparison float values
QVERIFY2(VFuzzyComparePoints(line1.p1(), line2.p1()) && VFuzzyComparePoints(line1.p2(), line2.p2()),
qUtf8Printable(
QStringLiteral("Index: %1. Got line '(%2;%3):(%4;%5)', Expected line '(%6;%7):(%8;%9)'.")
.arg(i)
.arg(line1.p1().x())
.arg(line1.p1().y())
.arg(line1.p2().x())
.arg(line1.p2().y())
.arg(line2.p1().x())
.arg(line2.p1().y())
.arg(line2.p2().x())
.arg(line2.p2().y())
)
);
QVERIFY2(
VFuzzyComparePoints(line1.p1(), line2.p1()) && VFuzzyComparePoints(line1.p2(), line2.p2()),
qUtf8Printable(QStringLiteral("Index: %1. Got line '(%2;%3):(%4;%5)', Expected line '(%6;%7):(%8;%9)'.")
.arg(i)
.arg(line1.p1().x())
.arg(line1.p1().y())
.arg(line1.p2().x())
.arg(line1.p2().y())
.arg(line2.p1().x())
.arg(line2.p1().y())
.arg(line2.p2().x())
.arg(line2.p2().y())));
}
}
@ -408,8 +407,8 @@ auto AbstractTest::Run(int exit, const QString &program, const QStringList &argu
{
msecs = AbstractTest::RunTimeout(msecs);
const QString parameters = QStringLiteral("Program: %1 \nArguments: %2.")
.arg(program, arguments.join(QStringLiteral(", ")));
const QString parameters =
QStringLiteral("Program: %1 \nArguments: %2.").arg(program, arguments.join(QStringLiteral(", ")));
QFileInfo info(program);
if (not info.exists())
@ -425,7 +424,7 @@ auto AbstractTest::Run(int exit, const QString &program, const QStringList &argu
if (not process->waitForStarted(msecs))
{
error = QStringLiteral("The start operation timed out or an error occurred.\n%1\n%2")
.arg(parameters, QString(process->readAllStandardError()));
.arg(parameters, QString(process->readAllStandardError()));
process->kill();
return TST_EX_START_TIME_OUT;
}
@ -433,7 +432,7 @@ auto AbstractTest::Run(int exit, const QString &program, const QStringList &argu
if (not process->waitForFinished(msecs))
{
error = QStringLiteral("The finish operation timed out or an error occurred.\n%1\n%2")
.arg(parameters, QString(process->readAllStandardError()));
.arg(parameters, QString(process->readAllStandardError()));
process->kill();
return TST_EX_FINISH_TIME_OUT;
}
@ -446,8 +445,9 @@ auto AbstractTest::Run(int exit, const QString &program, const QStringList &argu
if (process->exitCode() != exit)
{
error = QStringLiteral("Unexpected finish. Exit code: %1\n%2").arg(process->exitCode())
.arg(QString(process->readAllStandardError()));
error = QStringLiteral("Unexpected finish. Exit code: %1\n%2")
.arg(process->exitCode())
.arg(QString(process->readAllStandardError()));
return process->exitCode();
}
@ -470,8 +470,8 @@ auto AbstractTest::CopyRecursively(const QString &srcFilePath, const QString &tg
return false;
}
QDir sourceDir(srcFilePath);
const QStringList fileNames = sourceDir.entryList(QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot |
QDir::Hidden | QDir::System);
const QStringList fileNames =
sourceDir.entryList(QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot | QDir::Hidden | QDir::System);
for (auto &fileName : fileNames)
{
const QString newSrcFilePath = srcFilePath + QDir::separator() + fileName;
@ -504,8 +504,8 @@ auto AbstractTest::CopyRecursively(const QString &srcFilePath, const QString &tg
QFile srcFile(srcFilePath);
if (not srcFile.open(QFile::ReadOnly))
{
const QString msg = QStringLiteral("Can't copy file '%1'. Error: %2")
.arg(srcFilePath, srcFile.errorString());
const QString msg =
QStringLiteral("Can't copy file '%1'. Error: %2").arg(srcFilePath, srcFile.errorString());
QWARN(qUtf8Printable(msg));
return false;
}
@ -514,7 +514,7 @@ auto AbstractTest::CopyRecursively(const QString &srcFilePath, const QString &tg
if (not srcFile.copy(tgtFilePath))
{
const QString msg = QStringLiteral("Can't copy file '%1' to '%2'. Error: %3")
.arg(srcFilePath, tgtFilePath, srcFile.errorString());
.arg(srcFilePath, tgtFilePath, srcFile.errorString());
QWARN(qUtf8Printable(msg));
return false;
}
@ -589,8 +589,8 @@ void AbstractTest::ReadBooleanValue(const QJsonObject &itemObject, const QString
}
else
{
const QString error = QStringLiteral("%1 is not boolean value '%2'.").arg(attribute,
attributeValue.toString());
const QString error =
QStringLiteral("%1 is not boolean value '%2'.").arg(attribute, attributeValue.toString());
QFAIL(qUtf8Printable(error));
}
}
@ -703,9 +703,8 @@ void AbstractTest::ReadPieceNodeValue(const QJsonObject &itemObject, VPieceNode
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,
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,
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,
const QString &defaultValue)
{
@ -913,7 +912,7 @@ void AbstractTest::DBFromJson(const QJsonObject &dbObject, QSharedPointer<VConta
GOType objectType;
AbstractTest::ReadDoubleValue(itemObject, QStringLiteral("type"), objectType);
switch(objectType)
switch (objectType)
{
case GOType::Point:
{
@ -930,8 +929,8 @@ void AbstractTest::DBFromJson(const QJsonObject &dbObject, QSharedPointer<VConta
break;
default:
{
const QString error = QStringLiteral("Not supported item type '%1'.")
.arg(static_cast<int>(objectType));
const QString error =
QStringLiteral("Not supported item type '%1'.").arg(static_cast<int>(objectType));
QFAIL(qUtf8Printable(error));
}
}

View File

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

View File

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

View File

@ -29,8 +29,8 @@
#ifndef GLOBAL_H
#define GLOBAL_H
#include <QtGlobal>
#include <QStyleOptionGraphicsItem>
#include <QtGlobal>
extern const qreal minVisibleFontSize;
@ -52,7 +52,7 @@ auto CorrectColor(const QGraphicsItem *item, const QColor &color) -> QColor;
auto PointRect(qreal radius) -> QRectF;
auto ScaledRadius(qreal scale) -> qreal;
void ScaleCircleSize(QGraphicsEllipseItem *item, qreal scale);
void ScaleCircleSize(QGraphicsEllipseItem *item, qreal scale);
auto ScaleWidth(qreal width, qreal scale) -> qreal;
auto ItemShapeFromPath(const QPainterPath &path, const QPen &pen) -> QPainterPath;
@ -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
* 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,
QWidget *widget)
{

View File

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

View File

@ -31,13 +31,16 @@
//---------------------------------------------------------------------------------------------------------------------
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)
{

View File

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

View File

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

View File

@ -29,17 +29,27 @@
#include "tst_valentinacommandline.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 <QtTest>
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, 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)
:AbstractTest(parent)
: AbstractTest(parent)
{
}
@ -47,7 +57,7 @@ TST_ValentinaCommandLine::TST_ValentinaCommandLine(QObject *parent)
// cppcheck-suppress unusedFunction
void TST_ValentinaCommandLine::initTestCase()
{
{// Test files
{ // Test files
QDir tmpDir(*tmpTestFolder);
if (not tmpDir.removeRecursively())
{
@ -55,14 +65,14 @@ void TST_ValentinaCommandLine::initTestCase()
}
if (not CopyRecursively(QCoreApplication::applicationDirPath() + QDir::separator() +
QLatin1String("tst_valentina"),
QLatin1String("tst_valentina"),
QCoreApplication::applicationDirPath() + QDir::separator() + *tmpTestFolder))
{
QFAIL("Fail to prepare test files for testing.");
}
}
{// Collection
{ // Collection
QDir tmpDir(*tmpTestCollectionFolder);
if (not tmpDir.removeRecursively())
{
@ -70,7 +80,7 @@ void TST_ValentinaCommandLine::initTestCase()
}
if (not CopyRecursively(QCoreApplication::applicationDirPath() + QDir::separator() +
QLatin1String("tst_valentina_collection"),
QLatin1String("tst_valentina_collection"),
QCoreApplication::applicationDirPath() + QDir::separator() + *tmpTestCollectionFolder))
{
QFAIL("Fail to prepare collection files for testing.");
@ -87,25 +97,20 @@ void TST_ValentinaCommandLine::OpenPatterns_data() const
QTest::addColumn<int>("exitCode");
// The file doesn't exist!
QTest::newRow("Send wrong path to a file") << "wrongPath.val"
<< "--test"
<< V_EX_NOINPUT;
QTest::newRow("Send wrong path to a file") << "wrongPath.val"
<< "--test" << V_EX_NOINPUT;
QTest::newRow("Measurement independent empty file") << "empty.val"
<< "--test"
<< V_EX_OK;
QTest::newRow("Measurement independent empty file") << "empty.val"
<< "--test" << V_EX_OK;
QTest::newRow("File with invalid object type") << "wrong_obj_type.val"
<< "--test"
<< V_EX_NOINPUT;
QTest::newRow("File with invalid object type") << "wrong_obj_type.val"
<< "--test" << V_EX_NOINPUT;
QTest::newRow("Empty text VAL file") << "txt.val"
<< "--test"
<< V_EX_NOINPUT;
QTest::newRow("Empty text VAL file") << "txt.val"
<< "--test" << V_EX_NOINPUT;
QTest::newRow("Pattern with a warning") << "test_pedantic.val"
<< "--test;;--pedantic"
<< V_EX_DATAERR;
QTest::newRow("Pattern with a warning") << "test_pedantic.val"
<< "--test;;--pedantic" << V_EX_DATAERR;
}
//---------------------------------------------------------------------------------------------------------------------
@ -118,8 +123,8 @@ void TST_ValentinaCommandLine::OpenPatterns()
QString error;
const QString tmp = QCoreApplication::applicationDirPath() + QDir::separator() + *tmpTestFolder;
const int exit = Run(exitCode, ValentinaPath(), QStringList() << arguments.split(";;")
<< tmp + QDir::separator() + file, error);
const int exit =
Run(exitCode, ValentinaPath(), QStringList() << arguments.split(";;") << tmp + QDir::separator() + file, error);
QVERIFY2(exit == exitCode, qUtf8Printable(error.right(350)));
}
@ -134,9 +139,8 @@ void TST_ValentinaCommandLine::ExportMode_data() const
const QString tmp = QCoreApplication::applicationDirPath() + QDir::separator() + *tmpTestFolder;
QTest::newRow("Issue #372")<< "issue_372.val"
<< QString("-p;;0;;-d;;%1;;-b;;output;;--coefficient;;1").arg(tmp)
<< V_EX_OK;
QTest::newRow("Issue #372") << "issue_372.val" << QString("-p;;0;;-d;;%1;;-b;;output;;--coefficient;;1").arg(tmp)
<< V_EX_OK;
}
//---------------------------------------------------------------------------------------------------------------------
@ -149,8 +153,7 @@ void TST_ValentinaCommandLine::ExportMode()
QString error;
const QString tmp = QCoreApplication::applicationDirPath() + QDir::separator() + *tmpTestFolder;
const QStringList arg = QStringList() << tmp + QDir::separator() + file
<< arguments.split(";;");
const QStringList arg = QStringList() << tmp + QDir::separator() + file << arguments.split(";;");
const int exit = Run(exitCode, ValentinaPath(), arg, error);
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;
QTest::newRow("Issue #256. Correct path.")<< "issue_256.val"
<< QString("--test")
<< V_EX_OK;
QTest::newRow("Issue #256. Correct path.") << "issue_256.val" << QString("--test") << V_EX_OK;
QTest::newRow("Issue #256. Wrong path.")<< "issue_256_wrong_path.vit"
<< QString("--test")
<< V_EX_NOINPUT;
QTest::newRow("Issue #256. Wrong path.") << "issue_256_wrong_path.vit" << QString("--test") << V_EX_NOINPUT;
QTest::newRow("Issue #256. Correct individual measurements.")<< "issue_256.val"
<< QString("--test;;-m;;%1").arg(tmp + QDir::separator() +
QLatin1String("issue_256_correct.vit"))
<< V_EX_OK;
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;
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;
QTest::newRow("Issue #256. Correct multisize measurements.")<< "issue_256.val"
<< QString("--test;;-m;;%1").arg(tmp + QDir::separator() +
QLatin1String("issue_256_correct.vst"))
<< V_EX_OK;
QTest::newRow("Issue #256. Correct multisize measurements.")
<< "issue_256.val"
<< QString("--test;;-m;;%1").arg(tmp + QDir::separator() + QLatin1String("issue_256_correct.vst")) << V_EX_OK;
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("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;
QTest::newRow("Wrong formula.") << "wrong_formula.val" << QString("--test") << V_EX_DATAERR;
}
//---------------------------------------------------------------------------------------------------------------------
@ -207,8 +202,7 @@ void TST_ValentinaCommandLine::TestMode()
QString error;
const QString tmp = QCoreApplication::applicationDirPath() + QDir::separator() + *tmpTestFolder;
const QStringList arg = QStringList() << tmp + QDir::separator() + file
<< arguments.split(";;");
const QStringList arg = QStringList() << tmp + QDir::separator() + file << arguments.split(";;");
const int exit = Run(exitCode, ValentinaPath(), arg, error);
QVERIFY2(exit == exitCode, qUtf8Printable(error.right(350)));
@ -225,36 +219,36 @@ void TST_ValentinaCommandLine::TestOpenCollection_data() const
const QString testGOST = QString("--test;;-m;;%1").arg(tmp + QDir::separator() + QLatin1String("GOST_man_ru.vst"));
const QString keyTest = QStringLiteral("--test");
QTest::newRow("bra") << "bra.val" << keyTest << V_EX_OK;
QTest::newRow("bra") << "bra.val" << keyTest << V_EX_OK;
#ifdef Q_OS_WIN
Q_UNUSED(testGOST)
#else
QTest::newRow("jacketM1_52-176") << "jacketM1_52-176.val" << testGOST << V_EX_OK;
QTest::newRow("jacketM2_40-146") << "jacketM2_40-146.val" << testGOST << V_EX_OK;
QTest::newRow("jacketM3_40-146") << "jacketM3_40-146.val" << testGOST << V_EX_OK;
QTest::newRow("jacketM4_40-146") << "jacketM4_40-146.val" << testGOST << V_EX_OK;
QTest::newRow("jacketM5_30-110") << "jacketM5_30-110.val" << testGOST << V_EX_OK;
QTest::newRow("jacketM6_30-110") << "jacketM6_30-110.val" << testGOST << V_EX_OK;
QTest::newRow("pantsM1_52-176") << "pantsM1_52-176.val" << testGOST << V_EX_OK;
QTest::newRow("pantsM2_40-146") << "pantsM2_40-146.val" << testGOST << V_EX_OK;
QTest::newRow("pantsM7") << "pantsM7.val" << testGOST << V_EX_OK;
QTest::newRow("jacketM1_52-176") << "jacketM1_52-176.val" << testGOST << V_EX_OK;
QTest::newRow("jacketM2_40-146") << "jacketM2_40-146.val" << testGOST << V_EX_OK;
QTest::newRow("jacketM3_40-146") << "jacketM3_40-146.val" << testGOST << V_EX_OK;
QTest::newRow("jacketM4_40-146") << "jacketM4_40-146.val" << testGOST << V_EX_OK;
QTest::newRow("jacketM5_30-110") << "jacketM5_30-110.val" << testGOST << V_EX_OK;
QTest::newRow("jacketM6_30-110") << "jacketM6_30-110.val" << testGOST << V_EX_OK;
QTest::newRow("pantsM1_52-176") << "pantsM1_52-176.val" << testGOST << V_EX_OK;
QTest::newRow("pantsM2_40-146") << "pantsM2_40-146.val" << testGOST << V_EX_OK;
QTest::newRow("pantsM7") << "pantsM7.val" << testGOST << V_EX_OK;
#endif
QTest::newRow("TShirt_test") << "TShirt_test.val" << keyTest << V_EX_OK;
QTest::newRow("TestDart") << "TestDart.val" << keyTest << V_EX_OK;
QTest::newRow("MaleShirt") << "MaleShirt.val" << keyTest << V_EX_OK;
QTest::newRow("Trousers") << "Trousers.val" << keyTest << V_EX_OK;
QTest::newRow("Basic block women") << "Basic_block_women-2016.val" << keyTest << V_EX_OK;
QTest::newRow("TShirt_test") << "TShirt_test.val" << keyTest << V_EX_OK;
QTest::newRow("TestDart") << "TestDart.val" << keyTest << V_EX_OK;
QTest::newRow("MaleShirt") << "MaleShirt.val" << keyTest << V_EX_OK;
QTest::newRow("Trousers") << "Trousers.val" << keyTest << V_EX_OK;
QTest::newRow("Basic block women") << "Basic_block_women-2016.val" << keyTest << V_EX_OK;
QTest::newRow("Gent Jacket with tummy") << "Gent_Jacket_with_tummy.val" << keyTest << V_EX_OK;
QTest::newRow("Steampunk_trousers") << "Steampunk_trousers.val" << keyTest << V_EX_OK;
QTest::newRow("Steampunk_trousers") << "Steampunk_trousers.val" << keyTest << V_EX_OK;
#ifndef Q_OS_WIN
QTest::newRow("pattern_blusa") << "pattern_blusa.val" << keyTest << V_EX_OK;
QTest::newRow("PajamaTopWrap2") << "PajamaTopWrap2.val" << keyTest << V_EX_OK;
QTest::newRow("Keiko_skirt") << "Keiko_skirt.val" << keyTest << V_EX_OK;
QTest::newRow("pantalon_base_Eli") << "pantalon_base_Eli.val" << keyTest << V_EX_OK;
QTest::newRow("modell_2") << "modell_2.val" << keyTest << V_EX_OK;
QTest::newRow("IMK_Zhaketa") << "IMK_Zhaketa_poluprilegayuschego_silueta.val" << keyTest << V_EX_OK;
QTest::newRow("pattern_blusa") << "pattern_blusa.val" << keyTest << V_EX_OK;
QTest::newRow("PajamaTopWrap2") << "PajamaTopWrap2.val" << keyTest << V_EX_OK;
QTest::newRow("Keiko_skirt") << "Keiko_skirt.val" << keyTest << V_EX_OK;
QTest::newRow("pantalon_base_Eli") << "pantalon_base_Eli.val" << keyTest << V_EX_OK;
QTest::newRow("modell_2") << "modell_2.val" << keyTest << V_EX_OK;
QTest::newRow("IMK_Zhaketa") << "IMK_Zhaketa_poluprilegayuschego_silueta.val" << keyTest << V_EX_OK;
QTest::newRow("Moulage_0.5_armhole_neckline") << "Moulage_0.5_armhole_neckline.val" << keyTest << V_EX_OK;
QTest::newRow("0.7_Armhole_adjustment_0.10") << "0.7_Armhole_adjustment_0.10.val" << keyTest << V_EX_OK;
QTest::newRow("0.7_Armhole_adjustment_0.10") << "0.7_Armhole_adjustment_0.10.val" << keyTest << V_EX_OK;
#endif
// We have a problem with encoding in Windows when we try to open some files in terminal
}
@ -268,8 +262,7 @@ void TST_ValentinaCommandLine::TestOpenCollection()
QString error;
const QString tmp = QCoreApplication::applicationDirPath() + QDir::separator() + *tmpTestCollectionFolder;
const QStringList arg = QStringList() << tmp + QDir::separator() + file
<< arguments.split(";;");
const QStringList arg = QStringList() << tmp + QDir::separator() + file << arguments.split(";;");
const int exit = Run(exitCode, ValentinaPath(), arg, error);
QVERIFY2(exit == exitCode, qUtf8Printable(error.right(350)));

View File

@ -32,34 +32,35 @@
#include <xercesc/util/PlatformUtils.hpp>
#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_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 "../vmisc/def.h"
#include "../qmuparser/qmudef.h"
#include "../vmisc/def.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)
XERCES_CPP_NAMESPACE::XMLPlatformUtils::Initialize();
auto Terminate = qScopeGuard([](){ XERCES_CPP_NAMESPACE::XMLPlatformUtils::Terminate(); });
auto Terminate = qScopeGuard([]() { XERCES_CPP_NAMESPACE::XMLPlatformUtils::Terminate(); });
#endif
TestVApplication app( argc, argv );// For QPrinter
TestVApplication app(argc, argv); // For QPrinter
QResource::registerResource(QCoreApplication::applicationDirPath() + QStringLiteral("/test_data.rcc"));