diff --git a/qbs/imports/VToolApp.qbs b/qbs/imports/VToolApp.qbs index ad5dca7df..a0ac95056 100644 --- a/qbs/imports/VToolApp.qbs +++ b/qbs/imports/VToolApp.qbs @@ -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"; } diff --git a/src/app/puzzle/dialogs/configpages/puzzlepreferencesconfigurationpage.cpp b/src/app/puzzle/dialogs/configpages/puzzlepreferencesconfigurationpage.cpp index 520e18859..60963d67d 100644 --- a/src/app/puzzle/dialogs/configpages/puzzlepreferencesconfigurationpage.cpp +++ b/src/app/puzzle/dialogs/configpages/puzzlepreferencesconfigurationpage.cpp @@ -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::of(&QComboBox::currentIndexChanged), this, [this]() - { - m_langChanged = true; - }); + connect(ui->langCombo, QOverload::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 diff --git a/src/app/puzzle/dialogs/dialogsavemanuallayout.cpp b/src/app/puzzle/dialogs/dialogsavemanuallayout.cpp index 157253edf..2c1b1f407 100644 --- a/src/app/puzzle/dialogs/dialogsavemanuallayout.cpp +++ b/src/app/puzzle/dialogs/dialogsavemanuallayout.cpp @@ -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 #include +#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::of(&QComboBox::currentIndexChanged), - this, &DialogSaveManualLayout::ShowExample); + connect(ui->comboBoxFormat, QOverload::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 > +auto DialogSaveManualLayout::InitFormats() -> QVector> { QVector> 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 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 diff --git a/src/app/puzzle/scene/vpgraphicspiece.h b/src/app/puzzle/scene/vpgraphicspiece.h index 6c650808b..f142a0447 100644 --- a/src/app/puzzle/scene/vpgraphicspiece.h +++ b/src/app/puzzle/scene/vpgraphicspiece.h @@ -29,11 +29,11 @@ #ifndef VPGRAPHICSPIECE_H #define VPGRAPHICSPIECE_H -#include #include +#include -#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(PGraphicsItem::Piece)}; + auto type() const -> int override { return Type; } + enum + { + Type = UserType + static_cast(PGraphicsItem::Piece) + }; void SetStickyPoints(const QVector &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 &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); diff --git a/src/app/puzzle/scene/vpgraphicspiececontrols.cpp b/src/app/puzzle/scene/vpgraphicspiececontrols.cpp index 67296fa3d..1e199f4b6 100644 --- a/src/app/puzzle/scene/vpgraphicspiececontrols.cpp +++ b/src/app/puzzle/scene/vpgraphicspiececontrols.cpp @@ -28,26 +28,30 @@ #include "vpgraphicspiececontrols.h" #include +#include #include #include +#include #include #include -#include -#include #include -#include +#include -#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 auto VPGraphicsPieceControls::PiecesBoundingRect(const QList &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 corners - { + QMap 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()) diff --git a/src/app/puzzle/scene/vpmaingraphicsview.cpp b/src/app/puzzle/scene/vpmaingraphicsview.cpp index 7573c1999..4c6025775 100644 --- a/src/app/puzzle/scene/vpmaingraphicsview.cpp +++ b/src/app/puzzle/scene/vpmaingraphicsview.cpp @@ -29,26 +29,30 @@ #include "vpmaingraphicsview.h" #include -#include #include #include +#include #include #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 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 (mime); + const auto *mimePiece = qobject_cast(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 (mime); + const auto *mimePiece = qobject_cast(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 (mime); + const auto *mimePiece = qobject_cast(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 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 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 &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()); @@ -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); diff --git a/src/app/puzzle/vpmainwindow.cpp b/src/app/puzzle/vpmainwindow.cpp index 3e638ce96..d398cbd66 100644 --- a/src/app/puzzle/vpmainwindow.cpp +++ b/src/app/puzzle/vpmainwindow.cpp @@ -27,48 +27,48 @@ *************************************************************************/ #include "vpmainwindow.h" -#include #include -#include -#include +#include #include -#include -#include -#include #include #include +#include +#include +#include #include +#include +#include #include -#include "ui_vpmainwindow.h" -#include "dialogs/vpdialogabout.h" -#include "xml/vplayoutfilewriter.h" -#include "xml/vplayoutfilereader.h" -#include "vpapplication.h" -#include "../vlayout/vrawlayout.h" +#include "../ifc/exception/vexception.h" +#include "../ifc/xml/vlayoutconverter.h" +#include "../vdxf/libdxfrw/drw_base.h" +#include "../vlayout/dialogs/watermarkwindow.h" #include "../vlayout/vlayoutexporter.h" #include "../vlayout/vprintlayout.h" -#include "../vlayout/dialogs/watermarkwindow.h" -#include "../vmisc/vsysexits.h" -#include "../vmisc/projectversion.h" -#include "../ifc/xml/vlayoutconverter.h" -#include "../ifc/exception/vexception.h" -#include "../vwidgets/vmaingraphicsscene.h" -#include "layout/vpsheet.h" -#include "dialogs/dialogpuzzlepreferences.h" -#include "undocommands/vpundoaddsheet.h" -#include "undocommands/vpundopiecerotate.h" -#include "undocommands/vpundopiecemove.h" -#include "undocommands/vpundopiecezvaluemove.h" -#include "dialogs/dialogsavemanuallayout.h" -#include "../vdxf/libdxfrw/drw_base.h" +#include "../vlayout/vrawlayout.h" #include "../vmisc/dialogs/dialogselectlanguage.h" #include "../vmisc/lambdaconstants.h" +#include "../vmisc/projectversion.h" +#include "../vmisc/vsysexits.h" +#include "../vwidgets/vmaingraphicsscene.h" +#include "dialogs/dialogpuzzlepreferences.h" +#include "dialogs/dialogsavemanuallayout.h" +#include "dialogs/vpdialogabout.h" +#include "layout/vpsheet.h" +#include "ui_vpmainwindow.h" +#include "undocommands/vpundoaddsheet.h" +#include "undocommands/vpundopiecemove.h" +#include "undocommands/vpundopiecerotate.h" +#include "undocommands/vpundopiecezvaluemove.h" +#include "vpapplication.h" +#include "xml/vplayoutfilereader.h" +#include "xml/vplayoutfilewriter.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 "vptilefactory.h" #include "layout/vppiece.h" +#include "vptilefactory.h" #if QT_VERSION < QT_VERSION_CHECK(5, 12, 0) #include "../vmisc/backport/qscopeguard.h" @@ -160,7 +160,7 @@ void SetPlainTextEditValue(QPlainTextEdit *textEdit, const QString &value) auto PiecesBoundingRect(const QList &selectedPieces) -> QRectF { QRectF rect; - for (const auto& item : selectedPieces) + for (const auto &item : selectedPieces) { if (not item.isNull()) { @@ -172,15 +172,15 @@ auto PiecesBoundingRect(const QList &selectedPieces) -> QRectF } //--------------------------------------------------------------------------------------------------------------------- -Q_REQUIRED_RESULT auto PreparePrinter( - const QPrinterInfo &info, QPrinter::PrinterMode mode = QPrinter::ScreenResolution) -> QSharedPointer; +Q_REQUIRED_RESULT auto PreparePrinter(const QPrinterInfo &info, QPrinter::PrinterMode mode = QPrinter::ScreenResolution) + -> QSharedPointer; auto PreparePrinter(const QPrinterInfo &info, QPrinter::PrinterMode mode) -> QSharedPointer { QPrinterInfo tmpInfo = info; - if(tmpInfo.isNull() || tmpInfo.printerName().isEmpty()) + if (tmpInfo.isNull() || tmpInfo.printerName().isEmpty()) { const QStringList list = QPrinterInfo::availablePrinterNames(); - if(list.isEmpty()) + if (list.isEmpty()) { return {}; } @@ -272,14 +272,13 @@ void SetPrinterTiledPageSettings(const QSharedPointer &printer, const if (not layout->LayoutSettings().IgnoreTilesMargins()) { - if (not printer->setPageMargins(layout->LayoutSettings().GetTilesMargins(Unit::Mm), - QPageLayout::Millimeter)) + if (not printer->setPageMargins(layout->LayoutSettings().GetTilesMargins(Unit::Mm), QPageLayout::Millimeter)) { qWarning() << QObject::tr("Cannot set printer margins"); } } } -} // namespace +} // namespace struct VPExportData { @@ -297,8 +296,8 @@ struct VPExportData }; //--------------------------------------------------------------------------------------------------------------------- -VPMainWindow::VPMainWindow(const VPCommandLinePtr &cmd, QWidget *parent) : - VAbstractMainWindow(parent), +VPMainWindow::VPMainWindow(const VPCommandLinePtr &cmd, QWidget *parent) + : VAbstractMainWindow(parent), ui(new Ui::VPMainWindow), m_cmd(cmd), m_undoStack(new QUndoStack(this)), @@ -310,29 +309,22 @@ VPMainWindow::VPMainWindow(const VPCommandLinePtr &cmd, QWidget *parent) : ui->setupUi(this); connect(m_layout.data(), &VPLayout::PieceSelectionChanged, this, &VPMainWindow::on_PieceSelectionChanged); - connect(m_layout.data(), &VPLayout::LayoutChanged, this, [this]() - { - LayoutWasSaved(false); - }); - connect(m_layout.data(), &VPLayout::PieceTransformationChanged, this, [this]() - { - SetPropertyTabCurrentPieceData(); - }); - connect(m_layout.data(), &VPLayout::ActiveSheetChanged, this, [this]() - { - m_layout->TileFactory()->RefreshTileInfos(); - m_graphicsView->RefreshLayout(); - SetPropertyTabSheetData(); - }); + connect(m_layout.data(), &VPLayout::LayoutChanged, this, [this]() { LayoutWasSaved(false); }); + connect(m_layout.data(), &VPLayout::PieceTransformationChanged, this, + [this]() { SetPropertyTabCurrentPieceData(); }); + connect(m_layout.data(), &VPLayout::ActiveSheetChanged, this, + [this]() + { + m_layout->TileFactory()->RefreshTileInfos(); + m_graphicsView->RefreshLayout(); + SetPropertyTabSheetData(); + }); - connect(m_undoStack, &QUndoStack::cleanChanged, this, [this](bool clean) - { - LayoutWasSaved(clean); - }); + connect(m_undoStack, &QUndoStack::cleanChanged, this, [this](bool clean) { LayoutWasSaved(clean); }); // init status bar statusBar()->addPermanentWidget(m_statusLabel, 1); - + SetupMenu(); InitProperties(); InitCarrousel(); @@ -352,45 +344,46 @@ VPMainWindow::VPMainWindow(const VPCommandLinePtr &cmd, QWidget *parent) : connect(menu, &QMenu::aboutToShow, this, &VPMainWindow::AboutToShowDockMenu); AboutToShowDockMenu(); menu->setAsDockMenu(); -#endif //defined(Q_OS_MAC) +#endif // defined(Q_OS_MAC) - connect(m_layoutWatcher, &QFileSystemWatcher::fileChanged, this, [this](const QString &path) - { - QFileInfo checkFile(path); - if (not checkFile.exists()) - { - for(int i=0; i<=1000; i=i+10) + connect(m_layoutWatcher, &QFileSystemWatcher::fileChanged, this, + [this](const QString &path) { - if (checkFile.exists()) + QFileInfo checkFile(path); + if (not checkFile.exists()) { - break; + for (int i = 0; i <= 1000; i = i + 10) + { + if (checkFile.exists()) + { + break; + } + + std::this_thread::sleep_for(std::chrono::milliseconds(100)); + } } - std::this_thread::sleep_for(std::chrono::milliseconds(100)); - } - } + if (not curFile.isEmpty() && curFile == path) + { + UpdateWindowTitle(); + } - if (not curFile.isEmpty() && curFile == path) - { - UpdateWindowTitle(); - } + m_layout->TileFactory()->RefreshTileInfos(); - m_layout->TileFactory()->RefreshTileInfos(); + if (path == m_layout->LayoutSettings().WatermarkPath()) + { + m_layoutWatcher->blockSignals(true); + m_layout->TileFactory()->RefreshWatermarkData(); + m_layoutWatcher->blockSignals(false); + } - if (path == m_layout->LayoutSettings().WatermarkPath()) - { - m_layoutWatcher->blockSignals(true); - m_layout->TileFactory()->RefreshWatermarkData(); - m_layoutWatcher->blockSignals(false); - } + m_graphicsView->RefreshLayout(); - m_graphicsView->RefreshLayout(); - - if (checkFile.exists()) - { - m_layoutWatcher->addPath(path); - } - }); + if (checkFile.exists()) + { + m_layoutWatcher->addPath(path); + } + }); m_graphicsView->RefreshLayout(); @@ -415,7 +408,7 @@ auto VPMainWindow::CurrentFile() const -> QString } //--------------------------------------------------------------------------------------------------------------------- -auto VPMainWindow::LoadFile(const QString& path) -> bool +auto VPMainWindow::LoadFile(const QString &path) -> bool { if (not QFileInfo::exists(path)) { @@ -424,9 +417,9 @@ auto VPMainWindow::LoadFile(const QString& path) -> bool } // Check if file already opened - QList list = VPApplication::VApp()->MainWindows(); - auto w = std::find_if(list.begin(), list.end(), - [path](VPMainWindow *window) { return window->CurrentFile() == path; }); + QList list = VPApplication::VApp()->MainWindows(); + auto w = + std::find_if(list.begin(), list.end(), [path](VPMainWindow *window) { return window->CurrentFile() == path; }); if (w != list.end()) { (*w)->activateWindow(); @@ -472,8 +465,8 @@ auto VPMainWindow::LoadFile(const QString& path) -> bool } catch (VException &e) { - qCCritical(pWindow, "%s\n\n%s\n\n%s", qUtf8Printable(tr("File error.")), - qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation())); + qCCritical(pWindow, "%s\n\n%s\n\n%s", qUtf8Printable(tr("File error.")), qUtf8Printable(e.ErrorMessage()), + qUtf8Printable(e.DetailedInformation())); lock.reset(); return false; } @@ -510,7 +503,7 @@ auto VPMainWindow::LoadFile(const QString& path) -> bool void VPMainWindow::LayoutWasSaved(bool saved) { setWindowModified(!saved); - not IsLayoutReadOnly() ? ui->actionSave->setEnabled(!saved): ui->actionSave->setEnabled(false); + not IsLayoutReadOnly() ? ui->actionSave->setEnabled(!saved) : ui->actionSave->setEnabled(false); } //--------------------------------------------------------------------------------------------------------------------- @@ -578,7 +571,7 @@ auto VPMainWindow::SaveLayout(const QString &path, QString &error) -> bool void VPMainWindow::ImportRawLayouts(const QStringList &rawLayouts) { - for(const auto &path : rawLayouts) + for (const auto &path : rawLayouts) { if (not ImportRawLayout(path)) { @@ -607,21 +600,22 @@ void VPMainWindow::SetupMenu() ui->actionSaveAs->setShortcuts(QKeySequence::SaveAs); m_recentFileActs.fill(nullptr); - for (auto & recentFileAct : m_recentFileActs) + for (auto &recentFileAct : m_recentFileActs) { auto *action = new QAction(this); recentFileAct = action; - connect(action, &QAction::triggered, this, [this]() - { - if (auto *senderAction = qobject_cast(sender())) - { - const QString filePath = senderAction->data().toString(); - if (not filePath.isEmpty()) + connect(action, &QAction::triggered, this, + [this]() { - LoadFile(filePath); - } - } - }); + if (auto *senderAction = qobject_cast(sender())) + { + const QString filePath = senderAction->data().toString(); + if (not filePath.isEmpty()) + { + LoadFile(filePath); + } + } + }); ui->menuFile->insertAction(ui->actionPreferences, recentFileAct); recentFileAct->setVisible(false); } @@ -645,7 +639,7 @@ void VPMainWindow::SetupMenu() // Add dock properties action ui->menuSheet->addSeparator(); - QAction* actionDockWidgetToolOptions = ui->dockWidgetProperties->toggleViewAction(); + QAction *actionDockWidgetToolOptions = ui->dockWidgetProperties->toggleViewAction(); ui->menuSheet->addAction(actionDockWidgetToolOptions); ui->menuSheet->addSeparator(); @@ -664,13 +658,13 @@ void VPMainWindow::SetupMenu() // Z value connect(ui->actionZValueBottom, &QAction::triggered, this, - [this](){ZValueMove(static_cast(ML::ZValueMove::Bottom));}); + [this]() { ZValueMove(static_cast(ML::ZValueMove::Bottom)); }); connect(ui->actionZValueDown, &QAction::triggered, this, - [this](){ZValueMove(static_cast(ML::ZValueMove::Down));}); + [this]() { ZValueMove(static_cast(ML::ZValueMove::Down)); }); connect(ui->actionZValueUp, &QAction::triggered, this, - [this](){ZValueMove(static_cast(ML::ZValueMove::Up));}); + [this]() { ZValueMove(static_cast(ML::ZValueMove::Up)); }); connect(ui->actionZValueTop, &QAction::triggered, this, - [this](){ZValueMove(static_cast(ML::ZValueMove::Top));}); + [this]() { ZValueMove(static_cast(ML::ZValueMove::Top)); }); // Watermark connect(ui->actionWatermarkEditor, &QAction::triggered, this, &VPMainWindow::CreateWatermark); @@ -679,11 +673,12 @@ void VPMainWindow::SetupMenu() connect(ui->actionRemoveWatermark, &QAction::triggered, this, &VPMainWindow::RemoveWatermark); // Window - connect(ui->menuWindow, &QMenu::aboutToShow, this, [this]() - { - ui->menuWindow->clear(); - CreateWindowMenu(ui->menuWindow); - }); + connect(ui->menuWindow, &QMenu::aboutToShow, this, + [this]() + { + ui->menuWindow->clear(); + CreateWindowMenu(ui->menuWindow); + }); } //--------------------------------------------------------------------------------------------------------------------- @@ -703,39 +698,41 @@ void VPMainWindow::InitProperties() //--------------------------------------------------------------------------------------------------------------------- void VPMainWindow::InitPropertyTabCurrentPiece() { - connect(ui->checkBoxCurrentPieceShowSeamline, &QCheckBox::toggled, this, [this](bool checked) - { - QList selectedPieces = SelectedPieces(); - if (selectedPieces.size() == 1) - { - const VPPiecePtr &selectedPiece = ConstFirst(selectedPieces); - if (not selectedPiece.isNull()) + connect(ui->checkBoxCurrentPieceShowSeamline, &QCheckBox::toggled, this, + [this](bool checked) { - selectedPiece->SetHideMainPath(not checked); - LayoutWasSaved(false); - // nothing changed, but will force redraw - emit m_layout->PieceTransformationChanged(selectedPiece); - } - } - }); - - connect(ui->checkBoxCurrentPieceMirrorPiece, &QCheckBox::toggled, this, [this](bool checked) - { - QList selectedPieces = SelectedPieces(); - if (selectedPieces.size() == 1) - { - const VPPiecePtr &selectedPiece = ConstFirst(selectedPieces); - if (not selectedPiece.isNull()) - { - if (selectedPiece->IsMirror() != checked) + QList selectedPieces = SelectedPieces(); + if (selectedPieces.size() == 1) { - selectedPiece->Flip(); - LayoutWasSaved(false); - emit m_layout->PieceTransformationChanged(selectedPiece); + const VPPiecePtr &selectedPiece = ConstFirst(selectedPieces); + if (not selectedPiece.isNull()) + { + selectedPiece->SetHideMainPath(not checked); + LayoutWasSaved(false); + // nothing changed, but will force redraw + emit m_layout->PieceTransformationChanged(selectedPiece); + } } - } - } - }); + }); + + connect(ui->checkBoxCurrentPieceMirrorPiece, &QCheckBox::toggled, this, + [this](bool checked) + { + QList selectedPieces = SelectedPieces(); + if (selectedPieces.size() == 1) + { + const VPPiecePtr &selectedPiece = ConstFirst(selectedPieces); + if (not selectedPiece.isNull()) + { + if (selectedPiece->IsMirror() != checked) + { + selectedPiece->Flip(); + LayoutWasSaved(false); + emit m_layout->PieceTransformationChanged(selectedPiece); + } + } + } + }); // Translate ui->comboBoxTranslateUnit->addItem(tr("Millimiters"), QVariant(UnitsToStr(Unit::Mm))); @@ -752,37 +749,37 @@ void VPMainWindow::InitPropertyTabCurrentPiece() const int maxTranslate = 1000; ui->doubleSpinBoxCurrentPieceBoxPositionX->setMinimum( - UnitConvertor(minTranslate, Unit::Cm, m_oldPieceTranslationUnit)); + UnitConvertor(minTranslate, Unit::Cm, m_oldPieceTranslationUnit)); ui->doubleSpinBoxCurrentPieceBoxPositionX->setMaximum( - UnitConvertor(maxTranslate, Unit::Cm, m_oldPieceTranslationUnit)); + UnitConvertor(maxTranslate, Unit::Cm, m_oldPieceTranslationUnit)); ui->doubleSpinBoxCurrentPieceBoxPositionX->setValue(0); ui->doubleSpinBoxCurrentPieceBoxPositionY->setMinimum( - UnitConvertor(minTranslate, Unit::Cm, m_oldPieceTranslationUnit)); + UnitConvertor(minTranslate, Unit::Cm, m_oldPieceTranslationUnit)); ui->doubleSpinBoxCurrentPieceBoxPositionY->setMaximum( - UnitConvertor(maxTranslate, Unit::Cm, m_oldPieceTranslationUnit)); + UnitConvertor(maxTranslate, Unit::Cm, m_oldPieceTranslationUnit)); ui->doubleSpinBoxCurrentPieceBoxPositionY->setValue(0); connect(ui->comboBoxTranslateUnit, QOverload::of(&QComboBox::currentIndexChanged), this, [this V_LAMBDA_CONSTANTS(minTranslate, maxTranslate)]() - { - const Unit newUnit = TranslateUnit(); - const qreal oldTranslateX = ui->doubleSpinBoxCurrentPieceBoxPositionX->value(); - const qreal oldTranslateY = ui->doubleSpinBoxCurrentPieceBoxPositionY->value(); + { + const Unit newUnit = TranslateUnit(); + const qreal oldTranslateX = ui->doubleSpinBoxCurrentPieceBoxPositionX->value(); + const qreal oldTranslateY = ui->doubleSpinBoxCurrentPieceBoxPositionY->value(); - ui->doubleSpinBoxCurrentPieceBoxPositionX->setMinimum(UnitConvertor(minTranslate, Unit::Cm, newUnit)); - ui->doubleSpinBoxCurrentPieceBoxPositionX->setMaximum(UnitConvertor(maxTranslate, Unit::Cm, newUnit)); + ui->doubleSpinBoxCurrentPieceBoxPositionX->setMinimum(UnitConvertor(minTranslate, Unit::Cm, newUnit)); + ui->doubleSpinBoxCurrentPieceBoxPositionX->setMaximum(UnitConvertor(maxTranslate, Unit::Cm, newUnit)); - ui->doubleSpinBoxCurrentPieceBoxPositionY->setMinimum(UnitConvertor(minTranslate, Unit::Cm, newUnit)); - ui->doubleSpinBoxCurrentPieceBoxPositionY->setMaximum(UnitConvertor(maxTranslate, Unit::Cm, newUnit)); + ui->doubleSpinBoxCurrentPieceBoxPositionY->setMinimum(UnitConvertor(minTranslate, Unit::Cm, newUnit)); + ui->doubleSpinBoxCurrentPieceBoxPositionY->setMaximum(UnitConvertor(maxTranslate, Unit::Cm, newUnit)); - ui->doubleSpinBoxCurrentPieceBoxPositionX->setValue( + ui->doubleSpinBoxCurrentPieceBoxPositionX->setValue( UnitConvertor(oldTranslateX, m_oldPieceTranslationUnit, newUnit)); - ui->doubleSpinBoxCurrentPieceBoxPositionY->setValue( + ui->doubleSpinBoxCurrentPieceBoxPositionY->setValue( UnitConvertor(oldTranslateY, m_oldPieceTranslationUnit, newUnit)); - m_oldPieceTranslationUnit = newUnit; - }); + m_oldPieceTranslationUnit = newUnit; + }); SetCheckBoxValue(ui->checkBoxRelativeTranslation, true); connect(ui->checkBoxRelativeTranslation, &QCheckBox::toggled, this, &VPMainWindow::on_RelativeTranslationChanged); @@ -805,23 +802,24 @@ void VPMainWindow::InitPropertyTabCurrentPiece() //--------------------------------------------------------------------------------------------------------------------- void VPMainWindow::InitPropertyTabCurrentSheet() { - connect(ui->lineEditSheetName, &QLineEdit::textEdited, this, [this](const QString &text) - { - if (not m_layout.isNull()) - { - VPSheetPtr sheet = m_layout->GetFocusedSheet(); - if (not sheet.isNull()) + connect(ui->lineEditSheetName, &QLineEdit::textEdited, this, + [this](const QString &text) { - sheet->SetName(text); - LayoutWasSaved(false); - - if(m_carrousel != nullptr) + if (not m_layout.isNull()) { - m_carrousel->RefreshSheetNames(); + VPSheetPtr sheet = m_layout->GetFocusedSheet(); + if (not sheet.isNull()) + { + sheet->SetName(text); + LayoutWasSaved(false); + + if (m_carrousel != nullptr) + { + m_carrousel->RefreshSheetNames(); + } + } } - } - } - }); + }); // -------------------- layout units --------------------------- ui->comboBoxLayoutUnit->addItem(tr("Millimiters"), QVariant(UnitsToStr(Unit::Mm))); @@ -836,14 +834,14 @@ void VPMainWindow::InitPropertyTabCurrentSheet() ui->comboBoxLayoutUnit->setCurrentIndex(indexUnit); } - connect(ui->comboBoxLayoutUnit, QOverload::of(&QComboBox::currentIndexChanged), - this, &VPMainWindow::on_ConvertPaperSize); + connect(ui->comboBoxLayoutUnit, QOverload::of(&QComboBox::currentIndexChanged), this, + &VPMainWindow::on_ConvertPaperSize); // -------------------- sheet template --------------------------- VAbstractLayoutDialog::InitTemplates(ui->comboBoxSheetTemplates); - connect(ui->comboBoxSheetTemplates, QOverload::of(&QComboBox::currentIndexChanged), - this, [this]{SheetSize(SheetTemplate());}); + connect(ui->comboBoxSheetTemplates, QOverload::of(&QComboBox::currentIndexChanged), this, + [this] { SheetSize(SheetTemplate()); }); const QString suffix = " " + UnitsToStr(LayoutUnit(), true); // -------------------- paper size --------------------------- @@ -874,66 +872,69 @@ void VPMainWindow::InitPaperSizeData(const QString &suffix) connect(ui->toolButtonSheetLandscapeOrientation, &QToolButton::toggled, this, &VPMainWindow::on_SheetOrientationChanged); - connect(ui->toolButtonGrainlineHorizontalOrientation, &QToolButton::clicked, this, [this](bool checked) - { - VPSheetPtr sheet = m_layout->GetFocusedSheet(); - if (sheet.isNull()) - { - return; - } - - if (checked) - { - sheet->SetGrainlineType(GrainlineType::Horizontal); - ui->toolButtonGrainlineVerticalOrientation->setChecked(false); - } - else - { - sheet->SetGrainlineType(GrainlineType::NotFixed); - } - - RotatePiecesToGrainline(); - LayoutWasSaved(false); - }); - - connect(ui->toolButtonGrainlineVerticalOrientation, &QToolButton::clicked, this, [this](bool checked) - { - VPSheetPtr sheet = m_layout->GetFocusedSheet(); - if (sheet.isNull()) - { - return; - } - - if (checked) - { - sheet->SetGrainlineType(GrainlineType::Vertical); - ui->toolButtonGrainlineHorizontalOrientation->setChecked(false); - } - else - { - sheet->SetGrainlineType(GrainlineType::NotFixed); - } - - RotatePiecesToGrainline(); - LayoutWasSaved(false); - }); - - connect(ui->pushButtonSheetRemoveUnusedLength, &QPushButton::clicked, this, [this]() - { - if (not m_layout.isNull()) - { - VPSheetPtr sheet = m_layout->GetFocusedSheet(); - if (not sheet.isNull()) + connect(ui->toolButtonGrainlineHorizontalOrientation, &QToolButton::clicked, this, + [this](bool checked) { - sheet->RemoveUnusedLength(); + VPSheetPtr sheet = m_layout->GetFocusedSheet(); + if (sheet.isNull()) + { + return; + } + + if (checked) + { + sheet->SetGrainlineType(GrainlineType::Horizontal); + ui->toolButtonGrainlineVerticalOrientation->setChecked(false); + } + else + { + sheet->SetGrainlineType(GrainlineType::NotFixed); + } + + RotatePiecesToGrainline(); LayoutWasSaved(false); - m_layout->TileFactory()->RefreshTileInfos(); - m_graphicsView->RefreshLayout(); - m_graphicsView->RefreshPieces(); - SetPropertyTabSheetData(); - } - } - }); + }); + + connect(ui->toolButtonGrainlineVerticalOrientation, &QToolButton::clicked, this, + [this](bool checked) + { + VPSheetPtr sheet = m_layout->GetFocusedSheet(); + if (sheet.isNull()) + { + return; + } + + if (checked) + { + sheet->SetGrainlineType(GrainlineType::Vertical); + ui->toolButtonGrainlineHorizontalOrientation->setChecked(false); + } + else + { + sheet->SetGrainlineType(GrainlineType::NotFixed); + } + + RotatePiecesToGrainline(); + LayoutWasSaved(false); + }); + + connect(ui->pushButtonSheetRemoveUnusedLength, &QPushButton::clicked, this, + [this]() + { + if (not m_layout.isNull()) + { + VPSheetPtr sheet = m_layout->GetFocusedSheet(); + if (not sheet.isNull()) + { + sheet->RemoveUnusedLength(); + LayoutWasSaved(false); + m_layout->TileFactory()->RefreshTileInfos(); + m_graphicsView->RefreshLayout(); + m_graphicsView->RefreshPieces(); + SetPropertyTabSheetData(); + } + } + }); } //--------------------------------------------------------------------------------------------------------------------- @@ -953,27 +954,28 @@ void VPMainWindow::InitMarginsData(const QString &suffix) connect(ui->doubleSpinBoxSheetMarginLeft, QOverload::of(&QDoubleSpinBox::valueChanged), this, &VPMainWindow::on_SheetMarginChanged); - connect(ui->checkBoxLayoutIgnoreFileds, &QCheckBox::stateChanged, this, [this](int state) - { - if (not m_layout.isNull()) - { - ui->doubleSpinBoxSheetMarginLeft->setDisabled(state != 0); - ui->doubleSpinBoxSheetMarginRight->setDisabled(state != 0); - ui->doubleSpinBoxSheetMarginTop->setDisabled(state != 0); - ui->doubleSpinBoxSheetMarginBottom->setDisabled(state != 0); - - VPSheetPtr sheet = m_layout->GetFocusedSheet(); - if (not sheet.isNull()) + connect(ui->checkBoxLayoutIgnoreFileds, &QCheckBox::stateChanged, this, + [this](int state) { - sheet->SetIgnoreMargins(state != 0); - LayoutWasSaved(false); - m_layout->TileFactory()->RefreshTileInfos(); - m_graphicsView->RefreshLayout(); + if (not m_layout.isNull()) + { + ui->doubleSpinBoxSheetMarginLeft->setDisabled(state != 0); + ui->doubleSpinBoxSheetMarginRight->setDisabled(state != 0); + ui->doubleSpinBoxSheetMarginTop->setDisabled(state != 0); + ui->doubleSpinBoxSheetMarginBottom->setDisabled(state != 0); - sheet->ValidatePiecesOutOfBound(); - } - } - }); + VPSheetPtr sheet = m_layout->GetFocusedSheet(); + if (not sheet.isNull()) + { + sheet->SetIgnoreMargins(state != 0); + LayoutWasSaved(false); + m_layout->TileFactory()->RefreshTileInfos(); + m_graphicsView->RefreshLayout(); + + sheet->ValidatePiecesOutOfBound(); + } + } + }); } //--------------------------------------------------------------------------------------------------------------------- @@ -982,8 +984,8 @@ void VPMainWindow::InitPropertyTabTiles() // -------------------- tiles template VAbstractLayoutDialog::InitTileTemplates(ui->comboBoxTileTemplates, true); - connect(ui->comboBoxTileTemplates, QOverload::of(&QComboBox::currentIndexChanged), - this, [this]{TileSize(TileTemplate());}); + connect(ui->comboBoxTileTemplates, QOverload::of(&QComboBox::currentIndexChanged), this, + [this] { TileSize(TileTemplate()); }); // -------------------- paper size --------------------------- MinimumTilePaperSize(); @@ -1017,141 +1019,151 @@ void VPMainWindow::InitPropertyTabTiles() connect(ui->doubleSpinBoxTileMarginLeft, QOverload::of(&QDoubleSpinBox::valueChanged), this, &VPMainWindow::on_TilesMarginChanged); - connect(ui->checkBoxTileIgnoreFileds, &QCheckBox::stateChanged, this, [this](int state) - { - if (not m_layout.isNull()) - { - ui->doubleSpinBoxTileMarginLeft->setDisabled(state != 0); - ui->doubleSpinBoxTileMarginRight->setDisabled(state != 0); - ui->doubleSpinBoxTileMarginTop->setDisabled(state != 0); - ui->doubleSpinBoxTileMarginBottom->setDisabled(state != 0); + connect(ui->checkBoxTileIgnoreFileds, &QCheckBox::stateChanged, this, + [this](int state) + { + if (not m_layout.isNull()) + { + ui->doubleSpinBoxTileMarginLeft->setDisabled(state != 0); + ui->doubleSpinBoxTileMarginRight->setDisabled(state != 0); + ui->doubleSpinBoxTileMarginTop->setDisabled(state != 0); + ui->doubleSpinBoxTileMarginBottom->setDisabled(state != 0); - m_layout->LayoutSettings().SetIgnoreTilesMargins(state != 0); - LayoutWasSaved(false); - m_layout->TileFactory()->RefreshTileInfos(); - m_graphicsView->RefreshLayout(); - VMainGraphicsView::NewSceneRect(m_graphicsView->scene(), m_graphicsView); - } - }); + m_layout->LayoutSettings().SetIgnoreTilesMargins(state != 0); + LayoutWasSaved(false); + m_layout->TileFactory()->RefreshTileInfos(); + m_graphicsView->RefreshLayout(); + VMainGraphicsView::NewSceneRect(m_graphicsView->scene(), m_graphicsView); + } + }); // -------------------- control ------------------------ - connect(ui->checkBoxTilesShowTiles, &QCheckBox::toggled, this, [this](bool checked) - { - if (not m_layout.isNull()) - { - m_layout->LayoutSettings().SetShowTiles(checked); - LayoutWasSaved(false); - m_graphicsView->RefreshLayout(); - VMainGraphicsView::NewSceneRect(m_graphicsView->scene(), m_graphicsView); - } - }); + connect(ui->checkBoxTilesShowTiles, &QCheckBox::toggled, this, + [this](bool checked) + { + if (not m_layout.isNull()) + { + m_layout->LayoutSettings().SetShowTiles(checked); + LayoutWasSaved(false); + m_graphicsView->RefreshLayout(); + VMainGraphicsView::NewSceneRect(m_graphicsView->scene(), m_graphicsView); + } + }); - connect(ui->checkBoxTilesShowWatermark, &QCheckBox::toggled, this, [this](bool checked) - { - if (not m_layout.isNull()) - { - m_layout->LayoutSettings().SetShowWatermark(checked); - LayoutWasSaved(false); - m_graphicsView->RefreshLayout(); - VMainGraphicsView::NewSceneRect(m_graphicsView->scene(), m_graphicsView); - } - }); + connect(ui->checkBoxTilesShowWatermark, &QCheckBox::toggled, this, + [this](bool checked) + { + if (not m_layout.isNull()) + { + m_layout->LayoutSettings().SetShowWatermark(checked); + LayoutWasSaved(false); + m_graphicsView->RefreshLayout(); + VMainGraphicsView::NewSceneRect(m_graphicsView->scene(), m_graphicsView); + } + }); - connect(ui->checkBoxPrintTilesScheme, &QCheckBox::toggled, this, [this](bool checked) - { - if (not m_layout.isNull()) - { - m_layout->LayoutSettings().SetPrintTilesScheme(checked); - LayoutWasSaved(false); - } - }); + connect(ui->checkBoxPrintTilesScheme, &QCheckBox::toggled, this, + [this](bool checked) + { + if (not m_layout.isNull()) + { + m_layout->LayoutSettings().SetPrintTilesScheme(checked); + LayoutWasSaved(false); + } + }); - connect(ui->checkBoxShowTileNumber, &QCheckBox::toggled, this, [this](bool checked) - { - if (not m_layout.isNull()) - { - m_layout->LayoutSettings().SetShowTileNumber(checked); - LayoutWasSaved(false); - m_graphicsView->RefreshLayout(); - } - }); + connect(ui->checkBoxShowTileNumber, &QCheckBox::toggled, this, + [this](bool checked) + { + if (not m_layout.isNull()) + { + m_layout->LayoutSettings().SetShowTileNumber(checked); + LayoutWasSaved(false); + m_graphicsView->RefreshLayout(); + } + }); } //--------------------------------------------------------------------------------------------------------------------- void VPMainWindow::InitPropertyTabLayout() { - connect(ui->lineEditLayoutName, &QLineEdit::textEdited, this, [this](const QString &text) - { - if (not m_layout.isNull()) - { - m_layout->LayoutSettings().SetTitle(text); - LayoutWasSaved(false); - } - }); + connect(ui->lineEditLayoutName, &QLineEdit::textEdited, this, + [this](const QString &text) + { + if (not m_layout.isNull()) + { + m_layout->LayoutSettings().SetTitle(text); + LayoutWasSaved(false); + } + }); - connect(ui->plainTextEditLayoutDescription, &QPlainTextEdit::textChanged, this, [this]() - { - if (not m_layout.isNull()) - { - m_layout->LayoutSettings().SetDescription(ui->plainTextEditLayoutDescription->toPlainText()); - LayoutWasSaved(false); - } - }); + connect(ui->plainTextEditLayoutDescription, &QPlainTextEdit::textChanged, this, + [this]() + { + if (not m_layout.isNull()) + { + m_layout->LayoutSettings().SetDescription(ui->plainTextEditLayoutDescription->toPlainText()); + LayoutWasSaved(false); + } + }); connect(ui->checkBoxLayoutWarningPiecesSuperposition, &QCheckBox::toggled, this, &VPMainWindow::LayoutWarningPiecesSuperposition_toggled); connect(ui->checkBoxLayoutWarningPiecesOutOfBound, &QCheckBox::toggled, this, &VPMainWindow::LayoutWarningPiecesOutOfBound_toggled); - connect(ui->checkBoxSheetStickyEdges, &QCheckBox::toggled, this, [this](bool checked) - { - if (not m_layout.isNull()) - { - m_layout->LayoutSettings().SetStickyEdges(checked); - LayoutWasSaved(false); - } - }); - - connect(ui->checkBoxFollowGainline, &QCheckBox::toggled, this, [this](bool checked) - { - if (not m_layout.isNull()) - { - m_layout->LayoutSettings().SetFollowGrainline(checked); - - if (checked) + connect(ui->checkBoxSheetStickyEdges, &QCheckBox::toggled, this, + [this](bool checked) { - RotatePiecesToGrainline(); - } + if (not m_layout.isNull()) + { + m_layout->LayoutSettings().SetStickyEdges(checked); + LayoutWasSaved(false); + } + }); - LayoutWasSaved(false); - } - }); + connect(ui->checkBoxFollowGainline, &QCheckBox::toggled, this, + [this](bool checked) + { + if (not m_layout.isNull()) + { + m_layout->LayoutSettings().SetFollowGrainline(checked); + + if (checked) + { + RotatePiecesToGrainline(); + } + + LayoutWasSaved(false); + } + }); VPSettings *settings = VPApplication::VApp()->PuzzleSettings(); ui->doubleSpinBoxSheetPiecesGap->setMaximum( - UnitConvertor(VPSettings::GetMaxLayoutPieceGap(), Unit::Px, settings->LayoutUnit())); + UnitConvertor(VPSettings::GetMaxLayoutPieceGap(), Unit::Px, settings->LayoutUnit())); ui->doubleSpinBoxSheetPiecesGap->setSuffix(" " + UnitsToStr(LayoutUnit(), true)); connect(ui->doubleSpinBoxSheetPiecesGap, QOverload::of(&QDoubleSpinBox::valueChanged), this, [this](double d) - { - if (not m_layout.isNull()) - { - m_layout->LayoutSettings().SetPiecesGapConverted(d); - LayoutWasSaved(false); - } - }); + { + if (not m_layout.isNull()) + { + m_layout->LayoutSettings().SetPiecesGapConverted(d); + LayoutWasSaved(false); + } + }); - connect(ui->toolButtonScaleConnected, &QToolButton::clicked, this, [this]() - { - m_scaleConnected = not m_scaleConnected; + connect(ui->toolButtonScaleConnected, &QToolButton::clicked, this, + [this]() + { + m_scaleConnected = not m_scaleConnected; - UpdateScaleConnection(); - }); + UpdateScaleConnection(); + }); - connect(ui->doubleSpinBoxHorizontalScale, QOverload::of(&QDoubleSpinBox::valueChanged), - this, &VPMainWindow::HorizontalScaleChanged); - connect(ui->doubleSpinBoxVerticalScale, QOverload::of(&QDoubleSpinBox::valueChanged), - this, &VPMainWindow::VerticalScaleChanged); + connect(ui->doubleSpinBoxHorizontalScale, QOverload::of(&QDoubleSpinBox::valueChanged), this, + &VPMainWindow::HorizontalScaleChanged); + connect(ui->doubleSpinBoxVerticalScale, QOverload::of(&QDoubleSpinBox::valueChanged), this, + &VPMainWindow::VerticalScaleChanged); connect(ui->pushButtonLayoutExport, &QPushButton::clicked, this, &VPMainWindow::on_ExportLayout); } @@ -1162,7 +1174,7 @@ void VPMainWindow::InitCarrousel() ui->dockWidgetCarrousel->setWidget(m_carrousel); connect(ui->dockWidgetCarrousel, QOverload::of(&QDockWidget::dockLocationChanged), this, - &VPMainWindow::on_CarrouselLocationChanged); + &VPMainWindow::on_CarrouselLocationChanged); } //--------------------------------------------------------------------------------------------------------------------- @@ -1181,21 +1193,21 @@ void VPMainWindow::SetPropertyTabCurrentPieceData() ui->labelCurrentPieceNoPieceSelected->setVisible(false); - if(selectedPieces.isEmpty()) + if (selectedPieces.isEmpty()) { // show the content "no piece selected" ui->labelCurrentPieceNoPieceSelected->setVisible(true); ui->groupBoxCurrentPieceInfo->setVisible(false); ui->groupBoxPieceTransformation->setVisible(false); - ui-> groupBoxCurrentPieceSeamline->setVisible(false); + ui->groupBoxCurrentPieceSeamline->setVisible(false); ui->groupBoxCurrentPieceGeometry->setVisible(false); } - else if(selectedPieces.count() == 1) + else if (selectedPieces.count() == 1) { ui->groupBoxCurrentPieceInfo->setVisible(true); ui->groupBoxPieceTransformation->setVisible(true); - ui-> groupBoxCurrentPieceSeamline->setVisible(true); + ui->groupBoxCurrentPieceSeamline->setVisible(true); ui->groupBoxCurrentPieceGeometry->setVisible(true); const VPPiecePtr &selectedPiece = ConstFirst(selectedPieces); @@ -1216,9 +1228,9 @@ void VPMainWindow::SetPropertyTabCurrentPieceData() QRectF rect = PiecesBoundingRect(selectedPieces); ui->doubleSpinBoxCurrentPieceBoxPositionX->setValue( - UnitConvertor(rect.topLeft().x(), Unit::Px, TranslateUnit())); + UnitConvertor(rect.topLeft().x(), Unit::Px, TranslateUnit())); ui->doubleSpinBoxCurrentPieceBoxPositionY->setValue( - UnitConvertor(rect.topLeft().y(), Unit::Px, TranslateUnit())); + UnitConvertor(rect.topLeft().y(), Unit::Px, TranslateUnit())); } } else @@ -1234,9 +1246,9 @@ void VPMainWindow::SetPropertyTabCurrentPieceData() QRectF rect = PiecesBoundingRect(selectedPieces); ui->doubleSpinBoxCurrentPieceBoxPositionX->setValue( - UnitConvertor(rect.topLeft().x(), Unit::Px, TranslateUnit())); + UnitConvertor(rect.topLeft().x(), Unit::Px, TranslateUnit())); ui->doubleSpinBoxCurrentPieceBoxPositionY->setValue( - UnitConvertor(rect.topLeft().y(), Unit::Px, TranslateUnit())); + UnitConvertor(rect.topLeft().y(), Unit::Px, TranslateUnit())); } } } @@ -1442,10 +1454,8 @@ void VPMainWindow::SetPropertyTabLayoutData() m_layout->LayoutSettings().GetWarningPiecesOutOfBound()); SetCheckBoxValue(ui->checkBoxLayoutWarningPiecesSuperposition, m_layout->LayoutSettings().GetWarningSuperpositionOfPieces()); - SetCheckBoxValue(ui->checkBoxSheetStickyEdges, - m_layout->LayoutSettings().GetStickyEdges()); - SetCheckBoxValue(ui->checkBoxFollowGainline, - m_layout->LayoutSettings().GetFollowGrainline()); + SetCheckBoxValue(ui->checkBoxSheetStickyEdges, m_layout->LayoutSettings().GetStickyEdges()); + SetCheckBoxValue(ui->checkBoxFollowGainline, m_layout->LayoutSettings().GetFollowGrainline()); // set pieces gap SetDoubleSpinBoxValue(ui->doubleSpinBoxSheetPiecesGap, m_layout->LayoutSettings().GetPiecesGapConverted()); @@ -1491,8 +1501,6 @@ void VPMainWindow::SetPropertyTabLayoutData() } } - - //--------------------------------------------------------------------------------------------------------------------- void VPMainWindow::InitMainGraphics() { @@ -1578,23 +1586,22 @@ void VPMainWindow::InitZoomToolBar() //--------------------------------------------------------------------------------------------------------------------- void VPMainWindow::InitScaleToolBar() { - auto* zoomScale = new QLabel(tr("Scale:"), this); + auto *zoomScale = new QLabel(tr("Scale:"), this); ui->toolBarScale->addWidget(zoomScale); m_doubleSpinBoxScale = new QDoubleSpinBox(this); m_doubleSpinBoxScale->setDecimals(1); m_doubleSpinBoxScale->setSuffix(QChar('%')); on_ScaleChanged(m_graphicsView->transform().m11()); - connect(m_doubleSpinBoxScale.data(), QOverload::of(&QDoubleSpinBox::valueChanged), - this, [this](double d){m_graphicsView->Zoom(d/100.0);}); + connect(m_doubleSpinBoxScale.data(), QOverload::of(&QDoubleSpinBox::valueChanged), this, + [this](double d) { m_graphicsView->Zoom(d / 100.0); }); ui->toolBarScale->addWidget(m_doubleSpinBoxScale); - // define the mouse position ui->toolBarScale->addSeparator(); - m_mouseCoordinate = new QLabel(QStringLiteral("0, 0 (%1)") - .arg(UnitsToStr(m_layout->LayoutSettings().GetUnit(), true))); + m_mouseCoordinate = + new QLabel(QStringLiteral("0, 0 (%1)").arg(UnitsToStr(m_layout->LayoutSettings().GetUnit(), true))); ui->toolBarScale->addWidget(m_mouseCoordinate); ui->toolBarScale->addSeparator(); } @@ -1612,7 +1619,7 @@ void VPMainWindow::UpdateWindowTitle() vsizetype index = VPApplication::VApp()->MainWindows().indexOf(this); if (index != -1) { - showName = tr("untitled %1.vlt").arg(index+1); + showName = tr("untitled %1.vlt").arg(index + 1); } else { @@ -1631,8 +1638,7 @@ void VPMainWindow::UpdateWindowTitle() setWindowFilePath(curFile); #if defined(Q_OS_MAC) - static QIcon fileIcon = QIcon(QCoreApplication::applicationDirPath() + - QLatin1String("/../Resources/layout.icns")); + static QIcon fileIcon = QIcon(QCoreApplication::applicationDirPath() + QLatin1String("/../Resources/layout.icns")); QIcon icon; if (not curFile.isEmpty()) { @@ -1652,7 +1658,7 @@ void VPMainWindow::UpdateWindowTitle() } } setWindowIcon(icon); -#endif //defined(Q_OS_MAC) +#endif // defined(Q_OS_MAC) } //--------------------------------------------------------------------------------------------------------------------- @@ -1747,19 +1753,16 @@ void VPMainWindow::CreateWindowMenu(QMenu *menu) SCASSERT(menu != nullptr) QAction *action = menu->addAction(tr("&New Window")); - connect(action, &QAction::triggered, this, []() - { - VPApplication::VApp()->NewMainWindow()->activateWindow(); - }); + connect(action, &QAction::triggered, this, []() { VPApplication::VApp()->NewMainWindow()->activateWindow(); }); action->setMenuRole(QAction::NoRole); menu->addSeparator(); - const QList windows = VPApplication::VApp()->MainWindows(); + const QList windows = VPApplication::VApp()->MainWindows(); for (int i = 0; i < windows.count(); ++i) { VPMainWindow *window = windows.at(i); - QString title = QStringLiteral("%1. %2").arg(i+1).arg(window->windowTitle()); + QString title = QStringLiteral("%1. %2").arg(i + 1).arg(window->windowTitle()); const vsizetype index = title.lastIndexOf(QLatin1String("[*]")); if (index != -1) { @@ -1770,7 +1773,7 @@ void VPMainWindow::CreateWindowMenu(QMenu *menu) QAction *action = menu->addAction(title, this, SLOT(ShowWindow())); #else QAction *action = menu->addAction(title, this, &VPMainWindow::ShowWindow); -#endif //QT_VERSION < QT_VERSION_CHECK(5, 6, 0) +#endif // QT_VERSION < QT_VERSION_CHECK(5, 6, 0) action->setData(i); action->setCheckable(true); action->setMenuRole(QAction::NoRole); @@ -1796,15 +1799,15 @@ auto VPMainWindow::IsLayoutReadOnly() const -> bool return 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*/ bool fileWritable = f.isWritable(); -//#ifdef Q_OS_WIN32 -// qt_ntfs_permission_lookup--; // turn it off again -//#endif /*Q_OS_WIN32*/ + // #ifdef Q_OS_WIN32 + // qt_ntfs_permission_lookup--; // turn it off again + // #endif /*Q_OS_WIN32*/ return not fileWritable; } @@ -1815,13 +1818,14 @@ void VPMainWindow::ConnectToPreferences(const QSharedPointerRefreshScenePieces(); - } - }); + connect(preferences.data(), &DialogPuzzlePreferences::UpdateProperties, this, + [this]() + { + if (not m_layout.isNull()) + { + m_layout->RefreshScenePieces(); + } + }); } //--------------------------------------------------------------------------------------------------------------------- @@ -2048,10 +2052,10 @@ void VPMainWindow::FindTemplate(QComboBox *box, qreal width, qreal height) const Unit paperUnit = LayoutUnit(); const int max = static_cast(VAbstractLayoutDialog::PaperSizeTemplate::Custom); - for (int i=0; i < max; ++i) + for (int i = 0; i < max; ++i) { - const QSizeF tmplSize = VAbstractLayoutDialog::GetTemplateSize( - static_cast(i), paperUnit); + const QSizeF tmplSize = + VAbstractLayoutDialog::GetTemplateSize(static_cast(i), paperUnit); if (QSizeF(width, height) == tmplSize || QSizeF(height, width) == tmplSize) { box->blockSignals(true); @@ -2097,8 +2101,8 @@ void VPMainWindow::CorrectTileMaxMargins() const qreal tileHeight = ui->doubleSpinBoxTilePaperHeight->value(); // 80%/2 of paper size for each field - const qreal tileWidthMargin = (tileWidth*80.0/100.0)/2.0; - const qreal tileHeightMargin = (tileHeight*80.0/100.0)/2.0; + const qreal tileWidthMargin = (tileWidth * 80.0 / 100.0) / 2.0; + const qreal tileHeightMargin = (tileHeight * 80.0 / 100.0) / 2.0; ui->doubleSpinBoxTileMarginLeft->setMaximum(tileWidthMargin); ui->doubleSpinBoxTileMarginRight->setMaximum(tileWidthMargin); @@ -2113,8 +2117,8 @@ void VPMainWindow::CorrectSheetMaxMargins() const qreal sheetHeight = ui->doubleSpinBoxSheetPaperHeight->value(); // 80%/2 of paper size for each field - const qreal sheetWidthMargin = (sheetWidth*80.0/100.0)/2.0; - const qreal sheetHeightMargin = (sheetHeight*80.0/100.0)/2.0; + const qreal sheetWidthMargin = (sheetWidth * 80.0 / 100.0) / 2.0; + const qreal sheetHeightMargin = (sheetHeight * 80.0 / 100.0) / 2.0; ui->doubleSpinBoxSheetMarginLeft->setMaximum(sheetWidthMargin); ui->doubleSpinBoxSheetMarginRight->setMaximum(sheetWidthMargin); @@ -2138,12 +2142,12 @@ void VPMainWindow::RotatePiecesToGrainline() } QList sheets = m_layout->GetAllSheets(); - for(const auto& sheet : sheets) + for (const auto &sheet : sheets) { if (not sheet.isNull()) { QList pieces = sheet->GetPieces(); - for(const auto& piece : pieces) + for (const auto &piece : pieces) { if (not piece.isNull() && piece->IsGrainlineEnabled()) { @@ -2175,8 +2179,8 @@ void VPMainWindow::ExportData(const VPExportData &data) if (data.sheets.size() > 1) { - name = data.path + '/' + data.fileName + - QString::number(i+1) + VLayoutExporter::ExportFormatSuffix(data.format); + name = data.path + '/' + data.fileName + QString::number(i + 1) + + VLayoutExporter::ExportFormatSuffix(data.format); } else { @@ -2261,7 +2265,8 @@ void VPMainWindow::ExportFlatLayout(const VPExportData &data) ExportPdfTiledFile(data); } else if ((data.format == LayoutExportFormats::PDF || data.format == LayoutExportFormats::PS || - data.format == LayoutExportFormats::EPS) && data.exportUnified) + data.format == LayoutExportFormats::EPS) && + data.exportUnified) { ExportUnifiedPdfFile(data); } @@ -2291,9 +2296,9 @@ void VPMainWindow::ExportScene(const VPExportData &data) QList sheets = data.sheets; - for (int i=0; i < sheets.size(); ++i) + for (int i = 0; i < sheets.size(); ++i) { - const VPSheetPtr& sheet = sheets.at(i); + const VPSheetPtr &sheet = sheets.at(i); if (sheet.isNull()) { continue; @@ -2309,8 +2314,8 @@ void VPMainWindow::ExportScene(const VPExportData &data) QString name; if (sheets.size() > 1) { - name = data.path + '/' + data.fileName + QString::number(i+1) + - VLayoutExporter::ExportFormatSuffix(data.format); + name = data.path + '/' + data.fileName + QString::number(i + 1) + + VLayoutExporter::ExportFormatSuffix(data.format); } else { @@ -2445,7 +2450,7 @@ void VPMainWindow::GenerateUnifiedPdfFile(const VPExportData &data, const QStrin bool firstPage = true; - for (const auto& sheet : data.sheets) + for (const auto &sheet : data.sheets) { if (sheet.isNull()) { @@ -2463,8 +2468,8 @@ void VPMainWindow::GenerateUnifiedPdfFile(const VPExportData &data, const QStrin } painter.setRenderHint(QPainter::Antialiasing, true); - painter.setPen(QPen(Qt::black, VAbstractApplication::VApp()->Settings()->WidthHairLine(), - Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin)); + painter.setPen(QPen(Qt::black, VAbstractApplication::VApp()->Settings()->WidthHairLine(), Qt::SolidLine, + Qt::RoundCap, Qt::RoundJoin)); painter.setBrush(QBrush(Qt::NoBrush)); painter.scale(data.xScale, data.yScale); } @@ -2513,7 +2518,7 @@ void VPMainWindow::ExportPdfTiledFile(const VPExportData &data) QPainter painter; bool firstPage = true; - for (const auto& sheet : data.sheets) + for (const auto &sheet : data.sheets) { if (not GeneratePdfTiledFile(sheet, data.showTilesScheme, data.showGrainline, &painter, printer, firstPage)) { @@ -2525,7 +2530,7 @@ void VPMainWindow::ExportPdfTiledFile(const VPExportData &data) { for (int i = 0; i < data.sheets.size(); ++i) { - const QString name = data.path + '/' + data.fileName + QString::number(i+1) + + const QString name = data.path + '/' + data.fileName + QString::number(i + 1) + VLayoutExporter::ExportFormatSuffix(data.format); printer->setOutputFileName(name); @@ -2580,7 +2585,7 @@ auto VPMainWindow::GeneratePdfTiledFile(const VPSheetPtr &sheet, bool showTilesS } painter->setPen(QPen(Qt::black, VAbstractApplication::VApp()->Settings()->WidthMainLine(), Qt::SolidLine, - Qt::RoundCap, Qt::RoundJoin)); + Qt::RoundCap, Qt::RoundJoin)); painter->setBrush(QBrush(Qt::NoBrush)); painter->setRenderHint(QPainter::Antialiasing, true); } @@ -2594,14 +2599,14 @@ auto VPMainWindow::GeneratePdfTiledFile(const VPSheetPtr &sheet, bool showTilesS firstPage = false; } - for(int row=0; row < m_layout->TileFactory()->RowNb(sheet); row++) // for each row of the tiling grid + for (int row = 0; row < m_layout->TileFactory()->RowNb(sheet); row++) // for each row of the tiling grid { - for(int col=0; col < m_layout->TileFactory()->ColNb(sheet); col++) // for each column of tiling grid + for (int col = 0; col < m_layout->TileFactory()->ColNb(sheet); col++) // for each column of tiling grid { - if(not firstPage) + if (not firstPage) { - SetPrinterTiledPageSettings(printer, m_layout, sheet, - m_layout->LayoutSettings().GetTilesOrientation(), false); + SetPrinterTiledPageSettings(printer, m_layout, sheet, m_layout->LayoutSettings().GetTilesOrientation(), + false); if (not printer->newPage()) { @@ -2631,10 +2636,10 @@ void VPMainWindow::UpdateScaleConnection() const //--------------------------------------------------------------------------------------------------------------------- void VPMainWindow::OpenWatermark(const QString &path) { - for (const auto & m_watermarkEditor : qAsConst(m_watermarkEditors)) + for (const auto &m_watermarkEditor : qAsConst(m_watermarkEditors)) { - if (not m_watermarkEditor.isNull() && not m_watermarkEditor->CurrentFile().isEmpty() - && m_watermarkEditor->CurrentFile() == AbsoluteMPath(curFile, path)) + if (not m_watermarkEditor.isNull() && not m_watermarkEditor->CurrentFile().isEmpty() && + m_watermarkEditor->CurrentFile() == AbsoluteMPath(curFile, path)) { m_watermarkEditor->show(); return; @@ -2642,8 +2647,8 @@ void VPMainWindow::OpenWatermark(const QString &path) } auto *watermark = new WatermarkWindow(curFile, this); - connect(watermark, &WatermarkWindow::New, this, [this](){OpenWatermark();}); - connect(watermark, &WatermarkWindow::OpenAnother, this, [this](const QString &path){OpenWatermark(path);}); + connect(watermark, &WatermarkWindow::New, this, [this]() { OpenWatermark(); }); + connect(watermark, &WatermarkWindow::OpenAnother, this, [this](const QString &path) { OpenWatermark(path); }); m_watermarkEditors.append(watermark); watermark->show(); watermark->Open(path); @@ -2664,8 +2669,8 @@ void VPMainWindow::CleanWaterkmarkEditors() } //--------------------------------------------------------------------------------------------------------------------- -auto VPMainWindow::DrawTilesScheme(QPrinter *printer, QPainter *painter, const VPSheetPtr &sheet, - bool firstPage) -> bool +auto VPMainWindow::DrawTilesScheme(QPrinter *printer, QPainter *painter, const VPSheetPtr &sheet, bool firstPage) + -> bool { SCASSERT(printer != nullptr) SCASSERT(painter != nullptr) @@ -2675,7 +2680,7 @@ auto VPMainWindow::DrawTilesScheme(QPrinter *printer, QPainter *painter, const V return false; } - if(not firstPage) + if (not firstPage) { printer->setPageOrientation(sheet->GetSheetOrientation()); @@ -2702,9 +2707,8 @@ auto VPMainWindow::DrawTilesScheme(QPrinter *printer, QPainter *painter, const V const int nbCol = m_layout->TileFactory()->ColNb(sheet); const int nbRow = m_layout->TileFactory()->RowNb(sheet); - QRectF source = QRectF(sheetRect.topLeft(), - QSizeF(nbCol * ((width - VPTileFactory::tileStripeWidth) / xScale), - nbRow * ((height - VPTileFactory::tileStripeWidth) / yScale))); + QRectF source = QRectF(sheetRect.topLeft(), QSizeF(nbCol * ((width - VPTileFactory::tileStripeWidth) / xScale), + nbRow * ((height - VPTileFactory::tileStripeWidth) / yScale))); QRectF target; if (tileOrientation != sheetOrientation) @@ -2716,8 +2720,7 @@ auto VPMainWindow::DrawTilesScheme(QPrinter *printer, QPainter *painter, const V } QSizeF tilesSize = m_layout->LayoutSettings().GetTilesSize(); - target = QRectF(0, 0, - tilesSize.height() - margins.left() - margins.right(), + target = QRectF(0, 0, tilesSize.height() - margins.left() - margins.right(), tilesSize.width() - margins.top() - margins.bottom()); } else @@ -2764,9 +2767,9 @@ auto VPMainWindow::AskLayoutIsInvalid(const QList &sheets) -> bool bool pieceSuperpositionChecked = false; QList pieces = sheet->GetPieces(); - for (const auto& piece :pieces) + for (const auto &piece : pieces) { - if(not CheckPiecesOutOfBound(piece, outOfBoundChecked)) + if (not CheckPiecesOutOfBound(piece, outOfBoundChecked)) { return false; } @@ -2792,11 +2795,11 @@ auto VPMainWindow::CheckPiecesOutOfBound(const VPPiecePtr &piece, bool &outOfBou msgBox.setIcon(QMessageBox::Question); msgBox.setWindowTitle(tr("The layout is invalid.")); msgBox.setText(tr("The layout is invalid. Piece out of bound. Do you want to continue export?")); - msgBox.setStandardButtons(QMessageBox::Yes|QMessageBox::No); + msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No); msgBox.setDefaultButton(QMessageBox::No); const int width = 500; - auto* horizontalSpacer = new QSpacerItem(width, 0, QSizePolicy::Minimum, QSizePolicy::Expanding); - auto* layout = qobject_cast(msgBox.layout()); + auto *horizontalSpacer = new QSpacerItem(width, 0, QSizePolicy::Minimum, QSizePolicy::Expanding); + auto *layout = qobject_cast(msgBox.layout()); SCASSERT(layout != nullptr) layout->addItem(horizontalSpacer, layout->rowCount(), 0, 1, layout->columnCount()); if (msgBox.exec() == QMessageBox::No) @@ -2822,11 +2825,11 @@ auto VPMainWindow::CheckSuperpositionOfPieces(const VPPiecePtr &piece, bool &pie msgBox.setWindowTitle(tr("The layout is invalid.")); msgBox.setText(tr("The layout is invalid. Pieces superposition. Do you want to continue " "export?")); - msgBox.setStandardButtons(QMessageBox::Yes|QMessageBox::No); + msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No); msgBox.setDefaultButton(QMessageBox::No); const int width = 500; - auto* horizontalSpacer = new QSpacerItem(width, 0, QSizePolicy::Minimum, QSizePolicy::Expanding); - auto* layout = qobject_cast(msgBox.layout()); + auto *horizontalSpacer = new QSpacerItem(width, 0, QSizePolicy::Minimum, QSizePolicy::Expanding); + auto *layout = qobject_cast(msgBox.layout()); SCASSERT(layout != nullptr) layout->addItem(horizontalSpacer, layout->rowCount(), 0, 1, layout->columnCount()); if (msgBox.exec() == QMessageBox::No) @@ -2879,8 +2882,8 @@ void VPMainWindow::PrintLayoutSheets(QPrinter *printer, const QList } painter.setRenderHint(QPainter::Antialiasing, true); - painter.setPen(QPen(Qt::black, VAbstractApplication::VApp()->Settings()->WidthHairLine(), - Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin)); + painter.setPen(QPen(Qt::black, VAbstractApplication::VApp()->Settings()->WidthHairLine(), Qt::SolidLine, + Qt::RoundCap, Qt::RoundJoin)); painter.setBrush(QBrush(Qt::NoBrush)); painter.scale(m_layout->LayoutSettings().HorizontalScale(), m_layout->LayoutSettings().VerticalScale()); @@ -2888,10 +2891,10 @@ void VPMainWindow::PrintLayoutSheets(QPrinter *printer, const QList { for (int j = 0; j < numPages; ++j) { - vsizetype index = printer->pageOrder() == QPrinter::FirstPageFirst ? firstPageNumber + j - : lastPageNumber - j; + vsizetype index = + printer->pageOrder() == QPrinter::FirstPageFirst ? firstPageNumber + j : lastPageNumber - j; - const VPSheetPtr& sheet = sheets.at(index); + const VPSheetPtr &sheet = sheets.at(index); if (sheet.isNull()) { continue; @@ -2906,7 +2909,7 @@ void VPMainWindow::PrintLayoutSheets(QPrinter *printer, const QList } //--------------------------------------------------------------------------------------------------------------------- -auto VPMainWindow::PrintLayoutSheetPage(QPrinter *printer, QPainter &painter, const VPSheetPtr& sheet) -> bool +auto VPMainWindow::PrintLayoutSheetPage(QPrinter *printer, QPainter &painter, const VPSheetPtr &sheet) -> bool { SCASSERT(printer != nullptr) @@ -2916,8 +2919,7 @@ auto VPMainWindow::PrintLayoutSheetPage(QPrinter *printer, QPainter &painter, co if (not sheet->IgnoreMargins()) { QMarginsF margins = sheet->GetSheetMargins(); - if (not printer->setPageMargins(UnitConvertor(margins, Unit::Px, Unit::Mm), - QPageLayout::Millimeter)) + if (not printer->setPageMargins(UnitConvertor(margins, Unit::Px, Unit::Mm), QPageLayout::Millimeter)) { qWarning() << QObject::tr("Cannot set printer margins"); } @@ -2931,8 +2933,8 @@ auto VPMainWindow::PrintLayoutSheetPage(QPrinter *printer, QPainter &painter, co sheet->SceneData()->PrepareForExport(); QRectF imageRect = sheet->GetMarginsRect(); - sheet->SceneData()->Scene()->render(&painter, VPrintLayout::SceneTargetRect(printer, imageRect), - imageRect, Qt::IgnoreAspectRatio); + sheet->SceneData()->Scene()->render(&painter, VPrintLayout::SceneTargetRect(printer, imageRect), imageRect, + Qt::IgnoreAspectRatio); sheet->SceneData()->CleanAfterExport(); return true; @@ -2979,8 +2981,8 @@ void VPMainWindow::PrintLayoutTiledSheets(QPrinter *printer, const QListpageOrder() == QPrinter::FirstPageFirst ? firstPageNumber + j - : lastPageNumber - j; + vsizetype index = + printer->pageOrder() == QPrinter::FirstPageFirst ? firstPageNumber + j : lastPageNumber - j; const VPLayoutPrinterPage &page = pages.at(index); if (not PrintLayoutTiledSheetPage(printer, painter, page, firstPage)) @@ -2998,20 +3000,20 @@ auto VPMainWindow::PrepareLayoutTilePages(const QList &sheets) -> QV { QVector pages; - for (const auto& sheet : sheets) + for (const auto &sheet : sheets) { if (m_layout->LayoutSettings().GetPrintTilesScheme()) { VPLayoutPrinterPage page; page.sheet = sheet; - page.tilesScheme = true; + page.tilesScheme = true; pages.append(page); } - for(int row=0; row < m_layout->TileFactory()->RowNb(sheet); row++) // for each row of the tiling grid + for (int row = 0; row < m_layout->TileFactory()->RowNb(sheet); row++) // for each row of the tiling grid { - for(int col=0; col < m_layout->TileFactory()->ColNb(sheet); col++) // for each column of tiling grid + for (int col = 0; col < m_layout->TileFactory()->ColNb(sheet); col++) // for each column of tiling grid { VPLayoutPrinterPage page; page.sheet = sheet; @@ -3069,7 +3071,7 @@ auto VPMainWindow::PrintLayoutTiledSheetPage(QPrinter *printer, QPainter &painte firstPage = false; } - if(not firstPage) + if (not firstPage) { printer->setPageOrientation(m_layout->LayoutSettings().GetTilesOrientation()); @@ -3128,8 +3130,9 @@ auto VPMainWindow::ImportRawLayout(const QString &rawLayout) -> bool return AddLayoutPieces(data.pieces); } - qCCritical(pWindow, "%s\n", qPrintable(tr("Could not extract data from file '%1'. %2") - .arg(rawLayout, rawLayoutReader.ErrorString()))); + qCCritical( + pWindow, "%s\n", + qPrintable(tr("Could not extract data from file '%1'. %2").arg(rawLayout, rawLayoutReader.ErrorString()))); if (m_cmd != nullptr && not m_cmd->IsGuiEnabled()) { m_cmd->ShowHelp(V_EX_DATAERR); @@ -3142,7 +3145,7 @@ auto VPMainWindow::ImportRawLayout(const QString &rawLayout) -> bool //--------------------------------------------------------------------------------------------------------------------- auto VPMainWindow::AddLayoutPieces(const QVector &pieces) -> bool { - for (const auto& rawPiece : pieces) + for (const auto &rawPiece : pieces) { for (quint16 i = 1; i <= rawPiece.GetQuantity(); ++i) { @@ -3195,7 +3198,7 @@ void VPMainWindow::TranslatePieces() } QRectF rect = PiecesBoundingRect(selectedPieces); - for (const auto& piece : qAsConst(selectedPieces)) + for (const auto &piece : qAsConst(selectedPieces)) { TranslatePieceRelatively(piece, rect, selectedPieces.size(), dx, dy); } @@ -3242,12 +3245,12 @@ void VPMainWindow::TranslatePieceRelatively(const VPPiecePtr &piece, const QRect if (not qFuzzyIsNull(rect.width())) { - pieceDx += dx*((pieceRect.topLeft().x()-rect.topLeft().x())/rect.width())*2.; + pieceDx += dx * ((pieceRect.topLeft().x() - rect.topLeft().x()) / rect.width()) * 2.; } if (not qFuzzyIsNull(rect.height())) { - pieceDy += dy*((pieceRect.topLeft().y()-rect.topLeft().y())/rect.height())*2.; + pieceDy += dy * ((pieceRect.topLeft().y() - rect.topLeft().y()) / rect.height()) * 2.; } auto *command = new VPUndoPieceMove(piece, pieceDx, pieceDy); @@ -3286,7 +3289,7 @@ void VPMainWindow::RotatePieces() if (ui->checkBoxTransformSeparately->isChecked()) { m_layout->UndoStack()->beginMacro(tr("rotate pieces")); - for (const auto& piece : selectedPieces) + for (const auto &piece : selectedPieces) { if (not piece.isNull()) { @@ -3382,7 +3385,7 @@ void VPMainWindow::on_actionOpen_triggered() qCDebug(pWindow, "Openning puzzle layout file."); const QString filter(tr("Layout files") + QStringLiteral(" (*.vlt)")); - //Use standard path to individual measurements + // Use standard path to individual measurements const QString pathTo = VPApplication::VApp()->PuzzleSettings()->GetPathManualLayouts(); bool usedNotExistedDir = false; @@ -3414,8 +3417,8 @@ auto VPMainWindow::on_actionSave_triggered() -> bool return on_actionSaveAs_triggered(); } - if (m_curFileFormatVersion < VLayoutConverter::LayoutMaxVer - && not ContinueFormatRewrite(m_curFileFormatVersionStr, VLayoutConverter::LayoutMaxVerStr)) + if (m_curFileFormatVersion < VLayoutConverter::LayoutMaxVer && + not ContinueFormatRewrite(m_curFileFormatVersionStr, VLayoutConverter::LayoutMaxVerStr)) { return false; } @@ -3471,20 +3474,21 @@ auto VPMainWindow::on_actionSaveAs_triggered() -> bool QString fileName = QFileDialog::getSaveFileName(this, tr("Save as"), dir + QChar('/') + fName, filters, nullptr, VAbstractApplication::VApp()->NativeFileDialog()); - auto RemoveTempDir = qScopeGuard([usedNotExistedDir, dir]() - { - if (usedNotExistedDir) + auto RemoveTempDir = qScopeGuard( + [usedNotExistedDir, dir]() { - QDir(dir).rmpath(QChar('.')); - } - }); + if (usedNotExistedDir) + { + QDir(dir).rmpath(QChar('.')); + } + }); if (fileName.isEmpty()) { return false; } - QFileInfo f( fileName ); + QFileInfo f(fileName); if (f.suffix().isEmpty() && f.suffix() != suffix) { fileName += QChar('.') + suffix; @@ -3533,8 +3537,9 @@ auto VPMainWindow::on_actionSaveAs_triggered() -> bool VlpCreateLock(lock, fileName); if (not lock->IsLocked()) { - qCCritical(pWindow, "%s", qUtf8Printable(tr("Failed to lock. This file already opened in another window. " - "Expect collissions when run 2 copies of the program."))); + qCCritical(pWindow, "%s", + qUtf8Printable(tr("Failed to lock. This file already opened in another window. " + "Expect collissions when run 2 copies of the program."))); return false; } return true; @@ -3635,10 +3640,9 @@ void VPMainWindow::on_SheetMarginChanged() VPSheetPtr sheet = m_layout->GetFocusedSheet(); if (not sheet.isNull()) { - sheet->SetSheetMarginsConverted(ui->doubleSpinBoxSheetMarginLeft->value(), - ui->doubleSpinBoxSheetMarginTop->value(), - ui->doubleSpinBoxSheetMarginRight->value(), - ui->doubleSpinBoxSheetMarginBottom->value()); + sheet->SetSheetMarginsConverted( + ui->doubleSpinBoxSheetMarginLeft->value(), ui->doubleSpinBoxSheetMarginTop->value(), + ui->doubleSpinBoxSheetMarginRight->value(), ui->doubleSpinBoxSheetMarginBottom->value()); LayoutWasSaved(false); @@ -3675,9 +3679,8 @@ void VPMainWindow::on_TilesSizeChanged() { if (not m_layout.isNull()) { - m_layout->LayoutSettings().SetTilesSizeConverted( - ui->doubleSpinBoxTilePaperWidth->value(), - ui->doubleSpinBoxTilePaperHeight->value()); + m_layout->LayoutSettings().SetTilesSizeConverted(ui->doubleSpinBoxTilePaperWidth->value(), + ui->doubleSpinBoxTilePaperHeight->value()); FindTileTemplate(); TilePaperSizeChanged(); CorrectMaxMargins(); @@ -3715,10 +3718,8 @@ void VPMainWindow::on_TilesMarginChanged() if (not m_layout.isNull()) { m_layout->LayoutSettings().SetTilesMarginsConverted( - ui->doubleSpinBoxTileMarginLeft->value(), - ui->doubleSpinBoxTileMarginTop->value(), - ui->doubleSpinBoxTileMarginRight->value(), - ui->doubleSpinBoxTileMarginBottom->value()); + ui->doubleSpinBoxTileMarginLeft->value(), ui->doubleSpinBoxTileMarginTop->value(), + ui->doubleSpinBoxTileMarginRight->value(), ui->doubleSpinBoxTileMarginBottom->value()); LayoutWasSaved(false); m_layout->TileFactory()->RefreshTileInfos(); m_graphicsView->RefreshLayout(); @@ -3730,7 +3731,7 @@ void VPMainWindow::on_TilesMarginChanged() //--------------------------------------------------------------------------------------------------------------------- void VPMainWindow::on_CarrouselLocationChanged(Qt::DockWidgetArea area) { - if(area == Qt::BottomDockWidgetArea || area == Qt::TopDockWidgetArea) + if (area == Qt::BottomDockWidgetArea || area == Qt::TopDockWidgetArea) { m_carrousel->SetOrientation(Qt::Horizontal); } @@ -3753,9 +3754,9 @@ void VPMainWindow::on_ScaleChanged(qreal scale) if (not m_doubleSpinBoxScale.isNull()) { m_doubleSpinBoxScale->blockSignals(true); - m_doubleSpinBoxScale->setMaximum(qFloor(VPMainGraphicsView::MaxScale()*1000)/10.0); - m_doubleSpinBoxScale->setMinimum(qFloor(VPMainGraphicsView::MinScale()*1000)/10.0); - m_doubleSpinBoxScale->setValue(qFloor(scale*1000)/10.0); + m_doubleSpinBoxScale->setMaximum(qFloor(VPMainGraphicsView::MaxScale() * 1000) / 10.0); + m_doubleSpinBoxScale->setMinimum(qFloor(VPMainGraphicsView::MinScale() * 1000) / 10.0); + m_doubleSpinBoxScale->setValue(qFloor(scale * 1000) / 10.0); m_doubleSpinBoxScale->setSingleStep(1); m_doubleSpinBoxScale->blockSignals(false); } @@ -3766,25 +3767,24 @@ void VPMainWindow::on_MouseMoved(const QPointF &scenePos) { if (m_mouseCoordinate != nullptr) { - m_mouseCoordinate->setText(QStringLiteral("%1, %2 (%3)") - .arg(static_cast(FromPixel(scenePos.x(), - m_layout->LayoutSettings().GetUnit()))) - .arg(static_cast(FromPixel(scenePos.y(), - m_layout->LayoutSettings().GetUnit()))) - .arg(UnitsToStr(m_layout->LayoutSettings().GetUnit(), true))); + m_mouseCoordinate->setText( + QStringLiteral("%1, %2 (%3)") + .arg(static_cast(FromPixel(scenePos.x(), m_layout->LayoutSettings().GetUnit()))) + .arg(static_cast(FromPixel(scenePos.y(), m_layout->LayoutSettings().GetUnit()))) + .arg(UnitsToStr(m_layout->LayoutSettings().GetUnit(), true))); } } //--------------------------------------------------------------------------------------------------------------------- void VPMainWindow::ShowWindow() const { - if (auto *action = qobject_cast(sender())) + if (auto *action = qobject_cast(sender())) { const QVariant v = action->data(); if (v.canConvert()) { const int offset = qvariant_cast(v); - const QList windows = VPApplication::VApp()->MainWindows(); + const QList windows = VPApplication::VApp()->MainWindows(); windows.at(offset)->raise(); windows.at(offset)->activateWindow(); } @@ -3798,10 +3798,7 @@ void VPMainWindow::on_actionPreferences_triggered() // NOLINT(readability-conver QSharedPointer preferences = VPApplication::VApp()->PreferencesDialog(); if (preferences.isNull()) { - auto CleanAfterDialog = qScopeGuard([&preferences]() - { - preferences.clear(); - }); + auto CleanAfterDialog = qScopeGuard([&preferences]() { preferences.clear(); }); QGuiApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); @@ -3809,7 +3806,7 @@ void VPMainWindow::on_actionPreferences_triggered() // NOLINT(readability-conver preferences->setWindowModality(Qt::ApplicationModal); VPApplication::VApp()->SetPreferencesDialog(preferences); - const QList windows = VPApplication::VApp()->MainWindows(); + const QList windows = VPApplication::VApp()->MainWindows(); for (auto *window : windows) { window->ConnectToPreferences(preferences); @@ -3838,7 +3835,7 @@ void VPMainWindow::ToolBarStyles() void VPMainWindow::on_actionAddSheet_triggered() { VPSheetPtr sheet(new VPSheet(m_layout)); - sheet->SetName(tr("Sheet %1").arg(m_layout->GetAllSheets().size()+1)); + sheet->SetName(tr("Sheet %1").arg(m_layout->GetAllSheets().size() + 1)); m_layout->UndoStack()->push(new VPUndoAddSheet(sheet)); } @@ -3899,9 +3896,9 @@ void VPMainWindow::on_RelativeTranslationChanged(bool checked) QRectF rect = PiecesBoundingRect(SelectedPieces()); ui->doubleSpinBoxCurrentPieceBoxPositionX->setValue( - UnitConvertor(rect.topLeft().x(), Unit::Px, TranslateUnit())); + UnitConvertor(rect.topLeft().x(), Unit::Px, TranslateUnit())); ui->doubleSpinBoxCurrentPieceBoxPositionY->setValue( - UnitConvertor(rect.topLeft().y(), Unit::Px, TranslateUnit())); + UnitConvertor(rect.topLeft().y(), Unit::Px, TranslateUnit())); } } @@ -4011,7 +4008,7 @@ void VPMainWindow::on_ConvertPaperSize() on_TilesMarginChanged(); ui->doubleSpinBoxSheetPiecesGap->setMaximum( - UnitConvertor(VPSettings::GetMaxLayoutPieceGap(), Unit::Cm, layoutUnit)); + UnitConvertor(VPSettings::GetMaxLayoutPieceGap(), Unit::Cm, layoutUnit)); ui->doubleSpinBoxSheetPiecesGap->setValue(newGap); ui->doubleSpinBoxSheetPiecesGap->setSuffix(suffix); @@ -4124,7 +4121,7 @@ void VPMainWindow::on_actionPrintLayout_triggered() { if (not m_layout->IsSheetsUniform()) { - qCritical()<setDocName(m_layout->LayoutSettings().GetTitle()); - printer->setOutputFileName(QString());//Disable printing to file if was enabled. + printer->setOutputFileName(QString()); // Disable printing to file if was enabled. printer->setOutputFormat(QPrinter::NativeFormat); QPrintDialog dialog(printer.data(), this); @@ -4175,7 +4172,7 @@ void VPMainWindow::on_actionPrintPreviewLayout_triggered() { if (not m_layout->IsSheetsUniform()) { - qCritical()<LayoutSettings().GetTilesOrientation(), false); printer->setDocName(m_layout->LayoutSettings().GetTitle()); - printer->setOutputFileName(QString());//Disable printing to file if was enabled. + printer->setOutputFileName(QString()); // Disable printing to file if was enabled. printer->setOutputFormat(QPrinter::NativeFormat); QPrintDialog dialog(printer.data(), this); @@ -4268,7 +4265,6 @@ void VPMainWindow::on_actionPrintPreviewTiledLayout_triggered() printer->setCreator(QGuiApplication::applicationDisplayName() + QChar(QChar::Space) + QCoreApplication::applicationVersion()); - QList sheets = m_layout->GetSheets(); const VPSheetPtr &firstSheet = ConstFirst(sheets); if (firstSheet.isNull()) @@ -4329,7 +4325,7 @@ void VPMainWindow::on_actionPrintSheet_triggered() SetPrinterSheetPageSettings(printer, sheet, xScale, yScale); printer->setDocName(sheet->GetName()); - printer->setOutputFileName(QString());//Disable printing to file if was enabled. + printer->setOutputFileName(QString()); // Disable printing to file if was enabled. printer->setOutputFormat(QPrinter::NativeFormat); QPrintDialog dialog(printer.data(), this); @@ -4403,7 +4399,7 @@ void VPMainWindow::on_actionPrintTiledSheet_triggered() SetPrinterTiledPageSettings(printer, m_layout, sheet, m_layout->LayoutSettings().GetTilesOrientation(), false); printer->setDocName(sheet->GetName()); - printer->setOutputFileName(QString());//Disable printing to file if was enabled. + printer->setOutputFileName(QString()); // Disable printing to file if was enabled. printer->setOutputFormat(QPrinter::NativeFormat); QPrintDialog dialog(printer.data(), this); @@ -4661,4 +4657,4 @@ void VPMainWindow::AboutToShowDockMenu() connect(actionPreferences, &QAction::triggered, this, &VPMainWindow::on_actionPreferences_triggered); } } -#endif //defined(Q_OS_MAC) +#endif // defined(Q_OS_MAC) diff --git a/src/app/puzzle/vpsettings.cpp b/src/app/puzzle/vpsettings.cpp index 95d9b23c4..a9a862110 100644 --- a/src/app/puzzle/vpsettings.cpp +++ b/src/app/puzzle/vpsettings.cpp @@ -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 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(*this, *settingLayoutSheetPaperWidth, UnitConvertor(841/*A0*/, Unit::Mm, Unit::Px)); + return ValueOrDef(*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(*this, *settingLayoutSheetPaperHeight, UnitConvertor(1189/*A0*/, Unit::Mm, Unit::Px)); + return ValueOrDef(*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(*this, *settingLayoutTilePaperWidth, UnitConvertor(210/*A4*/, Unit::Mm, Unit::Px)); + return ValueOrDef(*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(*this, *settingLayoutTilePaperHeight, UnitConvertor(297/*A4*/, Unit::Mm, Unit::Px)); + return ValueOrDef(*this, *settingLayoutTilePaperHeight, UnitConvertor(297 /*A4*/, Unit::Mm, Unit::Px)); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/puzzle/vptilefactory.cpp b/src/app/puzzle/vptilefactory.cpp index e94edfcf5..dd7e911dd 100644 --- a/src/app/puzzle/vptilefactory.cpp +++ b/src/app/puzzle/vptilefactory.cpp @@ -2,31 +2,39 @@ #include -#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(scan + jj * depth); // NOLINT + auto *rgbpixel = reinterpret_cast(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 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("" "" "" "" "
%2
") - .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 "" "%2 - %3" "" - "").arg(tileColorStr, page, clippedSheetName)); + "") + .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 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()); diff --git a/src/app/puzzle/xml/vplayoutfilewriter.cpp b/src/app/puzzle/xml/vplayoutfilewriter.cpp index 86810cafe..d189417ae 100644 --- a/src/app/puzzle/xml/vplayoutfilewriter.cpp +++ b/src/app/puzzle/xml/vplayoutfilewriter.cpp @@ -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 -auto NumberToString(T number) -> QString +template 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 &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(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(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(ML::AttrPrintScheme, layout->LayoutSettings().GetPrintTilesScheme(), - [](bool print) noexcept {return not print;}); - SetAttributeOrRemoveIf(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(ML::AttrPrintScheme, layout->LayoutSettings().GetPrintTilesScheme(), + [](bool print) noexcept { return not print; }); + SetAttributeOrRemoveIf(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(ML::AttrMirrored, piece->IsMirror(), - [](bool mirrored) noexcept {return not mirrored;}); + [](bool mirrored) noexcept { return not mirrored; }); SetAttributeOrRemoveIf(ML::AttrForbidFlipping, piece->IsForbidFlipping(), - [](bool forbid) noexcept {return not forbid;}); + [](bool forbid) noexcept { return not forbid; }); SetAttributeOrRemoveIf(ML::AttrForceFlipping, piece->IsForceFlipping(), - [](bool force) noexcept {return not force;}); + [](bool force) noexcept { return not force; }); SetAttributeOrRemoveIf(ML::AttrSewLineOnDrawing, piece->IsSewLineOnDrawing(), - [](bool value) noexcept {return not value;}); + [](bool value) noexcept { return not value; }); SetAttribute(ML::AttrTransform, TransformToString(piece->GetMatrix())); SetAttributeOrRemoveIf(ML::AttrGradationLabel, piece->GetGradationId(), - [](const QString &label) noexcept {return label.isEmpty();}); + [](const QString &label) noexcept { return label.isEmpty(); }); SetAttribute(ML::AttrCopyNumber, piece->CopyNumber()); SetAttributeOrRemoveIf(ML::AttrShowSeamline, not piece->IsHideMainPath(), - [](bool show) noexcept {return show;}); + [](bool show) noexcept { return show; }); SetAttributeOrRemoveIf(ML::AttrXScale, piece->GetXScale(), - [](qreal xs) noexcept {return VFuzzyComparePossibleNulls(xs, 1.0);}); + [](qreal xs) noexcept { return VFuzzyComparePossibleNulls(xs, 1.0); }); SetAttributeOrRemoveIf(ML::AttrYScale, piece->GetYScale(), - [](qreal ys) noexcept {return VFuzzyComparePossibleNulls(ys, 1.0);}); + [](qreal ys) noexcept { return VFuzzyComparePossibleNulls(ys, 1.0); }); SetAttributeOrRemoveIf(ML::AttrZValue, piece->ZValue(), - [](qreal z) noexcept {return VFuzzyComparePossibleNulls(z, 1.0);}); + [](qreal z) noexcept { return VFuzzyComparePossibleNulls(z, 1.0); }); writeStartElement(ML::TagSeamLine); QVector contourPoints = piece->GetContourPoints(); @@ -302,9 +290,9 @@ void VPLayoutFileWriter::WritePiece(const VPPiecePtr &piece) writeStartElement(ML::TagSeamAllowance); SetAttributeOrRemoveIf(ML::AttrEnabled, piece->IsSeamAllowance(), - [](bool enabled) noexcept {return not enabled;}); + [](bool enabled) noexcept { return not enabled; }); SetAttributeOrRemoveIf(ML::AttrBuiltIn, piece->IsSeamAllowanceBuiltIn(), - [](bool builtin) noexcept {return not builtin;}); + [](bool builtin) noexcept { return not builtin; }); if (piece->IsSeamAllowance() && not piece->IsSeamAllowanceBuiltIn()) { QVector seamAllowancePoints = piece->GetSeamAllowancePoints(); @@ -317,7 +305,7 @@ void VPLayoutFileWriter::WritePiece(const VPPiecePtr &piece) writeStartElement(ML::TagGrainline); SetAttributeOrRemoveIf(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 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 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 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(ML::AttrLeft, margins.left(), [](qreal margin) noexcept {return margin <= 0;}); - SetAttributeOrRemoveIf(ML::AttrTop, margins.top(), [](qreal margin) noexcept {return margin <= 0;}); - SetAttributeOrRemoveIf(ML::AttrRight, margins.right(), [](qreal margin) noexcept {return margin <= 0;}); - SetAttributeOrRemoveIf(ML::AttrBottom, margins.bottom(), [](qreal margin) noexcept {return margin <= 0;}); + SetAttributeOrRemoveIf(ML::AttrLeft, margins.left(), [](qreal margin) noexcept { return margin <= 0; }); + SetAttributeOrRemoveIf(ML::AttrTop, margins.top(), [](qreal margin) noexcept { return margin <= 0; }); + SetAttributeOrRemoveIf(ML::AttrRight, margins.right(), [](qreal margin) noexcept { return margin <= 0; }); + SetAttributeOrRemoveIf(ML::AttrBottom, margins.bottom(), [](qreal margin) noexcept { return margin <= 0; }); - SetAttributeOrRemoveIf(ML::AttrIgnoreMargins, ignore, [](bool ignore) noexcept {return not ignore;}); + SetAttributeOrRemoveIf(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(ML::AttrTurnPoint, point.TurnPoint(), [](bool val) noexcept {return val;}); - SetAttributeOrRemoveIf(ML::AttrCurvePoint, point.CurvePoint(), [](bool val) noexcept {return val;}); + SetAttributeOrRemoveIf(ML::AttrTurnPoint, point.TurnPoint(), [](bool val) noexcept { return val; }); + SetAttributeOrRemoveIf(ML::AttrCurvePoint, point.CurvePoint(), [](bool val) noexcept { return val; }); writeEndElement(); } diff --git a/src/app/puzzle/xml/vplayoutliterals.cpp b/src/app/puzzle/xml/vplayoutliterals.cpp index b581f6ee2..dd95b1865 100644 --- a/src/app/puzzle/xml/vplayoutliterals.cpp +++ b/src/app/puzzle/xml/vplayoutliterals.cpp @@ -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 diff --git a/src/app/puzzle/xml/vplayoutliterals.h b/src/app/puzzle/xml/vplayoutliterals.h index ba2c51bd7..2fd39d5f2 100644 --- a/src/app/puzzle/xml/vplayoutliterals.h +++ b/src/app/puzzle/xml/vplayoutliterals.h @@ -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 diff --git a/src/app/tape/dialogs/configpages/tapepreferencesconfigurationpage.h b/src/app/tape/dialogs/configpages/tapepreferencesconfigurationpage.h index b9ec8c17b..afb46f610 100644 --- a/src/app/tape/dialogs/configpages/tapepreferencesconfigurationpage.h +++ b/src/app/tape/dialogs/configpages/tapepreferencesconfigurationpage.h @@ -31,11 +31,9 @@ #include -#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 diff --git a/src/app/tape/mapplication.cpp b/src/app/tape/mapplication.cpp index 17a841bb4..8f0d99efb 100644 --- a/src/app/tape/mapplication.cpp +++ b/src/app/tape/mapplication.cpp @@ -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 //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/tape/tmainwindow.cpp b/src/app/tape/tmainwindow.cpp index 793047d34..7ed670ebb 100644 --- a/src/app/tape/tmainwindow.cpp +++ b/src/app/tape/tmainwindow.cpp @@ -51,14 +51,15 @@ #include "dialogs/dialogsetupmultisize.h" #include "dialogs/dialogtapepreferences.h" #include "ui_tmainwindow.h" +#include "vtapesettings.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 "vlitepattern.h" #include "../qmuparser/qmudef.h" -#include "../vtools/dialogs/support/dialogeditwrongformula.h" #include "../vmisc/dialogs/dialogselectlanguage.h" +#include "../vtools/dialogs/support/dialogeditwrongformula.h" #include "mapplication.h" // Should be last because of definning qApp +#include "vlitepattern.h" #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) #include "../vmisc/vtextcodec.h" @@ -72,13 +73,13 @@ #include #endif +#include #include #include #include -#include #include -#include #include +#include #include #if (defined(Q_CC_GNU) && Q_CC_GNU < 409) && !defined(Q_CC_CLANG) @@ -93,9 +94,9 @@ using namespace bpstd::literals::chrono_literals; #endif //(defined(Q_CC_GNU) && Q_CC_GNU < 409) && !defined(Q_CC_CLANG) #if defined(Q_OS_MAC) -#include #include -#endif //defined(Q_OS_MAC) +#include +#endif // defined(Q_OS_MAC) constexpr int DIALOG_MAX_FORMULA_HEIGHT = 64; @@ -109,7 +110,11 @@ QT_WARNING_POP namespace { -enum class MUnits : qint8 { Table, Degrees}; +enum class MUnits : qint8 +{ + Table, + Degrees +}; struct IndividualMeasurement { @@ -151,7 +156,7 @@ void InitDimensionXItems(const QVector &bases, const DimesionLabels &labe { SCASSERT(control != nullptr) - for(auto base : bases) + for (auto base : bases) { if (VFuzzyContains(labels, base) && not VFuzzyValue(labels, base).isEmpty()) { @@ -168,7 +173,7 @@ void InitDimensionXItems(const QVector &bases, const DimesionLabels &labe void InitDimensionYWZItems(const QVector &bases, const DimesionLabels &labels, QComboBox *control, const QString &unit, bool bodyMeasurement, bool fc) { - for(auto base : bases) + for (auto base : bases) { if (VFuzzyContains(labels, base) && not VFuzzyValue(labels, base).isEmpty()) { @@ -178,7 +183,7 @@ void InitDimensionYWZItems(const QVector &bases, const DimesionLabels &la { if (bodyMeasurement) { - control->addItem(QStringLiteral("%1 %2").arg(fc ? base*2 : base).arg(unit), base); + control->addItem(QStringLiteral("%1 %2").arg(fc ? base * 2 : base).arg(unit), base); } else { @@ -234,10 +239,11 @@ void SetIndividualMeasurementDescription(int i, const QString &name, const QxtCs } } } -} // namespace +} // namespace // We need this enum in case we will add or delete a column. And also make code more readable. -enum { +enum +{ ColumnName = 0, ColumnFullName = 1, ColumnCalcValue = 2, @@ -251,11 +257,11 @@ enum { //--------------------------------------------------------------------------------------------------------------------- TMainWindow::TMainWindow(QWidget *parent) - : VAbstractMainWindow(parent), - ui(new Ui::TMainWindow), - m_formulaBaseHeight(0), - m_gradation(new QTimer(this)), - m_searchHistory(new QMenu(this)) + : VAbstractMainWindow(parent), + ui(new Ui::TMainWindow), + m_formulaBaseHeight(0), + m_gradation(new QTimer(this)), + m_searchHistory(new QMenu(this)) { ui->setupUi(this); @@ -294,7 +300,7 @@ TMainWindow::TMainWindow(QWidget *parent) connect(menu, &QMenu::aboutToShow, this, &TMainWindow::AboutToShowDockMenu); AboutToShowDockMenu(); menu->setAsDockMenu(); -#endif //defined(Q_OS_MAC) +#endif // defined(Q_OS_MAC) if (MApplication::VApp()->IsAppInGUIMode()) { @@ -433,9 +439,9 @@ auto TMainWindow::LoadFile(const QString &path) -> bool } // Check if file already opened - const QList list = MApplication::VApp()->MainWindows(); - auto w = std::find_if(list.begin(), list.end(), - [path](TMainWindow *window) { return window->CurrentFile() == path; }); + const QList list = MApplication::VApp()->MainWindows(); + auto w = + std::find_if(list.begin(), list.end(), [path](TMainWindow *window) { return window->CurrentFile() == path; }); if (w != list.end()) { (*w)->activateWindow(); @@ -455,7 +461,7 @@ auto TMainWindow::LoadFile(const QString &path) -> bool try { - m_data = new VContainer(VAbstractApplication::VApp()->TrVars(),&m_mUnit, VContainer::UniqueNamespace()); + m_data = new VContainer(VAbstractApplication::VApp()->TrVars(), &m_mUnit, VContainer::UniqueNamespace()); m_m = new VMeasurements(m_data); m_m->setXMLContent(path); @@ -472,14 +478,14 @@ auto TMainWindow::LoadFile(const QString &path) -> bool VVSTConverter converter(path); m_curFileFormatVersion = converter.GetCurrentFormatVersion(); m_curFileFormatVersionStr = converter.GetFormatVersionStr(); - m_m->setXMLContent(converter.Convert());// Read again after conversion + m_m->setXMLContent(converter.Convert()); // Read again after conversion } else { VVITConverter converter(path); m_curFileFormatVersion = converter.GetCurrentFormatVersion(); m_curFileFormatVersionStr = converter.GetFormatVersionStr(); - m_m->setXMLContent(converter.Convert());// Read again after conversion + m_m->setXMLContent(converter.Convert()); // Read again after conversion } if (not m_m->IsDefinedKnownNamesValid()) @@ -518,8 +524,8 @@ auto TMainWindow::LoadFile(const QString &path) -> bool } catch (VException &e) { - qCCritical(tMainWindow, "%s\n\n%s\n\n%s", qUtf8Printable(tr("File error.")), - qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation())); + qCCritical(tMainWindow, "%s\n\n%s\n\n%s", qUtf8Printable(tr("File error.")), qUtf8Printable(e.ErrorMessage()), + qUtf8Printable(e.DetailedInformation())); ui->labelToolTip->setVisible(true); ui->tabWidget->setVisible(false); delete m_m; @@ -604,8 +610,8 @@ void TMainWindow::FileNew() void TMainWindow::OpenIndividual() { const QString filter = tr("Individual measurements") + QStringLiteral(" (*.vit);;") + tr("Multisize measurements") + - QStringLiteral(" (*.vst);;") + tr("All files") + QStringLiteral(" (*.*)"); - //Use standard path to individual measurements + QStringLiteral(" (*.vst);;") + tr("All files") + QStringLiteral(" (*.*)"); + // Use standard path to individual measurements const QString pathTo = MApplication::VApp()->TapeSettings()->GetPathIndividualMeasurements(); bool usedNotExistedDir = false; @@ -627,8 +633,8 @@ void TMainWindow::OpenIndividual() void TMainWindow::OpenMultisize() { const QString filter = tr("Multisize measurements") + QStringLiteral(" (*.vst);;") + tr("Individual measurements") + - QStringLiteral(" (*.vit);;") + tr("All files") + QStringLiteral(" (*.*)"); - //Use standard path to multisize measurements + QStringLiteral(" (*.vit);;") + tr("All files") + QStringLiteral(" (*.*)"); + // Use standard path to multisize measurements QString pathTo = MApplication::VApp()->TapeSettings()->GetPathMultisizeMeasurements(); pathTo = VCommonSettings::PrepareMultisizeTables(pathTo); @@ -638,25 +644,25 @@ void TMainWindow::OpenMultisize() //--------------------------------------------------------------------------------------------------------------------- void TMainWindow::OpenTemplate() { - const QString filter = tr("Measurements") + QStringLiteral(" (*.vst *.vit);;") + tr("All files") + - QStringLiteral(" (*.*)"); - //Use standard path to template files + const QString filter = + tr("Measurements") + QStringLiteral(" (*.vst *.vit);;") + tr("All files") + QStringLiteral(" (*.*)"); + // Use standard path to template files QString pathTo = MApplication::VApp()->TapeSettings()->GetPathTemplate(); pathTo = VCommonSettings::PrepareStandardTemplates(pathTo); Open(pathTo, filter); if (m_m != nullptr) - {// The file was opened. + { // The file was opened. SetCurrentFile(QString()); // Force user to to save new file - m_lock.reset();// remove lock from template + m_lock.reset(); // remove lock from template } } //--------------------------------------------------------------------------------------------------------------------- void TMainWindow::CreateFromExisting() { - const QString filter = tr("Measurements") + QStringLiteral(" (*.vst *.vit);;") + tr("All files") + - QStringLiteral(" (*.*)"); + const QString filter = + tr("Measurements") + QStringLiteral(" (*.vst *.vit);;") + tr("All files") + QStringLiteral(" (*.*)"); const QString mPath = QFileDialog::getOpenFileName(this, tr("Select file"), QDir::homePath(), filter, nullptr, VAbstractApplication::VApp()->NativeFileDialog()); @@ -678,7 +684,7 @@ void TMainWindow::CreateFromExisting() void TMainWindow::Preferences() { // Calling constructor of the dialog take some time. Because of this user have time to call the dialog twice. - static QPointer guard;// Prevent any second run + static QPointer guard; // Prevent any second run if (guard.isNull()) { QGuiApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); @@ -886,7 +892,7 @@ void TMainWindow::ExportToCSVData(const QString &fileName, bool withHeader, int if (not ui->tableWidget->isColumnHidden(column)) { QString text; - if(QTableWidgetItem *item = ui->tableWidget->item(row, column)) + if (QTableWidgetItem *item = ui->tableWidget->item(row, column)) { text = item->text(); } @@ -914,16 +920,14 @@ auto TMainWindow::FileSave() -> bool return FileSaveAs(); } - if (m_mType == MeasurementsType::Multisize - && m_curFileFormatVersion < VVSTConverter::MeasurementMaxVer - && not ContinueFormatRewrite(m_curFileFormatVersionStr, VVSTConverter::MeasurementMaxVerStr)) + if (m_mType == MeasurementsType::Multisize && m_curFileFormatVersion < VVSTConverter::MeasurementMaxVer && + not ContinueFormatRewrite(m_curFileFormatVersionStr, VVSTConverter::MeasurementMaxVerStr)) { return false; } - if (m_mType == MeasurementsType::Individual - && m_curFileFormatVersion < VVITConverter::MeasurementMaxVer - && not ContinueFormatRewrite(m_curFileFormatVersionStr, VVITConverter::MeasurementMaxVerStr)) + if (m_mType == MeasurementsType::Individual && m_curFileFormatVersion < VVITConverter::MeasurementMaxVer && + not ContinueFormatRewrite(m_curFileFormatVersionStr, VVITConverter::MeasurementMaxVerStr)) { return false; } @@ -995,20 +999,21 @@ auto TMainWindow::FileSaveAs() -> bool QString fileName = QFileDialog::getSaveFileName(this, tr("Save as"), dir + QChar('/') + fName, filters, nullptr, VAbstractApplication::VApp()->NativeFileDialog()); - auto RemoveTempDir = qScopeGuard([usedNotExistedDir, dir]() - { - if (usedNotExistedDir) + auto RemoveTempDir = qScopeGuard( + [usedNotExistedDir, dir]() { - QDir(dir).rmpath(QChar('.')); - } - }); + if (usedNotExistedDir) + { + QDir(dir).rmpath(QChar('.')); + } + }); if (fileName.isEmpty()) { return false; } - QFileInfo f( fileName ); + QFileInfo f(fileName); if (f.suffix().isEmpty() && f.suffix() != suffix) { fileName += QChar('.') + suffix; @@ -1071,8 +1076,9 @@ auto TMainWindow::FileSaveAs() -> bool VlpCreateLock(m_lock, fileName); if (not m_lock->IsLocked()) { - qCCritical(tMainWindow, "%s", qUtf8Printable(tr("Failed to lock. This file already opened in another window. " - "Expect collissions when run 2 copies of the program."))); + qCCritical(tMainWindow, "%s", + qUtf8Printable(tr("Failed to lock. This file already opened in another window. " + "Expect collissions when run 2 copies of the program."))); return false; } return true; @@ -1088,13 +1094,13 @@ void TMainWindow::AboutToShowWindowMenu() //--------------------------------------------------------------------------------------------------------------------- void TMainWindow::ShowWindow() const { - if (auto *action = qobject_cast(sender())) + if (auto *action = qobject_cast(sender())) { const QVariant v = action->data(); if (v.canConvert()) { const int offset = qvariant_cast(v); - const QList windows = MApplication::VApp()->MainWindows(); + const QList windows = MApplication::VApp()->MainWindows(); windows.at(offset)->raise(); windows.at(offset)->activateWindow(); } @@ -1120,7 +1126,7 @@ void TMainWindow::ImportDataFromCSV() return; } - QFileInfo f( fileName ); + QFileInfo f(fileName); if (f.suffix().isEmpty() && f.suffix() != suffix) { fileName += QChar('.') + suffix; @@ -1205,7 +1211,7 @@ void TMainWindow::OpenAt(QAction *where) process.start(QStringLiteral("/usr/bin/open"), QStringList() << path, QIODevice::ReadOnly); process.waitForFinished(); } -#endif //defined(Q_OS_MAC) +#endif // defined(Q_OS_MAC) //--------------------------------------------------------------------------------------------------------------------- void TMainWindow::SaveCustomerName() @@ -1262,7 +1268,7 @@ void TMainWindow::SaveNotes() void TMainWindow::SavePMSystem(int index) { QString system = ui->comboBoxPMSystem->itemData(index).toString(); - system.remove(0, 1);// clear p + system.remove(0, 1); // clear p if (m_m->PMSystem() != system) { @@ -1299,7 +1305,7 @@ void TMainWindow::Remove() { MFields(false); - ui->actionExportToCSV->setEnabled(false); + ui->actionExportToCSV->setEnabled(false); ui->lineEditName->blockSignals(true); ui->lineEditName->setText(QString()); @@ -1389,7 +1395,7 @@ void TMainWindow::MoveUp() MeasurementsWereSaved(false); RefreshData(); m_search->RefreshList(ui->lineEditFind->text()); - ui->tableWidget->selectRow(row-1); + ui->tableWidget->selectRow(row - 1); ui->tableWidget->repaint(); // Force repain to fix paint artifacts on Mac OS X } @@ -1408,7 +1414,7 @@ void TMainWindow::MoveDown() MeasurementsWereSaved(false); RefreshData(); m_search->RefreshList(ui->lineEditFind->text()); - ui->tableWidget->selectRow(row+1); + ui->tableWidget->selectRow(row + 1); ui->tableWidget->repaint(); // Force repain to fix paint artifacts on Mac OS X } @@ -1427,7 +1433,7 @@ void TMainWindow::MoveBottom() MeasurementsWereSaved(false); RefreshData(); m_search->RefreshList(ui->lineEditFind->text()); - ui->tableWidget->selectRow(ui->tableWidget->rowCount()-1); + ui->tableWidget->selectRow(ui->tableWidget->rowCount() - 1); ui->tableWidget->repaint(); // Force repain to fix paint artifacts on Mac OS X } @@ -1447,10 +1453,10 @@ void TMainWindow::Fx() try { - // Translate to internal look. - meash = m_data->GetVariable(nameField->data(Qt::UserRole).toString()); + // Translate to internal look. + meash = m_data->GetVariable(nameField->data(Qt::UserRole).toString()); } - catch(const VExceptionBadId & e) + catch (const VExceptionBadId &e) { qCCritical(tMainWindow, "%s\n\n%s\n\n%s", qUtf8Printable(tr("Can't find measurement '%1'.").arg(nameField->text())), @@ -1462,7 +1468,7 @@ void TMainWindow::Fx() dialog->setWindowTitle(tr("Edit measurement")); dialog->SetMeasurementsMode(); dialog->SetFormula(VTranslateVars::TryFormulaFromUser(ui->plainTextEditFormula->toPlainText(), true)); - const QString postfix = UnitsToStr(m_mUnit, true);//Show unit in dialog lable (cm, mm or inch) + const QString postfix = UnitsToStr(m_mUnit, true); // Show unit in dialog lable (cm, mm or inch) dialog->setPostfix(postfix); if (dialog->exec() == QDialog::Accepted) @@ -1491,12 +1497,12 @@ void TMainWindow::AddCustom() if (ui->tableWidget->currentRow() == -1) { - currentRow = ui->tableWidget->rowCount(); + currentRow = ui->tableWidget->rowCount(); m_m->AddEmpty(name); } else { - currentRow = ui->tableWidget->currentRow()+1; + currentRow = ui->tableWidget->currentRow() + 1; const QTableWidgetItem *nameField = ui->tableWidget->item(ui->tableWidget->currentRow(), ColumnName); m_m->AddEmptyAfter(nameField->data(Qt::UserRole).toString(), name); } @@ -1516,7 +1522,7 @@ void TMainWindow::AddCustom() //--------------------------------------------------------------------------------------------------------------------- void TMainWindow::AddKnown() { - QScopedPointer dialog (new DialogMDataBase(m_m->ListKnown(), this)); + QScopedPointer dialog(new DialogMDataBase(m_m->ListKnown(), this)); if (dialog->exec() == QDialog::Accepted) { vsizetype currentRow; @@ -1524,7 +1530,7 @@ void TMainWindow::AddKnown() const QStringList list = dialog->GetNewNames(); if (ui->tableWidget->currentRow() == -1) { - currentRow = ui->tableWidget->rowCount() + list.size() - 1; + currentRow = ui->tableWidget->rowCount() + list.size() - 1; for (const auto &name : list) { if (m_mType == MeasurementsType::Individual) @@ -1541,7 +1547,7 @@ void TMainWindow::AddKnown() } else { - currentRow = ui->tableWidget->currentRow() + list.size(); + currentRow = ui->tableWidget->currentRow() + list.size(); const QTableWidgetItem *nameField = ui->tableWidget->item(ui->tableWidget->currentRow(), ColumnName); QString after = nameField->data(Qt::UserRole).toString(); for (const auto &name : list) @@ -1579,12 +1585,12 @@ void TMainWindow::AddSeparator() if (ui->tableWidget->currentRow() == -1) { - currentRow = ui->tableWidget->rowCount(); + currentRow = ui->tableWidget->rowCount(); m_m->AddSeparator(name); } else { - currentRow = ui->tableWidget->currentRow()+1; + currentRow = ui->tableWidget->currentRow() + 1; const QTableWidgetItem *nameField = ui->tableWidget->item(ui->tableWidget->currentRow(), ColumnName); m_m->AddSeparatorAfter(nameField->data(Qt::UserRole).toString(), name); } @@ -1610,7 +1616,7 @@ void TMainWindow::ImportFromPattern() } const QString filter(tr("Pattern files (*.val)")); - //Use standard path to individual measurements + // Use standard path to individual measurements QString pathTo = MApplication::VApp()->TapeSettings()->GetPathPattern(); const QString mPath = QFileDialog::getOpenFileName(this, tr("Import from a pattern"), pathTo, filter, nullptr, @@ -1637,8 +1643,8 @@ void TMainWindow::ImportFromPattern() } catch (VException &e) { - qCCritical(tMainWindow, "%s\n\n%s\n\n%s", qUtf8Printable(tr("File error.")), - qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation())); + qCCritical(tMainWindow, "%s\n\n%s\n\n%s", qUtf8Printable(tr("File error.")), qUtf8Printable(e.ErrorMessage()), + qUtf8Printable(e.DetailedInformation())); return; } @@ -1648,7 +1654,7 @@ void TMainWindow::ImportFromPattern() if (ui->tableWidget->currentRow() == -1) { - currentRow = ui->tableWidget->rowCount() + measurements.size() - 1; + currentRow = ui->tableWidget->rowCount() + measurements.size() - 1; for (auto &mName : measurements) { m_m->AddEmpty(mName); @@ -1656,7 +1662,7 @@ void TMainWindow::ImportFromPattern() } else { - currentRow = ui->tableWidget->currentRow() + measurements.size(); + currentRow = ui->tableWidget->currentRow() + measurements.size(); const QTableWidgetItem *nameField = ui->tableWidget->item(ui->tableWidget->currentRow(), ColumnName); QString after = nameField->data(Qt::UserRole).toString(); for (auto &mName : measurements) @@ -1705,7 +1711,7 @@ void TMainWindow::DimensionBBaseChanged() if (dimensions.size() > 2) { - const MeasurementDimension_p& dimension = dimensions.at(2); + const MeasurementDimension_p &dimension = dimensions.at(2); InitDimensionGradation(2, dimension, m_gradationDimensionC); } @@ -1762,7 +1768,7 @@ void TMainWindow::ShowNewMData(bool fresh) // Translate to internal look. meash = m_data->GetVariable(nameField->data(Qt::UserRole).toString()); } - catch(const VExceptionBadId &e) + catch (const VExceptionBadId &e) { Q_UNUSED(e) MFields(false); @@ -1785,9 +1791,9 @@ void TMainWindow::ShowNewMData(bool fresh) } else { - //Show known + // Show known ui->plainTextEditDescription->setPlainText( - VAbstractApplication::VApp()->TrVars()->Description(meash->GetName())); + VAbstractApplication::VApp()->TrVars()->Description(meash->GetName())); ui->lineEditFullName->setText(VAbstractApplication::VApp()->TrVars()->GuiText(meash->GetName())); ui->lineEditName->setText(nameField->text()); } @@ -1842,14 +1848,13 @@ void TMainWindow::ShowNewMData(bool fresh) if (meash->IsSpecialUnits()) { const qreal value = *m_data->DataVariables()->value(meash->GetName())->GetValue(); - calculatedValue = VAbstractApplication::VApp()->LocaleToString(value) + QChar(QChar::Space) + - degreeSymbol; + calculatedValue = VAbstractApplication::VApp()->LocaleToString(value) + QChar(QChar::Space) + degreeSymbol; } else { - const QString postfix = UnitsToStr(m_pUnit);//Show unit in dialog lable (cm, mm or inch) - const qreal value = UnitConvertor(*m_data->DataVariables()->value(meash->GetName())->GetValue(), - m_mUnit, m_pUnit); + const QString postfix = UnitsToStr(m_pUnit); // Show unit in dialog lable (cm, mm or inch) + const qreal value = + UnitConvertor(*m_data->DataVariables()->value(meash->GetName())->GetValue(), m_mUnit, m_pUnit); calculatedValue = VAbstractApplication::VApp()->LocaleToString(value) + QChar(QChar::Space) + postfix; } ui->labelCalculatedValue->setText(calculatedValue); @@ -1884,14 +1889,12 @@ void TMainWindow::ShowNewMData(bool fresh) ui->labelDimension->setVisible(meash->GetType() == VarType::Measurement); ui->comboBoxDimension->setVisible(meash->GetType() == VarType::Measurement); - EvalFormula(meash->GetFormula(), false, meash->GetData(), ui->labelCalculatedValue, - meash->IsSpecialUnits()); + EvalFormula(meash->GetFormula(), false, meash->GetData(), ui->labelCalculatedValue, meash->IsSpecialUnits()); ui->plainTextEditFormula->blockSignals(true); - QString formula = - VTranslateVars::TryFormulaToUser(meash->GetFormula(), - VAbstractApplication::VApp()->Settings()->GetOsSeparator()); + QString formula = VTranslateVars::TryFormulaToUser(meash->GetFormula(), + VAbstractApplication::VApp()->Settings()->GetOsSeparator()); ui->plainTextEditFormula->setPlainText(formula); ui->plainTextEditFormula->blockSignals(false); @@ -1920,13 +1923,13 @@ void TMainWindow::ShowMDiagram(const QString &name) { ui->labelDiagram->setText(QString("

%1

" "

%2. %3

") - .arg(DialogMDataBase::ImgTag(number), number, trv->GuiText(name))); + .arg(DialogMDataBase::ImgTag(number), number, trv->GuiText(name))); } // This part is very ugly, can't find better way to resize dockWidget. ui->labelDiagram->adjustSize(); // And also those 50 px. DockWidget has some border. And i can't find how big it is. // Can lead to problem in future. - ui->dockWidgetDiagram->setMaximumWidth(ui->labelDiagram->width()+50); + ui->dockWidgetDiagram->setMaximumWidth(ui->labelDiagram->width() + 50); } //--------------------------------------------------------------------------------------------------------------------- @@ -1940,16 +1943,16 @@ void TMainWindow::DeployFormula() if (ui->plainTextEditFormula->height() < DIALOG_MAX_FORMULA_HEIGHT) { ui->plainTextEditFormula->setFixedHeight(DIALOG_MAX_FORMULA_HEIGHT); - //Set icon from theme (internal for Windows system) - ui->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) + ui->pushButtonGrow->setIcon( + QIcon::fromTheme(QStringLiteral("go-next"), QIcon(":/icons/win.icon.theme/16x16/actions/go-next.png"))); } else { - ui->plainTextEditFormula->setFixedHeight(m_formulaBaseHeight); - //Set icon from theme (internal for Windows system) - ui->pushButtonGrow->setIcon(QIcon::fromTheme(QStringLiteral("go-down"), - QIcon(":/icons/win.icon.theme/16x16/actions/go-down.png"))); + ui->plainTextEditFormula->setFixedHeight(m_formulaBaseHeight); + // Set icon from theme (internal for Windows system) + ui->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. @@ -1981,7 +1984,7 @@ void TMainWindow::SaveMName(const QString &text) // Translate to internal look. meash = m_data->GetVariable(nameField->data(Qt::UserRole).toString()); } - catch(const VExceptionBadId &e) + catch (const VExceptionBadId &e) { qCWarning(tMainWindow, "%s\n\n%s\n\n%s", qUtf8Printable(tr("Can't find measurement '%1'.").arg(nameField->text())), @@ -2040,14 +2043,14 @@ void TMainWindow::SaveMValue() if (formulaField->text() == text) { QTableWidgetItem *result = ui->tableWidget->item(row, ColumnCalcValue); - const QString postfix = UnitsToStr(m_mUnit);//Show unit in dialog lable (cm, mm or inch) - ui->labelCalculatedValue->setText(result->text() + QChar(QChar::Space) +postfix); + const QString postfix = UnitsToStr(m_mUnit); // Show unit in dialog lable (cm, mm or inch) + ui->labelCalculatedValue->setText(result->text() + QChar(QChar::Space) + postfix); return; } if (text.isEmpty()) { - const QString postfix = UnitsToStr(m_mUnit);//Show unit in dialog lable (cm, mm or inch) + const QString postfix = UnitsToStr(m_mUnit); // Show unit in dialog lable (cm, mm or inch) ui->labelCalculatedValue->setText(tr("Error") + " (" + postfix + "). " + tr("Empty field.")); return; } @@ -2058,7 +2061,7 @@ void TMainWindow::SaveMValue() // Translate to internal look. meash = m_data->GetVariable(nameField->data(Qt::UserRole).toString()); } - catch(const VExceptionBadId & e) + catch (const VExceptionBadId &e) { qCWarning(tMainWindow, "%s\n\n%s\n\n%s", qUtf8Printable(tr("Can't find measurement '%1'.").arg(nameField->text())), @@ -2073,8 +2076,8 @@ void TMainWindow::SaveMValue() 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_m->SetMValue(nameField->data(Qt::UserRole).toString(), formula); } catch (qmu::QmuParserError &e) // Just in case something bad will happen @@ -2208,8 +2211,8 @@ void TMainWindow::SaveMCorrectionValue(double value) } const QTableWidgetItem *nameField = ui->tableWidget->item(ui->tableWidget->currentRow(), ColumnName); - m_m->SetMCorrectionValue(nameField->data(Qt::UserRole).toString(), - m_currentDimensionA, m_currentDimensionB, m_currentDimensionC, value); + m_m->SetMCorrectionValue(nameField->data(Qt::UserRole).toString(), m_currentDimensionA, m_currentDimensionB, + m_currentDimensionC, value); MeasurementsWereSaved(false); @@ -2249,7 +2252,6 @@ void TMainWindow::SaveMDescription() ui->plainTextEditDescription->setTextCursor(cursor); } - //--------------------------------------------------------------------------------------------------------------------- void TMainWindow::SaveMFullName() { @@ -2269,7 +2271,7 @@ void TMainWindow::SaveMFullName() // Translate to internal look. meash = m_data->GetVariable(nameField->data(Qt::UserRole).toString()); } - catch(const VExceptionBadId &e) + catch (const VExceptionBadId &e) { qCWarning(tMainWindow, "%s\n\n%s\n\n%s", qUtf8Printable(tr("Can't find measurement '%1'.").arg(nameField->text())), @@ -2378,16 +2380,17 @@ void TMainWindow::ExportToIndividual() QString filters = tr("Individual measurements") + QStringLiteral(" (*.vit)"); QString fName = tr("measurements.vit"); - QString fileName = QFileDialog::getSaveFileName(this, tr("Export to individual"), dir + QChar('/') + fName, - filters, nullptr, VAbstractApplication::VApp()->NativeFileDialog()); + QString fileName = QFileDialog::getSaveFileName(this, tr("Export to individual"), dir + QChar('/') + fName, filters, + nullptr, VAbstractApplication::VApp()->NativeFileDialog()); - auto RemoveTempDir = qScopeGuard([usedNotExistedDir, dir]() - { - if (usedNotExistedDir) - { - QDir(dir).rmpath(QChar('.')); - } - }); + auto RemoveTempDir = qScopeGuard( + [usedNotExistedDir, dir]() + { + if (usedNotExistedDir) + { + QDir(dir).rmpath(QChar('.')); + } + }); if (fileName.isEmpty()) { @@ -2395,19 +2398,19 @@ void TMainWindow::ExportToIndividual() } QString suffix = QStringLiteral("vit"); - QFileInfo f( fileName ); + QFileInfo f(fileName); if (f.suffix().isEmpty() && f.suffix() != suffix) { fileName += QChar('.') + suffix; } QScopedPointer tmpData( - new VContainer(VAbstractApplication::VApp()->TrVars(), &m_mUnit, VContainer::UniqueNamespace())); + new VContainer(VAbstractApplication::VApp()->TrVars(), &m_mUnit, VContainer::UniqueNamespace())); VMeasurements individualMeasurements(m_mUnit, tmpData.data()); - const QMap > orderedTable = OrderedMeasurments(); - QMap >::const_iterator iMap; + const QMap> orderedTable = OrderedMeasurments(); + QMap>::const_iterator iMap; for (iMap = orderedTable.constBegin(); iMap != orderedTable.constEnd(); ++iMap) { const QSharedPointer &meash = iMap.value(); @@ -2497,7 +2500,7 @@ void TMainWindow::RestrictThirdDimesion() //--------------------------------------------------------------------------------------------------------------------- void TMainWindow::EditDimensionLabels() { - const QMap dimensions = m_m->Dimensions(); + const QMap dimensions = m_m->Dimensions(); DialogDimensionLabels dialog(dimensions, m_m->IsFullCircumference(), this); if (dialog.exec() == QDialog::Rejected) @@ -2516,7 +2519,7 @@ void TMainWindow::EditDimensionLabels() //--------------------------------------------------------------------------------------------------------------------- void TMainWindow::DimensionCustomNames() { - const QMap dimensions = m_m->Dimensions(); + const QMap dimensions = m_m->Dimensions(); DialogDimensionCustomNames dialog(dimensions, this); if (dialog.exec() == QDialog::Rejected) @@ -2572,40 +2575,42 @@ void TMainWindow::SetupMenu() connect(ui->actionExportToCSV, &QAction::triggered, this, &TMainWindow::ExportDataToCSV); connect(ui->actionImportFromCSV, &QAction::triggered, this, &TMainWindow::ImportDataFromCSV); - connect(ui->actionReadOnly, &QAction::triggered, this, [this](bool ro) - { - if (not m_mIsReadOnly) - { - m_m->SetReadOnly(ro); - MeasurementsWereSaved(false); - UpdatePadlock(ro); - UpdateWindowTitle(); - } - else - { - if (auto *action = qobject_cast< QAction * >(this->sender())) + connect(ui->actionReadOnly, &QAction::triggered, this, + [this](bool ro) { - action->setChecked(true); - } - } - }); + if (not m_mIsReadOnly) + { + m_m->SetReadOnly(ro); + MeasurementsWereSaved(false); + UpdatePadlock(ro); + UpdateWindowTitle(); + } + else + { + if (auto *action = qobject_cast(this->sender())) + { + action->setChecked(true); + } + } + }); connect(ui->actionPreferences, &QAction::triggered, this, &TMainWindow::Preferences); - for (auto & recentFileAct : m_recentFileActs) + for (auto &recentFileAct : m_recentFileActs) { auto *action = new QAction(this); recentFileAct = action; - connect(action, &QAction::triggered, this, [this]() - { - if (auto *senderAction = qobject_cast(sender())) - { - const QString filePath = senderAction->data().toString(); - if (not filePath.isEmpty()) + connect(action, &QAction::triggered, this, + [this]() { - LoadFile(filePath); - } - } - }); + if (auto *senderAction = qobject_cast(sender())) + { + const QString filePath = senderAction->data().toString(); + if (not filePath.isEmpty()) + { + LoadFile(filePath); + } + } + }); ui->menuFile->insertAction(ui->actionPreferences, recentFileAct); recentFileAct->setVisible(false); } @@ -2613,7 +2618,7 @@ void TMainWindow::SetupMenu() m_separatorAct = new QAction(this); m_separatorAct->setSeparator(true); m_separatorAct->setVisible(false); - ui->menuFile->insertAction(ui->actionPreferences, m_separatorAct ); + ui->menuFile->insertAction(ui->actionPreferences, m_separatorAct); connect(ui->actionQuit, &QAction::triggered, this, &TMainWindow::close); ui->actionQuit->setShortcuts(QKeySequence::Quit); @@ -2630,20 +2635,17 @@ void TMainWindow::SetupMenu() AboutToShowWindowMenu(); // Help - connect(ui->actionAboutQt, &QAction::triggered, this, [this]() - { - QMessageBox::aboutQt(this, tr("About Qt")); - }); - connect(ui->actionAboutTape, &QAction::triggered, this, [this]() - { - auto *aboutDialog = new DialogAboutTape(this); - aboutDialog->setAttribute(Qt::WA_DeleteOnClose, true); - aboutDialog->show(); - }); + connect(ui->actionAboutQt, &QAction::triggered, this, [this]() { QMessageBox::aboutQt(this, tr("About Qt")); }); + connect(ui->actionAboutTape, &QAction::triggered, this, + [this]() + { + auto *aboutDialog = new DialogAboutTape(this); + aboutDialog->setAttribute(Qt::WA_DeleteOnClose, true); + aboutDialog->show(); + }); - //Actions for recent files loaded by a tape window application. + // Actions for recent files loaded by a tape window application. UpdateRecentFileActions(); - } //--------------------------------------------------------------------------------------------------------------------- @@ -2692,17 +2694,17 @@ void TMainWindow::InitWindow() InitDimesionShifts(); - connect(ui->doubleSpinBoxBaseValue, QOverload::of(&QDoubleSpinBox::valueChanged), - this, &TMainWindow::SaveMBaseValue); - connect(ui->doubleSpinBoxCorrection, QOverload::of(&QDoubleSpinBox::valueChanged), - this, &TMainWindow::SaveMCorrectionValue); + connect(ui->doubleSpinBoxBaseValue, QOverload::of(&QDoubleSpinBox::valueChanged), this, + &TMainWindow::SaveMBaseValue); + connect(ui->doubleSpinBoxCorrection, QOverload::of(&QDoubleSpinBox::valueChanged), this, + &TMainWindow::SaveMCorrectionValue); - connect(ui->doubleSpinBoxShiftA, QOverload::of(&QDoubleSpinBox::valueChanged), - this, &TMainWindow::SaveMShiftA); - connect(ui->doubleSpinBoxShiftB, QOverload::of(&QDoubleSpinBox::valueChanged), - this, &TMainWindow::SaveMShiftB); - connect(ui->doubleSpinBoxShiftC, QOverload::of(&QDoubleSpinBox::valueChanged), - this, &TMainWindow::SaveMShiftC); + connect(ui->doubleSpinBoxShiftA, QOverload::of(&QDoubleSpinBox::valueChanged), this, + &TMainWindow::SaveMShiftA); + connect(ui->doubleSpinBoxShiftB, QOverload::of(&QDoubleSpinBox::valueChanged), this, + &TMainWindow::SaveMShiftB); + connect(ui->doubleSpinBoxShiftC, QOverload::of(&QDoubleSpinBox::valueChanged), this, + &TMainWindow::SaveMShiftC); HackDimensionShifts(); @@ -2766,7 +2768,7 @@ void TMainWindow::InitWindow() ui->comboBoxPMSystem->setEnabled(true); ui->comboBoxPMSystem->clear(); InitPMSystems(ui->comboBoxPMSystem); - const qint32 index = ui->comboBoxPMSystem->findData(QLatin1Char('p')+m_m->PMSystem()); + const qint32 index = ui->comboBoxPMSystem->findData(QLatin1Char('p') + m_m->PMSystem()); ui->comboBoxPMSystem->setCurrentIndex(index); connect(ui->comboBoxPMSystem, QOverload::of(&QComboBox::currentIndexChanged), this, &TMainWindow::SavePMSystem); @@ -2782,9 +2784,8 @@ void TMainWindow::InitWindow() ui->actionImportFromPattern->setEnabled(true); ui->actionSaveAs->setEnabled(true); - ui->lineEditName->setValidator(new QRegularExpressionValidator(QRegularExpression( - QStringLiteral("^$|")+NameRegExp()), - this)); + ui->lineEditName->setValidator( + new QRegularExpressionValidator(QRegularExpression(QStringLiteral("^$|") + NameRegExp()), this)); connect(ui->toolButtonRemove, &QToolButton::clicked, this, &TMainWindow::Remove); connect(ui->toolButtonTop, &QToolButton::clicked, this, &TMainWindow::MoveTop); @@ -2796,10 +2797,7 @@ void TMainWindow::InitWindow() connect(ui->plainTextEditDescription, &QPlainTextEdit::textChanged, this, &TMainWindow::SaveMDescription); connect(ui->lineEditFullName, &QLineEdit::textEdited, this, &TMainWindow::SaveMFullName); - connect(ui->pushButtonShowInExplorer, &QPushButton::clicked, this, [this]() - { - ShowInGraphicalShell(m_curFile); - }); + connect(ui->pushButtonShowInExplorer, &QPushButton::clicked, this, [this]() { ShowInGraphicalShell(m_curFile); }); InitPatternUnits(); InitMeasurementUnits(); @@ -2881,14 +2879,14 @@ void TMainWindow::InitDimensionsBaseValue() if (dimensions.size() > index) { - const MeasurementDimension_p& dimension = dimensions.at(index); - name->setText(dimension->Name()+QChar(':')); + const MeasurementDimension_p &dimension = dimensions.at(index); + name->setText(dimension->Name() + QChar(':')); name->setToolTip(VAbstartMeasurementDimension::DimensionToolTip(dimension, m_m->IsFullCircumference())); DimesionLabels labels = dimension->Labels(); - if (VFuzzyContains(labels, dimension->BaseValue()) - && not VFuzzyValue(labels, dimension->BaseValue()).isEmpty()) + if (VFuzzyContains(labels, dimension->BaseValue()) && + not VFuzzyValue(labels, dimension->BaseValue()).isEmpty()) { base->setText(VFuzzyValue(labels, dimension->BaseValue())); } @@ -2898,7 +2896,7 @@ void TMainWindow::InitDimensionsBaseValue() { if (dimension->Type() != MeasurementDimension::X && fc) { - base->setText(QStringLiteral("%1 %2").arg(dimension->BaseValue()*2).arg(unit)); + base->setText(QStringLiteral("%1 %2").arg(dimension->BaseValue() * 2).arg(unit)); } else { @@ -2989,15 +2987,15 @@ void TMainWindow::InitDimensionControls() { if (dimensions.size() > index) { - const MeasurementDimension_p& dimension = dimensions.at(index); + const MeasurementDimension_p &dimension = dimensions.at(index); if (name == nullptr) { - name = new QLabel(dimension->Name()+QChar(':')); + name = new QLabel(dimension->Name() + QChar(':')); } else { - name->setText(dimension->Name()+QChar(':')); + name->setText(dimension->Name() + QChar(':')); } name->setToolTip(VAbstartMeasurementDimension::DimensionToolTip(dimension, m_m->IsFullCircumference())); @@ -3025,7 +3023,7 @@ void TMainWindow::InitDimesionShifts() { if (dimensions.size() > index) { - const MeasurementDimension_p& dimension = dimensions.at(index); + const MeasurementDimension_p &dimension = dimensions.at(index); name->setText(tr("Shift (%1):").arg(dimension->Name())); name->setToolTip(VAbstartMeasurementDimension::DimensionToolTip(dimension, m_m->IsFullCircumference())); @@ -3042,17 +3040,17 @@ void TMainWindow::InitTable() { if (m_mType == MeasurementsType::Multisize) { - ui->tableWidget->setColumnHidden( ColumnFormula, true );// formula + ui->tableWidget->setColumnHidden(ColumnFormula, true); // formula RetranslateTableHeaders(); } else { - ui->tableWidget->setColumnHidden( ColumnBaseValue, true );// base value - ui->tableWidget->setColumnHidden( ColumnShiftA, true ); - ui->tableWidget->setColumnHidden( ColumnShiftB, true ); - ui->tableWidget->setColumnHidden( ColumnShiftC, true ); - ui->tableWidget->setColumnHidden( ColumnCorrection, true ); + ui->tableWidget->setColumnHidden(ColumnBaseValue, true); // base value + ui->tableWidget->setColumnHidden(ColumnShiftA, true); + ui->tableWidget->setColumnHidden(ColumnShiftB, true); + ui->tableWidget->setColumnHidden(ColumnShiftC, true); + ui->tableWidget->setColumnHidden(ColumnCorrection, true); } connect(ui->tableWidget, &QTableWidget::itemSelectionChanged, this, &TMainWindow::ShowMData); @@ -3069,9 +3067,9 @@ void TMainWindow::ShowUnits() { const QString unit = UnitsToStr(m_mUnit); - ShowHeaderUnits(ui->tableWidget, ColumnCalcValue, UnitsToStr(m_pUnit));// calculated value - ShowHeaderUnits(ui->tableWidget, ColumnFormula, unit);// formula - ShowHeaderUnits(ui->tableWidget, ColumnBaseValue, unit);// base value + ShowHeaderUnits(ui->tableWidget, ColumnCalcValue, UnitsToStr(m_pUnit)); // calculated value + ShowHeaderUnits(ui->tableWidget, ColumnFormula, unit); // formula + ShowHeaderUnits(ui->tableWidget, ColumnBaseValue, unit); // base value ShowHeaderUnits(ui->tableWidget, ColumnShiftA, unit); ShowHeaderUnits(ui->tableWidget, ColumnShiftB, unit); ShowHeaderUnits(ui->tableWidget, ColumnShiftC, unit); @@ -3087,7 +3085,7 @@ void TMainWindow::ShowHeaderUnits(QTableWidget *table, int column, const QString const auto index = header.indexOf(QLatin1String("(")); if (index != -1) { - header.remove(index-1, 100); + header.remove(index - 1, 100); } const QString unitHeader = QStringLiteral("%1 (%2)").arg(header, unit); table->horizontalHeaderItem(column)->setText(unitHeader); @@ -3097,7 +3095,7 @@ void TMainWindow::ShowHeaderUnits(QTableWidget *table, int column, const QString void TMainWindow::MeasurementsWereSaved(bool saved) { setWindowModified(!saved); - not m_mIsReadOnly ? ui->actionSave->setEnabled(!saved): ui->actionSave->setEnabled(false); + not m_mIsReadOnly ? ui->actionSave->setEnabled(!saved) : ui->actionSave->setEnabled(false); } //--------------------------------------------------------------------------------------------------------------------- @@ -3151,7 +3149,7 @@ auto TMainWindow::MaybeSave() -> bool { if (m_curFile.isEmpty() && ui->tableWidget->rowCount() == 0) { - return true;// Don't ask if file was created without modifications. + return true; // Don't ask if file was created without modifications. } QScopedPointer messageBox(new QMessageBox(tr("Unsaved changes"), @@ -3216,8 +3214,8 @@ auto TMainWindow::AddCell(const QString &text, int row, int column, int aligment } //--------------------------------------------------------------------------------------------------------------------- -auto TMainWindow::AddSeparatorCell(const QString &text, int row, int column, int aligment, - bool ok) -> QTableWidgetItem * +auto TMainWindow::AddSeparatorCell(const QString &text, int row, int column, int aligment, bool ok) + -> QTableWidgetItem * { QTableWidgetItem *item = AddCell(text, row, column, aligment, ok); @@ -3249,9 +3247,9 @@ void TMainWindow::RefreshTable(bool freshCall) ShowUnits(); - const QMap > orderedTable = OrderedMeasurments(); + const QMap> orderedTable = OrderedMeasurments(); qint32 currentRow = -1; - ui->tableWidget->setRowCount ( static_cast(orderedTable.size()) ); + ui->tableWidget->setRowCount(static_cast(orderedTable.size())); for (auto iMap = orderedTable.constBegin(); iMap != orderedTable.constEnd(); ++iMap) { const QSharedPointer &meash = iMap.value(); @@ -3263,9 +3261,9 @@ void TMainWindow::RefreshTable(bool freshCall) } else if (meash->GetType() == VarType::MeasurementSeparator) { - QTableWidgetItem *item = AddSeparatorCell( - VAbstractApplication::VApp()->TrVars()->MToUser(meash->GetName()), currentRow, ColumnName, - Qt::AlignVCenter); // name + QTableWidgetItem *item = AddSeparatorCell(VAbstractApplication::VApp()->TrVars()->MToUser(meash->GetName()), + currentRow, ColumnName, + Qt::AlignVCenter); // name item->setData(Qt::UserRole, meash->GetName()); AddCell(meash->GetDescription(), currentRow, ColumnFullName, Qt::AlignVCenter); // description @@ -3296,8 +3294,8 @@ void TMainWindow::RefreshMeasurementData(const QSharedPointer &mea { if (m_mType == MeasurementsType::Individual) { - QTableWidgetItem *item = AddCell(VAbstractApplication::VApp()->TrVars()->MToUser(meash->GetName()), - currentRow, ColumnName, Qt::AlignVCenter); // name + QTableWidgetItem *item = AddCell(VAbstractApplication::VApp()->TrVars()->MToUser(meash->GetName()), currentRow, + ColumnName, Qt::AlignVCenter); // name item->setData(Qt::UserRole, meash->GetName()); if (meash->IsCustom()) @@ -3306,8 +3304,8 @@ void TMainWindow::RefreshMeasurementData(const QSharedPointer &mea } else { - AddCell(VAbstractApplication::VApp()->TrVars()->GuiText(meash->GetName()), currentRow, - ColumnFullName, Qt::AlignVCenter); + AddCell(VAbstractApplication::VApp()->TrVars()->GuiText(meash->GetName()), currentRow, ColumnFullName, + Qt::AlignVCenter); } QString calculatedValue; @@ -3323,16 +3321,15 @@ void TMainWindow::RefreshMeasurementData(const QSharedPointer &mea AddCell(calculatedValue, currentRow, ColumnCalcValue, Qt::AlignHCenter | Qt::AlignVCenter, meash->IsFormulaOk()); // calculated value - QString formula = - VTranslateVars::TryFormulaToUser(meash->GetFormula(), - VAbstractApplication::VApp()->Settings()->GetOsSeparator()); + QString formula = VTranslateVars::TryFormulaToUser(meash->GetFormula(), + VAbstractApplication::VApp()->Settings()->GetOsSeparator()); AddCell(formula, currentRow, ColumnFormula, Qt::AlignVCenter); // formula } else { - QTableWidgetItem *item = AddCell(VAbstractApplication::VApp()->TrVars()->MToUser(meash->GetName()), - currentRow, 0, Qt::AlignVCenter); // name + QTableWidgetItem *item = AddCell(VAbstractApplication::VApp()->TrVars()->MToUser(meash->GetName()), currentRow, + 0, Qt::AlignVCenter); // name item->setData(Qt::UserRole, meash->GetName()); if (meash->IsCustom()) @@ -3341,8 +3338,8 @@ void TMainWindow::RefreshMeasurementData(const QSharedPointer &mea } else { - AddCell(VAbstractApplication::VApp()->TrVars()->GuiText(meash->GetName()), currentRow, - ColumnFullName, Qt::AlignVCenter); + AddCell(VAbstractApplication::VApp()->TrVars()->GuiText(meash->GetName()), currentRow, ColumnFullName, + Qt::AlignVCenter); } QString calculatedValue; @@ -3353,28 +3350,24 @@ void TMainWindow::RefreshMeasurementData(const QSharedPointer &mea } else { - const qreal value = UnitConvertor(*m_data->DataVariables()->value(meash->GetName())->GetValue(), - m_mUnit, m_pUnit); + const qreal value = + UnitConvertor(*m_data->DataVariables()->value(meash->GetName())->GetValue(), m_mUnit, m_pUnit); calculatedValue = locale().toString(value); } - AddCell(calculatedValue, currentRow, ColumnCalcValue, - Qt::AlignHCenter | Qt::AlignVCenter, meash->IsFormulaOk()); // calculated value + AddCell(calculatedValue, currentRow, ColumnCalcValue, Qt::AlignHCenter | Qt::AlignVCenter, + meash->IsFormulaOk()); // calculated value AddCell(locale().toString(meash->GetBase()), currentRow, ColumnBaseValue, Qt::AlignHCenter | Qt::AlignVCenter); // base value - AddCell(locale().toString(meash->GetShiftA()), currentRow, ColumnShiftA, - Qt::AlignHCenter | Qt::AlignVCenter); + AddCell(locale().toString(meash->GetShiftA()), currentRow, ColumnShiftA, Qt::AlignHCenter | Qt::AlignVCenter); - AddCell(locale().toString(meash->GetShiftB()), currentRow, ColumnShiftB, - Qt::AlignHCenter | Qt::AlignVCenter); + AddCell(locale().toString(meash->GetShiftB()), currentRow, ColumnShiftB, Qt::AlignHCenter | Qt::AlignVCenter); - AddCell(locale().toString(meash->GetShiftC()), currentRow, ColumnShiftC, - Qt::AlignHCenter | Qt::AlignVCenter); + AddCell(locale().toString(meash->GetShiftC()), currentRow, ColumnShiftC, Qt::AlignHCenter | Qt::AlignVCenter); - AddCell(locale() - .toString(meash->GetCorrection(m_currentDimensionA, m_currentDimensionB, m_currentDimensionC)), + AddCell(locale().toString(meash->GetCorrection(m_currentDimensionA, m_currentDimensionB, m_currentDimensionC)), currentRow, ColumnCorrection, Qt::AlignHCenter | Qt::AlignVCenter); } } @@ -3387,7 +3380,7 @@ auto TMainWindow::GetCustomName() const -> QString do { name = CustomMSign + VAbstractApplication::VApp()->TrVars()->InternalVarToUser(measurement_) + - QString::number(num); + QString::number(num); num++; } while (not m_data->IsUnique(name)); @@ -3415,7 +3408,7 @@ void TMainWindow::Controls() ui->toolButtonDown->setEnabled(true); ui->toolButtonBottom->setEnabled(true); } - else if (ui->tableWidget->currentRow() == ui->tableWidget->rowCount()-1) + else if (ui->tableWidget->currentRow() == ui->tableWidget->rowCount() - 1) { ui->toolButtonTop->setEnabled(true); ui->toolButtonUp->setEnabled(true); @@ -3485,13 +3478,13 @@ void TMainWindow::UpdateWindowTitle() bool isFileWritable = true; if (not m_curFile.isEmpty()) { -//#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*/ isFileWritable = QFileInfo(m_curFile).isWritable(); -//#ifdef Q_OS_WIN32 -// qt_ntfs_permission_lookup--; // turn it off again -//#endif /*Q_OS_WIN32*/ + // #ifdef Q_OS_WIN32 + // qt_ntfs_permission_lookup--; // turn it off again + // #endif /*Q_OS_WIN32*/ showName = StrippedName(m_curFile); } else @@ -3499,7 +3492,7 @@ void TMainWindow::UpdateWindowTitle() auto index = MApplication::VApp()->MainWindows().indexOf(this); if (index != -1) { - showName = tr("untitled %1").arg(index+1); + showName = tr("untitled %1").arg(index + 1); } else { @@ -3519,8 +3512,8 @@ void TMainWindow::UpdateWindowTitle() setWindowFilePath(m_curFile); #if defined(Q_OS_MAC) - static QIcon fileIcon = QIcon(QCoreApplication::applicationDirPath() + - QLatin1String("/../Resources/measurements.icns")); + static QIcon fileIcon = + QIcon(QCoreApplication::applicationDirPath() + QLatin1String("/../Resources/measurements.icns")); QIcon icon; if (not m_curFile.isEmpty()) { @@ -3540,7 +3533,7 @@ void TMainWindow::UpdateWindowTitle() } } setWindowIcon(icon); -#endif //defined(Q_OS_MAC) +#endif // defined(Q_OS_MAC) } //--------------------------------------------------------------------------------------------------------------------- @@ -3556,8 +3549,8 @@ auto TMainWindow::ClearCustomName(const QString &name) -> QString } //--------------------------------------------------------------------------------------------------------------------- -auto TMainWindow::EvalFormula(const QString &formula, bool fromUser, VContainer *data, QLabel *label, - bool specialUnits) -> bool +auto TMainWindow::EvalFormula(const QString &formula, bool fromUser, VContainer *data, QLabel *label, bool specialUnits) + -> bool { const QString postfix = specialUnits ? degreeSymbol : UnitsToStr(m_pUnit); @@ -3574,8 +3567,8 @@ auto TMainWindow::EvalFormula(const QString &formula, bool fromUser, VContainer QString f; if (fromUser) { - f = VAbstractApplication::VApp()->TrVars() - ->FormulaFromUser(formula, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); + f = VAbstractApplication::VApp()->TrVars()->FormulaFromUser( + formula, VAbstractApplication::VApp()->Settings()->GetOsSeparator()); } else { @@ -3596,7 +3589,7 @@ auto TMainWindow::EvalFormula(const QString &formula, bool fromUser, VContainer result = UnitConvertor(result, m_mUnit, m_pUnit); } - label->setText(VAbstractApplication::VApp()->LocaleToString(result) + QChar(QChar::Space) +postfix); + label->setText(VAbstractApplication::VApp()->LocaleToString(result) + QChar(QChar::Space) + postfix); label->setToolTip(tr("Value")); return true; } @@ -3648,7 +3641,7 @@ void TMainWindow::MeasurementGUI() { if (const QTableWidgetItem *nameField = ui->tableWidget->item(ui->tableWidget->currentRow(), ColumnName)) { - const bool isCustom = not (nameField->text().indexOf(CustomMSign) == 0); + const bool isCustom = not(nameField->text().indexOf(CustomMSign) == 0); ui->lineEditName->setReadOnly(isCustom); ui->plainTextEditDescription->setReadOnly(isCustom); ui->lineEditFullName->setReadOnly(isCustom); @@ -3676,7 +3669,7 @@ void TMainWindow::ReadSettings() ToolBarStyles(); // Stack limit - //VAbstractApplication::VApp()->getUndoStack()->setUndoLimit(settings->GetUndoCount()); + // VAbstractApplication::VApp()->getUndoStack()->setUndoLimit(settings->GetUndoCount()); } else { @@ -3745,9 +3738,9 @@ auto TMainWindow::LoadFromExistingFile(const QString &path) -> bool } // Check if file already opened - const QList list = MApplication::VApp()->MainWindows(); - auto w = std::find_if(list.begin(), list.end(), - [path](TMainWindow *window) { return window->CurrentFile() == path; }); + const QList list = MApplication::VApp()->MainWindows(); + auto w = + std::find_if(list.begin(), list.end(), [path](TMainWindow *window) { return window->CurrentFile() == path; }); if (w != list.end()) { (*w)->activateWindow(); @@ -3780,12 +3773,12 @@ auto TMainWindow::LoadFromExistingFile(const QString &path) -> bool } QScopedPointer converter( - (m_mType == MeasurementsType::Individual) ? static_cast(new VVITConverter(path)) - : static_cast(new VVSTConverter(path))); + (m_mType == MeasurementsType::Individual) ? static_cast(new VVITConverter(path)) + : static_cast(new VVSTConverter(path))); m_curFileFormatVersion = converter->GetCurrentFormatVersion(); m_curFileFormatVersionStr = converter->GetFormatVersionStr(); - m_m->setXMLContent(converter->Convert());// Read again after conversion + m_m->setXMLContent(converter->Convert()); // Read again after conversion if (not m_m->IsDefinedKnownNamesValid()) { @@ -3813,7 +3806,7 @@ auto TMainWindow::LoadFromExistingFile(const QString &path) -> bool ui->tableWidget->selectRow(0); } - m_lock.reset();// Now we can unlock the file + m_lock.reset(); // Now we can unlock the file m_mIsReadOnly = m_m->IsReadOnly(); UpdatePadlock(m_mIsReadOnly); @@ -3821,8 +3814,8 @@ auto TMainWindow::LoadFromExistingFile(const QString &path) -> bool } catch (VException &e) { - qCCritical(tMainWindow, "%s\n\n%s\n\n%s", qUtf8Printable(tr("File error.")), - qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation())); + qCCritical(tMainWindow, "%s\n\n%s\n\n%s", qUtf8Printable(tr("File error.")), qUtf8Printable(e.ErrorMessage()), + qUtf8Printable(e.DetailedInformation())); ui->labelToolTip->setVisible(true); ui->tabWidget->setVisible(false); delete m_m; @@ -3847,19 +3840,16 @@ void TMainWindow::CreateWindowMenu(QMenu *menu) SCASSERT(menu != nullptr) QAction *action = menu->addAction(tr("&New Window")); - connect(action, &QAction::triggered, this, []() - { - MApplication::VApp()->NewMainWindow()->activateWindow(); - }); + connect(action, &QAction::triggered, this, []() { MApplication::VApp()->NewMainWindow()->activateWindow(); }); action->setMenuRole(QAction::NoRole); menu->addSeparator(); - const QList windows = MApplication::VApp()->MainWindows(); + const QList windows = MApplication::VApp()->MainWindows(); for (int i = 0; i < windows.count(); ++i) { TMainWindow *window = windows.at(i); - QString title = QStringLiteral("%1. %2").arg(i+1).arg(window->windowTitle()); + QString title = QStringLiteral("%1. %2").arg(i + 1).arg(window->windowTitle()); const auto index = title.lastIndexOf(QLatin1String("[*]")); if (index != -1) { @@ -3870,7 +3860,7 @@ void TMainWindow::CreateWindowMenu(QMenu *menu) QAction *action = menu->addAction(title, this, SLOT(ShowWindow())); #else QAction *action = menu->addAction(title, this, &TMainWindow::ShowWindow); -#endif //QT_VERSION < QT_VERSION_CHECK(5, 6, 0) +#endif // QT_VERSION < QT_VERSION_CHECK(5, 6, 0) action->setData(i); action->setCheckable(true); action->setMenuRole(QAction::NoRole); @@ -4006,7 +3996,7 @@ void TMainWindow::ImportIndividualMeasurements(const QxtCsvModel &csv, const QVe QVector measurements; QSet importedNames; - for(int i=0; i < rows; ++i) + for (int i = 0; i < rows; ++i) { try { @@ -4034,7 +4024,7 @@ void TMainWindow::ImportIndividualMeasurements(const QxtCsvModel &csv, const QVe } catch (VException &e) { - int rowIndex = i+1; + int rowIndex = i + 1; if (withHeader) { ++rowIndex; @@ -4044,7 +4034,7 @@ void TMainWindow::ImportIndividualMeasurements(const QxtCsvModel &csv, const QVe } } - for(const auto &im : qAsConst(measurements)) + for (const auto &im : qAsConst(measurements)) { m_m->AddEmpty(im.name, im.value); @@ -4076,10 +4066,10 @@ void TMainWindow::ImportMultisizeMeasurements(const QxtCsvModel &csv, const QVec QVector measurements; QSet importedNames; - const QMap dimensions = m_m->Dimensions(); + const QMap dimensions = m_m->Dimensions(); const int rows = csv.rowCount(); - for(int i=0; i < rows; ++i) + for (int i = 0; i < rows; ++i) { try { @@ -4087,7 +4077,7 @@ void TMainWindow::ImportMultisizeMeasurements(const QxtCsvModel &csv, const QVec } catch (VException &e) { - int rowIndex = i+1; + int rowIndex = i + 1; if (withHeader) { ++rowIndex; @@ -4097,7 +4087,7 @@ void TMainWindow::ImportMultisizeMeasurements(const QxtCsvModel &csv, const QVec } } - for(const auto &mm : qAsConst(measurements)) + for (const auto &mm : qAsConst(measurements)) { m_m->AddEmpty(mm.name); m_m->SetMBaseValue(mm.name, mm.base); @@ -4129,8 +4119,8 @@ void TMainWindow::ImportMultisizeMeasurements(const QxtCsvModel &csv, const QVec //--------------------------------------------------------------------------------------------------------------------- auto TMainWindow::ImportMultisizeMeasurement(const QxtCsvModel &csv, int i, const QVector &map, - vsizetype dimensionsCount, - QSet &importedNames) -> TMainWindow::MultisizeMeasurement + vsizetype dimensionsCount, QSet &importedNames) + -> TMainWindow::MultisizeMeasurement { const auto nameColumn = map.at(static_cast(MultisizeMeasurementsColumns::Name)); const QString name = csv.text(i, nameColumn).simplified(); @@ -4146,28 +4136,25 @@ auto TMainWindow::ImportMultisizeMeasurement(const QxtCsvModel &csv, int i, cons measurement.name = mName; const auto baseValueColumn = map.at(static_cast(MultisizeMeasurementsColumns::BaseValue)); - measurement.base = ConverToDouble(csv.text(i, baseValueColumn), - tr("Cannot convert base value to double in column 2.")); + measurement.base = + ConverToDouble(csv.text(i, baseValueColumn), tr("Cannot convert base value to double in column 2.")); const auto shiftAColumn = map.at(static_cast(MultisizeMeasurementsColumns::ShiftA)); measurement.shiftA = ConverToDouble(csv.text(i, shiftAColumn), - tr("Cannot convert shift value to double in column %1.") - .arg(shiftAColumn)); + tr("Cannot convert shift value to double in column %1.").arg(shiftAColumn)); if (dimensionsCount > 1) { const auto shiftBColumn = map.at(static_cast(MultisizeMeasurementsColumns::ShiftB)); measurement.shiftB = ConverToDouble(csv.text(i, shiftBColumn), - tr("Cannot convert shift value to double in column %1.") - .arg(shiftBColumn)); + tr("Cannot convert shift value to double in column %1.").arg(shiftBColumn)); } if (dimensionsCount > 2) { const auto shiftCColumn = map.at(static_cast(MultisizeMeasurementsColumns::ShiftC)); measurement.shiftC = ConverToDouble(csv.text(i, shiftCColumn), - tr("Cannot convert shift value to double in column %1.") - .arg(shiftCColumn)); + tr("Cannot convert shift value to double in column %1.").arg(shiftCColumn)); } const int columns = csv.columnCount(); @@ -4231,20 +4218,20 @@ void TMainWindow::ShowDimensionControls() if (m_gradationDimensionA) { - connect(m_gradationDimensionA, QOverload::of(&QComboBox::currentIndexChanged), - this, &TMainWindow::DimensionABaseChanged); + connect(m_gradationDimensionA, QOverload::of(&QComboBox::currentIndexChanged), this, + &TMainWindow::DimensionABaseChanged); } if (m_gradationDimensionB) { - connect(m_gradationDimensionB, QOverload::of(&QComboBox::currentIndexChanged), - this, &TMainWindow::DimensionBBaseChanged); + connect(m_gradationDimensionB, QOverload::of(&QComboBox::currentIndexChanged), this, + &TMainWindow::DimensionBBaseChanged); } if (m_gradationDimensionC) { - connect(m_gradationDimensionC, QOverload::of(&QComboBox::currentIndexChanged), - this, &TMainWindow::DimensionCBaseChanged); + connect(m_gradationDimensionC, QOverload::of(&QComboBox::currentIndexChanged), this, + &TMainWindow::DimensionCBaseChanged); } } @@ -4255,19 +4242,19 @@ void TMainWindow::SetDimensionBases() if (not dimensions.empty()) { - const MeasurementDimension_p& dimension = dimensions.at(0); + const MeasurementDimension_p &dimension = dimensions.at(0); m_currentDimensionA = dimension->BaseValue(); } if (dimensions.size() > 1) { - const MeasurementDimension_p& dimension = dimensions.at(1); + const MeasurementDimension_p &dimension = dimensions.at(1); m_currentDimensionB = dimension->BaseValue(); } if (dimensions.size() > 2) { - const MeasurementDimension_p& dimension = dimensions.at(2); + const MeasurementDimension_p &dimension = dimensions.at(2); m_currentDimensionC = dimension->BaseValue(); } @@ -4303,7 +4290,7 @@ void TMainWindow::SetCurrentDimensionValues() { if (dimensions.size() > index) { - const MeasurementDimension_p& dimension = dimensions.at(index); + const MeasurementDimension_p &dimension = dimensions.at(index); value = dimension->BaseValue(); } }; @@ -4345,11 +4332,11 @@ auto TMainWindow::DimensionRestrictedValues(int index, const MeasurementDimensio } //--------------------------------------------------------------------------------------------------------------------- -auto TMainWindow::OrderedMeasurments() const -> QMap > +auto TMainWindow::OrderedMeasurments() const -> QMap> { - const QMap > table = m_data->DataMeasurementsWithSeparators(); - QMap > orderedTable; - QMap >::const_iterator iterMap; + const QMap> table = m_data->DataMeasurementsWithSeparators(); + QMap> orderedTable; + QMap>::const_iterator iterMap; for (iterMap = table.constBegin(); iterMap != table.constEnd(); ++iterMap) { const QSharedPointer &meash = iterMap.value(); @@ -4427,12 +4414,13 @@ void TMainWindow::InitPatternUnits() InitComboBoxUnits(); SetCurrentPatternUnit(); - connect(m_comboBoxUnits, QOverload::of(&QComboBox::currentIndexChanged), this, [this](int index) - { - m_pUnit = static_cast(m_comboBoxUnits->itemData(index).toInt()); + connect(m_comboBoxUnits, QOverload::of(&QComboBox::currentIndexChanged), this, + [this](int index) + { + m_pUnit = static_cast(m_comboBoxUnits->itemData(index).toInt()); - UpdatePatternUnit(); - }); + UpdatePatternUnit(); + }); ui->toolBarGradation->addWidget(m_comboBoxUnits); } @@ -4542,105 +4530,115 @@ void TMainWindow::InitSearch() UpdateSearchControlsTooltips(); - connect(ui->lineEditFind, &QLineEdit::textChanged, this, [this] (const QString &term){m_search->Find(term);}); - connect(ui->lineEditFind, &QLineEdit::editingFinished, this, [this]() - { - SaveSearchRequest(); - InitSearchHistory(); - m_search->Find(ui->lineEditFind->text()); - }); - connect(ui->toolButtonFindPrevious, &QToolButton::clicked, this, [this]() - { - SaveSearchRequest(); - InitSearchHistory(); - m_search->FindPrevious(); - ui->labelResults->setText(QStringLiteral("%1/%2").arg(m_search->MatchIndex()+1).arg(m_search->MatchCount())); - }); - connect(ui->toolButtonFindNext, &QToolButton::clicked, this, [this]() - { - SaveSearchRequest(); - InitSearchHistory(); - m_search->FindNext(); - ui->labelResults->setText(QStringLiteral("%1/%2").arg(m_search->MatchIndex()+1).arg(m_search->MatchCount())); - }); + connect(ui->lineEditFind, &QLineEdit::textChanged, this, [this](const QString &term) { m_search->Find(term); }); + connect(ui->lineEditFind, &QLineEdit::editingFinished, this, + [this]() + { + SaveSearchRequest(); + InitSearchHistory(); + m_search->Find(ui->lineEditFind->text()); + }); + connect(ui->toolButtonFindPrevious, &QToolButton::clicked, this, + [this]() + { + SaveSearchRequest(); + InitSearchHistory(); + m_search->FindPrevious(); + ui->labelResults->setText( + QStringLiteral("%1/%2").arg(m_search->MatchIndex() + 1).arg(m_search->MatchCount())); + }); + connect(ui->toolButtonFindNext, &QToolButton::clicked, this, + [this]() + { + SaveSearchRequest(); + InitSearchHistory(); + m_search->FindNext(); + ui->labelResults->setText( + QStringLiteral("%1/%2").arg(m_search->MatchIndex() + 1).arg(m_search->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(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->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->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->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()); + }); m_searchHistory->setStyleSheet(QStringLiteral("QMenu { menu-scrollable: 1; }")); InitSearchHistory(); @@ -4652,21 +4650,22 @@ void TMainWindow::InitSearchHistory() { QStringList searchHistory = MApplication::VApp()->TapeSettings()->GetTapeSearchHistory(); 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(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(sender()); + if (action != nullptr) + { + QString term = action->data().toString(); + ui->lineEditFind->setText(term); + m_search->Find(term); + ui->lineEditFind->setFocus(); + } + }); } } @@ -4714,42 +4713,38 @@ void TMainWindow::RetranslateTableHeaders() { if (m_mType == MeasurementsType::Multisize) { - const QList< MeasurementDimension_p > dimensions = m_m->Dimensions().values(); + const QList dimensions = m_m->Dimensions().values(); if (not dimensions.isEmpty()) { - const MeasurementDimension_p& dimension = dimensions.at(0); - ui->tableWidget->horizontalHeaderItem(ColumnShiftA)->setText( - tr("%1 shift").arg(dimension->Name())); + const MeasurementDimension_p &dimension = dimensions.at(0); + ui->tableWidget->horizontalHeaderItem(ColumnShiftA)->setText(tr("%1 shift").arg(dimension->Name())); } if (dimensions.size() < 2) { - ui->tableWidget->setColumnHidden( ColumnShiftB, true ); + ui->tableWidget->setColumnHidden(ColumnShiftB, true); } else { const MeasurementDimension_p &dimension = dimensions.at(1); - ui->tableWidget->horizontalHeaderItem(ColumnShiftB)->setText( - tr("%1 shift").arg(dimension->Name())); + ui->tableWidget->horizontalHeaderItem(ColumnShiftB)->setText(tr("%1 shift").arg(dimension->Name())); } if (dimensions.size() < 3) { - ui->tableWidget->setColumnHidden( ColumnShiftC, true ); + ui->tableWidget->setColumnHidden(ColumnShiftC, true); } else { const MeasurementDimension_p &dimension = dimensions.at(2); - ui->tableWidget->horizontalHeaderItem(ColumnShiftC)->setText( - tr("%1 shift").arg(dimension->Name())); + ui->tableWidget->horizontalHeaderItem(ColumnShiftC)->setText(tr("%1 shift").arg(dimension->Name())); } } } //--------------------------------------------------------------------------------------------------------------------- -template -void TMainWindow::HackWidget(T **widget) +template void TMainWindow::HackWidget(T **widget) { delete *widget; *widget = new T(); diff --git a/src/app/tape/vtapesettings.cpp b/src/app/tape/vtapesettings.cpp index 2a0f96391..01ec461f7 100644 --- a/src/app/tape/vtapesettings.cpp +++ b/src/app/tape/vtapesettings.cpp @@ -28,27 +28,40 @@ #include "vtapesettings.h" -#include +#include #include +#include + +#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) { } diff --git a/src/app/tape/vtapesettings.h b/src/app/tape/vtapesettings.h index 08f0c2780..016c42eff 100644 --- a/src/app/tape/vtapesettings.h +++ b/src/app/tape/vtapesettings.h @@ -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: diff --git a/src/app/valentina/core/vtooloptionspropertybrowser.cpp b/src/app/valentina/core/vtooloptionspropertybrowser.cpp index 6960978e3..929a27bf1 100644 --- a/src/app/valentina/core/vtooloptionspropertybrowser.cpp +++ b/src/app/valentina/core/vtooloptionspropertybrowser.cpp @@ -27,79 +27,88 @@ *************************************************************************/ #include "vtooloptionspropertybrowser.h" -#include "../vtools/tools/backgroundimage/vbackgroundpixmapitem.h" -#include "../vtools/tools/backgroundimage/vbackgroundsvgitem.h" -#include "../vwidgets/vgraphicssimpletextitem.h" -#include "../vwidgets/vcontrolpointspline.h" -#include "../vwidgets/vsimplepoint.h" -#include "../vwidgets/vsimplecurve.h" -#include "../vmisc/def.h" -#include "vformulaproperty.h" -#include "../vpatterndb/vformula.h" +#include "../qmuparser/qmudef.h" #include "../vgeometry/vcubicbezier.h" #include "../vgeometry/vcubicbezierpath.h" -#include "../qmuparser/qmudef.h" -#include "../vpropertyexplorer/plugins/vlabelproperty.h" -#include "../vpropertyexplorer/plugins/vstringproperty.h" -#include "../vpropertyexplorer/plugins/vtextproperty.h" -#include "../vpropertyexplorer/plugins/vlinetypeproperty.h" -#include "../vpropertyexplorer/plugins/vlinecolorproperty.h" +#include "../vmisc/def.h" +#include "../vpatterndb/vformula.h" #include "../vpropertyexplorer/plugins/vboolproperty.h" #include "../vpropertyexplorer/plugins/venumproperty.h" +#include "../vpropertyexplorer/plugins/vlabelproperty.h" +#include "../vpropertyexplorer/plugins/vlinecolorproperty.h" +#include "../vpropertyexplorer/plugins/vlinetypeproperty.h" #include "../vpropertyexplorer/plugins/vnumberproperty.h" #include "../vpropertyexplorer/plugins/vpointfproperty.h" +#include "../vpropertyexplorer/plugins/vstringproperty.h" +#include "../vpropertyexplorer/plugins/vtextproperty.h" +#include "../vtools/tools/backgroundimage/vbackgroundpixmapitem.h" +#include "../vtools/tools/backgroundimage/vbackgroundsvgitem.h" +#include "../vwidgets/vcontrolpointspline.h" +#include "../vwidgets/vgraphicssimpletextitem.h" +#include "../vwidgets/vsimplecurve.h" +#include "../vwidgets/vsimplepoint.h" +#include "vformulaproperty.h" -#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolalongline.h" -#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolbisector.h" -#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolendline.h" -#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolnormal.h" -#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolshoulderpoint.h" -#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolheight.h" -#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoollineintersectaxis.h" -#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolcurveintersectaxis.h" +#include "../vtools/tools/drawTools/operation/flipping/vtoolflippingbyaxis.h" +#include "../vtools/tools/drawTools/operation/flipping/vtoolflippingbyline.h" +#include "../vtools/tools/drawTools/operation/vtoolmove.h" +#include "../vtools/tools/drawTools/operation/vtoolrotation.h" #include "../vtools/tools/drawTools/toolcurve/vtoolarc.h" -#include "../vtools/tools/drawTools/toolcurve/vtoolellipticalarc.h" #include "../vtools/tools/drawTools/toolcurve/vtoolarcwithlength.h" -#include "../vtools/tools/drawTools/toolcurve/vtoolspline.h" #include "../vtools/tools/drawTools/toolcurve/vtoolcubicbezier.h" -#include "../vtools/tools/drawTools/toolcurve/vtoolsplinepath.h" #include "../vtools/tools/drawTools/toolcurve/vtoolcubicbezierpath.h" -#include "../vtools/tools/drawTools/vtoolline.h" +#include "../vtools/tools/drawTools/toolcurve/vtoolellipticalarc.h" +#include "../vtools/tools/drawTools/toolcurve/vtoolspline.h" +#include "../vtools/tools/drawTools/toolcurve/vtoolsplinepath.h" +#include "../vtools/tools/drawTools/toolpoint/tooldoublepoint/vtooltruedarts.h" +#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutarc.h" #include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutspline.h" #include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutsplinepath.h" -#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutarc.h" -#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoollineintersect.h" -#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofcontact.h" +#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolalongline.h" +#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolbisector.h" +#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolcurveintersectaxis.h" +#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolendline.h" +#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolheight.h" +#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoollineintersectaxis.h" +#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolnormal.h" +#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolshoulderpoint.h" #include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolbasepoint.h" -#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/vtooltriangle.h" +#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoollineintersect.h" +#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromarcandtangent.h" +#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromcircleandtangent.h" +#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofcontact.h" #include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersection.h" #include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectionarcs.h" #include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncircles.h" #include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncurves.h" -#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromcircleandtangent.h" -#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromarcandtangent.h" -#include "../vtools/tools/drawTools/toolpoint/tooldoublepoint/vtooltruedarts.h" -#include "../vtools/tools/drawTools/operation/vtoolrotation.h" -#include "../vtools/tools/drawTools/operation/flipping/vtoolflippingbyline.h" -#include "../vtools/tools/drawTools/operation/flipping/vtoolflippingbyaxis.h" -#include "../vtools/tools/drawTools/operation/vtoolmove.h" +#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/vtooltriangle.h" +#include "../vtools/tools/drawTools/vtoolline.h" +#if QT_VERSION < QT_VERSION_CHECK(5, 5, 0) +#include "../vmisc/diagnostic.h" +#endif // QT_VERSION < QT_VERSION_CHECK(5, 5, 0) + +#include #include #include -#include #include #include namespace { -Q_GLOBAL_STATIC_WITH_ARGS(const QString, AttrHold, (QLatin1String("hold"))) // NOLINT +QT_WARNING_PUSH +QT_WARNING_DISABLE_CLANG("-Wunused-member-function") + +Q_GLOBAL_STATIC_WITH_ARGS(const QString, AttrHold, (QLatin1String("hold"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, AttrVisible, (QLatin1String("visible"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, AttrOpacity, (QLatin1String("opacity"))) // NOLINT -} + +QT_WARNING_POP +} // namespace //--------------------------------------------------------------------------------------------------------------------- VToolOptionsPropertyBrowser::VToolOptionsPropertyBrowser(QDockWidget *parent) - :QObject(parent) + : QObject(parent) { m_PropertyModel = new VPE::VPropertyModel(this); m_formView = new VPE::VPropertyFormView(m_PropertyModel, parent); @@ -386,8 +395,8 @@ void VToolOptionsPropertyBrowser::UpdateOptions() void VToolOptionsPropertyBrowser::RefreshOptions() { QGraphicsItem *item = m_currentItem; - itemClicked(nullptr);//close options - itemClicked(item);//reopen options + itemClicked(nullptr); // close options + itemClicked(item); // reopen options } //--------------------------------------------------------------------------------------------------------------------- @@ -396,7 +405,7 @@ void VToolOptionsPropertyBrowser::userChangedData(VPE::VProperty *property) VPE::VProperty *prop = property; if (!m_propertyToId.contains(prop)) { - if (!m_propertyToId.contains(prop->getParent()))// Maybe we know parent + if (!m_propertyToId.contains(prop->getParent())) // Maybe we know parent { return; } @@ -549,7 +558,6 @@ void VToolOptionsPropertyBrowser::itemClicked(QGraphicsItem *item) m_propertyToId.clear(); m_idToProperty.clear(); - if (m_currentItem != nullptr) { auto *previousTool = dynamic_cast(m_currentItem); @@ -579,7 +587,7 @@ void VToolOptionsPropertyBrowser::AddPropertyFormula(const QString &propertyName } //--------------------------------------------------------------------------------------------------------------------- -template +template void VToolOptionsPropertyBrowser::AddPropertyObjectName(Tool *i, const QString &propertyName, bool readOnly) { if (readOnly) @@ -596,12 +604,10 @@ void VToolOptionsPropertyBrowser::AddPropertyObjectName(Tool *i, const QString & itemName->setReadOnly(readOnly); AddProperty(itemName, AttrName); } - } //--------------------------------------------------------------------------------------------------------------------- -template -void VToolOptionsPropertyBrowser::AddPropertyAlias(Tool *i, const QString &propertyName) +template void VToolOptionsPropertyBrowser::AddPropertyAlias(Tool *i, const QString &propertyName) { auto *itemName = new VPE::VStringProperty(propertyName); itemName->setClearButtonEnable(true); @@ -610,8 +616,7 @@ void VToolOptionsPropertyBrowser::AddPropertyAlias(Tool *i, const QString &prope } //--------------------------------------------------------------------------------------------------------------------- -template -void VToolOptionsPropertyBrowser::AddPropertyAlias1(Tool *i, const QString &propertyName) +template void VToolOptionsPropertyBrowser::AddPropertyAlias1(Tool *i, const QString &propertyName) { auto *itemName = new VPE::VStringProperty(propertyName); itemName->setClearButtonEnable(true); @@ -620,8 +625,7 @@ void VToolOptionsPropertyBrowser::AddPropertyAlias1(Tool *i, const QString &prop } //--------------------------------------------------------------------------------------------------------------------- -template -void VToolOptionsPropertyBrowser::AddPropertyAlias2(Tool *i, const QString &propertyName) +template void VToolOptionsPropertyBrowser::AddPropertyAlias2(Tool *i, const QString &propertyName) { auto *itemName = new VPE::VStringProperty(propertyName); itemName->setClearButtonEnable(true); @@ -630,8 +634,7 @@ void VToolOptionsPropertyBrowser::AddPropertyAlias2(Tool *i, const QString &prop } //--------------------------------------------------------------------------------------------------------------------- -template -void VToolOptionsPropertyBrowser::AddPropertyPointName1(Tool *i, const QString &propertyName) +template void VToolOptionsPropertyBrowser::AddPropertyPointName1(Tool *i, const QString &propertyName) { auto *itemName = new VPE::VStringProperty(propertyName); itemName->setClearButtonEnable(true); @@ -640,8 +643,7 @@ void VToolOptionsPropertyBrowser::AddPropertyPointName1(Tool *i, const QString & } //--------------------------------------------------------------------------------------------------------------------- -template -void VToolOptionsPropertyBrowser::AddPropertyPointName2(Tool *i, const QString &propertyName) +template void VToolOptionsPropertyBrowser::AddPropertyPointName2(Tool *i, const QString &propertyName) { auto *itemName = new VPE::VStringProperty(propertyName); itemName->setClearButtonEnable(true); @@ -650,7 +652,7 @@ void VToolOptionsPropertyBrowser::AddPropertyPointName2(Tool *i, const QString & } //--------------------------------------------------------------------------------------------------------------------- -template +template void VToolOptionsPropertyBrowser::AddPropertyOperationSuffix(Tool *i, const QString &propertyName, bool readOnly) { auto *itemSuffix = new VPE::VStringProperty(propertyName); @@ -687,51 +689,47 @@ void VToolOptionsPropertyBrowser::AddPropertyBool(const QString &propertyName, b } //--------------------------------------------------------------------------------------------------------------------- -template -void VToolOptionsPropertyBrowser::AddPropertyCrossPoint(Tool *i, const QString &propertyName) +template void VToolOptionsPropertyBrowser::AddPropertyCrossPoint(Tool *i, const QString &propertyName) { auto *itemProperty = new VPE::VEnumProperty(propertyName); - itemProperty->setLiterals(QStringList({VToolOptionsPropertyBrowser::tr("First point"), - VToolOptionsPropertyBrowser::tr("Second point")})); - itemProperty->setValue(static_cast(i->GetCrossCirclesPoint())-1); + itemProperty->setLiterals( + QStringList({VToolOptionsPropertyBrowser::tr("First point"), VToolOptionsPropertyBrowser::tr("Second point")})); + itemProperty->setValue(static_cast(i->GetCrossCirclesPoint()) - 1); AddProperty(itemProperty, AttrCrossPoint); } //--------------------------------------------------------------------------------------------------------------------- -template -void VToolOptionsPropertyBrowser::AddPropertyVCrossPoint(Tool *i, const QString &propertyName) +template void VToolOptionsPropertyBrowser::AddPropertyVCrossPoint(Tool *i, const QString &propertyName) { auto *itemProperty = new VPE::VEnumProperty(propertyName); - itemProperty->setLiterals(QStringList({VToolOptionsPropertyBrowser::tr("Highest point"), - VToolOptionsPropertyBrowser::tr("Lowest point")})); - itemProperty->setValue(static_cast(i->GetVCrossPoint())-1); + itemProperty->setLiterals(QStringList( + {VToolOptionsPropertyBrowser::tr("Highest point"), VToolOptionsPropertyBrowser::tr("Lowest point")})); + itemProperty->setValue(static_cast(i->GetVCrossPoint()) - 1); AddProperty(itemProperty, AttrVCrossPoint); } //--------------------------------------------------------------------------------------------------------------------- -template -void VToolOptionsPropertyBrowser::AddPropertyHCrossPoint(Tool *i, const QString &propertyName) +template void VToolOptionsPropertyBrowser::AddPropertyHCrossPoint(Tool *i, const QString &propertyName) { auto *itemProperty = new VPE::VEnumProperty(propertyName); - itemProperty->setLiterals(QStringList({VToolOptionsPropertyBrowser::tr("Leftmost point"), - VToolOptionsPropertyBrowser::tr("Rightmost point")})); - itemProperty->setValue(static_cast(i->GetHCrossPoint())-1); + itemProperty->setLiterals(QStringList( + {VToolOptionsPropertyBrowser::tr("Leftmost point"), VToolOptionsPropertyBrowser::tr("Rightmost point")})); + itemProperty->setValue(static_cast(i->GetHCrossPoint()) - 1); AddProperty(itemProperty, AttrHCrossPoint); } //--------------------------------------------------------------------------------------------------------------------- -template -void VToolOptionsPropertyBrowser::AddPropertyAxisType(Tool *i, const QString &propertyName) +template void VToolOptionsPropertyBrowser::AddPropertyAxisType(Tool *i, const QString &propertyName) { auto *itemProperty = new VPE::VEnumProperty(propertyName); - itemProperty->setLiterals(QStringList({VToolOptionsPropertyBrowser::tr("Vertical axis"), - VToolOptionsPropertyBrowser::tr("Horizontal axis")})); - itemProperty->setValue(static_cast(i->GetAxisType())-1); + itemProperty->setLiterals(QStringList( + {VToolOptionsPropertyBrowser::tr("Vertical axis"), VToolOptionsPropertyBrowser::tr("Horizontal axis")})); + itemProperty->setValue(static_cast(i->GetAxisType()) - 1); AddProperty(itemProperty, AttrAxisType); } //--------------------------------------------------------------------------------------------------------------------- -template +template void VToolOptionsPropertyBrowser::AddPropertyLineType(Tool *i, const QString &propertyName, const QMap &styles) { @@ -740,14 +738,14 @@ void VToolOptionsPropertyBrowser::AddPropertyLineType(Tool *i, const QString &pr const auto index = VPE::VLineTypeProperty::IndexOfStyle(styles, i->getLineType()); if (index == -1) { - qWarning()<<"Can't find line style" << i->getLineType()<<"in list"; + qWarning() << "Can't find line style" << i->getLineType() << "in list"; } lineTypeProperty->setValue(index); AddProperty(lineTypeProperty, AttrTypeLine); } //--------------------------------------------------------------------------------------------------------------------- -template +template void VToolOptionsPropertyBrowser::AddPropertyCurvePenStyle(Tool *i, const QString &propertyName, const QMap &styles) { @@ -756,14 +754,14 @@ void VToolOptionsPropertyBrowser::AddPropertyCurvePenStyle(Tool *i, const QStrin const auto index = VPE::VLineTypeProperty::IndexOfStyle(styles, i->GetPenStyle()); if (index == -1) { - qWarning()<<"Can't find pen style" << i->getLineType()<<"in list"; + qWarning() << "Can't find pen style" << i->getLineType() << "in list"; } penStyleProperty->setValue(index); AddProperty(penStyleProperty, AttrPenStyle); } //--------------------------------------------------------------------------------------------------------------------- -template +template void VToolOptionsPropertyBrowser::AddPropertyLineColor(Tool *i, const QString &propertyName, const QMap &colors, const QString &id) { @@ -772,7 +770,7 @@ void VToolOptionsPropertyBrowser::AddPropertyLineColor(Tool *i, const QString &p const auto index = VPE::VLineColorProperty::IndexOfColor(colors, i->GetLineColor()); if (index == -1) { - qWarning()<<"Can't find line style" << i->GetLineColor()<<"in list"; + qWarning() << "Can't find line style" << i->GetLineColor() << "in list"; } lineColorProperty->setValue(index); AddProperty(lineColorProperty, id); @@ -795,13 +793,10 @@ void VToolOptionsPropertyBrowser::AddPropertyApproximationScale(const QString &p //--------------------------------------------------------------------------------------------------------------------- void VToolOptionsPropertyBrowser::AddPropertyOpacity(const QString &propertyName, int opacity) { - QMap settings - { - {QStringLiteral("Min"), 0}, - {QStringLiteral("Max"), 100}, - {QStringLiteral("Step"), 1}, - {QStringLiteral("Suffix"), QChar('%')} - }; + QMap settings{{QStringLiteral("Min"), 0}, + {QStringLiteral("Max"), 100}, + {QStringLiteral("Step"), 1}, + {QStringLiteral("Suffix"), QChar('%')}}; auto *opacityProperty = new VPE::VIntegerProperty(propertyName, settings); opacityProperty->setValue(opacity); @@ -809,8 +804,7 @@ void VToolOptionsPropertyBrowser::AddPropertyOpacity(const QString &propertyName } //--------------------------------------------------------------------------------------------------------------------- -template -void VToolOptionsPropertyBrowser::SetName(VPE::VProperty *property) +template void VToolOptionsPropertyBrowser::SetName(VPE::VProperty *property) { if (auto *i = qgraphicsitem_cast(m_currentItem)) { @@ -824,13 +818,12 @@ void VToolOptionsPropertyBrowser::SetName(VPE::VProperty *property) } else { - qWarning()<<"Can't cast item"; + qWarning() << "Can't cast item"; } } //--------------------------------------------------------------------------------------------------------------------- -template -void VToolOptionsPropertyBrowser::SetHold(VPE::VProperty *property) +template void VToolOptionsPropertyBrowser::SetHold(VPE::VProperty *property) { if (auto *i = qgraphicsitem_cast(m_currentItem)) { @@ -844,13 +837,12 @@ void VToolOptionsPropertyBrowser::SetHold(VPE::VProperty *property) } else { - qWarning()<<"Can't cast item"; + qWarning() << "Can't cast item"; } } //--------------------------------------------------------------------------------------------------------------------- -template -void VToolOptionsPropertyBrowser::SetVisible(VPE::VProperty *property) +template void VToolOptionsPropertyBrowser::SetVisible(VPE::VProperty *property) { if (auto *i = qgraphicsitem_cast(m_currentItem)) { @@ -864,13 +856,12 @@ void VToolOptionsPropertyBrowser::SetVisible(VPE::VProperty *property) } else { - qWarning()<<"Can't cast item"; + qWarning() << "Can't cast item"; } } //--------------------------------------------------------------------------------------------------------------------- -template -void VToolOptionsPropertyBrowser::SetOpacity(VPE::VProperty *property) +template void VToolOptionsPropertyBrowser::SetOpacity(VPE::VProperty *property) { if (auto *i = qgraphicsitem_cast(m_currentItem)) { @@ -880,17 +871,16 @@ void VToolOptionsPropertyBrowser::SetOpacity(VPE::VProperty *property) return; } - i->SetOpacity(opacity/100.); + i->SetOpacity(opacity / 100.); } else { - qWarning()<<"Can't cast item"; + qWarning() << "Can't cast item"; } } //--------------------------------------------------------------------------------------------------------------------- -template -void VToolOptionsPropertyBrowser::SetPointName(VPE::VProperty *property) +template void VToolOptionsPropertyBrowser::SetPointName(VPE::VProperty *property) { if (auto *i = qgraphicsitem_cast(m_currentItem)) { @@ -912,13 +902,12 @@ void VToolOptionsPropertyBrowser::SetPointName(VPE::VProperty *property) } else { - qWarning()<<"Can't cast item"; + qWarning() << "Can't cast item"; } } //--------------------------------------------------------------------------------------------------------------------- -template -void VToolOptionsPropertyBrowser::SetPointName1(VPE::VProperty *property) +template void VToolOptionsPropertyBrowser::SetPointName1(VPE::VProperty *property) { if (auto *i = qgraphicsitem_cast(m_currentItem)) { @@ -940,13 +929,12 @@ void VToolOptionsPropertyBrowser::SetPointName1(VPE::VProperty *property) } else { - qWarning()<<"Can't cast item"; + qWarning() << "Can't cast item"; } } //--------------------------------------------------------------------------------------------------------------------- -template -void VToolOptionsPropertyBrowser::SetPointName2(VPE::VProperty *property) +template void VToolOptionsPropertyBrowser::SetPointName2(VPE::VProperty *property) { if (auto *i = qgraphicsitem_cast(m_currentItem)) { @@ -968,13 +956,12 @@ void VToolOptionsPropertyBrowser::SetPointName2(VPE::VProperty *property) } else { - qWarning()<<"Can't cast item"; + qWarning() << "Can't cast item"; } } //--------------------------------------------------------------------------------------------------------------------- -template -void VToolOptionsPropertyBrowser::SetOperationSuffix(VPE::VProperty *property) +template void VToolOptionsPropertyBrowser::SetOperationSuffix(VPE::VProperty *property) { if (auto *item = qgraphicsitem_cast(m_currentItem)) { @@ -1007,13 +994,12 @@ void VToolOptionsPropertyBrowser::SetOperationSuffix(VPE::VProperty *property) } else { - qWarning()<<"Can't cast item"; + qWarning() << "Can't cast item"; } } //--------------------------------------------------------------------------------------------------------------------- -template -auto VToolOptionsPropertyBrowser::GetCrossPoint(const QVariant &value) -> Type +template auto VToolOptionsPropertyBrowser::GetCrossPoint(const QVariant &value) -> Type { bool ok = false; const int val = value.toInt(&ok); @@ -1021,11 +1007,11 @@ auto VToolOptionsPropertyBrowser::GetCrossPoint(const QVariant &value) -> Type auto cross = static_cast(1); if (ok) { - switch(val) + switch (val) { case 0: case 1: - cross = static_cast(val+1); + cross = static_cast(val + 1); break; default: break; @@ -1036,8 +1022,7 @@ auto VToolOptionsPropertyBrowser::GetCrossPoint(const QVariant &value) -> Type } //--------------------------------------------------------------------------------------------------------------------- -template -void VToolOptionsPropertyBrowser::SetCrossCirclesPoint(VPE::VProperty *property) +template void VToolOptionsPropertyBrowser::SetCrossCirclesPoint(VPE::VProperty *property) { if (auto *i = qgraphicsitem_cast(m_currentItem)) { @@ -1046,13 +1031,12 @@ void VToolOptionsPropertyBrowser::SetCrossCirclesPoint(VPE::VProperty *property) } else { - qWarning()<<"Can't cast item"; + qWarning() << "Can't cast item"; } } //--------------------------------------------------------------------------------------------------------------------- -template -void VToolOptionsPropertyBrowser::SetVCrossCurvesPoint(VPE::VProperty *property) +template void VToolOptionsPropertyBrowser::SetVCrossCurvesPoint(VPE::VProperty *property) { if (auto *i = qgraphicsitem_cast(m_currentItem)) { @@ -1067,13 +1051,12 @@ void VToolOptionsPropertyBrowser::SetVCrossCurvesPoint(VPE::VProperty *property) } else { - qWarning()<<"Can't cast item"; + qWarning() << "Can't cast item"; } } //--------------------------------------------------------------------------------------------------------------------- -template -void VToolOptionsPropertyBrowser::SetHCrossCurvesPoint(VPE::VProperty *property) +template void VToolOptionsPropertyBrowser::SetHCrossCurvesPoint(VPE::VProperty *property) { if (auto *i = qgraphicsitem_cast(m_currentItem)) { @@ -1088,13 +1071,12 @@ void VToolOptionsPropertyBrowser::SetHCrossCurvesPoint(VPE::VProperty *property) } else { - qWarning()<<"Can't cast item"; + qWarning() << "Can't cast item"; } } //--------------------------------------------------------------------------------------------------------------------- -template -void VToolOptionsPropertyBrowser::SetAxisType(VPE::VProperty *property) +template void VToolOptionsPropertyBrowser::SetAxisType(VPE::VProperty *property) { if (auto *i = qgraphicsitem_cast(m_currentItem)) { @@ -1109,13 +1091,12 @@ void VToolOptionsPropertyBrowser::SetAxisType(VPE::VProperty *property) } else { - qWarning()<<"Can't cast item"; + qWarning() << "Can't cast item"; } } //--------------------------------------------------------------------------------------------------------------------- -template -void VToolOptionsPropertyBrowser::SetNotes(VPE::VProperty *property) +template void VToolOptionsPropertyBrowser::SetNotes(VPE::VProperty *property) { if (auto *i = qgraphicsitem_cast(m_currentItem)) { @@ -1129,13 +1110,12 @@ void VToolOptionsPropertyBrowser::SetNotes(VPE::VProperty *property) } else { - qWarning()<<"Can't cast item"; + qWarning() << "Can't cast item"; } } //--------------------------------------------------------------------------------------------------------------------- -template -void VToolOptionsPropertyBrowser::SetAlias(VPE::VProperty *property) +template void VToolOptionsPropertyBrowser::SetAlias(VPE::VProperty *property) { if (auto *i = qgraphicsitem_cast(m_currentItem)) { @@ -1149,13 +1129,12 @@ void VToolOptionsPropertyBrowser::SetAlias(VPE::VProperty *property) } else { - qWarning()<<"Can't cast item"; + qWarning() << "Can't cast item"; } } //--------------------------------------------------------------------------------------------------------------------- -template -void VToolOptionsPropertyBrowser::SetAlias1(VPE::VProperty *property) +template void VToolOptionsPropertyBrowser::SetAlias1(VPE::VProperty *property) { if (auto *i = qgraphicsitem_cast(m_currentItem)) { @@ -1169,13 +1148,12 @@ void VToolOptionsPropertyBrowser::SetAlias1(VPE::VProperty *property) } else { - qWarning()<<"Can't cast item"; + qWarning() << "Can't cast item"; } } //--------------------------------------------------------------------------------------------------------------------- -template -void VToolOptionsPropertyBrowser::SetAlias2(VPE::VProperty *property) +template void VToolOptionsPropertyBrowser::SetAlias2(VPE::VProperty *property) { if (auto *i = qgraphicsitem_cast(m_currentItem)) { @@ -1189,13 +1167,12 @@ void VToolOptionsPropertyBrowser::SetAlias2(VPE::VProperty *property) } else { - qWarning()<<"Can't cast item"; + qWarning() << "Can't cast item"; } } //--------------------------------------------------------------------------------------------------------------------- -template -void VToolOptionsPropertyBrowser::SetLineType(VPE::VProperty *property) +template void VToolOptionsPropertyBrowser::SetLineType(VPE::VProperty *property) { if (auto *i = qgraphicsitem_cast(m_currentItem)) { @@ -1209,13 +1186,12 @@ void VToolOptionsPropertyBrowser::SetLineType(VPE::VProperty *property) } else { - qWarning()<<"Can't cast item"; + qWarning() << "Can't cast item"; } } //--------------------------------------------------------------------------------------------------------------------- -template -void VToolOptionsPropertyBrowser::SetLineColor(VPE::VProperty *property) +template void VToolOptionsPropertyBrowser::SetLineColor(VPE::VProperty *property) { if (auto *i = qgraphicsitem_cast(m_currentItem)) { @@ -1229,13 +1205,12 @@ void VToolOptionsPropertyBrowser::SetLineColor(VPE::VProperty *property) } else { - qWarning()<<"Can't cast item"; + qWarning() << "Can't cast item"; } } //--------------------------------------------------------------------------------------------------------------------- -template -void VToolOptionsPropertyBrowser::SetFormulaLength(VPE::VProperty *property) +template void VToolOptionsPropertyBrowser::SetFormulaLength(VPE::VProperty *property) { if (auto *i = qgraphicsitem_cast(m_currentItem)) { @@ -1249,13 +1224,12 @@ void VToolOptionsPropertyBrowser::SetFormulaLength(VPE::VProperty *property) } else { - qWarning()<<"Can't cast item"; + qWarning() << "Can't cast item"; } } //--------------------------------------------------------------------------------------------------------------------- -template -void VToolOptionsPropertyBrowser::SetFormulaAngle(VPE::VProperty *property) +template void VToolOptionsPropertyBrowser::SetFormulaAngle(VPE::VProperty *property) { if (auto *i = qgraphicsitem_cast(m_currentItem)) { @@ -1269,13 +1243,12 @@ void VToolOptionsPropertyBrowser::SetFormulaAngle(VPE::VProperty *property) } else { - qWarning()<<"Can't cast item"; + qWarning() << "Can't cast item"; } } //--------------------------------------------------------------------------------------------------------------------- -template -void VToolOptionsPropertyBrowser::SetFormulaRadius(VPE::VProperty *property) +template void VToolOptionsPropertyBrowser::SetFormulaRadius(VPE::VProperty *property) { if (auto *i = qgraphicsitem_cast(m_currentItem)) { @@ -1289,13 +1262,12 @@ void VToolOptionsPropertyBrowser::SetFormulaRadius(VPE::VProperty *property) } else { - qWarning()<<"Can't cast item"; + qWarning() << "Can't cast item"; } } //--------------------------------------------------------------------------------------------------------------------- -template -void VToolOptionsPropertyBrowser::SetFormulaF1(VPE::VProperty *property) +template void VToolOptionsPropertyBrowser::SetFormulaF1(VPE::VProperty *property) { if (auto *i = qgraphicsitem_cast(m_currentItem)) { @@ -1309,13 +1281,12 @@ void VToolOptionsPropertyBrowser::SetFormulaF1(VPE::VProperty *property) } else { - qWarning()<<"Can't cast item"; + qWarning() << "Can't cast item"; } } //--------------------------------------------------------------------------------------------------------------------- -template -void VToolOptionsPropertyBrowser::SetFormulaF2(VPE::VProperty *property) +template void VToolOptionsPropertyBrowser::SetFormulaF2(VPE::VProperty *property) { if (auto *i = qgraphicsitem_cast(m_currentItem)) { @@ -1329,13 +1300,12 @@ void VToolOptionsPropertyBrowser::SetFormulaF2(VPE::VProperty *property) } else { - qWarning()<<"Can't cast item"; + qWarning() << "Can't cast item"; } } //--------------------------------------------------------------------------------------------------------------------- -template -void VToolOptionsPropertyBrowser::SetPenStyle(VPE::VProperty *property) +template void VToolOptionsPropertyBrowser::SetPenStyle(VPE::VProperty *property) { if (auto *i = qgraphicsitem_cast(m_currentItem)) { @@ -1349,13 +1319,12 @@ void VToolOptionsPropertyBrowser::SetPenStyle(VPE::VProperty *property) } else { - qWarning()<<"Can't cast item"; + qWarning() << "Can't cast item"; } } //--------------------------------------------------------------------------------------------------------------------- -template -void VToolOptionsPropertyBrowser::SetFormulaRotationAngle(VPE::VProperty *property) +template void VToolOptionsPropertyBrowser::SetFormulaRotationAngle(VPE::VProperty *property) { if (auto *i = qgraphicsitem_cast(m_currentItem)) { @@ -1369,13 +1338,12 @@ void VToolOptionsPropertyBrowser::SetFormulaRotationAngle(VPE::VProperty *proper } else { - qWarning()<<"Can't cast item"; + qWarning() << "Can't cast item"; } } //--------------------------------------------------------------------------------------------------------------------- -template -void VToolOptionsPropertyBrowser::SetApproximationScale(VPE::VProperty *property) +template void VToolOptionsPropertyBrowser::SetApproximationScale(VPE::VProperty *property) { if (auto *i = qgraphicsitem_cast(m_currentItem)) { @@ -1389,7 +1357,7 @@ void VToolOptionsPropertyBrowser::SetApproximationScale(VPE::VProperty *property } else { - qWarning()<<"Can't cast item"; + qWarning() << "Can't cast item"; } } @@ -1417,7 +1385,7 @@ void VToolOptionsPropertyBrowser::ChangeDataToolSinglePoint(VPE::VProperty *prop } else { - qWarning()<<"Can't cast item"; + qWarning() << "Can't cast item"; } }; @@ -1433,7 +1401,7 @@ void VToolOptionsPropertyBrowser::ChangeDataToolSinglePoint(VPE::VProperty *prop SetNotes(property); break; default: - qWarning()<<"Unknown property type. id = "<(property); break; - case 10://AttrAngle2 + case 10: // AttrAngle2 SetFormulaF2(property); break; - case 42://AttrRotationAngle + case 42: // AttrRotationAngle SetFormulaRotationAngle(property); break; - case 27://AttrColor + case 27: // AttrColor SetLineColor(property); break; case 62: // AttrAlias @@ -2677,7 +2645,7 @@ void VToolOptionsPropertyBrowser::ChangeDataToolEllipticalArc(VPE::VProperty *pr case 11: // AttrCenter (read only) break; default: - qWarning()<<"Unknown property type. id = "<IsHold(), *AttrHold); AddPropertyBool(tr("Visible:"), i->IsVisible(), *AttrVisible); - AddPropertyOpacity(tr("Opacity:"), static_cast(i->GetOpacity()*100)); + AddPropertyOpacity(tr("Opacity:"), static_cast(i->GetOpacity() * 100)); } //--------------------------------------------------------------------------------------------------------------------- @@ -3329,7 +3297,7 @@ void VToolOptionsPropertyBrowser::ShowOptionsBackgroundSVGItem(QGraphicsItem *it AddPropertyObjectName(i, tr("Name:"), false); AddPropertyBool(tr("Hold:"), i->IsHold(), *AttrHold); AddPropertyBool(tr("Visible:"), i->IsVisible(), *AttrVisible); - AddPropertyOpacity(tr("Opacity:"), static_cast(i->GetOpacity()*100)); + AddPropertyOpacity(tr("Opacity:"), static_cast(i->GetOpacity() * 100)); } //--------------------------------------------------------------------------------------------------------------------- @@ -3348,13 +3316,13 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolEndLine() m_idToProperty[AttrName]->setValue(i->name()); { - const auto index = VPE::VLineTypeProperty::IndexOfStyle(LineStylesPics(), i->getLineType()); - m_idToProperty[AttrTypeLine]->setValue(index); + const auto index = VPE::VLineTypeProperty::IndexOfStyle(LineStylesPics(), i->getLineType()); + m_idToProperty[AttrTypeLine]->setValue(index); } { - const auto index = VPE::VLineColorProperty::IndexOfColor(VAbstractTool::ColorsList(), i->GetLineColor()); - m_idToProperty[AttrLineColor]->setValue(index); + const auto index = VPE::VLineColorProperty::IndexOfColor(VAbstractTool::ColorsList(), i->GetLineColor()); + m_idToProperty[AttrLineColor]->setValue(index); } QVariant valueFormula; @@ -3379,13 +3347,13 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolAlongLine() m_idToProperty[AttrName]->setValue(i->name()); { - const auto index = VPE::VLineTypeProperty::IndexOfStyle(LineStylesPics(), i->getLineType()); - m_idToProperty[AttrTypeLine]->setValue(index); + const auto index = VPE::VLineTypeProperty::IndexOfStyle(LineStylesPics(), i->getLineType()); + m_idToProperty[AttrTypeLine]->setValue(index); } { - const auto index = VPE::VLineColorProperty::IndexOfColor(VAbstractTool::ColorsList(), i->GetLineColor()); - m_idToProperty[AttrLineColor]->setValue(index); + const auto index = VPE::VLineColorProperty::IndexOfColor(VAbstractTool::ColorsList(), i->GetLineColor()); + m_idToProperty[AttrLineColor]->setValue(index); } QVariant valueFormula; @@ -3499,13 +3467,13 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolBisector() m_idToProperty[AttrLength]->setValue(valueFormula); { - const auto index = VPE::VLineTypeProperty::IndexOfStyle(LineStylesPics(), i->getLineType()); - m_idToProperty[AttrTypeLine]->setValue(index); + const auto index = VPE::VLineTypeProperty::IndexOfStyle(LineStylesPics(), i->getLineType()); + m_idToProperty[AttrTypeLine]->setValue(index); } { - const auto index = VPE::VLineColorProperty::IndexOfColor(VAbstractTool::ColorsList(), i->GetLineColor()); - m_idToProperty[AttrLineColor]->setValue(index); + const auto index = VPE::VLineColorProperty::IndexOfColor(VAbstractTool::ColorsList(), i->GetLineColor()); + m_idToProperty[AttrLineColor]->setValue(index); } QVariant valueFirstPoint; @@ -3625,13 +3593,13 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolHeight() m_idToProperty[AttrName]->setValue(i->name()); { - const auto index = VPE::VLineTypeProperty::IndexOfStyle(LineStylesPics(), i->getLineType()); - m_idToProperty[AttrTypeLine]->setValue(index); + const auto index = VPE::VLineTypeProperty::IndexOfStyle(LineStylesPics(), i->getLineType()); + m_idToProperty[AttrTypeLine]->setValue(index); } { - const auto index = VPE::VLineColorProperty::IndexOfColor(VAbstractTool::ColorsList(), i->GetLineColor()); - m_idToProperty[AttrLineColor]->setValue(index); + const auto index = VPE::VLineColorProperty::IndexOfColor(VAbstractTool::ColorsList(), i->GetLineColor()); + m_idToProperty[AttrLineColor]->setValue(index); } QVariant valueBasePoint; @@ -3655,13 +3623,13 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolLine() auto *i = qgraphicsitem_cast(m_currentItem); { - const auto index = VPE::VLineTypeProperty::IndexOfStyle(LineStylesPics(), i->getLineType()); - m_idToProperty[AttrTypeLine]->setValue(index); + const auto index = VPE::VLineTypeProperty::IndexOfStyle(LineStylesPics(), i->getLineType()); + m_idToProperty[AttrTypeLine]->setValue(index); } { - const auto index = VPE::VLineColorProperty::IndexOfColor(VAbstractTool::ColorsList(), i->GetLineColor()); - m_idToProperty[AttrLineColor]->setValue(index); + const auto index = VPE::VLineColorProperty::IndexOfColor(VAbstractTool::ColorsList(), i->GetLineColor()); + m_idToProperty[AttrLineColor]->setValue(index); } QVariant valueFirstPoint; @@ -3712,16 +3680,16 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolNormal() m_idToProperty[AttrName]->setValue(i->name()); - m_idToProperty[AttrAngle]->setValue( i->GetAngle()); + m_idToProperty[AttrAngle]->setValue(i->GetAngle()); { - const auto index = VPE::VLineTypeProperty::IndexOfStyle(LineStylesPics(), i->getLineType()); - m_idToProperty[AttrTypeLine]->setValue(index); + const auto index = VPE::VLineTypeProperty::IndexOfStyle(LineStylesPics(), i->getLineType()); + m_idToProperty[AttrTypeLine]->setValue(index); } { - const auto index = VPE::VLineColorProperty::IndexOfColor(VAbstractTool::ColorsList(), i->GetLineColor()); - m_idToProperty[AttrLineColor]->setValue(index); + const auto index = VPE::VLineColorProperty::IndexOfColor(VAbstractTool::ColorsList(), i->GetLineColor()); + m_idToProperty[AttrLineColor]->setValue(index); } QVariant valueBasePoint; @@ -3785,7 +3753,7 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolPointOfIntersectionArcs() auto *i = qgraphicsitem_cast(m_currentItem); m_idToProperty[AttrName]->setValue(i->name()); - m_idToProperty[AttrCrossPoint]->setValue(static_cast(i->GetCrossCirclesPoint())-1); + m_idToProperty[AttrCrossPoint]->setValue(static_cast(i->GetCrossCirclesPoint()) - 1); QVariant valueFirstArc; valueFirstArc.setValue(i->FirstArcName()); @@ -3804,7 +3772,7 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolPointOfIntersectionCircles() auto *i = qgraphicsitem_cast(m_currentItem); m_idToProperty[AttrName]->setValue(i->name()); - m_idToProperty[AttrCrossPoint]->setValue(static_cast(i->GetCrossCirclesPoint())-1); + m_idToProperty[AttrCrossPoint]->setValue(static_cast(i->GetCrossCirclesPoint()) - 1); QVariant c1Radius; c1Radius.setValue(i->GetFirstCircleRadius()); @@ -3831,8 +3799,8 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolPointOfIntersectionCurves() auto *i = qgraphicsitem_cast(m_currentItem); m_idToProperty[AttrName]->setValue(i->name()); - m_idToProperty[AttrVCrossPoint]->setValue(static_cast(i->GetVCrossPoint())-1); - m_idToProperty[AttrHCrossPoint]->setValue(static_cast(i->GetHCrossPoint())-1); + m_idToProperty[AttrVCrossPoint]->setValue(static_cast(i->GetVCrossPoint()) - 1); + m_idToProperty[AttrHCrossPoint]->setValue(static_cast(i->GetHCrossPoint()) - 1); QVariant valueCurve1; valueCurve1.setValue(i->FirstCurveName()); @@ -3851,7 +3819,7 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolPointFromCircleAndTangent() auto *i = qgraphicsitem_cast(m_currentItem); m_idToProperty[AttrName]->setValue(i->name()); - m_idToProperty[AttrCrossPoint]->setValue(static_cast(i->GetCrossCirclesPoint())-1); + m_idToProperty[AttrCrossPoint]->setValue(static_cast(i->GetCrossCirclesPoint()) - 1); QVariant cRadius; cRadius.setValue(i->GetCircleRadius()); @@ -3874,7 +3842,7 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolPointFromArcAndTangent() auto *i = qgraphicsitem_cast(m_currentItem); m_idToProperty[AttrName]->setValue(i->name()); - m_idToProperty[AttrCrossPoint]->setValue(static_cast(i->GetCrossCirclesPoint())-1); + m_idToProperty[AttrCrossPoint]->setValue(static_cast(i->GetCrossCirclesPoint()) - 1); QVariant valueTangentPoint; valueTangentPoint.setValue(i->TangentPointName()); @@ -3899,13 +3867,13 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolShoulderPoint() m_idToProperty[AttrName]->setValue(i->name()); { - const auto index = VPE::VLineTypeProperty::IndexOfStyle(LineStylesPics(), i->getLineType()); - m_idToProperty[AttrTypeLine]->setValue(index); + const auto index = VPE::VLineTypeProperty::IndexOfStyle(LineStylesPics(), i->getLineType()); + m_idToProperty[AttrTypeLine]->setValue(index); } { - const auto index = VPE::VLineColorProperty::IndexOfColor(VAbstractTool::ColorsList(), i->GetLineColor()); - m_idToProperty[AttrLineColor]->setValue(index); + const auto index = VPE::VLineColorProperty::IndexOfColor(VAbstractTool::ColorsList(), i->GetLineColor()); + m_idToProperty[AttrLineColor]->setValue(index); } QVariant valueBasePoint; @@ -3972,8 +3940,8 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolSpline() m_idToProperty[AttrPenStyle]->setValue(index); } - m_idToProperty[AttrColor]->setValue(VPE::VLineColorProperty::IndexOfColor(VAbstractTool::ColorsList(), - i->GetLineColor())); + m_idToProperty[AttrColor]->setValue( + VPE::VLineColorProperty::IndexOfColor(VAbstractTool::ColorsList(), i->GetLineColor())); QVariant valueApproximationScale; valueApproximationScale.setValue(spl.GetApproximationScale()); @@ -3996,8 +3964,8 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolCubicBezier() m_idToProperty[AttrPenStyle]->setValue(index); } - m_idToProperty[AttrColor]->setValue(VPE::VLineColorProperty::IndexOfColor(VAbstractTool::ColorsList(), - i->GetLineColor())); + m_idToProperty[AttrColor]->setValue( + VPE::VLineColorProperty::IndexOfColor(VAbstractTool::ColorsList(), i->GetLineColor())); QVariant valueFirstPoint; valueFirstPoint.setValue(i->FirstPointName()); @@ -4036,8 +4004,8 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolSplinePath() m_idToProperty[AttrPenStyle]->setValue(index); } - m_idToProperty[AttrColor]->setValue(VPE::VLineColorProperty::IndexOfColor(VAbstractTool::ColorsList(), - i->GetLineColor())); + m_idToProperty[AttrColor]->setValue( + VPE::VLineColorProperty::IndexOfColor(VAbstractTool::ColorsList(), i->GetLineColor())); QVariant valueApproximationScale; valueApproximationScale.setValue(i->getSplinePath().GetApproximationScale()); @@ -4060,8 +4028,8 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolCubicBezierPath() m_idToProperty[AttrPenStyle]->setValue(index); } - m_idToProperty[AttrColor]->setValue(VPE::VLineColorProperty::IndexOfColor(VAbstractTool::ColorsList(), - i->GetLineColor())); + m_idToProperty[AttrColor]->setValue( + VPE::VLineColorProperty::IndexOfColor(VAbstractTool::ColorsList(), i->GetLineColor())); QVariant valueApproximationScale; valueApproximationScale.setValue(i->getSplinePath().GetApproximationScale()); @@ -4105,13 +4073,13 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolLineIntersectAxis() m_idToProperty[AttrName]->setValue(i->name()); { - const auto index = VPE::VLineTypeProperty::IndexOfStyle(LineStylesPics(), i->getLineType()); - m_idToProperty[AttrTypeLine]->setValue(index); + const auto index = VPE::VLineTypeProperty::IndexOfStyle(LineStylesPics(), i->getLineType()); + m_idToProperty[AttrTypeLine]->setValue(index); } { - const auto index = VPE::VLineColorProperty::IndexOfColor(VAbstractTool::ColorsList(), i->GetLineColor()); - m_idToProperty[AttrLineColor]->setValue(index); + const auto index = VPE::VLineColorProperty::IndexOfColor(VAbstractTool::ColorsList(), i->GetLineColor()); + m_idToProperty[AttrLineColor]->setValue(index); } QVariant valueAngle; @@ -4140,13 +4108,13 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolCurveIntersectAxis() m_idToProperty[AttrName]->setValue(i->name()); { - const auto index = VPE::VLineTypeProperty::IndexOfStyle(LineStylesPics(), i->getLineType()); - m_idToProperty[AttrTypeLine]->setValue(index); + const auto index = VPE::VLineTypeProperty::IndexOfStyle(LineStylesPics(), i->getLineType()); + m_idToProperty[AttrTypeLine]->setValue(index); } { - const auto index = VPE::VLineColorProperty::IndexOfColor(VAbstractTool::ColorsList(), i->GetLineColor()); - m_idToProperty[AttrLineColor]->setValue(index); + const auto index = VPE::VLineColorProperty::IndexOfColor(VAbstractTool::ColorsList(), i->GetLineColor()); + m_idToProperty[AttrLineColor]->setValue(index); } QVariant valueAngle; @@ -4227,7 +4195,7 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolFlippingByLine() void VToolOptionsPropertyBrowser::UpdateOptionsToolFlippingByAxis() { auto *i = qgraphicsitem_cast(m_currentItem); - m_idToProperty[AttrAxisType]->setValue(static_cast(i->GetAxisType())-1); + m_idToProperty[AttrAxisType]->setValue(static_cast(i->GetAxisType()) - 1); m_idToProperty[AttrSuffix]->setValue(i->Suffix()); QVariant valueOriginPoint; @@ -4288,7 +4256,7 @@ void VToolOptionsPropertyBrowser::UpdateOptionsBackgroundPixmapItem() m_idToProperty.value(AttrName)->setValue(i->name()); m_idToProperty.value(*AttrHold)->setValue(i->IsHold()); m_idToProperty.value(*AttrVisible)->setValue(i->IsVisible()); - m_idToProperty.value(*AttrOpacity)->setValue(static_cast(i->GetOpacity()*100)); + m_idToProperty.value(*AttrOpacity)->setValue(static_cast(i->GetOpacity() * 100)); } //--------------------------------------------------------------------------------------------------------------------- @@ -4299,7 +4267,7 @@ void VToolOptionsPropertyBrowser::UpdateOptionsBackgroundSVGItem() m_idToProperty.value(AttrName)->setValue(i->name()); m_idToProperty.value(*AttrHold)->setValue(i->IsHold()); m_idToProperty.value(*AttrVisible)->setValue(i->IsVisible()); - m_idToProperty.value(*AttrOpacity)->setValue(static_cast(i->GetOpacity()*100)); + m_idToProperty.value(*AttrOpacity)->setValue(static_cast(i->GetOpacity() * 100)); } //--------------------------------------------------------------------------------------------------------------------- @@ -4331,49 +4299,50 @@ auto VToolOptionsPropertyBrowser::PropertiesList() -> QStringList AttrPShoulder, /* 22 */ AttrAxisP1, /* 23 */ AttrAxisP2, /* 24 */ - AttrKCurve, /*Not used*/ /* 25 */ - AttrLineColor, /* 26 */ - AttrColor, /* 27 */ - AttrCrossPoint, /* 28 */ - AttrC1Radius, /* 29 */ - AttrC2Radius, /* 30 */ - AttrCRadius, /* 31 */ - AttrName1, /* 32 */ - AttrName2, /* 33 */ - AttrVCrossPoint, /* 34 */ - AttrHCrossPoint, /* 35 */ - AttrLength1, /* 36 */ - AttrLength2, /* 37 */ - AttrSuffix, /* 38 */ - AttrAxisType, /* 39 */ - AttrRadius1, /* 40 */ - AttrRadius2, /* 41 */ - AttrRotationAngle, /* 42 */ - AttrDartP1, /* 43 */ - AttrDartP2, /* 44 */ - AttrDartP3, /* 45 */ - AttrCurve, /* 46 */ - AttrFirstArc, /* 47 */ - AttrSecondArc, /* 48 */ - AttrC1Center, /* 49 */ - AttrC2Center, /* 50 */ - AttrCurve1, /* 51 */ - AttrCurve2, /* 52 */ - AttrCCenter, /* 53 */ - AttrTangent, /* 54 */ - AttrPoint1, /* 55 */ - AttrPoint2, /* 56 */ - AttrPoint3, /* 57 */ - AttrPoint4, /* 58 */ - AttrPenStyle, /* 59 */ - AttrAScale, /* 60 */ - AttrNotes, /* 61 */ - AttrAlias, /* 62 */ - AttrAlias1, /* 63 */ - AttrAlias2, /* 64 */ - *AttrHold, /* 65 */ - *AttrVisible, /* 66 */ - *AttrOpacity /* 67 */ + AttrKCurve, + /*Not used*/ /* 25 */ + AttrLineColor, /* 26 */ + AttrColor, /* 27 */ + AttrCrossPoint, /* 28 */ + AttrC1Radius, /* 29 */ + AttrC2Radius, /* 30 */ + AttrCRadius, /* 31 */ + AttrName1, /* 32 */ + AttrName2, /* 33 */ + AttrVCrossPoint, /* 34 */ + AttrHCrossPoint, /* 35 */ + AttrLength1, /* 36 */ + AttrLength2, /* 37 */ + AttrSuffix, /* 38 */ + AttrAxisType, /* 39 */ + AttrRadius1, /* 40 */ + AttrRadius2, /* 41 */ + AttrRotationAngle, /* 42 */ + AttrDartP1, /* 43 */ + AttrDartP2, /* 44 */ + AttrDartP3, /* 45 */ + AttrCurve, /* 46 */ + AttrFirstArc, /* 47 */ + AttrSecondArc, /* 48 */ + AttrC1Center, /* 49 */ + AttrC2Center, /* 50 */ + AttrCurve1, /* 51 */ + AttrCurve2, /* 52 */ + AttrCCenter, /* 53 */ + AttrTangent, /* 54 */ + AttrPoint1, /* 55 */ + AttrPoint2, /* 56 */ + AttrPoint3, /* 57 */ + AttrPoint4, /* 58 */ + AttrPenStyle, /* 59 */ + AttrAScale, /* 60 */ + AttrNotes, /* 61 */ + AttrAlias, /* 62 */ + AttrAlias1, /* 63 */ + AttrAlias2, /* 64 */ + *AttrHold, /* 65 */ + *AttrVisible, /* 66 */ + *AttrOpacity /* 67 */ }; return attr; } diff --git a/src/app/valentina/dialogs/configpages/preferencespatternpage.cpp b/src/app/valentina/dialogs/configpages/preferencespatternpage.cpp index 20a08c648..dcf6173b7 100644 --- a/src/app/valentina/dialogs/configpages/preferencespatternpage.cpp +++ b/src/app/valentina/dialogs/configpages/preferencespatternpage.cpp @@ -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 #include #include +#include +#include #include namespace diff --git a/src/app/valentina/dialogs/dialogincrements.cpp b/src/app/valentina/dialogs/dialogincrements.cpp index 59b00834e..5d547c570 100644 --- a/src/app/valentina/dialogs/dialogincrements.cpp +++ b/src/app/valentina/dialogs/dialogincrements.cpp @@ -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 -#include -#include #include -#include +#include +#include +#include +#include #include +#include #include #include -#include 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 -void DialogIncrements::FillTable(const QMap &varTable, QTableWidget *table) +template void DialogIncrements::FillTable(const QMap &varTable, QTableWidget *table) { SCASSERT(table != nullptr) @@ -203,7 +205,7 @@ void DialogIncrements::FillTable(const QMap &varTable, QTableWidget i.next(); qreal length = *i.value()->GetValue(); currentRow++; - table->setRowCount ( static_cast(varTable.size()) ); + table->setRowCount(static_cast(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(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(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(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(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(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 > &increments, + const QMap> &increments, bool takePreviewCalculations) { SCASSERT(table != nullptr) @@ -1305,12 +1328,12 @@ void DialogIncrements::FillIncrementsTable(QTableWidget *table, table->blockSignals(true); table->clearContents(); - QMap >::const_iterator i; + QMap>::const_iterator i; QMap map; - //Sorting QHash by id + // Sorting QHash by id for (i = increments.constBegin(); i != increments.constEnd(); ++i) { - const QSharedPointer& incr = i.value(); + const QSharedPointer &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 iMap(map); - table->setRowCount ( static_cast(map.size()) ); + table->setRowCount(static_cast(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; } diff --git a/src/app/valentina/dialogs/dialogpatternproperties.cpp b/src/app/valentina/dialogs/dialogpatternproperties.cpp index 70353375e..1dbd1b974 100644 --- a/src/app/valentina/dialogs/dialogpatternproperties.cpp +++ b/src/app/valentina/dialogs/dialogpatternproperties.cpp @@ -29,36 +29,36 @@ #include "dialogpatternproperties.h" #include "ui_dialogpatternproperties.h" #include -#include -#include -#include -#include -#include -#include #include -#include -#include -#include +#include #include +#include +#include +#include +#include +#include +#include +#include +#include #include -#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(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); diff --git a/src/app/valentina/dialogs/dialogsavelayout.cpp b/src/app/valentina/dialogs/dialogsavelayout.cpp index acd4f736d..8f04ef87d 100644 --- a/src/app/valentina/dialogs/dialogsavelayout.cpp +++ b/src/app/valentina/dialogs/dialogsavelayout.cpp @@ -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 #include +#include #include #include -#include #include #include -#include + +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::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::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::of(&QDoubleSpinBox::valueChanged), - this, &DialogSaveLayout::HorizontalScaleChanged); - connect(ui->doubleSpinBoxVerticalScale, QOverload::of(&QDoubleSpinBox::valueChanged), - this, &DialogSaveLayout::VerticalScaleChanged); + connect(ui->doubleSpinBoxHorizontalScale, QOverload::of(&QDoubleSpinBox::valueChanged), this, + &DialogSaveLayout::HorizontalScaleChanged); + connect(ui->doubleSpinBoxVerticalScale, QOverload::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(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(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 > +auto DialogSaveLayout::InitFormats() -> QVector> { QVector> 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); @@ -701,8 +710,8 @@ auto DialogSaveLayout::InitFormats() -> QVectorGetTiledPDFPaperWidth(Unit::Mm), settings->GetTiledPDFPaperHeight(Unit::Mm)); const int max = static_cast(PaperSizeTemplate::Custom); - for (int i=0; i < max; ++i) + for (int i = 0; i < max; ++i) { const QSizeF tmplSize = GetTemplateSize(static_cast(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(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()); } } - diff --git a/src/app/valentina/dialogs/vwidgetdetails.cpp b/src/app/valentina/dialogs/vwidgetdetails.cpp index 0946d23e0..d3d54b0e0 100644 --- a/src/app/valentina/dialogs/vwidgetdetails.cpp +++ b/src/app/valentina/dialogs/vwidgetdetails.cpp @@ -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 #include @@ -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; itableWidget->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(VAbstractPattern::getTool(id)); + tool = qobject_cast(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; itableWidget->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!!! } } diff --git a/src/app/valentina/mainwindow.cpp b/src/app/valentina/mainwindow.cpp index 0ae81763a..460b9f017 100644 --- a/src/app/valentina/mainwindow.cpp +++ b/src/app/valentina/mainwindow.cpp @@ -27,31 +27,33 @@ *************************************************************************/ #include "mainwindow.h" -#include "ui_mainwindow.h" -#include "../ifc/exception/vexceptionobjecterror.h" #include "../ifc/exception/vexceptionconversionerror.h" #include "../ifc/exception/vexceptionemptyparameter.h" -#include "../ifc/exception/vexceptionwrongid.h" -#include "../ifc/exception/vexceptionundo.h" #include "../ifc/exception/vexceptioninvalidhistory.h" -#include "core/vapplication.h" +#include "../ifc/exception/vexceptionobjecterror.h" +#include "../ifc/exception/vexceptionundo.h" +#include "../ifc/exception/vexceptionwrongid.h" +#include "../ifc/xml/vpatternconverter.h" +#include "../ifc/xml/vvitconverter.h" +#include "../ifc/xml/vvstconverter.h" +#include "../vformat/vmeasurements.h" +#include "../vformat/vpatternrecipe.h" +#include "../vlayout/dialogs/watermarkwindow.h" #include "../vmisc/customevents.h" -#include "../vmisc/vvalentinasettings.h" #include "../vmisc/def.h" #include "../vmisc/qxtcsvmodel.h" #include "../vmisc/vmodifierkey.h" #include "../vmisc/vsysexits.h" +#include "../vmisc/vvalentinasettings.h" #include "../vtools/undocommands/renamepp.h" -#include "core/vtooloptionspropertybrowser.h" -#include "../ifc/xml/vpatternconverter.h" -#include "../vformat/vmeasurements.h" -#include "../ifc/xml/vvstconverter.h" -#include "../ifc/xml/vvitconverter.h" -#include "../vwidgets/vwidgetpopup.h" -#include "../vwidgets/vmaingraphicsscene.h" #include "../vtools/undocommands/undogroup.h" -#include "../vformat/vpatternrecipe.h" -#include "../vlayout/dialogs/watermarkwindow.h" +#include "../vwidgets/vmaingraphicsscene.h" +#include "../vwidgets/vwidgetpopup.h" +#include "core/vapplication.h" +#include "core/vtooloptionspropertybrowser.h" +#include "ui_mainwindow.h" +#include "vabstractapplication.h" +#include "vsinglelineoutlinechar.h" #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) #include "../vmisc/vtextcodec.h" @@ -63,30 +65,30 @@ #include "../vmisc/backport/qoverload.h" #endif // QT_VERSION < QT_VERSION_CHECK(5, 7, 0) -#include "../vlayout/vlayoutexporter.h" -#include "../vwidgets/vgraphicssimpletextitem.h" #include "../vlayout/dialogs/dialoglayoutscale.h" +#include "../vlayout/vlayoutexporter.h" #include "../vmisc/dialogs/dialogselectlanguage.h" +#include "../vwidgets/vgraphicssimpletextitem.h" #include "../vpatterndb/variables/vincrement.h" #include "../vpatterndb/variables/vmeasurement.h" -#include "../vtools/undocommands/image/addbackgroundimage.h" -#include "../vtools/undocommands/image/deletebackgroundimage.h" #include "../ifc/xml/utils.h" #include "../ifc/xml/vbackgroundpatternimage.h" +#include "../vtools/undocommands/image/addbackgroundimage.h" +#include "../vtools/undocommands/image/deletebackgroundimage.h" -#include "dialogs/vwidgetbackgroundimages.h" -#include "dialogs/vwidgetgroups.h" -#include "dialogs/vwidgetdetails.h" +#include "dialogs/dialogaboutapp.h" #include "dialogs/dialogaddbackgroundimage.h" +#include "dialogs/dialogfinalmeasurements.h" #include "dialogs/dialoghistory.h" #include "dialogs/dialogincrements.h" -#include "dialogs/dialogpatternproperties.h" #include "dialogs/dialognewpattern.h" -#include "dialogs/dialogaboutapp.h" +#include "dialogs/dialogpatternproperties.h" #include "dialogs/dialogpreferences.h" -#include "dialogs/dialogfinalmeasurements.h" +#include "dialogs/vwidgetbackgroundimages.h" +#include "dialogs/vwidgetdetails.h" +#include "dialogs/vwidgetgroups.h" #include "../vtools/dialogs/support/dialogeditlabel.h" @@ -94,83 +96,83 @@ #include "../vtools/dialogs/tools/dialogarc.h" #include "../vtools/dialogs/tools/dialogarcwithlength.h" #include "../vtools/dialogs/tools/dialogbisector.h" -#include "../vtools/dialogs/tools/piece/dialogseamallowance.h" -#include "../vtools/dialogs/tools/dialogendline.h" -#include "../vtools/dialogs/tools/dialogline.h" -#include "../vtools/dialogs/tools/dialoglineintersect.h" -#include "../vtools/dialogs/tools/dialognormal.h" -#include "../vtools/dialogs/tools/dialogpointofcontact.h" -#include "../vtools/dialogs/tools/dialogshoulderpoint.h" -#include "../vtools/dialogs/tools/dialogspline.h" #include "../vtools/dialogs/tools/dialogcubicbezier.h" -#include "../vtools/dialogs/tools/dialogsplinepath.h" #include "../vtools/dialogs/tools/dialogcubicbezierpath.h" -#include "../vtools/dialogs/tools/dialogheight.h" +#include "../vtools/dialogs/tools/dialogcurveintersectaxis.h" #include "../vtools/dialogs/tools/dialogcutarc.h" #include "../vtools/dialogs/tools/dialogcutspline.h" #include "../vtools/dialogs/tools/dialogcutsplinepath.h" -#include "../vtools/dialogs/tools/dialoguniondetails.h" -#include "../vtools/dialogs/tools/dialogtriangle.h" -#include "../vtools/dialogs/tools/dialogpointofintersection.h" +#include "../vtools/dialogs/tools/dialogellipticalarc.h" +#include "../vtools/dialogs/tools/dialogendline.h" +#include "../vtools/dialogs/tools/dialogflippingbyaxis.h" +#include "../vtools/dialogs/tools/dialogflippingbyline.h" +#include "../vtools/dialogs/tools/dialoggroup.h" +#include "../vtools/dialogs/tools/dialogheight.h" +#include "../vtools/dialogs/tools/dialogline.h" +#include "../vtools/dialogs/tools/dialoglineintersect.h" #include "../vtools/dialogs/tools/dialoglineintersectaxis.h" -#include "../vtools/dialogs/tools/dialogcurveintersectaxis.h" +#include "../vtools/dialogs/tools/dialogmove.h" +#include "../vtools/dialogs/tools/dialognormal.h" +#include "../vtools/dialogs/tools/dialogpointfromarcandtangent.h" +#include "../vtools/dialogs/tools/dialogpointfromcircleandtangent.h" +#include "../vtools/dialogs/tools/dialogpointofcontact.h" +#include "../vtools/dialogs/tools/dialogpointofintersection.h" #include "../vtools/dialogs/tools/dialogpointofintersectionarcs.h" #include "../vtools/dialogs/tools/dialogpointofintersectioncircles.h" #include "../vtools/dialogs/tools/dialogpointofintersectioncurves.h" -#include "../vtools/dialogs/tools/dialogpointfromcircleandtangent.h" -#include "../vtools/dialogs/tools/dialogpointfromarcandtangent.h" -#include "../vtools/dialogs/tools/dialogtruedarts.h" -#include "../vtools/dialogs/tools/dialoggroup.h" #include "../vtools/dialogs/tools/dialogrotation.h" -#include "../vtools/dialogs/tools/dialogflippingbyline.h" -#include "../vtools/dialogs/tools/dialogflippingbyaxis.h" -#include "../vtools/dialogs/tools/dialogmove.h" -#include "../vtools/dialogs/tools/dialogellipticalarc.h" +#include "../vtools/dialogs/tools/dialogshoulderpoint.h" +#include "../vtools/dialogs/tools/dialogspline.h" +#include "../vtools/dialogs/tools/dialogsplinepath.h" +#include "../vtools/dialogs/tools/dialogtriangle.h" +#include "../vtools/dialogs/tools/dialogtruedarts.h" +#include "../vtools/dialogs/tools/dialoguniondetails.h" +#include "../vtools/dialogs/tools/piece/dialogduplicatedetail.h" +#include "../vtools/dialogs/tools/piece/dialoginsertnode.h" #include "../vtools/dialogs/tools/piece/dialogpiecepath.h" #include "../vtools/dialogs/tools/piece/dialogpin.h" -#include "../vtools/dialogs/tools/piece/dialoginsertnode.h" #include "../vtools/dialogs/tools/piece/dialogplacelabel.h" -#include "../vtools/dialogs/tools/piece/dialogduplicatedetail.h" +#include "../vtools/dialogs/tools/piece/dialogseamallowance.h" +#include "../vtools/tools/backgroundimage/vbackgroundimagecontrols.h" #include "../vtools/tools/backgroundimage/vbackgroundimageitem.h" #include "../vtools/tools/backgroundimage/vbackgroundpixmapitem.h" #include "../vtools/tools/backgroundimage/vbackgroundsvgitem.h" -#include "../vtools/tools/backgroundimage/vbackgroundimagecontrols.h" -#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolalongline.h" -#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolbisector.h" -#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolendline.h" -#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolnormal.h" -#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolshoulderpoint.h" -#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolheight.h" -#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoollineintersectaxis.h" -#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolcurveintersectaxis.h" +#include "../vtools/tools/drawTools/operation/flipping/vtoolflippingbyaxis.h" +#include "../vtools/tools/drawTools/operation/flipping/vtoolflippingbyline.h" +#include "../vtools/tools/drawTools/operation/vtoolmove.h" +#include "../vtools/tools/drawTools/operation/vtoolrotation.h" #include "../vtools/tools/drawTools/toolcurve/vtoolarc.h" -#include "../vtools/tools/drawTools/toolcurve/vtoolellipticalarc.h" #include "../vtools/tools/drawTools/toolcurve/vtoolarcwithlength.h" -#include "../vtools/tools/drawTools/toolcurve/vtoolspline.h" #include "../vtools/tools/drawTools/toolcurve/vtoolcubicbezier.h" -#include "../vtools/tools/drawTools/toolcurve/vtoolsplinepath.h" #include "../vtools/tools/drawTools/toolcurve/vtoolcubicbezierpath.h" -#include "../vtools/tools/drawTools/vtoolline.h" +#include "../vtools/tools/drawTools/toolcurve/vtoolellipticalarc.h" +#include "../vtools/tools/drawTools/toolcurve/vtoolspline.h" +#include "../vtools/tools/drawTools/toolcurve/vtoolsplinepath.h" +#include "../vtools/tools/drawTools/toolpoint/tooldoublepoint/vtooltruedarts.h" +#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutarc.h" #include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutspline.h" #include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutsplinepath.h" -#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutarc.h" -#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoollineintersect.h" -#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofcontact.h" +#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolalongline.h" +#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolbisector.h" +#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolcurveintersectaxis.h" +#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolendline.h" +#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolheight.h" +#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoollineintersectaxis.h" +#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolnormal.h" +#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolshoulderpoint.h" #include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolbasepoint.h" -#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/vtooltriangle.h" +#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoollineintersect.h" +#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromarcandtangent.h" +#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromcircleandtangent.h" +#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofcontact.h" #include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersection.h" #include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectionarcs.h" #include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncircles.h" #include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncurves.h" -#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromcircleandtangent.h" -#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromarcandtangent.h" -#include "../vtools/tools/drawTools/toolpoint/tooldoublepoint/vtooltruedarts.h" -#include "../vtools/tools/drawTools/operation/vtoolrotation.h" -#include "../vtools/tools/drawTools/operation/flipping/vtoolflippingbyline.h" -#include "../vtools/tools/drawTools/operation/flipping/vtoolflippingbyaxis.h" -#include "../vtools/tools/drawTools/operation/vtoolmove.h" +#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/vtooltriangle.h" +#include "../vtools/tools/drawTools/vtoolline.h" #include "../vtools/tools/vtoolseamallowance.h" #include "../vtools/tools/vtooluniondetails.h" @@ -178,43 +180,47 @@ #include "../vtools/tools/nodeDetails/vtoolpin.h" #include "../vtools/tools/nodeDetails/vtoolplacelabel.h" +#if QT_VERSION < QT_VERSION_CHECK(5, 5, 0) +#include "../vmisc/diagnostic.h" +#endif // QT_VERSION < QT_VERSION_CHECK(5, 5, 0) + #if QT_VERSION < QT_VERSION_CHECK(5, 12, 0) #include "../vmisc/backport/qscopeguard.h" #else #include #endif -#include -#include -#include -#include -#include #include +#include +#include +#include +#include +#include #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) #include #endif -#include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include #include +#include #include -#include -#include +#include #include -#include -#include +#include #include +#include +#include +#include +#include +#include +#include #include +#include +#include +#include +#include +#include #if defined(Q_OS_WIN32) && QT_VERSION < QT_VERSION_CHECK(6, 0, 0) && QT_VERSION >= QT_VERSION_CHECK(5, 7, 0) #include @@ -222,9 +228,9 @@ #endif #if defined(Q_OS_MAC) -#include #include -#endif //defined(Q_OS_MAC) +#include +#endif // defined(Q_OS_MAC) #if (defined(Q_CC_GNU) && Q_CC_GNU < 409) && !defined(Q_CC_CLANG) // DO NOT WORK WITH GCC 4.8 @@ -247,11 +253,16 @@ QT_WARNING_POP namespace { +QT_WARNING_PUSH +QT_WARNING_DISABLE_CLANG("-Wunused-member-function") + Q_GLOBAL_STATIC_WITH_ARGS(const QString, autosavePrefix, (QLatin1String(".autosave"))) // NOLINT +QT_WARNING_POP + //--------------------------------------------------------------------------------------------------------------------- -auto SortDetailsForLayout(const QHash *allDetails, - const QString &nameRegex = QString()) -> QVector +auto SortDetailsForLayout(const QHash *allDetails, const QString &nameRegex = QString()) + -> QVector { QVector details; QHash::const_iterator i = allDetails->constBegin(); @@ -301,8 +312,9 @@ void WarningNotUniquePieceName(const QHash *allDetails) else { const QString errorMsg = QObject::tr("Piece name '%1' is not unique.").arg(pieceName); - VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) : - qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; + VAbstractApplication::VApp()->IsPedantic() + ? throw VException(errorMsg) + : qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; } ++i; @@ -317,7 +329,7 @@ void WarningNotUniquePieceName(const QHash *allDetails) * @param parent parent widget. */ MainWindow::MainWindow(QWidget *parent) - : MainWindowsNoGUI(parent), + : MainWindowsNoGUI(parent), ui(new Ui::MainWindow), m_watcher(new QFileSystemWatcher(this)), m_dialogTable(nullptr), @@ -338,16 +350,17 @@ MainWindow::MainWindow(QWidget *parent) connect(doc, &VPattern::patternChanged, this, &MainWindow::PatternChangesWereSaved); connect(doc, &VPattern::UndoCommand, this, &MainWindow::FullParseFile); connect(doc, &VPattern::SetEnabledGUI, this, &MainWindow::SetEnabledGUI); - connect(doc, &VPattern::CheckLayout, this, [this]() - { - if (pattern->DataPieces()->count() == 0) - { - if(not ui->actionDraw->isChecked()) + connect(doc, &VPattern::CheckLayout, this, + [this]() { - ActionDraw(true); - } - } - }); + if (pattern->DataPieces()->count() == 0) + { + if (not ui->actionDraw->isChecked()) + { + ActionDraw(true); + } + } + }); connect(doc, &VPattern::SetCurrentPP, this, &MainWindow::GlobalChangePP); connect(doc, &VPattern::MadeProgress, this, &MainWindow::ShowProgress); VAbstractValApplication::VApp()->setCurrentDocument(doc); @@ -388,28 +401,29 @@ MainWindow::MainWindow(QWidget *parent) connect(m_watcher, &QFileSystemWatcher::fileChanged, this, &MainWindow::MeasurementsChanged); m_measurementsSyncTimer->setTimerType(Qt::VeryCoarseTimer); - connect(m_measurementsSyncTimer, &QTimer::timeout, this, [this]() - { - if (isActiveWindow()) - { - static bool asking = false; - if (not asking && m_mChanges && not m_mChangesAsked) + connect(m_measurementsSyncTimer, &QTimer::timeout, this, + [this]() { - asking = true; - m_mChangesAsked = true; - m_measurementsSyncTimer->stop(); - const auto answer = - QMessageBox::question(this, tr("Measurements"), - tr("Measurements were changed. Do you want to sync measurements now?"), - QMessageBox::Yes|QMessageBox::No, QMessageBox::Yes); - if (answer == QMessageBox::Yes) + if (isActiveWindow()) { - SyncMeasurements(); + static bool asking = false; + if (not asking && m_mChanges && not m_mChangesAsked) + { + asking = true; + m_mChangesAsked = true; + m_measurementsSyncTimer->stop(); + const auto answer = QMessageBox::question( + this, tr("Measurements"), + tr("Measurements were changed. Do you want to sync measurements now?"), + QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes); + if (answer == QMessageBox::Yes) + { + SyncMeasurements(); + } + asking = false; + } } - asking = false; - } - } - }); + }); #if defined(Q_OS_MAC) // On Mac deafault icon size is 32x32. @@ -440,53 +454,53 @@ MainWindow::MainWindow(QWidget *parent) connect(actionPreferences, &QAction::triggered, this, &MainWindow::Preferences); menu->setAsDockMenu(); -#endif //defined(Q_OS_MAC) +#endif // defined(Q_OS_MAC) - connect(ui->toolButtonMessagesZoomInFont, &QToolButton::clicked, this, [this]() - { - VValentinaSettings *settings = VAbstractValApplication::VApp()->ValentinaSettings(); - QFont f = ui->plainTextEditPatternMessages->font(); - if (f.pointSize() < VValentinaSettings::GetDefMaxPatternMessageFontSize()) - { - f.setPointSize(f.pointSize()+1); - ui->plainTextEditPatternMessages->setFont(f); - settings->SetPatternMessageFontSize(f.pointSize()); - } - }); + connect(ui->toolButtonMessagesZoomInFont, &QToolButton::clicked, this, + [this]() + { + VValentinaSettings *settings = VAbstractValApplication::VApp()->ValentinaSettings(); + QFont f = ui->plainTextEditPatternMessages->font(); + if (f.pointSize() < VValentinaSettings::GetDefMaxPatternMessageFontSize()) + { + f.setPointSize(f.pointSize() + 1); + ui->plainTextEditPatternMessages->setFont(f); + settings->SetPatternMessageFontSize(f.pointSize()); + } + }); - connect(ui->toolButtonMessagesZoomOutFont, &QToolButton::clicked, this, [this]() - { - VValentinaSettings *settings = VAbstractValApplication::VApp()->ValentinaSettings(); - QFont f = ui->plainTextEditPatternMessages->font(); - if (f.pointSize() > VValentinaSettings::GetDefMinPatternMessageFontSize()) - { - f.setPointSize(f.pointSize()-1); - ui->plainTextEditPatternMessages->setFont(f); - settings->SetPatternMessageFontSize(f.pointSize()); - } - }); + connect(ui->toolButtonMessagesZoomOutFont, &QToolButton::clicked, this, + [this]() + { + VValentinaSettings *settings = VAbstractValApplication::VApp()->ValentinaSettings(); + QFont f = ui->plainTextEditPatternMessages->font(); + if (f.pointSize() > VValentinaSettings::GetDefMinPatternMessageFontSize()) + { + f.setPointSize(f.pointSize() - 1); + ui->plainTextEditPatternMessages->setFont(f); + settings->SetPatternMessageFontSize(f.pointSize()); + } + }); - connect(ui->lineEditMessagesFilter, &QLineEdit::textChanged, this, [this](const QString &text) - { - ui->plainTextEditPatternMessages->SetFilter(text); - }); + connect(ui->lineEditMessagesFilter, &QLineEdit::textChanged, this, + [this](const QString &text) { ui->plainTextEditPatternMessages->SetFilter(text); }); connect(ui->toolButtonClearMessages, &QToolButton::clicked, this, &MainWindow::ClearPatternMessages); - ui->toolButtonAutoRefresh->setChecked( - VAbstractValApplication::VApp()->ValentinaSettings()->GetAutoRefreshPatternMessage()); - connect(ui->toolButtonAutoRefresh, &QToolButton::clicked, this, [](bool checked) - { - VAbstractValApplication::VApp()->ValentinaSettings()->SetAutoRefreshPatternMessage(checked); - }); + VValentinaSettings *settings = VAbstractValApplication::VApp()->ValentinaSettings(); + ui->toolButtonAutoRefresh->setChecked(settings->GetAutoRefreshPatternMessage()); + connect(ui->toolButtonAutoRefresh, &QToolButton::clicked, this, + [](bool checked) + { VAbstractValApplication::VApp()->ValentinaSettings()->SetAutoRefreshPatternMessage(checked); }); - connect(doc, &VPattern::PreParseState, this, [this]() - { - if (ui->toolButtonAutoRefresh->isChecked()) - { - ClearPatternMessages(); - } - }); + connect(doc, &VPattern::PreParseState, this, + [this]() + { + if (ui->toolButtonAutoRefresh->isChecked()) + { + ClearPatternMessages(); + } + }); if (VApplication::IsGUIMode()) { @@ -513,8 +527,8 @@ void MainWindow::AddPP(const QString &PPName) m_comboBoxDraws->addItem(PPName); pattern->ClearCalculationGObjects(); - //Create single point - emit ui->view->itemClicked(nullptr);//hide options previous tool + // Create single point + emit ui->view->itemClicked(nullptr); // hide options previous tool const QString label = doc->GenerateLabel(LabelType::NewPatternPiece); const QPointF startPosition = StartPositionNewPP(); @@ -536,7 +550,7 @@ void MainWindow::AddPP(const QString &PPName) SetEnableWidgets(true); const qint32 index = m_comboBoxDraws->findText(PPName); - if ( index != -1 ) + if (index != -1) { // -1 for not found m_comboBoxDraws->setCurrentIndex(index); } @@ -548,7 +562,7 @@ void MainWindow::AddPP(const QString &PPName) // Show best for new PP VMainGraphicsView::NewSceneRect(ui->view->scene(), ui->view, spoint); - //ZoomFitBestCurrent(); + // ZoomFitBestCurrent(); QApplication::postEvent(this, new FitBestCurrentEvent()); ui->actionNewDraw->setEnabled(true); @@ -566,10 +580,10 @@ auto MainWindow::StartPositionNewPP() const -> QPointF const QRectF rect = m_sceneDraw->VisibleItemsBoundingRect(); if (rect.width() <= rect.height()) { - return {rect.width()+margin, originY}; + return {rect.width() + margin, originY}; } - return {originX, rect.height()+margin}; + return {originX, rect.height() + margin}; } return {originX, originY}; @@ -621,9 +635,9 @@ void MainWindow::InitScenes() m_sceneDraw->setTransform(ui->view->transform()); m_sceneDetails->setTransform(ui->view->transform()); - connect(ui->view, &VMainGraphicsView::MouseRelease, this, [this](){EndVisualization(true);}); + connect(ui->view, &VMainGraphicsView::MouseRelease, this, [this]() { EndVisualization(true); }); connect(ui->view, &VMainGraphicsView::ScaleChanged, this, &MainWindow::ScaleChanged); - connect(ui->view, &VMainGraphicsView::ZoomFitBestCurrent, this, [this](){ZoomFitBestCurrent();}); + connect(ui->view, &VMainGraphicsView::ZoomFitBestCurrent, this, [this]() { ZoomFitBestCurrent(); }); QSizePolicy policy(QSizePolicy::Expanding, QSizePolicy::Expanding); policy.setHorizontalStretch(12); ui->view->setSizePolicy(policy); @@ -652,9 +666,7 @@ auto MainWindow::LoadMeasurements(const QString &path) -> bool else if (m_m->Type() == MeasurementsType::Multisize) { auto DimensionBase = [](qreal current, qreal tableBase) - { - return not VFuzzyComparePossibleNulls(current, -1) ? current : tableBase; - }; + { return not VFuzzyComparePossibleNulls(current, -1) ? current : tableBase; }; m_currentDimensionA = DimensionBase(doc->GetDimensionAValue(), m_m->DimensionABase()); m_currentDimensionB = DimensionBase(doc->GetDimensionBValue(), m_m->DimensionBBase()); @@ -668,8 +680,8 @@ auto MainWindow::LoadMeasurements(const QString &path) -> bool } catch (VExceptionEmptyParameter &e) { - qCCritical(vMainWindow, "%s\n\n%s\n\n%s", qUtf8Printable(tr("File error.")), - qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation())); + qCCritical(vMainWindow, "%s\n\n%s\n\n%s", qUtf8Printable(tr("File error.")), qUtf8Printable(e.ErrorMessage()), + qUtf8Printable(e.DetailedInformation())); if (not VApplication::IsGUIMode()) { QCoreApplication::exit(V_EX_NOINPUT); @@ -689,8 +701,8 @@ auto MainWindow::UpdateMeasurements(const QString &path, qreal baseA, qreal base } //--------------------------------------------------------------------------------------------------------------------- -auto MainWindow::UpdateMeasurements(const QSharedPointer &mFile, qreal baseA, qreal baseB, - qreal baseC) -> bool +auto MainWindow::UpdateMeasurements(const QSharedPointer &mFile, qreal baseA, qreal baseB, qreal baseC) + -> bool { m_m = mFile; @@ -715,8 +727,8 @@ auto MainWindow::UpdateMeasurements(const QSharedPointer &mFile, } catch (VExceptionEmptyParameter &e) { - qCCritical(vMainWindow, "%s\n\n%s\n\n%s", qUtf8Printable(tr("File error.")), - qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation())); + qCCritical(vMainWindow, "%s\n\n%s\n\n%s", qUtf8Printable(tr("File error.")), qUtf8Printable(e.ErrorMessage()), + qUtf8Printable(e.DetailedInformation())); if (not VApplication::IsGUIMode()) { QCoreApplication::exit(V_EX_NOINPUT); @@ -736,8 +748,8 @@ void MainWindow::ReadMeasurements(qreal baseA, qreal baseB, qreal baseC) { const QList dimensions = m_m->Dimensions().values(); - auto InitDimensionLabel = [this](const MeasurementDimension_p& dimension, - QPointer &name, QPointer &control) + auto InitDimensionLabel = + [this](const MeasurementDimension_p &dimension, QPointer &name, QPointer &control) { if (dimension.isNull()) { @@ -746,11 +758,11 @@ void MainWindow::ReadMeasurements(qreal baseA, qreal baseB, qreal baseC) if (name == nullptr) { - name = new QLabel(dimension->Name()+QChar(':')); + name = new QLabel(dimension->Name() + QChar(':')); } else { - name->setText(dimension->Name()+QChar(':')); + name->setText(dimension->Name() + QChar(':')); } name->setToolTip(VAbstartMeasurementDimension::DimensionToolTip(dimension, m_m->IsFullCircumference())); @@ -829,7 +841,7 @@ void MainWindow::SetToolButton(bool checked, Tool t, const QString &cursor, cons // This check helps to find missed tools in the switch Q_STATIC_ASSERT_X(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 59, "Check if need to extend."); - switch(t) + switch (t) { case Tool::Midpoint: m_dialogTool->Build(t); @@ -865,7 +877,7 @@ void MainWindow::SetToolButton(bool checked, Tool t, const QString &cursor, cons } else { - if (auto *tButton = qobject_cast< QToolButton * >(this->sender())) + if (auto *tButton = qobject_cast(this->sender())) { tButton->setChecked(true); } @@ -894,7 +906,7 @@ void MainWindow::SetToolButtonWithApply(bool checked, Tool t, const QString &cur } else { - if (auto *tButton = qobject_cast< QToolButton * >(this->sender())) + if (auto *tButton = qobject_cast(this->sender())) { tButton->setChecked(true); } @@ -905,8 +917,7 @@ void MainWindow::SetToolButtonWithApply(bool checked, Tool t, const QString &cur * @brief ClosedDialog handle close dialog * @param result result working dialog. */ -template -void MainWindow::ClosedDialog(int result) +template void MainWindow::ClosedDialog(int result) { SCASSERT(not m_dialogTool.isNull()) if (result == QDialog::Accepted) @@ -926,8 +937,7 @@ void MainWindow::ClosedDialog(int result) * @brief ClosedDialogWithApply handle close dialog that has apply button * @param result result working dialog. */ -template -void MainWindow::ClosedDialogWithApply(int result, VMainGraphicsScene *scene) +template void MainWindow::ClosedDialogWithApply(int result, VMainGraphicsScene *scene) { SCASSERT(not m_dialogTool.isNull()) if (result == QDialog::Accepted) @@ -935,7 +945,7 @@ void MainWindow::ClosedDialogWithApply(int result, VMainGraphicsScene *scene) ApplyDialog(scene); } // If before Cancel was used Apply we have an item - auto *vtool = qobject_cast(m_dialogTool->GetAssociatedTool());// Don't check for nullptr here + auto *vtool = qobject_cast(m_dialogTool->GetAssociatedTool()); // Don't check for nullptr here if (m_dialogTool->GetAssociatedTool() != nullptr) { SCASSERT(vtool != nullptr) @@ -943,10 +953,10 @@ void MainWindow::ClosedDialogWithApply(int result, VMainGraphicsScene *scene) connect(vtool, &DrawTool::ToolTip, this, &MainWindow::ShowToolTip); } ArrowTool(true); - ui->view->itemClicked(vtool);// Don't check for nullptr here + ui->view->itemClicked(vtool); // Don't check for nullptr here if (vtool) { - vtool->setFocus(); + vtool->setFocus(); } // If insert not to the end of file call lite parse if (doc->getCursor() > 0) @@ -963,8 +973,7 @@ void MainWindow::ClosedDialogWithApply(int result, VMainGraphicsScene *scene) /** * @brief ApplyDialog handle apply in dialog */ -template -void MainWindow::ApplyDialog(VMainGraphicsScene *scene) +template void MainWindow::ApplyDialog(VMainGraphicsScene *scene) { SCASSERT(not m_dialogTool.isNull()) @@ -977,36 +986,32 @@ void MainWindow::ApplyDialog(VMainGraphicsScene *scene) } else { // Or update associated tool with data - auto * vtool = qobject_cast(m_dialogTool->GetAssociatedTool()); + auto *vtool = qobject_cast(m_dialogTool->GetAssociatedTool()); SCASSERT(vtool != nullptr) vtool->FullUpdateFromGuiApply(); } } //--------------------------------------------------------------------------------------------------------------------- -template -void MainWindow::ClosedDrawDialogWithApply(int result) +template void MainWindow::ClosedDrawDialogWithApply(int result) { ClosedDialogWithApply(result, m_sceneDraw); } //--------------------------------------------------------------------------------------------------------------------- -template -void MainWindow::ApplyDrawDialog() +template void MainWindow::ApplyDrawDialog() { ApplyDialog(m_sceneDraw); } //--------------------------------------------------------------------------------------------------------------------- -template -void MainWindow::ClosedDetailsDialogWithApply(int result) +template void MainWindow::ClosedDetailsDialogWithApply(int result) { ClosedDialogWithApply(result, m_sceneDetails); } //--------------------------------------------------------------------------------------------------------------------- -template -void MainWindow::ApplyDetailsDialog() +template void MainWindow::ApplyDetailsDialog() { ApplyDialog(m_sceneDetails); } @@ -1020,8 +1025,7 @@ void MainWindow::ToolEndLine(bool checked) { ToolSelectPointByRelease(); SetToolButtonWithApply(checked, Tool::EndLine, QStringLiteral(":/cursor/endline_cursor.png"), - tr("Select point"), - &MainWindow::ClosedDrawDialogWithApply, + tr("Select point"), &MainWindow::ClosedDrawDialogWithApply, &MainWindow::ApplyDrawDialog); } @@ -1034,8 +1038,7 @@ void MainWindow::ToolLine(bool checked) { ToolSelectPointByRelease(); SetToolButtonWithApply(checked, Tool::Line, QStringLiteral(":/cursor/line_cursor.png"), - tr("Select first point"), - &MainWindow::ClosedDrawDialogWithApply, + tr("Select first point"), &MainWindow::ClosedDrawDialogWithApply, &MainWindow::ApplyDrawDialog); } @@ -1070,11 +1073,9 @@ void MainWindow::ToolMidpoint(bool checked) void MainWindow::ToolShoulderPoint(bool checked) { ToolSelectPointByRelease(); - SetToolButtonWithApply(checked, Tool::ShoulderPoint, - QStringLiteral(":/cursor/shoulder_cursor.png"), - tr("Select point"), - &MainWindow::ClosedDrawDialogWithApply, - &MainWindow::ApplyDrawDialog); + SetToolButtonWithApply( + checked, Tool::ShoulderPoint, QStringLiteral(":/cursor/shoulder_cursor.png"), tr("Select point"), + &MainWindow::ClosedDrawDialogWithApply, &MainWindow::ApplyDrawDialog); } //--------------------------------------------------------------------------------------------------------------------- @@ -1085,10 +1086,9 @@ void MainWindow::ToolShoulderPoint(bool checked) void MainWindow::ToolNormal(bool checked) { ToolSelectPointByRelease(); - SetToolButtonWithApply(checked, Tool::Normal, QStringLiteral(":/cursor/normal_cursor.png"), - tr("Select first point of line"), - &MainWindow::ClosedDrawDialogWithApply, - &MainWindow::ApplyDrawDialog); + SetToolButtonWithApply( + checked, Tool::Normal, QStringLiteral(":/cursor/normal_cursor.png"), tr("Select first point of line"), + &MainWindow::ClosedDrawDialogWithApply, &MainWindow::ApplyDrawDialog); } //--------------------------------------------------------------------------------------------------------------------- @@ -1099,10 +1099,9 @@ void MainWindow::ToolNormal(bool checked) void MainWindow::ToolBisector(bool checked) { ToolSelectPointByRelease(); - SetToolButtonWithApply(checked, Tool::Bisector, QStringLiteral(":/cursor/bisector_cursor.png"), - tr("Select first point of angle"), - &MainWindow::ClosedDrawDialogWithApply, - &MainWindow::ApplyDrawDialog); + SetToolButtonWithApply( + checked, Tool::Bisector, QStringLiteral(":/cursor/bisector_cursor.png"), tr("Select first point of angle"), + &MainWindow::ClosedDrawDialogWithApply, &MainWindow::ApplyDrawDialog); } //--------------------------------------------------------------------------------------------------------------------- @@ -1113,11 +1112,10 @@ void MainWindow::ToolBisector(bool checked) void MainWindow::ToolLineIntersect(bool checked) { ToolSelectPointByRelease(); - SetToolButtonWithApply(checked, Tool::LineIntersect, - QStringLiteral(":/cursor/intersect_cursor.png"), - tr("Select first point of first line"), - &MainWindow::ClosedDrawDialogWithApply, - &MainWindow::ApplyDrawDialog); + SetToolButtonWithApply( + checked, Tool::LineIntersect, QStringLiteral(":/cursor/intersect_cursor.png"), + tr("Select first point of first line"), &MainWindow::ClosedDrawDialogWithApply, + &MainWindow::ApplyDrawDialog); } //--------------------------------------------------------------------------------------------------------------------- @@ -1128,21 +1126,18 @@ void MainWindow::ToolLineIntersect(bool checked) void MainWindow::ToolSpline(bool checked) { ToolSelectPointByPress(); - SetToolButtonWithApply(checked, Tool::Spline, QStringLiteral(":/cursor/spline_cursor.png"), - tr("Select first point curve"), - &MainWindow::ClosedDrawDialogWithApply, - &MainWindow::ApplyDrawDialog); + SetToolButtonWithApply( + checked, Tool::Spline, QStringLiteral(":/cursor/spline_cursor.png"), tr("Select first point curve"), + &MainWindow::ClosedDrawDialogWithApply, &MainWindow::ApplyDrawDialog); } //--------------------------------------------------------------------------------------------------------------------- void MainWindow::ToolCubicBezier(bool checked) { ToolSelectPointByRelease(); - SetToolButtonWithApply(checked, Tool::CubicBezier, - QStringLiteral(":/cursor/cubic_bezier_cursor.png"), - tr("Select first curve point"), - &MainWindow::ClosedDrawDialogWithApply, - &MainWindow::ApplyDrawDialog); + SetToolButtonWithApply( + checked, Tool::CubicBezier, QStringLiteral(":/cursor/cubic_bezier_cursor.png"), tr("Select first curve point"), + &MainWindow::ClosedDrawDialogWithApply, &MainWindow::ApplyDrawDialog); } //--------------------------------------------------------------------------------------------------------------------- @@ -1153,11 +1148,9 @@ void MainWindow::ToolCubicBezier(bool checked) void MainWindow::ToolCutSpline(bool checked) { ToolSelectSpline(); - SetToolButtonWithApply(checked, Tool::CutSpline, - QStringLiteral(":/cursor/spline_cut_point_cursor.png"), - tr("Select simple curve"), - &MainWindow::ClosedDrawDialogWithApply, - &MainWindow::ApplyDrawDialog); + SetToolButtonWithApply( + checked, Tool::CutSpline, QStringLiteral(":/cursor/spline_cut_point_cursor.png"), tr("Select simple curve"), + &MainWindow::ClosedDrawDialogWithApply, &MainWindow::ApplyDrawDialog); } //--------------------------------------------------------------------------------------------------------------------- @@ -1168,10 +1161,9 @@ void MainWindow::ToolCutSpline(bool checked) void MainWindow::ToolArc(bool checked) { ToolSelectPointByRelease(); - SetToolButtonWithApply(checked, Tool::Arc, QStringLiteral(":/cursor/arc_cursor.png"), - tr("Select point of center of arc"), - &MainWindow::ClosedDrawDialogWithApply, - &MainWindow::ApplyDrawDialog); + SetToolButtonWithApply( + checked, Tool::Arc, QStringLiteral(":/cursor/arc_cursor.png"), tr("Select point of center of arc"), + &MainWindow::ClosedDrawDialogWithApply, &MainWindow::ApplyDrawDialog); } //--------------------------------------------------------------------------------------------------------------------- @@ -1182,11 +1174,10 @@ void MainWindow::ToolArc(bool checked) void MainWindow::ToolEllipticalArc(bool checked) { ToolSelectPointByRelease(); - SetToolButtonWithApply(checked, Tool::EllipticalArc, - QStringLiteral(":/cursor/el_arc_cursor.png"), - tr("Select point of center of elliptical arc"), - &MainWindow::ClosedDrawDialogWithApply, - &MainWindow::ApplyDrawDialog); + SetToolButtonWithApply( + checked, Tool::EllipticalArc, QStringLiteral(":/cursor/el_arc_cursor.png"), + tr("Select point of center of elliptical arc"), &MainWindow::ClosedDrawDialogWithApply, + &MainWindow::ApplyDrawDialog); } //--------------------------------------------------------------------------------------------------------------------- @@ -1197,22 +1188,19 @@ void MainWindow::ToolEllipticalArc(bool checked) void MainWindow::ToolSplinePath(bool checked) { ToolSelectPointByPress(); - SetToolButtonWithApply(checked, Tool::SplinePath, - QStringLiteral(":/cursor/splinepath_cursor.png"), - tr("Select point of curve path"), - &MainWindow::ClosedDrawDialogWithApply, - &MainWindow::ApplyDrawDialog); + SetToolButtonWithApply( + checked, Tool::SplinePath, QStringLiteral(":/cursor/splinepath_cursor.png"), tr("Select point of curve path"), + &MainWindow::ClosedDrawDialogWithApply, &MainWindow::ApplyDrawDialog); } //--------------------------------------------------------------------------------------------------------------------- void MainWindow::ToolCubicBezierPath(bool checked) { ToolSelectPointByRelease(); - SetToolButtonWithApply(checked, Tool::CubicBezierPath, - QStringLiteral(":/cursor/cubic_bezier_path_cursor.png"), - tr("Select point of cubic bezier path"), - &MainWindow::ClosedDrawDialogWithApply, - &MainWindow::ApplyDrawDialog); + SetToolButtonWithApply( + checked, Tool::CubicBezierPath, QStringLiteral(":/cursor/cubic_bezier_path_cursor.png"), + tr("Select point of cubic bezier path"), &MainWindow::ClosedDrawDialogWithApply, + &MainWindow::ApplyDrawDialog); } //--------------------------------------------------------------------------------------------------------------------- @@ -1223,11 +1211,10 @@ void MainWindow::ToolCubicBezierPath(bool checked) void MainWindow::ToolCutSplinePath(bool checked) { ToolSelectSplinePath(); - SetToolButtonWithApply(checked, Tool::CutSplinePath, - QStringLiteral(":/cursor/splinepath_cut_point_cursor.png"), - tr("Select curve path"), - &MainWindow::ClosedDrawDialogWithApply, - &MainWindow::ApplyDrawDialog); + SetToolButtonWithApply( + checked, Tool::CutSplinePath, QStringLiteral(":/cursor/splinepath_cut_point_cursor.png"), + tr("Select curve path"), &MainWindow::ClosedDrawDialogWithApply, + &MainWindow::ApplyDrawDialog); } //--------------------------------------------------------------------------------------------------------------------- @@ -1238,11 +1225,10 @@ void MainWindow::ToolCutSplinePath(bool checked) void MainWindow::ToolPointOfContact(bool checked) { ToolSelectPointByRelease(); - SetToolButtonWithApply(checked, Tool::PointOfContact, - QStringLiteral(":/cursor/pointcontact_cursor.png"), - tr("Select first point of line"), - &MainWindow::ClosedDrawDialogWithApply, - &MainWindow::ApplyDrawDialog); + SetToolButtonWithApply( + checked, Tool::PointOfContact, QStringLiteral(":/cursor/pointcontact_cursor.png"), + tr("Select first point of line"), &MainWindow::ClosedDrawDialogWithApply, + &MainWindow::ApplyDrawDialog); } //--------------------------------------------------------------------------------------------------------------------- @@ -1253,8 +1239,7 @@ void MainWindow::ToolPointOfContact(bool checked) void MainWindow::ToolDetail(bool checked) { ToolSelectAllDrawObjects(); - SetToolButtonWithApply(checked, Tool::Piece, - QStringLiteral("://cursor/new_detail_cursor.png"), + SetToolButtonWithApply(checked, Tool::Piece, QStringLiteral("://cursor/new_detail_cursor.png"), tr("Select main path objects clockwise."), &MainWindow::ClosedDetailsDialogWithApply, &MainWindow::ApplyDetailsDialog); @@ -1264,10 +1249,10 @@ void MainWindow::ToolDetail(bool checked) void MainWindow::ToolPiecePath(bool checked) { ToolSelectAllDrawObjects(); - SetToolButton(checked, Tool::PiecePath, QStringLiteral("://cursor/path_cursor.png"), - tr("Select path objects, %1 - reverse direction curve") - .arg(VModifierKey::Shift()), - &MainWindow::ClosedDialogPiecePath); + SetToolButton( + checked, Tool::PiecePath, QStringLiteral("://cursor/path_cursor.png"), + tr("Select path objects, %1 - reverse direction curve").arg(VModifierKey::Shift()), + &MainWindow::ClosedDialogPiecePath); } //--------------------------------------------------------------------------------------------------------------------- @@ -1295,8 +1280,7 @@ void MainWindow::ToolHeight(bool checked) { ToolSelectPointByRelease(); SetToolButtonWithApply(checked, Tool::Height, QStringLiteral(":/cursor/height_cursor.png"), - tr("Select base point"), - &MainWindow::ClosedDrawDialogWithApply, + tr("Select base point"), &MainWindow::ClosedDrawDialogWithApply, &MainWindow::ApplyDrawDialog); } @@ -1308,10 +1292,9 @@ void MainWindow::ToolHeight(bool checked) void MainWindow::ToolTriangle(bool checked) { ToolSelectPointByRelease(); - SetToolButtonWithApply(checked, Tool::Triangle, QStringLiteral(":/cursor/triangle_cursor.png"), - tr("Select first point of axis"), - &MainWindow::ClosedDrawDialogWithApply, - &MainWindow::ApplyDrawDialog); + SetToolButtonWithApply( + checked, Tool::Triangle, QStringLiteral(":/cursor/triangle_cursor.png"), tr("Select first point of axis"), + &MainWindow::ClosedDrawDialogWithApply, &MainWindow::ApplyDrawDialog); } //--------------------------------------------------------------------------------------------------------------------- @@ -1322,11 +1305,10 @@ void MainWindow::ToolTriangle(bool checked) void MainWindow::ToolPointOfIntersection(bool checked) { ToolSelectPointByRelease(); - SetToolButtonWithApply(checked, Tool::PointOfIntersection, - QStringLiteral(":/cursor/pointofintersect_cursor.png"), - tr("Select point for X value (vertical)"), - &MainWindow::ClosedDrawDialogWithApply, - &MainWindow::ApplyDrawDialog); + SetToolButtonWithApply( + checked, Tool::PointOfIntersection, QStringLiteral(":/cursor/pointofintersect_cursor.png"), + tr("Select point for X value (vertical)"), &MainWindow::ClosedDrawDialogWithApply, + &MainWindow::ApplyDrawDialog); } //--------------------------------------------------------------------------------------------------------------------- @@ -1348,7 +1330,7 @@ void MainWindow::ToolUnionDetails(bool checked) */ void MainWindow::ClosedDialogUnionDetails(int result) { - ClosedDialog(result);// Avoid error: Template function as signal or slot + ClosedDialog(result); // Avoid error: Template function as signal or slot } //--------------------------------------------------------------------------------------------------------------------- @@ -1356,8 +1338,8 @@ void MainWindow::ToolDuplicateDetail(bool checked) { ToolSelectDetail(); SetToolButton(checked, Tool::DuplicateDetail, - QStringLiteral(":/cursor/duplicate_detail_cursor.png"), - tr("Select detail"), &MainWindow::ClosedDialogDuplicateDetail); + QStringLiteral(":/cursor/duplicate_detail_cursor.png"), tr("Select detail"), + &MainWindow::ClosedDialogDuplicateDetail); } //--------------------------------------------------------------------------------------------------------------------- @@ -1382,7 +1364,7 @@ void MainWindow::ToolGroup(bool checked) ToolSelectGroupObjects(); const QString tooltip = tr("Select one or more objects, hold %1 - for multiple selection, " "%2 - finish creation") - .arg(VModifierKey::Control(), VModifierKey::EnterKey()); + .arg(VModifierKey::Control(), VModifierKey::EnterKey()); SetToolButton(checked, Tool::Group, QStringLiteral(":/cursor/group_plus_cursor.png"), tooltip, &MainWindow::ClosedDialogGroup); } @@ -1393,7 +1375,7 @@ void MainWindow::ToolRotation(bool checked) ToolSelectOperationObjects(); const QString tooltip = tr("Select one or more objects, hold %1 - for multiple selection, " "%2 - confirm selection") - .arg(VModifierKey::Control(), VModifierKey::EnterKey()); + .arg(VModifierKey::Control(), VModifierKey::EnterKey()); SetToolButtonWithApply(checked, Tool::Rotation, QStringLiteral(":/cursor/rotation_cursor.png"), tooltip, &MainWindow::ClosedDrawDialogWithApply, &MainWindow::ApplyDrawDialog); @@ -1405,11 +1387,10 @@ void MainWindow::ToolFlippingByLine(bool checked) ToolSelectOperationObjects(); const QString tooltip = tr("Select one or more objects, hold %1 - for multiple selection, " "%2 - confirm selection") - .arg(VModifierKey::Control(), VModifierKey::EnterKey()); - SetToolButtonWithApply(checked, Tool::FlippingByLine, - QStringLiteral(":/cursor/flipping_line_cursor.png"), - tooltip, &MainWindow::ClosedDrawDialogWithApply, - &MainWindow::ApplyDrawDialog); + .arg(VModifierKey::Control(), VModifierKey::EnterKey()); + SetToolButtonWithApply( + checked, Tool::FlippingByLine, QStringLiteral(":/cursor/flipping_line_cursor.png"), tooltip, + &MainWindow::ClosedDrawDialogWithApply, &MainWindow::ApplyDrawDialog); } //--------------------------------------------------------------------------------------------------------------------- @@ -1418,11 +1399,10 @@ void MainWindow::ToolFlippingByAxis(bool checked) ToolSelectOperationObjects(); const QString tooltip = tr("Select one or more objects, hold %1 - for multiple selection, " "%2 - confirm selection") - .arg(VModifierKey::Control(), VModifierKey::EnterKey()); - SetToolButtonWithApply(checked, Tool::FlippingByAxis, - QStringLiteral(":/cursor/flipping_axis_cursor.png"), - tooltip, &MainWindow::ClosedDrawDialogWithApply, - &MainWindow::ApplyDrawDialog); + .arg(VModifierKey::Control(), VModifierKey::EnterKey()); + SetToolButtonWithApply( + checked, Tool::FlippingByAxis, QStringLiteral(":/cursor/flipping_axis_cursor.png"), tooltip, + &MainWindow::ClosedDrawDialogWithApply, &MainWindow::ApplyDrawDialog); } //--------------------------------------------------------------------------------------------------------------------- @@ -1431,7 +1411,7 @@ void MainWindow::ToolMove(bool checked) ToolSelectOperationObjects(); const QString tooltip = tr("Select one or more objects, hold %1 - for multiple selection, " "%2 - confirm selection") - .arg(VModifierKey::Control(), VModifierKey::EnterKey()); + .arg(VModifierKey::Control(), VModifierKey::EnterKey()); SetToolButtonWithApply(checked, Tool::Move, QStringLiteral(":/cursor/move_cursor.png"), tooltip, &MainWindow::ClosedDrawDialogWithApply, &MainWindow::ApplyDrawDialog); @@ -1445,8 +1425,8 @@ void MainWindow::ClosedDialogGroup(int result) { const QPointer dialog = qobject_cast(m_dialogTool); SCASSERT(not dialog.isNull()) - const QDomElement group = doc->CreateGroup(pattern->getNextId(), dialog->GetName(), dialog->GetTags(), - dialog->GetGroup()); + const QDomElement group = + doc->CreateGroup(pattern->getNextId(), dialog->GetName(), dialog->GetTags(), dialog->GetGroup()); if (not group.isNull()) { auto *addGroup = new AddGroup(group, doc); @@ -1510,7 +1490,7 @@ void MainWindow::ClosedDialogInsertNode(int result) //--------------------------------------------------------------------------------------------------------------------- void MainWindow::ZoomFitBestCurrent() { - if(m_drawMode) + if (m_drawMode) { const QRectF rect = doc->ActiveDrawBoundingRect(); if (rect.isEmpty()) @@ -1545,7 +1525,7 @@ void MainWindow::PlaceBackgroundImage(const QPointF &pos, const QString &fileNam image.SetName(dialog.Name()); VValentinaSettings *settings = VAbstractValApplication::VApp()->ValentinaSettings(); - image.SetOpacity(settings->GetBackgroundImageDefOpacity()/100.); + image.SetOpacity(settings->GetBackgroundImageDefOpacity() / 100.); QTransform m; m.translate(pos.x(), pos.y()); @@ -1561,7 +1541,7 @@ void MainWindow::PlaceBackgroundImage(const QPointF &pos, const QString &fileNam return; } - auto* addBackgroundImage = new AddBackgroundImage(image, doc); + auto *addBackgroundImage = new AddBackgroundImage(image, doc); connect(addBackgroundImage, &AddBackgroundImage::AddItem, this, &MainWindow::AddBackgroundImageItem); connect(addBackgroundImage, &AddBackgroundImage::DeleteItem, this, &MainWindow::DeleteBackgroundImageItem); VApplication::VApp()->getUndoStack()->push(addBackgroundImage); @@ -1572,7 +1552,7 @@ void MainWindow::RemoveBackgroundImage(const QUuid &id) { VBackgroundPatternImage image = doc->GetBackgroundImage(id); - auto* deleteBackgroundImage = new DeleteBackgroundImage(image, doc); + auto *deleteBackgroundImage = new DeleteBackgroundImage(image, doc); connect(deleteBackgroundImage, &DeleteBackgroundImage::AddItem, this, &MainWindow::AddBackgroundImageItem); connect(deleteBackgroundImage, &DeleteBackgroundImage::DeleteItem, this, &MainWindow::DeleteBackgroundImageItem); VApplication::VApp()->getUndoStack()->push(deleteBackgroundImage); @@ -1595,22 +1575,20 @@ void MainWindow::ToolCutArc(bool checked) void MainWindow::ToolLineIntersectAxis(bool checked) { ToolSelectPointByRelease(); - SetToolButtonWithApply(checked, Tool::LineIntersectAxis, - QStringLiteral(":/cursor/line_intersect_axis_cursor.png"), - tr("Select first point of line"), - &MainWindow::ClosedDrawDialogWithApply, - &MainWindow::ApplyDrawDialog); + SetToolButtonWithApply( + checked, Tool::LineIntersectAxis, QStringLiteral(":/cursor/line_intersect_axis_cursor.png"), + tr("Select first point of line"), &MainWindow::ClosedDrawDialogWithApply, + &MainWindow::ApplyDrawDialog); } //--------------------------------------------------------------------------------------------------------------------- void MainWindow::ToolCurveIntersectAxis(bool checked) { ToolSelectAllDrawObjects(); - SetToolButtonWithApply(checked, Tool::CurveIntersectAxis, - QStringLiteral(":/cursor/curve_intersect_axis_cursor.png"), - tr("Select curve"), - &MainWindow::ClosedDrawDialogWithApply, - &MainWindow::ApplyDrawDialog); + SetToolButtonWithApply( + checked, Tool::CurveIntersectAxis, QStringLiteral(":/cursor/curve_intersect_axis_cursor.png"), + tr("Select curve"), &MainWindow::ClosedDrawDialogWithApply, + &MainWindow::ApplyDrawDialog); } //--------------------------------------------------------------------------------------------------------------------- @@ -1618,22 +1596,20 @@ void MainWindow::ToolArcIntersectAxis(bool checked) { ToolSelectAllDrawObjects(); // Reuse ToolCurveIntersectAxis but with different cursor and tool tip - SetToolButtonWithApply(checked, Tool::ArcIntersectAxis, - QStringLiteral(":/cursor/arc_intersect_axis_cursor.png"), - tr("Select arc"), - &MainWindow::ClosedDrawDialogWithApply, - &MainWindow::ApplyDrawDialog); + SetToolButtonWithApply( + checked, Tool::ArcIntersectAxis, QStringLiteral(":/cursor/arc_intersect_axis_cursor.png"), tr("Select arc"), + &MainWindow::ClosedDrawDialogWithApply, + &MainWindow::ApplyDrawDialog); } //--------------------------------------------------------------------------------------------------------------------- void MainWindow::ToolPointOfIntersectionArcs(bool checked) { ToolSelectArc(); - SetToolButtonWithApply(checked, Tool::PointOfIntersectionArcs, - QStringLiteral("://cursor/point_of_intersection_arcs.png"), - tr("Select first an arc"), - &MainWindow::ClosedDrawDialogWithApply, - &MainWindow::ApplyDrawDialog); + SetToolButtonWithApply( + checked, Tool::PointOfIntersectionArcs, QStringLiteral("://cursor/point_of_intersection_arcs.png"), + tr("Select first an arc"), &MainWindow::ClosedDrawDialogWithApply, + &MainWindow::ApplyDrawDialog); } //--------------------------------------------------------------------------------------------------------------------- @@ -1680,11 +1656,10 @@ void MainWindow::ToolPointFromArcAndTangent(bool checked) void MainWindow::ToolArcWithLength(bool checked) { ToolSelectPointByRelease(); - SetToolButtonWithApply(checked, Tool::ArcWithLength, - QStringLiteral("://cursor/arc_with_length_cursor.png"), - tr("Select point of the center of the arc"), - &MainWindow::ClosedDrawDialogWithApply, - &MainWindow::ApplyDrawDialog); + SetToolButtonWithApply( + checked, Tool::ArcWithLength, QStringLiteral("://cursor/arc_with_length_cursor.png"), + tr("Select point of the center of the arc"), &MainWindow::ClosedDrawDialogWithApply, + &MainWindow::ApplyDrawDialog); } //--------------------------------------------------------------------------------------------------------------------- @@ -1718,7 +1693,6 @@ void MainWindow::ShowToolTip(const QString &toolTip) m_statusLabel->setText(toolTip); } - //--------------------------------------------------------------------------------------------------------------------- /** * @brief triggers the update of the visibility groups @@ -1742,10 +1716,10 @@ void MainWindow::UpdateDetailsList() * @brief showEvent handle after show window. * @param event show event. */ -void MainWindow::showEvent( QShowEvent *event ) +void MainWindow::showEvent(QShowEvent *event) { - QMainWindow::showEvent( event ); - if ( event->spontaneous() ) + QMainWindow::showEvent(event); + if (event->spontaneous()) { return; } @@ -1762,7 +1736,7 @@ void MainWindow::showEvent( QShowEvent *event ) MinimumScrollBar(); - m_isInitialized = true;//first show windows are held + m_isInitialized = true; // first show windows are held } //--------------------------------------------------------------------------------------------------------------------- @@ -1858,9 +1832,9 @@ void MainWindow::CleanLayout() void MainWindow::PrepareSceneList(PreviewQuatilty quality) { ui->listWidget->clear(); - for (int i=1; i<=m_layoutSettings->LayoutScenes().size(); ++i) + for (int i = 1; i <= m_layoutSettings->LayoutScenes().size(); ++i) { - auto *item = new QListWidgetItem(ScenePreview(i-1, ui->listWidget->iconSize(), quality), QString::number(i)); + auto *item = new QListWidgetItem(ScenePreview(i - 1, ui->listWidget->iconSize(), quality), QString::number(i)); ui->listWidget->addItem(item); } @@ -1887,15 +1861,15 @@ void MainWindow::ExportToCSVData(const QString &fileName, bool withHeader, int m csv.setHeaderText(2, tr("Formula")); } - const QMap > increments = pattern->DataIncrements(); + const QMap> increments = pattern->DataIncrements(); qint32 currentRow = -1; auto SavePreviewCalculation = [¤tRow, &csv, increments](bool save) { - QMap >::const_iterator i; + QMap>::const_iterator i; QMap map; - //Sorting QHash by id + // Sorting QHash by id for (i = increments.constBegin(); i != increments.constEnd(); ++i) { const QSharedPointer &incr = i.value(); @@ -1917,9 +1891,8 @@ void MainWindow::ExportToCSVData(const QString &fileName, bool withHeader, int m csv.setText(currentRow, 1, VAbstractApplication::VApp()->LocaleToString(*incr->GetValue())); // calculated value - QString formula = - VTranslateVars::TryFormulaToUser(incr->GetFormula(), - VAbstractApplication::VApp()->Settings()->GetOsSeparator()); + QString formula = VTranslateVars::TryFormulaToUser( + incr->GetFormula(), VAbstractApplication::VApp()->Settings()->GetOsSeparator()); csv.setText(currentRow, 2, formula); // formula } }; @@ -1939,7 +1912,7 @@ void MainWindow::ToolBarStyle(QToolBar *bar) const #if defined(Q_OS_MAC) // Temporary fix issue with toolbar black background on mac with OpenGL render if (VAbstractValApplication::VApp()->getSceneView() && - VAbstractValApplication::VApp()->getSceneView()->IsOpenGLRender()) + VAbstractValApplication::VApp()->getSceneView()->IsOpenGLRender()) { bar->setStyle(QStyleFactory::create("fusion")); } @@ -1952,9 +1925,9 @@ void MainWindow::ScaleChanged(qreal scale) if (not m_doubleSpinBoxScale.isNull()) { m_doubleSpinBoxScale->blockSignals(true); - m_doubleSpinBoxScale->setMaximum(qFloor(VMainGraphicsView::MaxScale()*1000)/10.0); - m_doubleSpinBoxScale->setMinimum(qFloor(VMainGraphicsView::MinScale()*1000)/10.0); - m_doubleSpinBoxScale->setValue(qFloor(scale*1000)/10.0); + m_doubleSpinBoxScale->setMaximum(qFloor(VMainGraphicsView::MaxScale() * 1000) / 10.0); + m_doubleSpinBoxScale->setMinimum(qFloor(VMainGraphicsView::MinScale() * 1000) / 10.0); + m_doubleSpinBoxScale->setValue(qFloor(scale * 1000) / 10.0); m_doubleSpinBoxScale->setSingleStep(1); m_doubleSpinBoxScale->blockSignals(false); } @@ -1965,7 +1938,7 @@ void MainWindow::LoadIndividual() { const QString filter = tr("Individual measurements") + QStringLiteral(" (*.vit);;") + tr("Multisize measurements") + QStringLiteral(" (*.vst)"); - //Use standard path to individual measurements + // Use standard path to individual measurements const QString path = VAbstractValApplication::VApp()->ValentinaSettings()->GetPathIndividualMeasurements(); bool usedNotExistedDir = false; @@ -2010,7 +1983,7 @@ void MainWindow::LoadMultisize() { const QString filter = tr("Multisize measurements") + QStringLiteral(" (*.vst);;") + tr("Individual measurements") + QStringLiteral("(*.vit)"); - //Use standard path to multisize measurements + // Use standard path to multisize measurements QString path = VAbstractValApplication::VApp()->ValentinaSettings()->GetPathMultisizeMeasurements(); path = VCommonSettings::PrepareMultisizeTables(path); const QString mPath = QFileDialog::getOpenFileName(this, tr("Open file"), path, filter, nullptr, @@ -2018,7 +1991,7 @@ void MainWindow::LoadMultisize() if (not mPath.isEmpty()) { - if(LoadMeasurements(mPath)) + if (LoadMeasurements(mPath)) { if (not doc->MPath().isEmpty()) { @@ -2157,7 +2130,7 @@ void MainWindow::MeasurementsChanged(const QString &path) } else { - for(int i=0; i<=1000; i=i+10) + for (int i = 0; i <= 1000; i = i + 10) { if (checkFile.exists()) { @@ -2185,7 +2158,7 @@ void MainWindow::SyncMeasurements() // Temporarily remove the path to prevent infinite synchronization after a format conversion. m_watcher->removePath(path); - if(UpdateMeasurements(path, m_currentDimensionA, m_currentDimensionB, m_currentDimensionC)) + if (UpdateMeasurements(path, m_currentDimensionA, m_currentDimensionB, m_currentDimensionC)) { const QString msg = tr("Measurements have been synced"); qCDebug(vMainWindow, "%s", qUtf8Printable(msg)); @@ -2260,7 +2233,6 @@ void MainWindow::RemoveWatermark() } } - //--------------------------------------------------------------------------------------------------------------------- void MainWindow::CleanWaterkmarkEditors() { @@ -2286,7 +2258,7 @@ void MainWindow::StoreMultisizeMDimensions() { if (not m_dimensionALabel.isNull()) { - m_dimensionALabel->setText(dimensions.at(0)->Name()+QChar(':')); + m_dimensionALabel->setText(dimensions.at(0)->Name() + QChar(':')); } } @@ -2294,7 +2266,7 @@ void MainWindow::StoreMultisizeMDimensions() { if (not m_dimensionBLabel.isNull()) { - m_dimensionBLabel->setText(dimensions.at(1)->Name()+QChar(':')); + m_dimensionBLabel->setText(dimensions.at(1)->Name() + QChar(':')); } } @@ -2302,7 +2274,7 @@ void MainWindow::StoreMultisizeMDimensions() { if (not m_dimensionCLabel.isNull()) { - m_dimensionCLabel->setText(dimensions.at(2)->Name()+QChar(':')); + m_dimensionCLabel->setText(dimensions.at(2)->Name() + QChar(':')); } } @@ -2314,7 +2286,7 @@ void MainWindow::StoreMultisizeMDimensions() //--------------------------------------------------------------------------------------------------------------------- void MainWindow::StoreIndividualMDimensions() { - QMap > measurements = pattern->DataMeasurements(); + QMap> measurements = pattern->DataMeasurements(); StoreIndividualMDimension(measurements, IMD::X); StoreIndividualMDimension(measurements, IMD::Y); @@ -2327,56 +2299,56 @@ void MainWindow::StoreMultisizeMDimension(const QList &d { if (dimensions.size() > index) { - const MeasurementDimension_p& dimension = dimensions.at(index); + const MeasurementDimension_p &dimension = dimensions.at(index); const DimesionLabels labels = dimension->Labels(); - switch(dimension->Type()) + switch (dimension->Type()) { - case MeasurementDimension::X: - VAbstractValApplication::VApp()->SetDimensionHeight(currentBase); - VAbstractValApplication::VApp()->SetDimensionHeightLabel( - VFuzzyValue(labels, currentBase, QString::number(currentBase))); - break; - case MeasurementDimension::Y: - { - const bool fc = m_m->IsFullCircumference(); - VAbstractValApplication::VApp()->SetDimensionSize(fc ? currentBase*2 : currentBase); - VAbstractValApplication::VApp()->SetDimensionSizeLabel( - VFuzzyValue(labels, currentBase, QString::number(fc ? currentBase*2 : currentBase))); - const bool measurement = dimension->IsBodyMeasurement(); - VAbstractValApplication::VApp() - ->SetDimensionSizeUnits(measurement ? m_m->Units() : Unit::LAST_UNIT_DO_NOT_USE); - break; - } - case MeasurementDimension::W: - { - const bool fc = m_m->IsFullCircumference(); - VAbstractValApplication::VApp()->SetDimensionWaist(fc ? currentBase*2 : currentBase); - VAbstractValApplication::VApp()->SetDimensionWaistLabel( - VFuzzyValue(labels, currentBase, QString::number(fc ? currentBase*2 : currentBase))); - break; - } - case MeasurementDimension::Z: - { - const bool fc = m_m->IsFullCircumference(); - VAbstractValApplication::VApp()->SetDimensionHip(fc ? currentBase*2 : currentBase); - VAbstractValApplication::VApp()->SetDimensionHipLabel( - VFuzzyValue(labels, currentBase, QString::number(fc ? currentBase*2 : currentBase))); - break; - } - default: - break; + case MeasurementDimension::X: + VAbstractValApplication::VApp()->SetDimensionHeight(currentBase); + VAbstractValApplication::VApp()->SetDimensionHeightLabel( + VFuzzyValue(labels, currentBase, QString::number(currentBase))); + break; + case MeasurementDimension::Y: + { + const bool fc = m_m->IsFullCircumference(); + VAbstractValApplication::VApp()->SetDimensionSize(fc ? currentBase * 2 : currentBase); + VAbstractValApplication::VApp()->SetDimensionSizeLabel( + VFuzzyValue(labels, currentBase, QString::number(fc ? currentBase * 2 : currentBase))); + const bool measurement = dimension->IsBodyMeasurement(); + VAbstractValApplication::VApp()->SetDimensionSizeUnits(measurement ? m_m->Units() + : Unit::LAST_UNIT_DO_NOT_USE); + break; + } + case MeasurementDimension::W: + { + const bool fc = m_m->IsFullCircumference(); + VAbstractValApplication::VApp()->SetDimensionWaist(fc ? currentBase * 2 : currentBase); + VAbstractValApplication::VApp()->SetDimensionWaistLabel( + VFuzzyValue(labels, currentBase, QString::number(fc ? currentBase * 2 : currentBase))); + break; + } + case MeasurementDimension::Z: + { + const bool fc = m_m->IsFullCircumference(); + VAbstractValApplication::VApp()->SetDimensionHip(fc ? currentBase * 2 : currentBase); + VAbstractValApplication::VApp()->SetDimensionHipLabel( + VFuzzyValue(labels, currentBase, QString::number(fc ? currentBase * 2 : currentBase))); + break; + } + default: + break; } } } //--------------------------------------------------------------------------------------------------------------------- -void MainWindow::StoreIndividualMDimension(const QMap > &measurements, IMD type) +void MainWindow::StoreIndividualMDimension(const QMap> &measurements, IMD type) { const QString name = VAbstractApplication::VApp()->TrVars()->VarToUser(m_m->MeasurementForDimension(type)); const bool valid = not name.isEmpty() && measurements.contains(name); const qreal value = valid ? *measurements.value(name)->GetValue() : 0; - switch(type) + switch (type) { case IMD::X: VAbstractValApplication::VApp()->SetDimensionHeight(value); @@ -2436,7 +2408,7 @@ void MainWindow::SetDimensionBases() { const QList dimensions = m_m->Dimensions().values(); - auto SetBase = [dimensions](int index, const QPointer& control, double &value) + auto SetBase = [dimensions](int index, const QPointer &control, double &value) { if (dimensions.size() > index) { @@ -2509,7 +2481,7 @@ void MainWindow::ExportDraw(const QString &fileName) item->setEnabled(true); if (item->type() == VGraphicsSimpleTextItem::Type) { - auto *text = dynamic_cast(item); + auto *text = dynamic_cast(item); text->setBrush(text->BaseColor()); // Regular update doesn't work on labels } } @@ -2610,7 +2582,7 @@ auto MainWindow::SavePatternAs(const QString &fileName) -> bool const bool wasModified = doc->IsModified(); // Need because SetReadOnly() will change internal state const bool readOnly = doc->IsReadOnly(); - doc->SetReadOnly(false);// Save as... disable read only state + doc->SetReadOnly(false); // Save as... disable read only state QString error; const bool result = SavePattern(fileName, error); if (not result) @@ -2702,7 +2674,7 @@ auto MainWindow::FullParsePattern() -> bool { if (VAbstractValApplication::VApp()->getOpeningPattern()) { - futureTestUniqueId = QtConcurrent::run([this](){doc->TestUniqueId();}); + futureTestUniqueId = QtConcurrent::run([this]() { doc->TestUniqueId(); }); } SetEnabledGUI(true); @@ -2788,8 +2760,9 @@ auto MainWindow::FullParsePattern() -> bool #if defined(Q_OS_MAC) void MainWindow::OpenAt(QAction *where) { - const QString path = VAbstractValApplication::VApp()->GetPatternPath() - .left(VAbstractValApplication::VApp()->GetPatternPath().indexOf(where->text())) + where->text(); + const QString path = VAbstractValApplication::VApp()->GetPatternPath().left( + VAbstractValApplication::VApp()->GetPatternPath().indexOf(where->text())) + + where->text(); if (path == VAbstractValApplication::VApp()->GetPatternPath()) { return; @@ -2798,7 +2771,7 @@ void MainWindow::OpenAt(QAction *where) process.start(QStringLiteral("/usr/bin/open"), QStringList() << path, QIODevice::ReadOnly); process.waitForFinished(); } -#endif //defined(Q_OS_MAC) +#endif // defined(Q_OS_MAC) //--------------------------------------------------------------------------------------------------------------------- /** @@ -2836,14 +2809,14 @@ void MainWindow::ToolBarOption() m_doubleSpinBoxScale->setDecimals(1); m_doubleSpinBoxScale->setSuffix(QChar('%')); ScaleChanged(ui->view->transform().m11()); - connect(m_doubleSpinBoxScale.data(), QOverload::of(&QDoubleSpinBox::valueChanged), - this, [this](double d){ui->view->Zoom(d/100.0);}); + connect(m_doubleSpinBoxScale.data(), QOverload::of(&QDoubleSpinBox::valueChanged), this, + [this](double d) { ui->view->Zoom(d / 100.0); }); ui->toolBarOption->addWidget(m_doubleSpinBoxScale); ui->toolBarOption->addSeparator(); - m_mouseCoordinate = new QLabel(QStringLiteral("0, 0 (%1)") - .arg(UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true))); + m_mouseCoordinate = + new QLabel(QStringLiteral("0, 0 (%1)").arg(UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true))); ui->toolBarOption->addWidget(m_mouseCoordinate); ui->toolBarOption->addSeparator(); @@ -2877,19 +2850,20 @@ void MainWindow::ToolBarDraws() ui->toolBarDraws->addWidget(m_comboBoxDraws); m_comboBoxDraws->setSizeAdjustPolicy(QComboBox::AdjustToContents); m_comboBoxDraws->setEnabled(false); - connect(m_comboBoxDraws, QOverload::of(&QComboBox::currentIndexChanged), - this, [this](int index){ChangePP(index);}); + connect(m_comboBoxDraws, QOverload::of(&QComboBox::currentIndexChanged), this, + [this](int index) { ChangePP(index); }); - connect(ui->actionOptionDraw, &QAction::triggered, this, [this]() - { - QString draw = doc->GetNameActivPP(); - bool ok = PatternPieceName(draw); - if (not ok) - { - return; - } - VAbstractApplication::VApp()->getUndoStack()->push(new RenamePP(doc, draw, m_comboBoxDraws)); - }); + connect(ui->actionOptionDraw, &QAction::triggered, this, + [this]() + { + QString draw = doc->GetNameActivPP(); + bool ok = PatternPieceName(draw); + if (not ok) + { + return; + } + VAbstractApplication::VApp()->getUndoStack()->push(new RenamePP(doc, draw, m_comboBoxDraws)); + }); } //--------------------------------------------------------------------------------------------------------------------- @@ -2972,20 +2946,21 @@ void MainWindow::ToolBarTools() #else QKeySequence(Qt::ShiftModifier + Qt::Key_Plus)); #endif - connect(ui->actionIncreaseLabelFont, &QAction::triggered, this, [this]() - { - VValentinaSettings *settings = VAbstractValApplication::VApp()->ValentinaSettings(); - settings->SetPatternLabelFontSize(settings->GetPatternLabelFontSize() + 1); - if (m_sceneDraw) - { - m_sceneDraw->update(); - } + connect(ui->actionIncreaseLabelFont, &QAction::triggered, this, + [this]() + { + VValentinaSettings *settings = VAbstractValApplication::VApp()->ValentinaSettings(); + settings->SetPatternLabelFontSize(settings->GetPatternLabelFontSize() + 1); + if (m_sceneDraw) + { + m_sceneDraw->update(); + } - if (m_sceneDetails) - { - m_sceneDetails->update(); - } - }); + if (m_sceneDetails) + { + m_sceneDetails->update(); + } + }); ui->actionDecreaseLabelFont->setShortcut( #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) @@ -2993,20 +2968,21 @@ void MainWindow::ToolBarTools() #else QKeySequence(Qt::ShiftModifier + Qt::Key_Minus)); #endif - connect(ui->actionDecreaseLabelFont, &QAction::triggered, this, [this]() - { - VValentinaSettings *settings = VAbstractValApplication::VApp()->ValentinaSettings(); - settings->SetPatternLabelFontSize(settings->GetPatternLabelFontSize() - 1); - if (m_sceneDraw) - { - m_sceneDraw->update(); - } + connect(ui->actionDecreaseLabelFont, &QAction::triggered, this, + [this]() + { + VValentinaSettings *settings = VAbstractValApplication::VApp()->ValentinaSettings(); + settings->SetPatternLabelFontSize(settings->GetPatternLabelFontSize() - 1); + if (m_sceneDraw) + { + m_sceneDraw->update(); + } - if (m_sceneDetails) - { - m_sceneDetails->update(); - } - }); + if (m_sceneDetails) + { + m_sceneDetails->update(); + } + }); ui->actionOriginalLabelFont->setShortcut( #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) @@ -3014,20 +2990,21 @@ void MainWindow::ToolBarTools() #else QKeySequence(Qt::ShiftModifier + Qt::Key_0)); #endif - connect(ui->actionOriginalLabelFont, &QAction::triggered, this, [this]() - { - VValentinaSettings *settings = VAbstractValApplication::VApp()->ValentinaSettings(); - settings->SetPatternLabelFontSize(VCommonSettings::GetDefPatternLabelFontSize()); - if (m_sceneDraw) - { - m_sceneDraw->update(); - } + connect(ui->actionOriginalLabelFont, &QAction::triggered, this, + [this]() + { + VValentinaSettings *settings = VAbstractValApplication::VApp()->ValentinaSettings(); + settings->SetPatternLabelFontSize(VCommonSettings::GetDefPatternLabelFontSize()); + if (m_sceneDraw) + { + m_sceneDraw->update(); + } - if (m_sceneDetails) - { - m_sceneDetails->update(); - } - }); + if (m_sceneDetails) + { + m_sceneDetails->update(); + } + }); ui->actionHideLabels->setShortcut( #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) @@ -3036,19 +3013,20 @@ void MainWindow::ToolBarTools() QKeySequence(Qt::AltModifier + Qt::Key_L)); #endif ui->actionHideLabels->setChecked(VAbstractValApplication::VApp()->ValentinaSettings()->GetHideLabels()); - connect(ui->actionHideLabels, &QAction::triggered, this, [this](bool checked) - { - VAbstractValApplication::VApp()->ValentinaSettings()->SetHideLabels(checked); - if (m_sceneDraw) - { - m_sceneDraw->update(); - } + connect(ui->actionHideLabels, &QAction::triggered, this, + [this](bool checked) + { + VAbstractValApplication::VApp()->ValentinaSettings()->SetHideLabels(checked); + if (m_sceneDraw) + { + m_sceneDraw->update(); + } - if (m_sceneDetails) - { - m_sceneDetails->update(); - } - }); + if (m_sceneDetails) + { + m_sceneDetails->update(); + } + }); QT_WARNING_POP } @@ -3133,10 +3111,11 @@ void MainWindow::MouseMove(const QPointF &scenePos) { if (not m_mouseCoordinate.isNull()) { - m_mouseCoordinate->setText(QStringLiteral("%1, %2 (%3)") - .arg(static_cast(VAbstractValApplication::VApp()->fromPixel(scenePos.x()))) - .arg(static_cast(VAbstractValApplication::VApp()->fromPixel(scenePos.y()))) - .arg(UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true))); + m_mouseCoordinate->setText( + QStringLiteral("%1, %2 (%3)") + .arg(static_cast(VAbstractValApplication::VApp()->fromPixel(scenePos.x()))) + .arg(static_cast(VAbstractValApplication::VApp()->fromPixel(scenePos.y()))) + .arg(UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true))); } } @@ -3152,7 +3131,7 @@ void MainWindow::CancelTool() Q_STATIC_ASSERT_X(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 59, "Not all tools were handled."); qCDebug(vMainWindow, "Canceling tool."); - if(not m_dialogTool.isNull()) + if (not m_dialogTool.isNull()) { m_dialogTool->hide(); m_dialogTool->deleteLater(); @@ -3163,7 +3142,7 @@ void MainWindow::CancelTool() currentScene->clearSelection(); emit ui->view->itemClicked(nullptr); // Hide visualization to avoid a crash - switch ( m_currentTool ) + switch (m_currentTool) { case Tool::Arrow: for (auto *pointer : qAsConst(m_toolButtonPointerList)) @@ -3196,7 +3175,7 @@ void MainWindow::CancelTool() case Tool::BackgroundPixmapImage: case Tool::BackgroundSVGImage: Q_UNREACHABLE(); //-V501 - //Nothing to do here because we can't create this tool from main window. + // Nothing to do here because we can't create this tool from main window. break; case Tool::EndLine: ui->toolButtonEndLine->setChecked(false); @@ -3342,7 +3321,7 @@ QT_WARNING_POP /** * @brief ArrowTool enable arrow tool. */ -void MainWindow::ArrowTool(bool checked) +void MainWindow::ArrowTool(bool checked) { if (checked && m_currentTool != Tool::Arrow) { @@ -3367,7 +3346,7 @@ void MainWindow::ArrowTool(bool checked) emit EnableSplinePathSelection(false); emit EnableNodeLabelSelection(true); emit EnableNodePointSelection(true); - emit EnableDetailSelection(true);// Disable when done visualization details + emit EnableDetailSelection(true); // Disable when done visualization details emit EnableBackgroundImageSelection(true); // Hovering @@ -3405,7 +3384,7 @@ void MainWindow::ArrowTool(bool checked) * @brief keyPressEvent handle key press events. * @param event key event. */ -void MainWindow::keyPressEvent ( QKeyEvent * event ) +void MainWindow::keyPressEvent(QKeyEvent *event) { switch (event->key()) { @@ -3419,7 +3398,7 @@ void MainWindow::keyPressEvent ( QKeyEvent * event ) default: break; } - QMainWindow::keyPressEvent ( event ); + QMainWindow::keyPressEvent(event); } //--------------------------------------------------------------------------------------------------------------------- @@ -3429,7 +3408,7 @@ void MainWindow::keyPressEvent ( QKeyEvent * event ) void MainWindow::SaveCurrentScene() { if (VAbstractValApplication::VApp()->GetDrawMode() == Draw::Calculation || - VAbstractValApplication::VApp()->GetDrawMode() == Draw::Modeling) + VAbstractValApplication::VApp()->GetDrawMode() == Draw::Modeling) { auto *scene = qobject_cast(currentScene); SCASSERT(scene != nullptr) @@ -3487,7 +3466,7 @@ void MainWindow::ActionDraw(bool checked) RestoreCurrentScene(); VAbstractValApplication::VApp()->SetDrawMode(Draw::Calculation); - m_comboBoxDraws->setCurrentIndex(m_currentDrawIndex);//restore current pattern peace + m_comboBoxDraws->setCurrentIndex(m_currentDrawIndex); // restore current pattern peace m_drawMode = true; SetEnableTool(true); @@ -3526,12 +3505,12 @@ void MainWindow::ActionDetails(bool checked) { ArrowTool(true); - if(m_drawMode) + if (m_drawMode) { - m_currentDrawIndex = m_comboBoxDraws->currentIndex();//save current pattern piece + m_currentDrawIndex = m_comboBoxDraws->currentIndex(); // save current pattern piece m_drawMode = false; } - m_comboBoxDraws->setCurrentIndex(m_comboBoxDraws->count()-1);// Need to get data about all details + m_comboBoxDraws->setCurrentIndex(m_comboBoxDraws->count() - 1); // Need to get data about all details m_leftGoToStage->setPixmap(QPixmap(QStringLiteral("://icon/24x24/right_to_left_arrow.png"))); m_rightGoToStage->setPixmap(QPixmap(QStringLiteral("://icon/24x24/left_to_right_arrow.png"))); @@ -3540,12 +3519,13 @@ void MainWindow::ActionDetails(bool checked) ui->actionDetails->setChecked(true); ui->actionLayout->setChecked(false); - if(not VAbstractValApplication::VApp()->getOpeningPattern()) + if (not VAbstractValApplication::VApp()->getOpeningPattern()) { if (pattern->DataPieces()->count() == 0) { - QMessageBox::information(this, tr("Detail mode"), tr("You can't use Detail mode yet. " - "Please, create at least one workpiece."), + QMessageBox::information(this, tr("Detail mode"), + tr("You can't use Detail mode yet. " + "Please, create at least one workpiece."), QMessageBox::Ok, QMessageBox::Ok); ActionDraw(true); return; @@ -3611,12 +3591,12 @@ void MainWindow::ActionLayout(bool checked) ArrowTool(true); - if(m_drawMode) + if (m_drawMode) { - m_currentDrawIndex = m_comboBoxDraws->currentIndex();//save current pattern piece + m_currentDrawIndex = m_comboBoxDraws->currentIndex(); // save current pattern piece m_drawMode = false; } - m_comboBoxDraws->setCurrentIndex(m_comboBoxDraws->count()-1);// Need to get data about all details + m_comboBoxDraws->setCurrentIndex(m_comboBoxDraws->count() - 1); // Need to get data about all details m_leftGoToStage->setPixmap(QPixmap(QStringLiteral("://icon/24x24/right_to_left_arrow.png"))); m_rightGoToStage->setPixmap(QPixmap(QStringLiteral("://icon/24x24/fast_forward_right_to_left_arrow.png"))); @@ -3626,13 +3606,14 @@ void MainWindow::ActionLayout(bool checked) ui->actionLayout->setChecked(true); QVector details; - if(not VAbstractValApplication::VApp()->getOpeningPattern()) + if (not VAbstractValApplication::VApp()->getOpeningPattern()) { const QHash *allDetails = pattern->DataPieces(); if (allDetails->count() == 0) { - QMessageBox::information(this, tr("Layout mode"), tr("You can't use Layout mode yet. " - "Please, create at least one workpiece."), + QMessageBox::information(this, tr("Layout mode"), + tr("You can't use Layout mode yet. " + "Please, create at least one workpiece."), QMessageBox::Ok, QMessageBox::Ok); ActionDraw(true); return; @@ -3643,17 +3624,17 @@ void MainWindow::ActionLayout(bool checked) if (details.count() == 0) { - QMessageBox::information(this, tr("Layout mode"), tr("You can't use Layout mode yet. Please, " - "include at least one detail in layout."), + QMessageBox::information(this, tr("Layout mode"), + tr("You can't use Layout mode yet. Please, " + "include at least one detail in layout."), QMessageBox::Ok, QMessageBox::Ok); VAbstractValApplication::VApp()->GetDrawMode() == Draw::Calculation ? ActionDraw(true) : ActionDetails(true); return; } - } - m_comboBoxDraws->setCurrentIndex(-1);// Hide pattern pieces + m_comboBoxDraws->setCurrentIndex(-1); // Hide pattern pieces qCDebug(vMainWindow, "Show layout scene"); @@ -3669,8 +3650,7 @@ void MainWindow::ActionLayout(bool checked) QMessageBox::warning(this, tr("Layout mode"), tr("You can't use Layout mode yet.") + QStringLiteral(" \n") + e.ErrorMessage(), QMessageBox::Ok, QMessageBox::Ok); - VAbstractValApplication::VApp()->GetDrawMode() == Draw::Calculation ? ActionDraw(true) - : ActionDetails(true); + VAbstractValApplication::VApp()->GetDrawMode() == Draw::Calculation ? ActionDraw(true) : ActionDetails(true); return; } @@ -3737,31 +3717,31 @@ auto MainWindow::on_actionSaveAs_triggered() -> bool } QString newFileName = tr("pattern") + QStringLiteral(".val"); - if(not VAbstractValApplication::VApp()->GetPatternPath().isEmpty()) + if (not VAbstractValApplication::VApp()->GetPatternPath().isEmpty()) { newFileName = StrippedName(VAbstractValApplication::VApp()->GetPatternPath()); } QString filters(tr("Pattern files") + QStringLiteral("(*.val)")); - QString fileName = QFileDialog::getSaveFileName(this, tr("Save as"), - dir + QChar('/') + newFileName, - filters, nullptr, VAbstractApplication::VApp()->NativeFileDialog()); + QString fileName = QFileDialog::getSaveFileName(this, tr("Save as"), dir + QChar('/') + newFileName, filters, + nullptr, VAbstractApplication::VApp()->NativeFileDialog()); - auto RemoveTempDir = qScopeGuard([usedNotExistedDir, dir]() - { - if (usedNotExistedDir) + auto RemoveTempDir = qScopeGuard( + [usedNotExistedDir, dir]() { - QDir directory(dir); - directory.rmpath(QChar('.')); - } - }); + if (usedNotExistedDir) + { + QDir directory(dir); + directory.rmpath(QChar('.')); + } + }); if (fileName.isEmpty()) { return false; } - QFileInfo f( fileName ); + QFileInfo f(fileName); if (f.suffix().isEmpty() && f.suffix() != QLatin1String("val")) { fileName += QLatin1String(".val"); @@ -3795,8 +3775,8 @@ auto MainWindow::on_actionSave_triggered() -> bool return on_actionSaveAs_triggered(); } - if (m_curFileFormatVersion < VPatternConverter::PatternMaxVer - && not ContinueFormatRewrite(m_curFileFormatVersionStr, VPatternConverter::PatternMaxVerStr)) + if (m_curFileFormatVersion < VPatternConverter::PatternMaxVer && + not ContinueFormatRewrite(m_curFileFormatVersionStr, VPatternConverter::PatternMaxVerStr)) { return false; } @@ -3835,7 +3815,7 @@ void MainWindow::on_actionOpen_triggered() { qCDebug(vMainWindow, "Openning new file."); const QString filter(tr("Pattern files") + QStringLiteral(" (*.val)")); - //Get list last open files + // Get list last open files const QStringList files = VAbstractValApplication::VApp()->ValentinaSettings()->GetRecentFileList(); QString dir; if (files.isEmpty()) @@ -3844,7 +3824,7 @@ void MainWindow::on_actionOpen_triggered() } else { - //Absolute path to last open file + // Absolute path to last open file dir = QFileInfo(ConstFirst(files)).absolutePath(); } qCDebug(vMainWindow, "Run QFileDialog::getOpenFileName: dir = %s.", qUtf8Printable(dir)); @@ -3872,15 +3852,16 @@ void MainWindow::on_actionOpenPuzzle_triggered() //--------------------------------------------------------------------------------------------------------------------- void MainWindow::on_actionCreateManualLayout_triggered() { - QTemporaryFile rldFile(QDir::tempPath()+"/puzzle.rld.XXXXXX"); + QTemporaryFile rldFile(QDir::tempPath() + "/puzzle.rld.XXXXXX"); if (rldFile.open()) { QVector detailsInLayout = SortDetailsForLayout(pattern->DataPieces()); if (detailsInLayout.count() == 0) { - QMessageBox::information(this, tr("Layout mode"), tr("You don't have enough details to export. Please, " - "include at least one detail in layout."), + QMessageBox::information(this, tr("Layout mode"), + tr("You don't have enough details to export. Please, " + "include at least one detail in layout."), QMessageBox::Ok, QMessageBox::Ok); return; } @@ -3909,7 +3890,7 @@ void MainWindow::on_actionCreateManualLayout_triggered() exporter.SetYScale(layoutScale.GetYScale()); exporter.ExportToRLD(listDetails); - QStringList arguments {"-r", rldFile.fileName()}; + QStringList arguments{"-r", rldFile.fileName()}; if (isNoScaling) { arguments.append(QStringLiteral("--") + LONG_OPTION_NO_HDPI_SCALING); @@ -3930,7 +3911,7 @@ void MainWindow::on_actionUpdateManualLayout_triggered() { const QString filter(tr("Manual layout files") + QStringLiteral(" (*.vlt)")); - //Use standard path to manual layouts + // Use standard path to manual layouts const QString path = VAbstractValApplication::VApp()->ValentinaSettings()->GetPathManualLayouts(); bool usedNotExistedDir = false; @@ -3940,14 +3921,15 @@ void MainWindow::on_actionUpdateManualLayout_triggered() usedNotExistedDir = directory.mkpath(QChar('.')); } - auto RemoveUnsuded = qScopeGuard([usedNotExistedDir, path]() - { - if (usedNotExistedDir) + auto RemoveUnsuded = qScopeGuard( + [usedNotExistedDir, path]() { - QDir directory(path); - directory.rmpath(QChar('.')); - } - }); + if (usedNotExistedDir) + { + QDir directory(path); + directory.rmpath(QChar('.')); + } + }); const QString filePath = QFileDialog::getOpenFileName(this, tr("Select manual layout"), path, filter, nullptr); @@ -3956,7 +3938,7 @@ void MainWindow::on_actionUpdateManualLayout_triggered() return; } - QTemporaryFile rldFile(QDir::tempPath()+"/puzzle.rld.XXXXXX"); + QTemporaryFile rldFile(QDir::tempPath() + "/puzzle.rld.XXXXXX"); rldFile.setAutoRemove(false); if (rldFile.open()) { @@ -3964,8 +3946,9 @@ void MainWindow::on_actionUpdateManualLayout_triggered() if (detailsInLayout.count() == 0) { - QMessageBox::information(this, tr("Layout mode"), tr("You don't have enough details to export. Please, " - "include at least one detail in layout."), + QMessageBox::information(this, tr("Layout mode"), + tr("You don't have enough details to export. Please, " + "include at least one detail in layout."), QMessageBox::Ok, QMessageBox::Ok); return; } @@ -3994,7 +3977,7 @@ void MainWindow::on_actionUpdateManualLayout_triggered() exporter.SetYScale(layoutScale.GetYScale()); exporter.ExportToRLD(listDetails); - QStringList arguments {filePath, "-r", rldFile.fileName()}; + QStringList arguments{filePath, "-r", rldFile.fileName()}; if (isNoScaling) { arguments.append(QStringLiteral("--") + LONG_OPTION_NO_HDPI_SCALING); @@ -4013,9 +3996,9 @@ void MainWindow::on_actionUpdateManualLayout_triggered() //--------------------------------------------------------------------------------------------------------------------- void MainWindow::ActionAddBackgroundImage() { - const QString fileName = QFileDialog::getOpenFileName(this, tr("Select background image"), QDir::homePath(), - PrepareImageFilters(), nullptr, - VAbstractApplication::VApp()->NativeFileDialog()); + const QString fileName = + QFileDialog::getOpenFileName(this, tr("Select background image"), QDir::homePath(), PrepareImageFilters(), + nullptr, VAbstractApplication::VApp()->NativeFileDialog()); if (not fileName.isEmpty()) { QRect viewportRect(0, 0, ui->view->viewport()->width(), ui->view->viewport()->height()); @@ -4034,7 +4017,7 @@ void MainWindow::Clear() qCDebug(vMainWindow, "Unlocked pattern file."); ActionDraw(true); qCDebug(vMainWindow, "Returned to Draw mode."); - setCurrentFile(QString());// Keep before cleaning a pattern data to prevent a crash + setCurrentFile(QString()); // Keep before cleaning a pattern data to prevent a crash pattern->Clear(); qCDebug(vMainWindow, "Clearing pattern."); if (not VAbstractValApplication::VApp()->GetPatternPath().isEmpty() && not doc->MPath().isEmpty()) @@ -4115,7 +4098,7 @@ void MainWindow::FileClosedCorrect() { WriteSettings(); - //File was closed correct. + // File was closed correct. QStringList restoreFiles = VAbstractValApplication::VApp()->ValentinaSettings()->GetRestoreFileList(); restoreFiles.removeAll(VAbstractValApplication::VApp()->GetPatternPath()); VAbstractValApplication::VApp()->ValentinaSettings()->SetRestoreFileList(restoreFiles); @@ -4155,12 +4138,12 @@ void MainWindow::FullParseFile() if (not m_drawMode) { - m_comboBoxDraws->setCurrentIndex(m_comboBoxDraws->count()-1); + m_comboBoxDraws->setCurrentIndex(m_comboBoxDraws->count() - 1); } else { const qint32 index = m_comboBoxDraws->findText(patternPiece); - if ( index != -1 ) + if (index != -1) { m_comboBoxDraws->setCurrentIndex(index); } @@ -4183,7 +4166,7 @@ void MainWindow::GlobalChangePP(const QString &patternPiece) const qint32 index = m_comboBoxDraws->findText(patternPiece); try { - if ( index != -1 ) + if (index != -1) { // -1 for not found ChangePP(index, false); m_comboBoxDraws->blockSignals(true); @@ -4197,8 +4180,8 @@ void MainWindow::GlobalChangePP(const QString &patternPiece) } catch (VExceptionBadId &e) { - qCCritical(vMainWindow, "%s\n\n%s\n\n%s", qUtf8Printable(tr("Bad id.")), - qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation())); + qCCritical(vMainWindow, "%s\n\n%s\n\n%s", qUtf8Printable(tr("Bad id.")), qUtf8Printable(e.ErrorMessage()), + qUtf8Printable(e.DetailedInformation())); SetEnabledGUI(false); if (not VApplication::IsGUIMode()) { @@ -4251,7 +4234,7 @@ void MainWindow::NextPatternPiece() return; } - if (index == m_comboBoxDraws->count()-1) + if (index == m_comboBoxDraws->count() - 1) { index = 0; } @@ -4279,9 +4262,9 @@ void MainWindow::SetEnabledGUI(bool enabled) SetEnableTool(enabled); ui->toolBarOption->setEnabled(enabled); - #ifndef QT_NO_CURSOR +#ifndef QT_NO_CURSOR QGuiApplication::setOverrideCursor(Qt::ArrowCursor); - #endif +#endif } } @@ -4351,7 +4334,7 @@ void MainWindow::SetEnableWidgets(bool enable) undoAction->setEnabled(enableOnDesignStage && VAbstractApplication::VApp()->getUndoStack()->canUndo()); redoAction->setEnabled(enableOnDesignStage && VAbstractApplication::VApp()->getUndoStack()->canRedo()); - //Now we don't want allow user call context menu + // Now we don't want allow user call context menu m_sceneDraw->SetDisableTools(!enable, doc->GetNameActivPP()); ui->view->setEnabled(enable); } @@ -4365,7 +4348,7 @@ void MainWindow::on_actionNew_triggered() if (m_comboBoxDraws->count() == 0) { qCDebug(vMainWindow, "New PP."); - QString patternPieceName = tr("Pattern piece %1").arg(m_comboBoxDraws->count()+1); + QString patternPieceName = tr("Pattern piece %1").arg(m_comboBoxDraws->count() + 1); qCDebug(vMainWindow, "Generated PP name: %s", qUtf8Printable(patternPieceName)); qCDebug(vMainWindow, "First PP"); @@ -4382,14 +4365,14 @@ void MainWindow::on_actionNew_triggered() return; } - //Set scene size to size scene view + // Set scene size to size scene view VMainGraphicsView::NewSceneRect(m_sceneDraw, ui->view); VMainGraphicsView::NewSceneRect(m_sceneDetails, ui->view); AddPP(patternPieceName); - m_mouseCoordinate = new QLabel(QStringLiteral("0, 0 (%1)") - .arg(UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true))); + m_mouseCoordinate = new QLabel( + QStringLiteral("0, 0 (%1)").arg(UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true))); ui->toolBarOption->addWidget(m_mouseCoordinate); m_curFileFormatVersion = VPatternConverter::PatternMaxVer; @@ -4415,7 +4398,7 @@ void MainWindow::PatternChangesWereSaved(bool saved) { const bool state = doc->IsModified() || !saved; setWindowModified(state); - not m_patternReadOnly ? ui->actionSave->setEnabled(state): ui->actionSave->setEnabled(false); + not m_patternReadOnly ? ui->actionSave->setEnabled(state) : ui->actionSave->setEnabled(false); m_layoutSettings->SetLayoutStale(true); isNeedAutosave = not saved; } @@ -4460,7 +4443,7 @@ void MainWindow::DimensionBBaseChanged() if (dimensions.size() > 2) { - const MeasurementDimension_p& dimension = dimensions.at(2); + const MeasurementDimension_p &dimension = dimensions.at(2); InitDimensionGradation(2, dimension, m_dimensionC); } @@ -4566,7 +4549,7 @@ void MainWindow::DeleteBackgroundImageItem(const QUuid &id) { VBackgroundImageItem *item = m_backgroundImages.value(id); emit ui->view->itemClicked(nullptr); // Hide visualization to avoid a crash - item->setVisible(false); // Do not remove the item from scene to prevent crashes. + item->setVisible(false); // Do not remove the item from scene to prevent crashes. if (m_backgroudcontrols != nullptr && m_backgroudcontrols->Id() == id) { m_backgroudcontrols->ActivateControls(QUuid()); @@ -4643,7 +4626,7 @@ void MainWindow::ParseBackgroundImages() { // No memory leak. Scene should take care of these items m_backgroudcontrols = nullptr; // force creating new controls - m_backgroundImages.clear(); // clear dangling pointers + m_backgroundImages.clear(); // clear dangling pointers QVector allImages = doc->GetBackgroundImages(); for (const auto &image : allImages) @@ -4661,7 +4644,8 @@ void MainWindow::ActionHistory_triggered(bool checked) m_dialogHistory = new DialogHistory(pattern, doc, this); m_dialogHistory->setWindowFlags(Qt::Window); connect(this, &MainWindow::RefreshHistory, m_dialogHistory.data(), &DialogHistory::UpdateHistory); - connect(m_dialogHistory.data(), &DialogHistory::DialogClosed, this, [this]() + connect(m_dialogHistory.data(), &DialogHistory::DialogClosed, this, + [this]() { ui->actionHistory->setChecked(false); delete m_dialogHistory; @@ -4681,10 +4665,9 @@ void MainWindow::ActionHistory_triggered(bool checked) void MainWindow::ActionExportRecipe_triggered() { QString filters(tr("Recipe files") + QStringLiteral("(*.vpr)")); - QString fileName = - QFileDialog::getSaveFileName(this, tr("Export recipe"), - QDir::homePath() + '/' + tr("recipe") + QStringLiteral(".vpr"), - filters, nullptr, VAbstractApplication::VApp()->NativeFileDialog()); + QString fileName = QFileDialog::getSaveFileName(this, tr("Export recipe"), + QDir::homePath() + '/' + tr("recipe") + QStringLiteral(".vpr"), + filters, nullptr, VAbstractApplication::VApp()->NativeFileDialog()); if (fileName.isEmpty()) { return; @@ -4709,7 +4692,7 @@ void MainWindow::ActionExportRecipe_triggered() void MainWindow::ActionNewDraw_triggered() { qCDebug(vMainWindow, "New PP."); - QString patternPieceName = tr("Pattern piece %1").arg(m_comboBoxDraws->count()+1); + QString patternPieceName = tr("Pattern piece %1").arg(m_comboBoxDraws->count() + 1); qCDebug(vMainWindow, "Generated PP name: %s", qUtf8Printable(patternPieceName)); qCDebug(vMainWindow, "PP count %d", m_comboBoxDraws->count()); @@ -4750,7 +4733,8 @@ void MainWindow::ActionFinalMeasurements_triggered() { m_dialogFMeasurements = new DialogFinalMeasurements(doc, this); m_dialogFMeasurements->setAttribute(Qt::WA_DeleteOnClose); - connect(m_dialogFMeasurements.data(), &DialogFinalMeasurements::finished, this, [this](int result) + connect(m_dialogFMeasurements.data(), &DialogFinalMeasurements::finished, this, + [this](int result) { if (result == QDialog::Accepted) { @@ -4774,7 +4758,7 @@ void MainWindow::ActionShowMainPath_triggered(bool checked) const QList ids = pattern->DataPieces()->keys(); const bool updateChildren = false; QGuiApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); - for(const auto &id : ids) + for (const auto &id : ids) { try { @@ -4783,8 +4767,9 @@ void MainWindow::ActionShowMainPath_triggered(bool checked) tool->RefreshGeometry(updateChildren); } } - catch(VExceptionBadId &) - {} + catch (VExceptionBadId &) + { + } } QGuiApplication::restoreOverrideCursor(); } @@ -4839,15 +4824,15 @@ void MainWindow::InitDimensionControls() { if (dimensions.size() > index) { - const MeasurementDimension_p& dimension = dimensions.at(index); + const MeasurementDimension_p &dimension = dimensions.at(index); if (name.isNull()) { - name = new QLabel(dimension->Name()+QChar(':')); + name = new QLabel(dimension->Name() + QChar(':')); } else { - name->setText(dimension->Name()+QChar(':')); + name->setText(dimension->Name() + QChar(':')); } name->setToolTip(VAbstartMeasurementDimension::DimensionToolTip(dimension, m_m->IsFullCircumference())); @@ -4870,20 +4855,20 @@ void MainWindow::InitDimensionControls() if (not m_dimensionA.isNull()) { - connect(m_dimensionA.data(), QOverload::of(&QComboBox::currentIndexChanged), - this, &MainWindow::DimensionABaseChanged); + connect(m_dimensionA.data(), QOverload::of(&QComboBox::currentIndexChanged), this, + &MainWindow::DimensionABaseChanged); } if (not m_dimensionB.isNull()) { - connect(m_dimensionB.data(), QOverload::of(&QComboBox::currentIndexChanged), - this, &MainWindow::DimensionBBaseChanged); + connect(m_dimensionB.data(), QOverload::of(&QComboBox::currentIndexChanged), this, + &MainWindow::DimensionBBaseChanged); } if (not m_dimensionC.isNull()) { - connect(m_dimensionC.data(), QOverload::of(&QComboBox::currentIndexChanged), - this, &MainWindow::DimensionCBaseChanged); + connect(m_dimensionC.data(), QOverload::of(&QComboBox::currentIndexChanged), this, + &MainWindow::DimensionCBaseChanged); } ui->toolBarOption->addSeparator(); @@ -4956,7 +4941,7 @@ void MainWindow::InitDimensionXGradation(const QVector &bases, const Dime { const QString unit = UnitsToStr(VAbstractValApplication::VApp()->MeasurementsUnits(), true); - for(auto base : bases) + for (auto base : bases) { if (VFuzzyContains(labels, base) && not VFuzzyValue(labels, base).isEmpty()) { @@ -4976,7 +4961,7 @@ void MainWindow::InitDimensionYWZGradation(const QVector &bases, const Di const bool fc = m_m->IsFullCircumference(); const QString unit = UnitsToStr(VAbstractValApplication::VApp()->MeasurementsUnits(), true); - for(auto base : bases) + for (auto base : bases) { if (VFuzzyContains(labels, base) && not VFuzzyValue(labels, base).isEmpty()) { @@ -4986,7 +4971,7 @@ void MainWindow::InitDimensionYWZGradation(const QVector &bases, const Di { if (bodyMeasurement) { - control->addItem(QStringLiteral("%1 %2").arg(fc ? base*2 : base).arg(unit), base); + control->addItem(QStringLiteral("%1 %2").arg(fc ? base * 2 : base).arg(unit), base); } else { @@ -5007,8 +4992,8 @@ void MainWindow::SetEnableTool(bool enable) bool modelingTools = false; bool layoutTools = false; -QT_WARNING_PUSH -QT_WARNING_DISABLE_GCC("-Wswitch-default") + QT_WARNING_PUSH + QT_WARNING_DISABLE_GCC("-Wswitch-default") switch (VAbstractValApplication::VApp()->GetDrawMode()) { case Draw::Calculation: @@ -5021,12 +5006,12 @@ QT_WARNING_DISABLE_GCC("-Wswitch-default") layoutTools = enable; break; } -QT_WARNING_POP + QT_WARNING_POP // This check helps to find missed tools Q_STATIC_ASSERT_X(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 59, "Not all tools were handled."); - //Drawing Tools + // Drawing Tools ui->toolButtonEndLine->setEnabled(drawTools); ui->toolButtonLine->setEnabled(drawTools); ui->toolButtonAlongLine->setEnabled(drawTools); @@ -5078,12 +5063,12 @@ QT_WARNING_POP pointer->setChecked(drawTools || modelingTools); } - //Modeling Tools + // Modeling Tools ui->toolButtonUnionDetails->setEnabled(modelingTools); ui->toolButtonDetailExportAs->setEnabled(modelingTools); ui->toolButtonDuplicateDetail->setEnabled(modelingTools); - //Layout tools + // Layout tools ui->toolButtonLayoutSettings->setEnabled(layoutTools); } @@ -5155,8 +5140,8 @@ auto MainWindow::SavePattern(const QString &fileName, QString &error) -> bool */ void MainWindow::AutoSavePattern() { - if (VApplication::IsGUIMode() && not VAbstractValApplication::VApp()->GetPatternPath().isEmpty() - && isWindowModified() && isNeedAutosave) + if (VApplication::IsGUIMode() && not VAbstractValApplication::VApp()->GetPatternPath().isEmpty() && + isWindowModified() && isNeedAutosave) { qCDebug(vMainWindow, "Autosaving pattern."); QString error; @@ -5295,8 +5280,9 @@ auto MainWindow::MaybeSave() -> bool messageBox->setEscapeButton(QMessageBox::Cancel); messageBox->setButtonText(QMessageBox::Yes, - VAbstractValApplication::VApp() - ->GetPatternPath().isEmpty() || m_patternReadOnly ? tr("Save…") : tr("Save")); + VAbstractValApplication::VApp()->GetPatternPath().isEmpty() || m_patternReadOnly + ? tr("Save…") + : tr("Save")); messageBox->setButtonText(QMessageBox::No, tr("Don't Save")); messageBox->setWindowModality(Qt::ApplicationModal); @@ -5336,7 +5322,7 @@ void MainWindow::CreateMenus() ui->menuFile->insertAction(ui->actionPreferences, m_separatorAct); UpdateRecentFileActions(); - //Add Undo/Redo actions. + // Add Undo/Redo actions. undoAction = VAbstractApplication::VApp()->getUndoStack()->createUndoAction(this, tr("&Undo")); connect(undoAction, &QAction::triggered, m_toolOptions, &VToolOptionsPropertyBrowser::RefreshOptions); undoAction->setShortcuts(QKeySequence::Undo); @@ -5371,7 +5357,7 @@ void MainWindow::LastUsedTool() return; } - switch ( m_lastUsedTool ) + switch (m_lastUsedTool) { case Tool::Arrow: for (auto *pointer : qAsConst(m_toolButtonPointerList)) @@ -5397,7 +5383,7 @@ void MainWindow::LastUsedTool() case Tool::BackgroundPixmapImage: case Tool::BackgroundSVGImage: Q_UNREACHABLE(); //-V501 - //Nothing to do here because we can't create this tool from main window. + // Nothing to do here because we can't create this tool from main window. break; case Tool::EndLine: ui->toolButtonEndLine->setChecked(true); @@ -5581,33 +5567,23 @@ void MainWindow::AddDocks() { ui->menuWindow->addSeparator(); - //Add dock + // Add dock actionDockWidgetToolOptions = ui->dockWidgetToolOptions->toggleViewAction(); - connect(actionDockWidgetToolOptions, &QAction::triggered, this, [this](bool checked) - { - m_toolOptionsActive = checked; - }); + connect(actionDockWidgetToolOptions, &QAction::triggered, this, + [this](bool checked) { m_toolOptionsActive = checked; }); ui->menuWindow->addAction(actionDockWidgetToolOptions); actionDockWidgetGroups = ui->dockWidgetGroups->toggleViewAction(); - connect(actionDockWidgetGroups, &QAction::triggered, this, [this](bool checked) - { - m_groupsActive = checked; - }); + connect(actionDockWidgetGroups, &QAction::triggered, this, [this](bool checked) { m_groupsActive = checked; }); ui->menuWindow->addAction(actionDockWidgetGroups); QAction *action = ui->dockWidgetMessages->toggleViewAction(); - connect(action, &QAction::triggered, this, [this](bool checked) - { - m_patternMessagesActive = checked; - }); + connect(action, &QAction::triggered, this, [this](bool checked) { m_patternMessagesActive = checked; }); ui->menuWindow->addAction(action); actionDockWidgetBackgroundImages = ui->dockWidgetBackgroundImages->toggleViewAction(); - connect(actionDockWidgetBackgroundImages, &QAction::triggered, this, [this](bool checked) - { - m_backgroundImagesActive = checked; - }); + connect(actionDockWidgetBackgroundImages, &QAction::triggered, this, + [this](bool checked) { m_backgroundImagesActive = checked; }); ui->menuWindow->addAction(actionDockWidgetBackgroundImages); } @@ -5665,74 +5641,77 @@ void MainWindow::CreateActions() connect(ui->actionTable, &QAction::triggered, this, &MainWindow::ActionTable_triggered); connect(ui->actionFinalMeasurements, &QAction::triggered, this, &MainWindow::ActionFinalMeasurements_triggered); - connect(ui->actionAbout_Qt, &QAction::triggered, this, [this]() - { - QMessageBox::aboutQt(this, tr("About Qt")); - }); + connect(ui->actionAbout_Qt, &QAction::triggered, this, [this]() { QMessageBox::aboutQt(this, tr("About Qt")); }); - connect(ui->actionAbout_Valentina, &QAction::triggered, this, [this]() - { - auto *aboutDialog = new DialogAboutApp(this); - aboutDialog->setAttribute(Qt::WA_DeleteOnClose, true); - aboutDialog->show(); - }); + connect(ui->actionAbout_Valentina, &QAction::triggered, this, + [this]() + { + auto *aboutDialog = new DialogAboutApp(this); + aboutDialog->setAttribute(Qt::WA_DeleteOnClose, true); + aboutDialog->show(); + }); connect(ui->actionExit, &QAction::triggered, this, &MainWindow::close); connect(ui->actionPreferences, &QAction::triggered, this, &MainWindow::Preferences); - connect(ui->actionReportBug, &QAction::triggered, this, []() - { - qCDebug(vMainWindow, "Reporting bug"); - QDesktopServices::openUrl(QUrl(QStringLiteral("https://gitlab.com/smart-pattern/valentina/issues/new"))); - }); - connect(ui->actionShop, &QAction::triggered, this, []() - { - qCDebug(vMainWindow, "Open shop"); - QDesktopServices::openUrl(QUrl(QStringLiteral("https://smart-pattern.com.ua/catalogue/"))); - }); + connect(ui->actionReportBug, &QAction::triggered, this, + []() + { + qCDebug(vMainWindow, "Reporting bug"); + QDesktopServices::openUrl( + QUrl(QStringLiteral("https://gitlab.com/smart-pattern/valentina/issues/new"))); + }); + connect(ui->actionShop, &QAction::triggered, this, + []() + { + qCDebug(vMainWindow, "Open shop"); + QDesktopServices::openUrl(QUrl(QStringLiteral("https://smart-pattern.com.ua/catalogue/"))); + }); connect(ui->actionLast_tool, &QAction::triggered, this, &MainWindow::LastUsedTool); ui->actionInteractiveTools->setChecked(VAbstractValApplication::VApp()->ValentinaSettings()->IsInteractiveTools()); - connect(ui->actionInteractiveTools, &QAction::triggered, this, [](bool checked) - { - VAbstractValApplication::VApp()->ValentinaSettings()->SetInteractiveTools(checked); - }); + connect(ui->actionInteractiveTools, &QAction::triggered, this, + [](bool checked) { VAbstractValApplication::VApp()->ValentinaSettings()->SetInteractiveTools(checked); }); - connect(ui->actionPattern_properties, &QAction::triggered, this, [this]() - { - DialogPatternProperties proper(doc, pattern, this); - connect(&proper, &DialogPatternProperties::UpddatePieces, m_sceneDetails, - &VMainGraphicsScene::UpdatePiecePassmarks); - proper.exec(); - }); + connect(ui->actionPattern_properties, &QAction::triggered, this, + [this]() + { + DialogPatternProperties proper(doc, pattern, this); + connect(&proper, &DialogPatternProperties::UpddatePieces, m_sceneDetails, + &VMainGraphicsScene::UpdatePiecePassmarks); + proper.exec(); + }); ui->actionPattern_properties->setEnabled(false); - connect(ui->actionClosePattern, &QAction::triggered, this, [this]() - { - if (MaybeSave()) - { - FileClosedCorrect(); - Clear(); - } - }); + connect(ui->actionClosePattern, &QAction::triggered, this, + [this]() + { + if (MaybeSave()) + { + FileClosedCorrect(); + Clear(); + } + }); ui->actionShowCurveDetails->setChecked(VAbstractValApplication::VApp()->ValentinaSettings()->IsShowCurveDetails()); - connect(ui->actionShowCurveDetails, &QAction::triggered, this, [this](bool checked) - { - emit ui->view->itemClicked(nullptr); - m_sceneDraw->EnableDetailsMode(checked); - VAbstractValApplication::VApp()->ValentinaSettings()->SetShowCurveDetails(checked); - }); + connect(ui->actionShowCurveDetails, &QAction::triggered, this, + [this](bool checked) + { + emit ui->view->itemClicked(nullptr); + m_sceneDraw->EnableDetailsMode(checked); + VAbstractValApplication::VApp()->ValentinaSettings()->SetShowCurveDetails(checked); + }); ui->actionShowAccuracyRadius->setChecked( VAbstractValApplication::VApp()->ValentinaSettings()->GetShowAccuracyRadius()); - connect(ui->actionShowAccuracyRadius, &QAction::triggered, this, [this](bool checked) - { - VAbstractValApplication::VApp()->ValentinaSettings()->SetShowAccuracyRadius(checked); - m_sceneDetails->update(); - m_sceneDraw->update(); - }); + connect(ui->actionShowAccuracyRadius, &QAction::triggered, this, + [this](bool checked) + { + VAbstractValApplication::VApp()->ValentinaSettings()->SetShowAccuracyRadius(checked); + m_sceneDetails->update(); + m_sceneDraw->update(); + }); ui->actionShowMainPath->setChecked(VAbstractValApplication::VApp()->ValentinaSettings()->IsPieceShowMainPath()); connect(ui->actionShowMainPath, &QAction::triggered, this, &MainWindow::ActionShowMainPath_triggered); @@ -5747,33 +5726,35 @@ void MainWindow::CreateActions() connect(ui->actionPrint, &QAction::triggered, this, &MainWindow::PrintOrigin); connect(ui->actionPrintTiled, &QAction::triggered, this, &MainWindow::PrintTiled); - //Actions for recent files loaded by a main window application. + // Actions for recent files loaded by a main window application. for (int i = 0; i < MaxRecentFiles; ++i) { auto *action = new QAction(this); action->setVisible(false); m_recentFileActs[i] = action; - connect(m_recentFileActs[i], &QAction::triggered, this, [this]() - { - if (auto *action = qobject_cast(sender())) - { - const QString filePath = action->data().toString(); - if (not filePath.isEmpty()) + connect(m_recentFileActs[i], &QAction::triggered, this, + [this]() { - LoadPattern(filePath); - } - } - }); + if (auto *action = qobject_cast(sender())) + { + const QString filePath = action->data().toString(); + if (not filePath.isEmpty()) + { + LoadPattern(filePath); + } + } + }); } connect(ui->actionSyncMeasurements, &QAction::triggered, this, &MainWindow::SyncMeasurements); connect(ui->actionUnloadMeasurements, &QAction::triggered, this, &MainWindow::UnloadMeasurements); - connect(ui->actionLabelTemplateEditor, &QAction::triggered, this, [this]() - { - DialogEditLabel editor(doc, pattern); - editor.exec(); - }); + connect(ui->actionLabelTemplateEditor, &QAction::triggered, this, + [this]() + { + DialogEditLabel editor(doc, pattern); + editor.exec(); + }); connect(ui->actionWatermarkEditor, &QAction::triggered, this, &MainWindow::CreateWatermark); connect(ui->actionEditCurrentWatermark, &QAction::triggered, this, &MainWindow::EditCurrentWatermark); @@ -5784,7 +5765,7 @@ void MainWindow::CreateActions() //--------------------------------------------------------------------------------------------------------------------- void MainWindow::InitAutoSave() { - //Autosaving file each 1 minutes + // Autosaving file each 1 minutes delete m_autoSaveTimer; m_autoSaveTimer = nullptr; @@ -5796,7 +5777,7 @@ void MainWindow::InitAutoSave() if (VAbstractValApplication::VApp()->ValentinaSettings()->GetAutosaveState()) { const qint32 autoTime = VAbstractValApplication::VApp()->ValentinaSettings()->GetAutosaveTime(); - m_autoSaveTimer->start(autoTime*60000); + m_autoSaveTimer->start(autoTime * 60000); qCDebug(vMainWindow, "Autosaving each %d minutes.", autoTime); } VApplication::VApp()->setAutoSaveTimer(m_autoSaveTimer); @@ -5806,7 +5787,7 @@ void MainWindow::InitAutoSave() auto MainWindow::PatternPieceName(QString &name) -> bool { QScopedPointer dlg(new QInputDialog(this)); - dlg->setInputMode( QInputDialog::TextInput ); + dlg->setInputMode(QInputDialog::TextInput); dlg->setLabelText(tr("Pattern piece:")); dlg->setTextEchoMode(QLineEdit::Normal); dlg->setWindowTitle(tr("Enter a new label for the pattern piece.")); @@ -5830,7 +5811,7 @@ auto MainWindow::PatternPieceName(QString &name) -> bool if (m_comboBoxDraws->findText(nameDraw) == -1) { name = nameDraw; - break;// unique name + break; // unique name } } return true; @@ -5850,7 +5831,7 @@ MainWindow::~MainWindow() * @brief LoadPattern open pattern file. * @param fileName name of file. */ -auto MainWindow::LoadPattern(QString fileName, const QString& customMeasureFile) -> bool +auto MainWindow::LoadPattern(QString fileName, const QString &customMeasureFile) -> bool { qCDebug(vMainWindow, "Loading new file %s.", qUtf8Printable(fileName)); @@ -5862,13 +5843,14 @@ auto MainWindow::LoadPattern(QString fileName, const QString& customMeasureFile) } } - QFuture futureConverter = QtConcurrent::run([fileName]() - { - std::unique_ptr converter(new VPatternConverter(fileName)); - return converter.release(); - }); + QFuture futureConverter = QtConcurrent::run( + [fileName]() + { + std::unique_ptr converter(new VPatternConverter(fileName)); + return converter.release(); + }); - //We have unsaved changes or load more then one file per time + // We have unsaved changes or load more then one file per time if (OpenNewValentina(fileName)) { return false; @@ -5892,7 +5874,7 @@ auto MainWindow::LoadPattern(QString fileName, const QString& customMeasureFile) if (m.Type() == MeasurementsType::Multisize || m.Type() == MeasurementsType::Individual) { - QStringList arguments {fileName}; + QStringList arguments{fileName}; if (isNoScaling) { arguments.append(QStringLiteral("--") + LONG_OPTION_NO_HDPI_SCALING); @@ -5920,7 +5902,7 @@ auto MainWindow::LoadPattern(QString fileName, const QString& customMeasureFile) { // Here comes undocumented Valentina's feature. // Because app bundle in Mac OS X doesn't allow setup assosiation for Puzzle we must do this through Valentina - QStringList arguments {fileName}; + QStringList arguments{fileName}; if (isNoScaling) { arguments.append(QStringLiteral("--") + LONG_OPTION_NO_HDPI_SCALING); @@ -5950,7 +5932,7 @@ auto MainWindow::LoadPattern(QString fileName, const QString& customMeasureFile) VMainGraphicsView::NewSceneRect(m_sceneDraw, ui->view); VMainGraphicsView::NewSceneRect(m_sceneDetails, ui->view); - VAbstractValApplication::VApp()->setOpeningPattern();//Begin opening file + VAbstractValApplication::VApp()->setOpeningPattern(); // Begin opening file try { // Quick reading measurements @@ -5982,10 +5964,10 @@ auto MainWindow::LoadPattern(QString fileName, const QString& customMeasureFile) fixedMPath = CheckPathToMeasurements(fileName, fakeName); if (fixedMPath.isEmpty()) { - VAbstractValApplication::VApp()->setOpeningPattern();// End opening file + VAbstractValApplication::VApp()->setOpeningPattern(); // End opening file Clear(); - qCCritical(vMainWindow, "%s", qUtf8Printable(tr("The measurements file '%1' could not be found.") - .arg(fakeName))); + qCCritical(vMainWindow, "%s", + qUtf8Printable(tr("The measurements file '%1' could not be found.").arg(fakeName))); if (not VApplication::IsGUIMode()) { QCoreApplication::exit(V_EX_NOINPUT); @@ -6002,10 +5984,10 @@ auto MainWindow::LoadPattern(QString fileName, const QString& customMeasureFile) fixedMPath = CheckPathToMeasurements(fileName, path); if (fixedMPath.isEmpty()) { - VAbstractValApplication::VApp()->setOpeningPattern();// End opening file + VAbstractValApplication::VApp()->setOpeningPattern(); // End opening file Clear(); - qCCritical(vMainWindow, "%s", qUtf8Printable(tr("The measurements file '%1' could not be found.") - .arg(path))); + qCCritical(vMainWindow, "%s", + qUtf8Printable(tr("The measurements file '%1' could not be found.").arg(path))); if (not VApplication::IsGUIMode()) { QCoreApplication::exit(V_EX_NOINPUT); @@ -6015,10 +5997,11 @@ auto MainWindow::LoadPattern(QString fileName, const QString& customMeasureFile) if (not LoadMeasurements(fixedMPath)) { - qCCritical(vMainWindow, "%s", qUtf8Printable(tr("The measurements file '%1' could not be found or " - "provides not enough information.") - .arg(fixedMPath))); - VAbstractValApplication::VApp()->setOpeningPattern();// End opening file + qCCritical(vMainWindow, "%s", + qUtf8Printable(tr("The measurements file '%1' could not be found or " + "provides not enough information.") + .arg(fixedMPath))); + VAbstractValApplication::VApp()->setOpeningPattern(); // End opening file Clear(); if (not VApplication::IsGUIMode()) { @@ -6033,7 +6016,7 @@ auto MainWindow::LoadPattern(QString fileName, const QString& customMeasureFile) } if (VAbstractValApplication::VApp()->GetMeasurementsType() == MeasurementsType::Unknown) - {// Show toolbar only if was not uploaded any measurements. + { // Show toolbar only if was not uploaded any measurements. ToolBarOption(); } @@ -6057,9 +6040,9 @@ auto MainWindow::LoadPattern(QString fileName, const QString& customMeasureFile) } catch (VException &e) { - qCCritical(vMainWindow, "%s\n\n%s\n\n%s", qUtf8Printable(tr("File error.")), - qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation())); - VAbstractValApplication::VApp()->setOpeningPattern();// End opening file + qCCritical(vMainWindow, "%s\n\n%s\n\n%s", qUtf8Printable(tr("File error.")), qUtf8Printable(e.ErrorMessage()), + qUtf8Printable(e.DetailedInformation())); + VAbstractValApplication::VApp()->setOpeningPattern(); // End opening file Clear(); if (not VApplication::IsGUIMode()) { @@ -6077,7 +6060,7 @@ auto MainWindow::LoadPattern(QString fileName, const QString& customMeasureFile) m_taskbarProgress->setVisible(true); m_taskbarProgress->setMaximum(elements); #endif - + FullParseFile(); m_progressBar->setVisible(false); @@ -6090,9 +6073,9 @@ auto MainWindow::LoadPattern(QString fileName, const QString& customMeasureFile) { // No errors occurred if (VApplication::IsGUIMode()) { - /* Collect garbage only after successfully parse. This way wrongly accused items have one more time to restore - * a reference. */ - QTimer::singleShot(V_MSECONDS(100), Qt::CoarseTimer, this, [this](){doc->GarbageCollector(true);}); + /* Collect garbage only after successfully parse. This way wrongly accused items have one more time to + * restore a reference. */ + QTimer::singleShot(V_MSECONDS(100), Qt::CoarseTimer, this, [this]() { doc->GarbageCollector(true); }); } m_patternReadOnly = doc->IsReadOnly(); @@ -6101,17 +6084,17 @@ auto MainWindow::LoadPattern(QString fileName, const QString& customMeasureFile) setCurrentFile(fileName); qCDebug(vMainWindow, "File loaded."); - //Fit scene size to best size for first show + // Fit scene size to best size for first show ZoomFirstShow(); ActionDraw(true); - VAbstractValApplication::VApp()->setOpeningPattern();// End opening file + VAbstractValApplication::VApp()->setOpeningPattern(); // End opening file m_statusLabel->setText(QString()); return true; } - VAbstractValApplication::VApp()->setOpeningPattern();// End opening file + VAbstractValApplication::VApp()->setOpeningPattern(); // End opening file return false; } @@ -6119,7 +6102,7 @@ auto MainWindow::LoadPattern(QString fileName, const QString& customMeasureFile) auto MainWindow::GetUnlokedRestoreFileList() -> QStringList { QStringList restoreFiles; - //Take all files that need to be restored + // Take all files that need to be restored QStringList files = VAbstractValApplication::VApp()->ValentinaSettings()->GetRestoreFileList(); if (not files.empty()) { @@ -6170,7 +6153,8 @@ void MainWindow::ToolBoxSizePolicy() { ui->toolBox->setSizePolicy(ui->toolBox->sizePolicy().horizontalPolicy(), VAbstractValApplication::VApp()->ValentinaSettings()->GetToolPanelScaling() - ? QSizePolicy::Fixed : QSizePolicy::Preferred); + ? QSizePolicy::Fixed + : QSizePolicy::Preferred); } //--------------------------------------------------------------------------------------------------------------------- @@ -6192,7 +6176,7 @@ void MainWindow::ShowPaper(int index) void MainWindow::Preferences() { // Calling constructor of the dialog take some time. Because of this user have time to call the dialog twice. - static QPointer guard;// Prevent any second run + static QPointer guard; // Prevent any second run if (guard.isNull()) { QGuiApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); @@ -6205,7 +6189,7 @@ void MainWindow::Preferences() &VToolOptionsPropertyBrowser::RefreshOptions); connect(dlg.data(), &DialogPreferences::UpdateProperties, this, &MainWindow::ToolBarStyles); connect(dlg.data(), &DialogPreferences::UpdateProperties, this, &MainWindow::ToolBoxSizePolicy); - connect(dlg.data(), &DialogPreferences::UpdateProperties, this, [this](){emit doc->FullUpdateFromFile();}); + connect(dlg.data(), &DialogPreferences::UpdateProperties, this, [this]() { emit doc->FullUpdateFromFile(); }); connect(dlg.data(), &DialogPreferences::UpdateProperties, ui->view, &VMainGraphicsView::ResetScrollingAnimation); QGuiApplication::restoreOverrideCursor(); @@ -6237,7 +6221,7 @@ void MainWindow::CreateMeasurements() //--------------------------------------------------------------------------------------------------------------------- void MainWindow::ExportDrawAs() { - auto Uncheck = qScopeGuard([this] {ui->toolButtonExportDraw->setChecked(false);}); + auto Uncheck = qScopeGuard([this] { ui->toolButtonExportDraw->setChecked(false); }); QString filters(tr("Scalable Vector Graphics files") + QStringLiteral("(*.svg)")); QString dir = QDir::homePath() + QChar('/') + FileName() + QStringLiteral(".svg"); @@ -6249,7 +6233,7 @@ void MainWindow::ExportDrawAs() return; } - QFileInfo f( fileName ); + QFileInfo f(fileName); if (f.suffix().isEmpty() || f.suffix() != QLatin1String("svg")) { fileName += QLatin1String(".svg"); @@ -6261,7 +6245,7 @@ void MainWindow::ExportDrawAs() //--------------------------------------------------------------------------------------------------------------------- void MainWindow::ExportLayoutAs() { - auto Uncheck = qScopeGuard([this] {ui->toolButtonLayoutExportAs->setChecked(false);}); + auto Uncheck = qScopeGuard([this] { ui->toolButtonLayoutExportAs->setChecked(false); }); if (m_layoutSettings->IsLayoutStale()) { @@ -6273,9 +6257,8 @@ void MainWindow::ExportLayoutAs() try { - m_dialogSaveLayout = QSharedPointer( - new DialogSaveLayout(static_cast(m_layoutSettings->LayoutScenes().size()), Draw::Layout, FileName(), - this)); + m_dialogSaveLayout = QSharedPointer(new DialogSaveLayout( + static_cast(m_layoutSettings->LayoutScenes().size()), Draw::Layout, FileName(), this)); if (m_dialogSaveLayout->exec() == QDialog::Rejected) { @@ -6289,8 +6272,8 @@ void MainWindow::ExportLayoutAs() catch (const VException &e) { m_dialogSaveLayout.clear(); - qCritical("%s\n\n%s\n\n%s", qUtf8Printable(tr("Export error.")), - qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation())); + qCritical("%s\n\n%s\n\n%s", qUtf8Printable(tr("Export error.")), qUtf8Printable(e.ErrorMessage()), + qUtf8Printable(e.DetailedInformation())); return; } } @@ -6298,14 +6281,15 @@ void MainWindow::ExportLayoutAs() //--------------------------------------------------------------------------------------------------------------------- void MainWindow::ExportDetailsAs() { - auto Uncheck = qScopeGuard([this] {ui->toolButtonDetailExportAs->setChecked(false);}); + auto Uncheck = qScopeGuard([this] { ui->toolButtonDetailExportAs->setChecked(false); }); QVector detailsInLayout = SortDetailsForLayout(pattern->DataPieces()); if (detailsInLayout.count() == 0) { - QMessageBox::information(this, tr("Layout mode"), tr("You don't have enough details to export. Please, " - "include at least one detail in layout."), + QMessageBox::information(this, tr("Layout mode"), + tr("You don't have enough details to export. Please, " + "include at least one detail in layout."), QMessageBox::Ok, QMessageBox::Ok); return; } @@ -6318,15 +6302,15 @@ void MainWindow::ExportDetailsAs() catch (VException &e) { QMessageBox::warning(this, tr("Export details"), - tr("Can't export details.") + QStringLiteral(" \n") + e.ErrorMessage(), - QMessageBox::Ok, QMessageBox::Ok); + tr("Can't export details.") + QStringLiteral(" \n") + e.ErrorMessage(), QMessageBox::Ok, + QMessageBox::Ok); return; } try { - m_dialogSaveLayout = QSharedPointer(new DialogSaveLayout(1, Draw::Modeling, FileName(), - this)); + m_dialogSaveLayout = + QSharedPointer(new DialogSaveLayout(1, Draw::Modeling, FileName(), this)); if (m_dialogSaveLayout->exec() == QDialog::Rejected) { @@ -6340,8 +6324,8 @@ void MainWindow::ExportDetailsAs() catch (const VException &e) { m_dialogSaveLayout.clear(); - qCritical("%s\n\n%s\n\n%s", qUtf8Printable(tr("Export error.")), - qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation())); + qCritical("%s\n\n%s\n\n%s", qUtf8Printable(tr("Export error.")), qUtf8Printable(e.ErrorMessage()), + qUtf8Printable(e.DetailedInformation())); return; } } @@ -6445,14 +6429,14 @@ auto MainWindow::CheckPathToMeasurements(const QString &patternPath, const QStri { if (not VApplication::IsGUIMode()) { - return {};// console mode doesn't support fixing path to a measurement file + return {}; // console mode doesn't support fixing path to a measurement file } const QString text = tr("The measurements file

%1

could not be found. Do you " - "want to update the file location?").arg(path); + "want to update the file location?") + .arg(path); QMessageBox::StandardButton res = QMessageBox::question(this, tr("Loading measurements file"), text, - QMessageBox::Yes | QMessageBox::No, - QMessageBox::Yes); + QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes); if (res == QMessageBox::No) { return {}; @@ -6490,28 +6474,25 @@ auto MainWindow::CheckPathToMeasurements(const QString &patternPath, const QStri return dirPath; }; - QString mPath; if (patternType == MeasurementsType::Multisize) { const QString filter = tr("Multisize measurements") + QStringLiteral(" (*.vst);;") + tr("Individual measurements") + QStringLiteral(" (*.vit)"); - //Use standard path to multisize measurements + // Use standard path to multisize measurements QString selectedName; - const QString dirPath = DirPath(VAbstractValApplication::VApp() - ->ValentinaSettings()->GetPathMultisizeMeasurements(), - selectedName); + const QString dirPath = DirPath( + VAbstractValApplication::VApp()->ValentinaSettings()->GetPathMultisizeMeasurements(), selectedName); mPath = FindLocation(filter, dirPath, selectedName); } else { const QString filter = tr("Individual measurements") + QStringLiteral(" (*.vit);;") + tr("Multisize measurements") + QStringLiteral(" (*.vst)"); - //Use standard path to individual measurements + // Use standard path to individual measurements QString selectedName; - const QString dirPath = DirPath(VAbstractValApplication::VApp() - ->ValentinaSettings()->GetPathIndividualMeasurements(), - selectedName); + const QString dirPath = DirPath( + VAbstractValApplication::VApp()->ValentinaSettings()->GetPathIndividualMeasurements(), selectedName); mPath = FindLocation(filter, dirPath, selectedName); } @@ -6533,12 +6514,12 @@ auto MainWindow::CheckPathToMeasurements(const QString &patternPath, const QStri if (patternType == MeasurementsType::Multisize) { VVSTConverter converter(mPath); - m->setXMLContent(converter.Convert());// Read again after conversion + m->setXMLContent(converter.Convert()); // Read again after conversion } else { VVITConverter converter(mPath); - m->setXMLContent(converter.Convert());// Read again after conversion + m->setXMLContent(converter.Convert()); // Read again after conversion } if (not m->IsDefinedKnownNamesValid()) @@ -6571,7 +6552,7 @@ void MainWindow::ChangePP(int index, bool zoomBestFit) ZoomFitBestCurrent(); } } - m_toolOptions->itemClicked(nullptr);//hide options for tool in previous pattern piece + m_toolOptions->itemClicked(nullptr); // hide options for tool in previous pattern piece m_groupsWidget->UpdateGroups(); } } @@ -6626,7 +6607,7 @@ void MainWindow::ZoomFirstShow() auto MainWindow::DoExport(const VCommandLinePtr &expParams) -> bool { QVector details; - if(not VAbstractValApplication::VApp()->getOpeningPattern()) + if (not VAbstractValApplication::VApp()->getOpeningPattern()) { const QHash *allDetails = pattern->DataPieces(); if (allDetails->count() == 0) @@ -6640,8 +6621,9 @@ auto MainWindow::DoExport(const VCommandLinePtr &expParams) -> bool if (details.count() == 0) { - qCCritical(vMainWindow, "%s", qUtf8Printable(tr("You can't export empty scene. Please, " - "include at least one detail in layout."))); + qCCritical(vMainWindow, "%s", + qUtf8Printable(tr("You can't export empty scene. Please, " + "include at least one detail in layout."))); QCoreApplication::exit(V_EX_DATAERR); return false; } @@ -6653,8 +6635,8 @@ auto MainWindow::DoExport(const VCommandLinePtr &expParams) -> bool { try { - m_dialogSaveLayout = QSharedPointer(new DialogSaveLayout(1, Draw::Modeling, - expParams->OptBaseName(), this)); + m_dialogSaveLayout = QSharedPointer( + new DialogSaveLayout(1, Draw::Modeling, expParams->OptBaseName(), this)); m_dialogSaveLayout->SetDestinationPath(expParams->OptDestinationPath()); m_dialogSaveLayout->SelectFormat(static_cast(expParams->OptExportType())); m_dialogSaveLayout->SetBinaryDXFFormat(expParams->IsBinaryDXF()); @@ -6692,8 +6674,8 @@ auto MainWindow::DoExport(const VCommandLinePtr &expParams) -> bool try { m_dialogSaveLayout = QSharedPointer( - new DialogSaveLayout(static_cast(m_layoutSettings->LayoutScenes().size()), - Draw::Layout, expParams->OptBaseName(), this)); + new DialogSaveLayout(static_cast(m_layoutSettings->LayoutScenes().size()), Draw::Layout, + expParams->OptBaseName(), this)); m_dialogSaveLayout->SetDestinationPath(expParams->OptDestinationPath()); m_dialogSaveLayout->SelectFormat(static_cast(expParams->OptExportType())); m_dialogSaveLayout->SetBinaryDXFFormat(expParams->IsBinaryDXF()); @@ -6772,7 +6754,6 @@ auto MainWindow::DoFMExport(const VCommandLinePtr &expParams) -> bool } return ExportFMeasurementsToCSVData(filePath, expParams->IsCSVWithHeader(), mib, separator); - } //--------------------------------------------------------------------------------------------------------------------- @@ -6791,9 +6772,9 @@ auto MainWindow::SetDimensionA(int value) -> bool } else { - qCCritical(vMainWindow, "%s", - qUtf8Printable(tr("Not supported dimension A value '%1' for this pattern file.") - .arg(value))); + qCCritical( + vMainWindow, "%s", + qUtf8Printable(tr("Not supported dimension A value '%1' for this pattern file.").arg(value))); return false; } } @@ -6834,16 +6815,16 @@ auto MainWindow::SetDimensionB(int value) -> bool } else { - qCCritical(vMainWindow, "%s", - qUtf8Printable(tr("Not supported dimension B value '%1' for this pattern file.") - .arg(value))); + qCCritical( + vMainWindow, "%s", + qUtf8Printable(tr("Not supported dimension B value '%1' for this pattern file.").arg(value))); return false; } } else { qCCritical(vMainWindow, "%s", - qUtf8Printable(tr("Couldn't set dimension B. Need a file with multisize measurements."))); + qUtf8Printable(tr("Couldn't set dimension B. Need a file with multisize measurements."))); return false; } } @@ -6877,9 +6858,9 @@ auto MainWindow::SetDimensionC(int value) -> bool } else { - qCCritical(vMainWindow, "%s", - qUtf8Printable(tr("Not supported dimension C value '%1' for this pattern file.") - .arg(value))); + qCCritical( + vMainWindow, "%s", + qUtf8Printable(tr("Not supported dimension C value '%1' for this pattern file.").arg(value))); return false; } } @@ -6957,7 +6938,7 @@ void MainWindow::ProcessCMD() cSetted = SetDimensionB(cmd->OptDimensionC()); } - if (not (aSetted && bSetted && cSetted)) + if (not(aSetted && bSetted && cSetted)) { QCoreApplication::exit(V_EX_DATAERR); return; @@ -6976,7 +6957,7 @@ void MainWindow::ProcessCMD() } } - QCoreApplication::exit(V_EX_OK);// close program after processing in console mode + QCoreApplication::exit(V_EX_OK); // close program after processing in console mode } } @@ -6984,7 +6965,7 @@ void MainWindow::ProcessCMD() auto MainWindow::GetPatternFileName() -> QString { QString shownName = tr("untitled.val"); - if(not VAbstractValApplication::VApp()->GetPatternPath().isEmpty()) + if (not VAbstractValApplication::VApp()->GetPatternPath().isEmpty()) { shownName = StrippedName(VAbstractValApplication::VApp()->GetPatternPath()); } @@ -6995,7 +6976,7 @@ auto MainWindow::GetPatternFileName() -> QString //--------------------------------------------------------------------------------------------------------------------- auto MainWindow::GetMeasurementFileName() -> QString { - if(doc->MPath().isEmpty()) + if (doc->MPath().isEmpty()) { return {}; } @@ -7003,7 +6984,7 @@ auto MainWindow::GetMeasurementFileName() -> QString QString shownName = QStringLiteral(" ["); shownName += StrippedName(AbsoluteMPath(VAbstractValApplication::VApp()->GetPatternPath(), doc->MPath())); - if(m_mChanges) + if (m_mChanges) { shownName += QChar('*'); } @@ -7018,29 +6999,29 @@ void MainWindow::UpdateWindowTitle() bool isFileWritable = true; if (not VAbstractValApplication::VApp()->GetPatternPath().isEmpty()) { -//#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*/ isFileWritable = QFileInfo(VAbstractValApplication::VApp()->GetPatternPath()).isWritable(); -//#ifdef Q_OS_WIN32 -// qt_ntfs_permission_lookup--; // turn it off again -//#endif /*Q_OS_WIN32*/ + // #ifdef Q_OS_WIN32 + // qt_ntfs_permission_lookup--; // turn it off again + // #endif /*Q_OS_WIN32*/ } if (not m_patternReadOnly && isFileWritable) { - setWindowTitle(GetPatternFileName()+GetMeasurementFileName()); + setWindowTitle(GetPatternFileName() + GetMeasurementFileName()); } else { - setWindowTitle(GetPatternFileName()+GetMeasurementFileName() + QStringLiteral(" (") + tr("read only") + + setWindowTitle(GetPatternFileName() + GetMeasurementFileName() + QStringLiteral(" (") + tr("read only") + QChar(')')); } setWindowFilePath(VAbstractValApplication::VApp()->GetPatternPath()); #if defined(Q_OS_MAC) - static QIcon fileIcon = QIcon(QCoreApplication::applicationDirPath() + - QLatin1String("/../Resources/Valentina.icns")); + static QIcon fileIcon = + QIcon(QCoreApplication::applicationDirPath() + QLatin1String("/../Resources/Valentina.icns")); QIcon icon; if (not VAbstractValApplication::VApp()->GetPatternPath().isEmpty()) { @@ -7060,7 +7041,7 @@ void MainWindow::UpdateWindowTitle() } } setWindowIcon(icon); -#endif //defined(Q_OS_MAC) +#endif // defined(Q_OS_MAC) } //--------------------------------------------------------------------------------------------------------------------- @@ -7316,7 +7297,7 @@ void MainWindow::ToolSelectDetail() // Only true for rubber band selection emit EnableNodeLabelSelection(false); emit EnableNodePointSelection(false); - emit EnableDetailSelection(true);// Disable when done visualization details + emit EnableDetailSelection(true); // Disable when done visualization details // Hovering emit EnableNodeLabelHover(true); @@ -7332,11 +7313,12 @@ void MainWindow::ToolSelectDetail() void MainWindow::PrintPatternMessage(QEvent *event) { SCASSERT(event != nullptr) - auto *patternMessage = static_cast(event); // NOLINT(cppcoreguidelines-pro-type-static-cast-downcast) + auto *patternMessage = + static_cast(event); // NOLINT(cppcoreguidelines-pro-type-static-cast-downcast) QString severity; - switch(patternMessage->Severity()) + switch (patternMessage->Severity()) { case QtDebugMsg: severity = tr("DEBUG"); @@ -7350,11 +7332,11 @@ void MainWindow::PrintPatternMessage(QEvent *event) case QtFatalMsg: severity = tr("FATAL"); break; - #if QT_VERSION >= QT_VERSION_CHECK(5, 5, 0) +#if QT_VERSION >= QT_VERSION_CHECK(5, 5, 0) case QtInfoMsg: severity = tr("INFO"); break; - #endif +#endif default: break; } @@ -7382,8 +7364,8 @@ void MainWindow::OpenWatermark(const QString &path) } auto *watermark = new WatermarkWindow(VAbstractValApplication::VApp()->GetPatternPath(), this); - connect(watermark, &WatermarkWindow::New, this, [this](){OpenWatermark();}); - connect(watermark, &WatermarkWindow::OpenAnother, this, [this](const QString &path){OpenWatermark(path);}); + connect(watermark, &WatermarkWindow::New, this, [this]() { OpenWatermark(); }); + connect(watermark, &WatermarkWindow::OpenAnother, this, [this](const QString &path) { OpenWatermark(path); }); m_watermarkEditors.append(watermark); watermark->show(); watermark->Open(path); diff --git a/src/app/valentina/mainwindow.h b/src/app/valentina/mainwindow.h index 8f927b447..2b52c261b 100644 --- a/src/app/valentina/mainwindow.h +++ b/src/app/valentina/mainwindow.h @@ -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 #include 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 m_dialogTable; - QPointer m_dialogTool{}; - QPointer m_dialogHistory; + QPointer m_dialogTable; + QPointer m_dialogTool{}; + QPointer m_dialogHistory; QPointer 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> m_lock{nullptr}; - QList m_toolButtonPointerList{}; + QList m_toolButtonPointerList{}; QProgressBar *m_progressBar; - QLabel *m_statusLabel; + QLabel *m_statusLabel; QList> m_watermarkEditors{}; @@ -332,7 +334,7 @@ private: QTimer *m_gradation; QMap m_backgroundImages{}; - VBackgroundImageControls* m_backgroudcontrols{nullptr}; + VBackgroundImageControls *m_backgroudcontrols{nullptr}; bool m_groupsActive{false}; bool m_toolOptionsActive{false}; @@ -366,21 +368,14 @@ private: template void SetToolButtonWithApply(bool checked, Tool t, const QString &cursor, const QString &toolTip, Func closeDialogSlot, Func2 applyDialogSlot); - template - void ClosedDialog(int result); + template void ClosedDialog(int result); - template - void ClosedDialogWithApply(int result, VMainGraphicsScene *scene); - template - void ApplyDialog(VMainGraphicsScene *scene); - template - void ClosedDrawDialogWithApply(int result); - template - void ApplyDrawDialog(); - template - void ClosedDetailsDialogWithApply(int result); - template - void ApplyDetailsDialog(); + template void ClosedDialogWithApply(int result, VMainGraphicsScene *scene); + template void ApplyDialog(VMainGraphicsScene *scene); + template void ClosedDrawDialogWithApply(int result); + template void ApplyDrawDialog(); + template void ClosedDetailsDialogWithApply(int result); + template 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 &dimensions, int index, qreal currentBase); - void StoreIndividualMDimension(const QMap > &measurements, IMD type); + void StoreIndividualMDimension(const QMap> &measurements, IMD type); auto DimensionRestrictedValues(int index, const MeasurementDimension_p &dimension) -> QVector; void SetDimensionBases(); diff --git a/src/libs/fervor/fvupdater.cpp b/src/libs/fervor/fvupdater.cpp index dfc411577..8e731954c 100644 --- a/src/libs/fervor/fvupdater.cpp +++ b/src/libs/fervor/fvupdater.cpp @@ -21,25 +21,25 @@ #include "fvupdater.h" -#include -#include #include #include #include #include +#include +#include #include #include #include #include #include #include +#include #include #include #include #include -#include -#include -#include +#include +#include #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::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 diff --git a/src/libs/ifc/xml/vabstractpattern.cpp b/src/libs/ifc/xml/vabstractpattern.cpp index c4ea37f6f..f042fb18a 100644 --- a/src/libs/ifc/xml/vabstractpattern.cpp +++ b/src/libs/ifc/xml/vabstractpattern.cpp @@ -30,151 +30,160 @@ #include #include +#include #include #include #include -#include -#include -#include -#include -#include #include +#include +#include +#include +#include +#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 VAbstractPattern::tools = QHash(); +QHash VAbstractPattern::tools = QHash(); QVector VAbstractPattern::patternLabelLines = QVector(); QMap VAbstractPattern::patternMaterials = QMap(); 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 &expressions, const QDomElement &element, const QString &attribute) { VFormulaField formula; @@ -202,7 +211,7 @@ auto GetTokens(const VFormulaField &formula) -> QList 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(); } catch (const qmu::QmuParserWarning &e) @@ -276,8 +285,7 @@ auto StringToTransfrom(const QString &matrix) -> QTransform } //--------------------------------------------------------------------------------------------------------------------- -template -auto NumberToString(T number) -> QString +template 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()), - history(QVector()), - patternPieces(), - modified(false) -{} + : VDomDocument(parent), + nameActivPP(), + cursor(0), + toolsOnRemove(QVector()), + history(QVector()), + patternPieces(), + modified(false) +{ +} //--------------------------------------------------------------------------------------------------------------------- VAbstractPattern::~VAbstractPattern() @@ -329,9 +329,9 @@ auto VAbstractPattern::RequiresMeasurements() const -> bool //--------------------------------------------------------------------------------------------------------------------- auto VAbstractPattern::ListMeasurements() const -> QStringList { - const QFuture futureIncrements = QtConcurrent::run([this](){return ListIncrements();}); - const QList tokens = ConvertToList(QtConcurrent::blockingMappedReduced(ListExpressions(), GetTokens, - GatherTokens)); + const QFuture futureIncrements = QtConcurrent::run([this]() { return ListIncrements(); }); + const QList tokens = + ConvertToList(QtConcurrent::blockingMappedReduced(ListExpressions(), GetTokens, GatherTokens)); QSet measurements; QSet others = ConvertToSet(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 { QVector 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 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 > groupData = ParseItemElement(domElement); + const QPair> groupData = ParseItemElement(domElement); const QMap 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"< 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(GetParametrUInt(element, - VAbstractPattern::AttrIncludeAs, - QChar('1'))); + record.includeType = static_cast( + 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"< 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 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 // 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 list; list << futurePointExpressions.result(); @@ -1801,7 +1793,7 @@ auto VAbstractPattern::ListPointExpressions() const -> QVector QVector 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 QVector 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 QVector 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 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 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 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 QVector 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 QVector 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 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 > group; + QPair> group; group.first = visible; group.second = items; @@ -2210,7 +2202,7 @@ void VAbstractPattern::SetFMeasurements(QDomElement &element, const QVector(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(element, AttrContentType, image.ContentType(), - [](const QString &contentType) noexcept {return contentType.isEmpty();}); + [](const QString &contentType) noexcept { return contentType.isEmpty(); }); setTagText(element, image.ContentData()); SetAttributeOrRemoveIf(element, AttrPath, image.FilePath(), - [](const QString &path) noexcept {return path.isEmpty();}); + [](const QString &path) noexcept { return path.isEmpty(); }); } SetAttributeOrRemoveIf(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(element, AttrHold, image.Hold(), [](bool hold) noexcept {return not hold;}); - SetAttributeOrRemoveIf(element, AttrZValue, image.ZValue(), [](qreal z) noexcept {return qFuzzyIsNull(z);}); - SetAttributeOrRemoveIf(element, AttrVisible, image.Visible(), [](bool visible) noexcept {return visible;}); + SetAttributeOrRemoveIf(element, AttrHold, image.Hold(), [](bool hold) noexcept { return not hold; }); + SetAttributeOrRemoveIf(element, AttrZValue, image.ZValue(), + [](qreal z) noexcept { return qFuzzyIsNull(z); }); + SetAttributeOrRemoveIf(element, AttrVisible, image.Visible(), [](bool visible) noexcept { return visible; }); SetAttributeOrRemoveIf(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(group, AttrTool, tool, [](vidtype tool) noexcept { return tool == null_id;}); + SetAttributeOrRemoveIf(group, AttrTool, tool, [](vidtype tool) noexcept { return tool == null_id; }); SetAttributeOrRemoveIf(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(item, AttrObject, i.key(), [i](vidtype object) noexcept - {return object == i.value();}); + SetAttributeOrRemoveIf(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(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"< double return GetParametrDouble(domElement, AttrDimensionB, *dimensionDefValue); } - qDebug()<<"Can't save dimension B of measurements"< double return GetParametrDouble(domElement, AttrDimensionC, *dimensionDefValue); } - qDebug()<<"Can't save dimension C of measurements"< QStringList QSet 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 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(item, AttrObject, objectId, [toolId](vidtype object) noexcept - {return object == toolId;}); + SetAttributeOrRemoveIf(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); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/ifc/xml/vdomdocument.cpp b/src/libs/ifc/xml/vdomdocument.cpp index 3e4e7a7fb..fa8118056 100644 --- a/src/libs/ifc/xml/vdomdocument.cpp +++ b/src/libs/ifc/xml/vdomdocument.cpp @@ -28,15 +28,15 @@ #include "vdomdocument.h" +#include #include #include -#include +#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 +#include #include #include #include +#include +#include #include #include #include @@ -55,14 +58,12 @@ #include #include #include +#include #include #include -#include #include -#include #include -#include -#include +#include 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 < bool QList attributes1 = GetElementAttributes(element1); QList 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() < 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>(this)) + : QObject(parent), + QDomDocument(), + m_elementIdCache(), + m_watcher(new QFutureWatcher>(this)) { connect(m_watcher, &QFutureWatcher>::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 &cache, const QDomElement &n } } - for (qint32 i=0; i &cache, const QDomElement &n return false; } - //--------------------------------------------------------------------------------------------------------------------- auto VDomDocument::RefreshCache(const QDomElement &root) const -> QHash { @@ -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 &vector) vector.append(id); } - for (qint32 i=0; iisFinished()) { - 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(Unit::Mm), last = static_cast(Unit::LAST_UNIT_DO_NOT_USE); i < last;++i) + for (auto i = static_cast(Unit::Mm), last = static_cast(Unit::LAST_UNIT_DO_NOT_USE); i < last; ++i) { r += UnitsToStr(static_cast(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 "< 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; } diff --git a/src/libs/ifc/xml/vlayoutconverter.cpp b/src/libs/ifc/xml/vlayoutconverter.cpp index c67f30a98..764158159 100644 --- a/src/libs/ifc/xml/vlayoutconverter.cpp +++ b/src/libs/ifc/xml/vlayoutconverter.cpp @@ -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 QVector 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 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 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")); diff --git a/src/libs/ifc/xml/vpatternconverter.cpp b/src/libs/ifc/xml/vpatternconverter.cpp index c9e3388a7..4a68a228b 100644 --- a/src/libs/ifc/xml/vpatternconverter.cpp +++ b/src/libs/ifc/xml/vpatternconverter.cpp @@ -34,11 +34,11 @@ #include #include #include +#include #include #include -#include -#include #include +#include #include "../exception/vexception.h" #include "../exception/vexceptionemptyparameter.h" @@ -46,6 +46,10 @@ #include "../qmuparser/qmutokenparser.h" #include "../vmisc/def.h" +#if QT_VERSION < QT_VERSION_CHECK(5, 5, 0) +#include "../vmisc/diagnostic.h" +#endif // QT_VERSION < QT_VERSION_CHECK(5, 5, 0) + class QDomElement; /* @@ -58,123 +62,130 @@ class QDomElement; const QString VPatternConverter::PatternMinVerStr = QStringLiteral("0.1.4"); const QString VPatternConverter::PatternMaxVerStr = QStringLiteral("0.9.2"); -const QString VPatternConverter::CurrentSchema = QStringLiteral("://schema/pattern/v0.9.2.xsd"); +const QString VPatternConverter::CurrentSchema = QStringLiteral("://schema/pattern/v0.9.2.xsd"); -//VPatternConverter::PatternMinVer; // <== DON'T FORGET TO UPDATE TOO!!!! -//VPatternConverter::PatternMaxVer; // <== DON'T FORGET TO UPDATE TOO!!!! +// VPatternConverter::PatternMinVer; // <== DON'T FORGET TO UPDATE TOO!!!! +// VPatternConverter::PatternMaxVer; // <== 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, strUnit, (QLatin1String("unit"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strVersion, (QLatin1String("version"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strName, (QLatin1String("name"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strBase, (QLatin1String("base"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strFormula, (QLatin1String("formula"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strId, (QLatin1String("id"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strKGrowth , (QLatin1String("kgrowth"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strKSize, (QLatin1String("ksize"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strPoint, (QLatin1String("point"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strLength, (QLatin1String("length"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strAngle, (QLatin1String("angle"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strC1Radius, (QLatin1String("c1Radius"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strC2Radius, (QLatin1String("c2Radius"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strCRadius, (QLatin1String("cRadius"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strArc, (QLatin1String("arc"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strAngle1, (QLatin1String("angle1"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strAngle2, (QLatin1String("angle2"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strRadius, (QLatin1String("radius"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strPathPoint, (QLatin1String("pathPoint"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strKAsm1, (QLatin1String("kAsm1"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strKAsm2, (QLatin1String("kAsm2"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strPath, (QLatin1String("path"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strType, (QLatin1String("type"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strCutArc, (QLatin1String("cutArc"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strSpline, (QLatin1String("spline"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strSplinePath, (QLatin1String("splinePath"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strCutSpline, (QLatin1String("cutSpline"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strCutSplinePath, (QLatin1String("cutSplinePath"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strColor, (QLatin1String("color"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strMeasurements, (QLatin1String("measurements"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strIncrement, (QLatin1String("increment"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strIncrements, (QLatin1String("increments"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strUnit, (QLatin1String("unit"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strVersion, (QLatin1String("version"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strName, (QLatin1String("name"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strBase, (QLatin1String("base"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strFormula, (QLatin1String("formula"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strId, (QLatin1String("id"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strKGrowth, (QLatin1String("kgrowth"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strKSize, (QLatin1String("ksize"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strPoint, (QLatin1String("point"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strLength, (QLatin1String("length"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strAngle, (QLatin1String("angle"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strC1Radius, (QLatin1String("c1Radius"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strC2Radius, (QLatin1String("c2Radius"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strCRadius, (QLatin1String("cRadius"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strArc, (QLatin1String("arc"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strAngle1, (QLatin1String("angle1"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strAngle2, (QLatin1String("angle2"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strRadius, (QLatin1String("radius"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strPathPoint, (QLatin1String("pathPoint"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strKAsm1, (QLatin1String("kAsm1"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strKAsm2, (QLatin1String("kAsm2"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strPath, (QLatin1String("path"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strType, (QLatin1String("type"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strCutArc, (QLatin1String("cutArc"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strSpline, (QLatin1String("spline"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strSplinePath, (QLatin1String("splinePath"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strCutSpline, (QLatin1String("cutSpline"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strCutSplinePath, (QLatin1String("cutSplinePath"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strColor, (QLatin1String("color"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strMeasurements, (QLatin1String("measurements"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strIncrement, (QLatin1String("increment"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strIncrements, (QLatin1String("increments"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, strPreviewCalculations, (QLatin1String("previewCalculations"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strModeling, (QLatin1String("modeling"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strTools, (QLatin1String("tools"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strIdTool, (QLatin1String("idTool"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strIdObject, (QLatin1String("idObject"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strChildren, (QLatin1String("children"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strChild, (QLatin1String("child"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strPointOfIntersectionCurves, (QLatin1String("pointOfIntersectionCurves"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strCurveIntersectAxis, (QLatin1String("curveIntersectAxis"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strCurve, (QLatin1String("curve"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strCurve1, (QLatin1String("curve1"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strCurve2, (QLatin1String("curve2"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strModelingPath, (QLatin1String("modelingPath"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strModelingSpline, (QLatin1String("modelingSpline"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strModeling, (QLatin1String("modeling"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strTools, (QLatin1String("tools"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strIdTool, (QLatin1String("idTool"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strIdObject, (QLatin1String("idObject"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strChildren, (QLatin1String("children"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strChild, (QLatin1String("child"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strPointOfIntersectionCurves, + (QLatin1String("pointOfIntersectionCurves"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strCurveIntersectAxis, (QLatin1String("curveIntersectAxis"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strCurve, (QLatin1String("curve"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strCurve1, (QLatin1String("curve1"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strCurve2, (QLatin1String("curve2"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strModelingPath, (QLatin1String("modelingPath"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strModelingSpline, (QLatin1String("modelingSpline"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, strPointFromArcAndTangent, (QLatin1String("pointFromArcAndTangent"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strPointOfIntersectionArcs, (QLatin1String("pointOfIntersectionArcs"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strFirstArc, (QLatin1String("firstArc"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strSecondArc, (QLatin1String("secondArc"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strDetail, (QLatin1String("detail"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strPointOfIntersectionArcs, + (QLatin1String("pointOfIntersectionArcs"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strFirstArc, (QLatin1String("firstArc"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strSecondArc, (QLatin1String("secondArc"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strDetail, (QLatin1String("detail"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, strSupplement, (QLatin1String("supplement"))) // NOLINT -//Q_GLOBAL_STATIC_WITH_ARGS(const QString, strClosed, (QLatin1String("closed"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strWidth, (QLatin1String("width"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strHeight, (QLatin1String("height"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strNode, (QLatin1String("node"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strNodes, (QLatin1String("nodes"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strData, (QLatin1String("data"))) // NOLINT +// Q_GLOBAL_STATIC_WITH_ARGS(const QString, strClosed, (QLatin1String("closed"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strWidth, (QLatin1String("width"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strHeight, (QLatin1String("height"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strNode, (QLatin1String("node"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strNodes, (QLatin1String("nodes"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strData, (QLatin1String("data"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, strPatternInfo, (QLatin1String("patternInfo"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strGrainline, (QLatin1String("grainline"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strReverse, (QLatin1String("reverse"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strMx, (QLatin1String("mx"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strMy, (QLatin1String("my"))) // NOLINT -//Q_GLOBAL_STATIC_WITH_ARGS(const QString, strForbidFlipping, (QLatin1String("forbidFlipping"))) // NOLINT -//Q_GLOBAL_STATIC_WITH_ARGS(const QString, strInLayout, (QLatin1String("inLayout"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strGrainline, (QLatin1String("grainline"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strReverse, (QLatin1String("reverse"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strMx, (QLatin1String("mx"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strMy, (QLatin1String("my"))) // NOLINT +// Q_GLOBAL_STATIC_WITH_ARGS(const QString, strForbidFlipping, (QLatin1String("forbidFlipping"))) // NOLINT +// Q_GLOBAL_STATIC_WITH_ARGS(const QString, strInLayout, (QLatin1String("inLayout"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, strSeamAllowance, (QLatin1String("seamAllowance"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strUUID, (QLatin1String("uuid"))) // NOLINT -//Q_GLOBAL_STATIC_WITH_ARGS(const QString, strNodeType, (QLatin1String("nodeType"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strDet, (QLatin1String("det"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strTypeObject, (QLatin1String("typeObject"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strReadOnly, (QLatin1String("readOnly"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strPatternLabel, (QLatin1String("patternLabel"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strImage, (QLatin1String("image"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strAuthor, (QLatin1String("author"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strDescription, (QLatin1String("description"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strNotes, (QLatin1String("notes"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strGradation, (QLatin1String("gradation"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strPatternName, (QLatin1String("patternName"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strPatternNum, (QLatin1String("patternNumber"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strCompanyName, (QLatin1String("company"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strCustomerName, (QLatin1String("customer"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strLine, (QLatin1String("line"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strText, (QLatin1String("text"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strBold, (QLatin1String("bold"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strItalic, (QLatin1String("italic"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strAlignment, (QLatin1String("alignment"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strFSIncrement, (QLatin1String("sfIncrement"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strShowDate, (QLatin1String("showDate"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strUUID, (QLatin1String("uuid"))) // NOLINT +// Q_GLOBAL_STATIC_WITH_ARGS(const QString, strNodeType, (QLatin1String("nodeType"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strDet, (QLatin1String("det"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strTypeObject, (QLatin1String("typeObject"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strReadOnly, (QLatin1String("readOnly"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strPatternLabel, (QLatin1String("patternLabel"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strImage, (QLatin1String("image"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strAuthor, (QLatin1String("author"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strDescription, (QLatin1String("description"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strNotes, (QLatin1String("notes"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strGradation, (QLatin1String("gradation"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strPatternName, (QLatin1String("patternName"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strPatternNum, (QLatin1String("patternNumber"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strCompanyName, (QLatin1String("company"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strCustomerName, (QLatin1String("customer"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strLine, (QLatin1String("line"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strText, (QLatin1String("text"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strBold, (QLatin1String("bold"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strItalic, (QLatin1String("italic"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strAlignment, (QLatin1String("alignment"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strFSIncrement, (QLatin1String("sfIncrement"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strShowDate, (QLatin1String("showDate"))) // NOLINT Q_GLOBAL_STATIC_WITH_ARGS(const QString, strShowMeasurements, (QLatin1String("showMeasurements"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strSize, (QLatin1String("size"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strMCP, (QLatin1String("mcp"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strLetter, (QLatin1String("letter"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strMaterial , (QLatin1String("material"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strUserDefined, (QLatin1String("userDef"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strPlacement, (QLatin1String("placement"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strCutNumber, (QLatin1String("cutNumber"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strQuantity, (QLatin1String("quantity"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strExtension, (QLatin1String("extension"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strContentType, (QLatin1String("contentType"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strFirstToCountour, (QLatin1String("firstToCountour"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strFirstToContour, (QLatin1String("firstToContour"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strLastToCountour, (QLatin1String("lastToCountour"))) // NOLINT -Q_GLOBAL_STATIC_WITH_ARGS(const QString, strLastToContour, (QLatin1String("lastToContour"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strSize, (QLatin1String("size"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strMCP, (QLatin1String("mcp"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strLetter, (QLatin1String("letter"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strMaterial, (QLatin1String("material"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strUserDefined, (QLatin1String("userDef"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strPlacement, (QLatin1String("placement"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strCutNumber, (QLatin1String("cutNumber"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strQuantity, (QLatin1String("quantity"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strExtension, (QLatin1String("extension"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strContentType, (QLatin1String("contentType"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strFirstToCountour, (QLatin1String("firstToCountour"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strFirstToContour, (QLatin1String("firstToContour"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strLastToCountour, (QLatin1String("lastToCountour"))) // NOLINT +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strLastToContour, (QLatin1String("lastToContour"))) // NOLINT + +QT_WARNING_POP } // anonymous namespace //--------------------------------------------------------------------------------------------------------------------- VPatternConverter::VPatternConverter(const QString &fileName) - : VAbstractConverter(fileName) + : VAbstractConverter(fileName) { m_ver = GetFormatVersion(GetFormatVersionStr()); ValidateInputFile(CurrentSchema); @@ -183,8 +194,7 @@ VPatternConverter::VPatternConverter(const QString &fileName) //--------------------------------------------------------------------------------------------------------------------- auto VPatternConverter::XSDSchemas() -> QHash { - static const auto schemas = QHash - { + static const auto schemas = QHash{ std::make_pair(FormatVersion(0, 1, 4), QStringLiteral("://schema/pattern/v0.1.4.xsd")), std::make_pair(FormatVersion(0, 2, 0), QStringLiteral("://schema/pattern/v0.2.0.xsd")), std::make_pair(FormatVersion(0, 2, 1), QStringLiteral("://schema/pattern/v0.2.1.xsd")), @@ -252,8 +262,7 @@ auto VPatternConverter::XSDSchemas() -> QHash std::make_pair(FormatVersion(0, 8, 13), QStringLiteral("://schema/pattern/v0.8.13.xsd")), std::make_pair(FormatVersion(0, 9, 0), QStringLiteral("://schema/pattern/v0.9.0.xsd")), std::make_pair(FormatVersion(0, 9, 1), QStringLiteral("://schema/pattern/v0.9.1.xsd")), - std::make_pair(FormatVersion(0, 9, 2), CurrentSchema) - }; + std::make_pair(FormatVersion(0, 9, 2), CurrentSchema)}; return schemas; } @@ -391,8 +400,7 @@ void VPatternConverter::DowngradeToCurrentMaxVersion() auto VPatternConverter::IsReadOnly() const -> bool { // Check if attribute readOnly was not changed in file format - Q_STATIC_ASSERT_X(VPatternConverter::PatternMaxVer == FormatVersion(0, 9, 2), - "Check attribute readOnly."); + Q_STATIC_ASSERT_X(VPatternConverter::PatternMaxVer == FormatVersion(0, 9, 2), "Check attribute readOnly."); // Possibly in future attribute readOnly will change position etc. // For now position is the same for all supported format versions. @@ -418,14 +426,13 @@ auto VPatternConverter::Schemas() const -> QHash void VPatternConverter::ToV0_2_0() { // TODO. Delete if minimal supported version is 0.2.0 - Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 2, 0), - "Time to refactor the code."); + Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 2, 0), "Time to refactor the code."); SetVersion(QStringLiteral("0.2.0")); TagUnitToV0_2_0(); TagIncrementToV0_2_0(); ConvertMeasurementsToV0_2_0(); - TagMeasurementsToV0_2_0();//Alwayse last!!! + TagMeasurementsToV0_2_0(); // Alwayse last!!! Save(); } @@ -433,8 +440,7 @@ void VPatternConverter::ToV0_2_0() void VPatternConverter::ToV0_2_1() { // TODO. Delete if minimal supported version is 0.2.1 - Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 2, 1), - "Time to refactor the code."); + Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 2, 1), "Time to refactor the code."); SetVersion(QStringLiteral("0.2.1")); ConvertMeasurementsToV0_2_1(); @@ -445,8 +451,7 @@ void VPatternConverter::ToV0_2_1() void VPatternConverter::ToV0_2_4() { // TODO. Delete if minimal supported version is 0.2.4 - Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 2, 4), - "Time to refactor the code."); + Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 2, 4), "Time to refactor the code."); FixToolUnionToV0_2_4(); SetVersion(QStringLiteral("0.2.4")); @@ -457,10 +462,9 @@ void VPatternConverter::ToV0_2_4() void VPatternConverter::ToV0_3_0() { // TODO. Delete if minimal supported version is 0.3.0 - Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 3, 0), - "Time to refactor the code."); + Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 3, 0), "Time to refactor the code."); - //Cutting path do not create anymore subpaths + // Cutting path do not create anymore subpaths FixCutPoint(); FixCutPoint(); SetVersion(QStringLiteral("0.3.0")); @@ -471,8 +475,7 @@ void VPatternConverter::ToV0_3_0() void VPatternConverter::ToV0_3_1() { // TODO. Delete if minimal supported version is 0.3.1 - Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 3, 1), - "Time to refactor the code."); + Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 3, 1), "Time to refactor the code."); SetVersion(QStringLiteral("0.3.1")); RemoveColorToolCutV0_3_1(); @@ -483,8 +486,7 @@ void VPatternConverter::ToV0_3_1() void VPatternConverter::ToV0_4_0() { // TODO. Delete if minimal supported version is 0.4.0 - Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 4, 0), - "Time to refactor the code."); + Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 4, 0), "Time to refactor the code."); SetVersion(QStringLiteral("0.4.0")); TagRemoveAttributeTypeObjectInV0_4_0(); @@ -497,8 +499,7 @@ void VPatternConverter::ToV0_4_0() void VPatternConverter::ToV0_4_4() { // TODO. Delete if minimal supported version is 0.4.4 - Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 4, 4), - "Time to refactor the code."); + Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 4, 4), "Time to refactor the code."); SetVersion(QStringLiteral("0.4.4")); LabelTagToV0_4_4(*strData); @@ -510,8 +511,7 @@ void VPatternConverter::ToV0_4_4() void VPatternConverter::ToV0_6_0() { // TODO. Delete if minimal supported version is 0.6.0 - Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 6, 0), - "Time to refactor the code."); + Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 6, 0), "Time to refactor the code."); SetVersion(QStringLiteral("0.6.0")); QDomElement label = AddTagPatternLabelV0_5_1(); PortPatternLabeltoV0_6_0(label); @@ -524,8 +524,7 @@ void VPatternConverter::ToV0_6_0() void VPatternConverter::ToV0_6_2() { // TODO. Delete if minimal supported version is 0.6.2 - Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 6, 2), - "Time to refactor the code."); + Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 6, 2), "Time to refactor the code."); SetVersion(QStringLiteral("0.6.2")); AddTagPreviewCalculationsV0_6_2(); Save(); @@ -535,8 +534,7 @@ void VPatternConverter::ToV0_6_2() void VPatternConverter::ToV0_8_8() { // TODO. Delete if minimal supported version is 0.8.8 - Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 8, 8), - "Time to refactor the code."); + Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 8, 8), "Time to refactor the code."); SetVersion(QStringLiteral("0.8.8")); RemoveGradationV0_8_8(); AddPieceUUIDV0_8_8(); @@ -547,8 +545,7 @@ void VPatternConverter::ToV0_8_8() void VPatternConverter::ToV0_9_0() { // TODO. Delete if minimal supported version is 0.9.0 - Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 9, 0), - "Time to refactor the code."); + Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 9, 0), "Time to refactor the code."); ConvertImageToV0_9_0(); @@ -560,8 +557,7 @@ void VPatternConverter::ToV0_9_0() void VPatternConverter::ToV0_9_1() { // TODO. Delete if minimal supported version is 0.9.1 - Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 9, 1), - "Time to refactor the code."); + Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 9, 1), "Time to refactor the code."); ConvertMeasurementsPathToV0_9_1(); SetVersion(QStringLiteral("0.9.1")); @@ -572,8 +568,7 @@ void VPatternConverter::ToV0_9_1() void VPatternConverter::ToV0_9_2() { // TODO. Delete if minimal supported version is 0.9.2 - Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 9, 2), - "Time to refactor the code."); + Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 9, 2), "Time to refactor the code."); ConvertPathAttributesToV0_9_2(); SetVersion(QStringLiteral("0.9.2")); @@ -584,8 +579,7 @@ void VPatternConverter::ToV0_9_2() void VPatternConverter::TagUnitToV0_2_0() { // TODO. Delete if minimal supported version is 0.2.0 - Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 2, 0), - "Time to refactor the code."); + Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 2, 0), "Time to refactor the code."); QDomElement patternElement = documentElement(); patternElement.insertAfter(CreateElementWithText(*strUnit, MUnitV0_1_4()), @@ -596,8 +590,7 @@ void VPatternConverter::TagUnitToV0_2_0() void VPatternConverter::TagIncrementToV0_2_0() { // TODO. Delete if minimal supported version is 0.2.0 - Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 2, 0), - "Time to refactor the code."); + Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 2, 0), "Time to refactor the code."); const QSet names = FixIncrementsToV0_2_0(); @@ -610,8 +603,7 @@ void VPatternConverter::TagIncrementToV0_2_0() void VPatternConverter::ConvertMeasurementsToV0_2_0() { // TODO. Delete if minimal supported version is 0.2.0 - Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 2, 0), - "Time to refactor the code."); + Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 2, 0), "Time to refactor the code."); const QMap names = OldNamesToNewNames_InV0_2_0(); ConvertPointExpressionsToV0_2_0(names); @@ -623,8 +615,7 @@ void VPatternConverter::ConvertMeasurementsToV0_2_0() auto VPatternConverter::FixIncrementsToV0_2_0() -> QSet { // TODO. Delete if minimal supported version is 0.2.0 - Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 2, 0), - "Time to refactor the code."); + Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 2, 0), "Time to refactor the code."); QSet names; const QDomElement incr = TagIncrementsV0_1_4(); @@ -642,7 +633,7 @@ auto VPatternConverter::FixIncrementsToV0_2_0() -> QSet { const QString name = GetParametrString(domElement, *strName); names.insert(name); - domElement.setAttribute(*strName, QLatin1String("#")+name); + domElement.setAttribute(*strName, QLatin1String("#") + name); const QString base = GetParametrString(domElement, *strBase); domElement.setAttribute(*strFormula, base); @@ -669,12 +660,11 @@ auto VPatternConverter::FixIncrementsToV0_2_0() -> QSet void VPatternConverter::FixPointExpressionsToV0_2_0(const QSet &names) { // TODO. Delete if minimal supported version is 0.2.0 - Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 2, 0), - "Time to refactor the code."); + Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 2, 0), "Time to refactor the code."); QString formula; const QDomNodeList list = elementsByTagName(*strPoint); - for (int i=0; i < list.size(); ++i) + for (int i = 0; i < list.size(); ++i) { QDomElement dom = list.at(i).toElement(); @@ -733,12 +723,11 @@ void VPatternConverter::FixPointExpressionsToV0_2_0(const QSet &names) void VPatternConverter::FixArcExpressionsToV0_2_0(const QSet &names) { // TODO. Delete if minimal supported version is 0.2.0 - Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 2, 0), - "Time to refactor the code."); + Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 2, 0), "Time to refactor the code."); QString formula; const QDomNodeList list = elementsByTagName(*strArc); - for (int i=0; i < list.size(); ++i) + for (int i = 0; i < list.size(); ++i) { QDomElement dom = list.at(i).toElement(); @@ -788,12 +777,11 @@ void VPatternConverter::FixArcExpressionsToV0_2_0(const QSet &names) void VPatternConverter::FixPathPointExpressionsToV0_2_0(const QSet &names) { // TODO. Delete if minimal supported version is 0.2.0 - Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 2, 0), - "Time to refactor the code."); + Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 2, 0), "Time to refactor the code."); QString formula; const QDomNodeList list = elementsByTagName(*strPathPoint); - for (int i=0; i < list.size(); ++i) + for (int i = 0; i < list.size(); ++i) { QDomElement dom = list.at(i).toElement(); @@ -833,12 +821,11 @@ void VPatternConverter::FixPathPointExpressionsToV0_2_0(const QSet &nam void VPatternConverter::ConvertPointExpressionsToV0_2_0(const QMap &names) { // TODO. Delete if minimal supported version is 0.2.0 - Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 2, 0), - "Time to refactor the code."); + Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 2, 0), "Time to refactor the code."); QString formula; const QDomNodeList list = elementsByTagName(*strPoint); - for (int i=0; i < list.size(); ++i) + for (int i = 0; i < list.size(); ++i) { QDomElement dom = list.at(i).toElement(); @@ -897,12 +884,11 @@ void VPatternConverter::ConvertPointExpressionsToV0_2_0(const QMap &names) { // TODO. Delete if minimal supported version is 0.2.0 - Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 2, 0), - "Time to refactor the code."); + Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 2, 0), "Time to refactor the code."); QString formula; const QDomNodeList list = elementsByTagName(*strArc); - for (int i=0; i < list.size(); ++i) + for (int i = 0; i < list.size(); ++i) { QDomElement dom = list.at(i).toElement(); @@ -952,12 +938,11 @@ void VPatternConverter::ConvertArcExpressionsToV0_2_0(const QMap &names) { // TODO. Delete if minimal supported version is 0.2.0 - Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 2, 0), - "Time to refactor the code."); + Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 2, 0), "Time to refactor the code."); QString formula; const QDomNodeList list = elementsByTagName(*strPathPoint); - for (int i=0; i < list.size(); ++i) + for (int i = 0; i < list.size(); ++i) { QDomElement dom = list.at(i).toElement(); @@ -998,17 +983,16 @@ auto VPatternConverter::FixMeasurementInFormulaToV0_2_0(const QString &formula, -> QString { // TODO. Delete if minimal supported version is 0.2.0 - Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 2, 0), - "Time to refactor the code."); + Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 2, 0), "Time to refactor the code."); - QScopedPointer cal(new qmu::QmuTokenParser(formula, false, false));// Eval formula - QMap tokens = cal->GetTokens();// Tokens (variables, measurements) + QScopedPointer cal(new qmu::QmuTokenParser(formula, false, false)); // Eval formula + QMap tokens = cal->GetTokens(); // Tokens (variables, measurements) cal.reset(); - QList tKeys = tokens.keys();// Take all tokens positions + QList tKeys = tokens.keys(); // Take all tokens positions QList tValues = tokens.values(); - QString newFormula = formula;// Local copy for making changes + QString newFormula = formula; // Local copy for making changes for (int i = 0; i < tValues.size(); ++i) { if (not names.contains(tValues.at(i))) @@ -1019,7 +1003,7 @@ auto VPatternConverter::FixMeasurementInFormulaToV0_2_0(const QString &formula, vsizetype bias = 0; Replace(newFormula, names.value(tValues.at(i)), tKeys.at(i), tValues.at(i), bias); if (bias != 0) - {// Translated token has different length than original. Position next tokens need to be corrected. + { // Translated token has different length than original. Position next tokens need to be corrected. CorrectionsPositions(tKeys.at(i), bias, tokens); tKeys = tokens.keys(); tValues = tokens.values(); @@ -1032,17 +1016,16 @@ auto VPatternConverter::FixMeasurementInFormulaToV0_2_0(const QString &formula, auto VPatternConverter::FixIncrementInFormulaToV0_2_0(const QString &formula, const QSet &names) -> QString { // TODO. Delete if minimal supported version is 0.2.0 - Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 2, 0), - "Time to refactor the code."); + Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 2, 0), "Time to refactor the code."); - qmu::QmuTokenParser *cal = new qmu::QmuTokenParser(formula, false, false);// Eval formula - QMap tokens = cal->GetTokens();// Tokens (variables, measurements) + qmu::QmuTokenParser *cal = new qmu::QmuTokenParser(formula, false, false); // Eval formula + QMap tokens = cal->GetTokens(); // Tokens (variables, measurements) delete cal; - QList tKeys = tokens.keys();// Take all tokens positions + QList tKeys = tokens.keys(); // Take all tokens positions QList tValues = tokens.values(); - QString newFormula = formula;// Local copy for making changes + QString newFormula = formula; // Local copy for making changes for (vsizetype i = 0; i < tValues.size(); ++i) { if (not names.contains(tValues.at(i))) @@ -1051,9 +1034,9 @@ auto VPatternConverter::FixIncrementInFormulaToV0_2_0(const QString &formula, co } vsizetype bias = 0; - Replace(newFormula, "#"+tValues.at(i), tKeys.at(i), tValues.at(i), bias); + Replace(newFormula, "#" + tValues.at(i), tKeys.at(i), tValues.at(i), bias); if (bias != 0) - {// Translated token has different length than original. Position next tokens need to be corrected. + { // Translated token has different length than original. Position next tokens need to be corrected. CorrectionsPositions(tKeys.at(i), bias, tokens); tKeys = tokens.keys(); tValues = tokens.values(); @@ -1066,8 +1049,7 @@ auto VPatternConverter::FixIncrementInFormulaToV0_2_0(const QString &formula, co void VPatternConverter::TagMeasurementsToV0_2_0() { // TODO. Delete if minimal supported version is 0.2.0 - Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 2, 0), - "Time to refactor the code."); + Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 2, 0), "Time to refactor the code."); QDomElement ms = TagMeasurementsV0_1_4(); const QString path = GetParametrString(ms, *strPath); @@ -1083,8 +1065,7 @@ void VPatternConverter::TagMeasurementsToV0_2_0() void VPatternConverter::ConvertMeasurementsToV0_2_1() { // TODO. Delete if minimal supported version is 0.2.1 - Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 2, 1), - "Time to refactor the code."); + Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 2, 1), "Time to refactor the code."); const QMap names = OldNamesToNewNames_InV0_2_1(); @@ -1098,11 +1079,10 @@ void VPatternConverter::ConvertMeasurementsToV0_2_1() void VPatternConverter::RemoveColorToolCutV0_3_1() { // TODO. Delete if minimal supported version is 0.3.1 - Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 3, 1), - "Time to refactor the code."); + Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 3, 1), "Time to refactor the code."); const QDomNodeList list = elementsByTagName(*strPoint); - for (int i=0; i < list.size(); ++i) + for (int i = 0; i < list.size(); ++i) { QDomElement element = list.at(i).toElement(); if (not element.isNull()) @@ -1120,8 +1100,7 @@ void VPatternConverter::RemoveColorToolCutV0_3_1() auto VPatternConverter::MUnitV0_1_4() const -> QString { // TODO. Delete if minimal supported version is 0.2.0 - Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 2, 0), - "Time to refactor the code."); + Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 2, 0), "Time to refactor the code."); const QDomElement element = TagMeasurementsV0_1_4(); try @@ -1140,8 +1119,7 @@ auto VPatternConverter::MUnitV0_1_4() const -> QString auto VPatternConverter::TagMeasurementsV0_1_4() const -> QDomElement { // TODO. Delete if minimal supported version is 0.2.0 - Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 2, 0), - "Time to refactor the code."); + Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 2, 0), "Time to refactor the code."); const QDomNodeList list = elementsByTagName(*strMeasurements); const QDomElement element = list.at(0).toElement(); @@ -1157,8 +1135,7 @@ auto VPatternConverter::TagMeasurementsV0_1_4() const -> QDomElement auto VPatternConverter::TagIncrementsV0_1_4() const -> QDomElement { // TODO. Delete if minimal supported version is 0.2.0 - Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 2, 0), - "Time to refactor the code."); + Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 2, 0), "Time to refactor the code."); const QDomNodeList list = elementsByTagName(*strIncrements); const QDomElement element = list.at(0).toElement(); @@ -1174,12 +1151,11 @@ auto VPatternConverter::TagIncrementsV0_1_4() const -> QDomElement void VPatternConverter::FixToolUnionToV0_2_4() { // TODO. Delete if minimal supported version is 0.2.4 - Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 2, 4), - "Time to refactor the code."); + Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 2, 4), "Time to refactor the code."); QDomElement root = documentElement(); const QDomNodeList modelings = root.elementsByTagName(*strModeling); - for (int i=0; i &children) { // TODO. Delete if minimal supported version is 0.2.4 - Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 2, 4), - "Time to refactor the code."); + Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 2, 4), "Time to refactor the code."); QDomElement toolUnion = elementById(id); if (toolUnion.isNull()) @@ -1251,8 +1225,7 @@ void VPatternConverter::SaveChildrenToolUnionToV0_2_4(quint32 id, const QVector< auto VPatternConverter::OldNamesToNewNames_InV0_2_0() -> QMap { // TODO. Delete if minimal supported version is 0.2.0 - Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 2, 0), - "Time to refactor the code."); + Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 2, 0), "Time to refactor the code."); // old name, new name QMap names; @@ -1431,8 +1404,7 @@ auto VPatternConverter::OldNamesToNewNames_InV0_2_0() -> QMap auto VPatternConverter::OldNamesToNewNames_InV0_2_1() -> QMap { // TODO. Delete if minimal supported version is 0.2.1 - Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 2, 1), - "Time to refactor the code."); + Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 2, 1), "Time to refactor the code."); // old name, new name QMap names; @@ -1446,34 +1418,32 @@ auto VPatternConverter::OldNamesToNewNames_InV0_2_1() -> QMap //--------------------------------------------------------------------------------------------------------------------- void VPatternConverter::FixCutPoint() { - const QStringList types = QStringList() << *strCutSplinePath - << *strCutSpline - << *strCutArc; + const QStringList types = QStringList() << *strCutSplinePath << *strCutSpline << *strCutArc; const QDomNodeList list = elementsByTagName(*strPoint); - for (int i=0; i < list.size(); ++i) + for (int i = 0; i < list.size(); ++i) { QDomElement element = list.at(i).toElement(); if (not element.isNull()) { const QString type = element.attribute(*strType); - switch(types.indexOf(type)) + switch (types.indexOf(type)) { - case 0: //strCutSplinePath + case 0: // strCutSplinePath { const quint32 id = element.attribute(*strId).toUInt(); quint32 curve = element.attribute(*strSplinePath).toUInt(); FixSubPaths(i, id, curve); break; } - case 1: //strCutSpline + case 1: // strCutSpline { const quint32 id = element.attribute(*strId).toUInt(); quint32 curve = element.attribute(*strSpline).toUInt(); FixSubPaths(i, id, curve); break; } - case 2: //strCutArc + case 2: // strCutArc { const quint32 id = element.attribute(*strId).toUInt(); quint32 curve = element.attribute(*strArc).toUInt(); @@ -1490,83 +1460,80 @@ void VPatternConverter::FixCutPoint() //--------------------------------------------------------------------------------------------------------------------- void VPatternConverter::FixSubPaths(int i, quint32 id, quint32 baseCurve) { - const QStringList pointTypes = QStringList() << *strCutSplinePath - << *strCutSpline - << *strPointOfIntersectionCurves - << *strCurveIntersectAxis - << *strPointFromArcAndTangent + const QStringList pointTypes = QStringList() << *strCutSplinePath << *strCutSpline << *strPointOfIntersectionCurves + << *strCurveIntersectAxis << *strPointFromArcAndTangent << *strPointOfIntersectionArcs; const QDomNodeList listPoints = elementsByTagName(*strPoint); - for (int j = i+1; j < listPoints.size(); ++j) + for (int j = i + 1; j < listPoints.size(); ++j) { QDomElement element = listPoints.at(j).toElement(); if (not element.isNull()) { const QString type = element.attribute(*strType); - switch(pointTypes.indexOf(type)) + switch (pointTypes.indexOf(type)) { - case 0: //strCutSplinePath + case 0: // strCutSplinePath { const quint32 spl = element.attribute(*strSplinePath).toUInt(); - if (spl == id+1 || spl == id+2) + if (spl == id + 1 || spl == id + 2) { element.setAttribute(*strSplinePath, baseCurve); } break; } - case 1: //strCutSpline + case 1: // strCutSpline { const quint32 spl = element.attribute(*strSpline).toUInt(); - if (spl == id+1 || spl == id+2) + if (spl == id + 1 || spl == id + 2) { element.setAttribute(*strSpline, baseCurve); } break; } - case 2: //strPointOfIntersectionCurves + case 2: // strPointOfIntersectionCurves { quint32 spl = element.attribute(*strCurve1).toUInt(); - if (spl == id+1 || spl == id+2) + if (spl == id + 1 || spl == id + 2) { element.setAttribute(*strCurve1, baseCurve); } spl = element.attribute(*strCurve2).toUInt(); - if (spl == id+1 || spl == id+2) + if (spl == id + 1 || spl == id + 2) { element.setAttribute(*strCurve2, baseCurve); } break; } - case 3: //strCurveIntersectAxis + case 3: // strCurveIntersectAxis { const quint32 spl = element.attribute(*strCurve).toUInt(); - if (spl == id+1 || spl == id+2) + if (spl == id + 1 || spl == id + 2) { element.setAttribute(*strCurve, baseCurve); } break; } - case 4: //strPointFromArcAndTangent + case 4: // strPointFromArcAndTangent { const quint32 spl = element.attribute(*strArc).toUInt(); - if (spl == id+1 || spl == id+2) + if (spl == id + 1 || spl == id + 2) { element.setAttribute(*strArc, baseCurve); } break; } - case 5: //strPointOfIntersectionArcs + case 5: // strPointOfIntersectionArcs { quint32 arc = element.attribute(*strFirstArc).toUInt(); - if (arc == id+1 || arc == id+2) + if (arc == id + 1 || arc == id + 2) { element.setAttribute(*strFirstArc, baseCurve); } arc = element.attribute(*strSecondArc).toUInt(); - if (arc == id+1 || arc == id+2) + if (arc == id + 1 || arc == id + 2) { element.setAttribute(*strSecondArc, baseCurve); } @@ -1578,8 +1545,7 @@ void VPatternConverter::FixSubPaths(int i, quint32 id, quint32 baseCurve) } } - const QStringList splTypes = QStringList() << *strModelingPath - << *strModelingSpline; + const QStringList splTypes = QStringList() << *strModelingPath << *strModelingSpline; const QDomNodeList listSplines = elementsByTagName(*strSpline); for (int j = 0; j < listSplines.size(); ++j) @@ -1588,13 +1554,13 @@ void VPatternConverter::FixSubPaths(int i, quint32 id, quint32 baseCurve) if (not element.isNull()) { const QString type = element.attribute(*strType); - switch(splTypes.indexOf(type)) + switch (splTypes.indexOf(type)) { - case 0: //strModelingPath - case 1: //strModelingSpline + case 0: // strModelingPath + case 1: // strModelingSpline { const quint32 spl = element.attribute(*strIdObject).toUInt(); - if (spl == id+1 || spl == id+2) + if (spl == id + 1 || spl == id + 2) { element.setAttribute(*strIdObject, baseCurve); } @@ -1616,7 +1582,7 @@ void VPatternConverter::FixSubPaths(int i, quint32 id, quint32 baseCurve) if (type == *strModeling) { const quint32 arc = element.attribute(*strIdObject).toUInt(); - if (arc == id+1 || arc == id+2) + if (arc == id + 1 || arc == id + 2) { element.setAttribute(*strIdObject, baseCurve); } @@ -1629,8 +1595,7 @@ void VPatternConverter::FixSubPaths(int i, quint32 id, quint32 baseCurve) void VPatternConverter::TagRemoveAttributeTypeObjectInV0_4_0() { // TODO. Delete if minimal supported version is 0.4.0 - Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 4, 0), - "Time to refactor the code."); + Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 4, 0), "Time to refactor the code."); const QDomNodeList list = elementsByTagName(*strModeling); for (int i = 0; i < list.size(); ++i) @@ -1659,11 +1624,10 @@ void VPatternConverter::TagRemoveAttributeTypeObjectInV0_4_0() void VPatternConverter::TagDetailToV0_4_0() { // TODO. Delete if minimal supported version is 0.4.0 - Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 4, 0), - "Time to refactor the code."); + Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 4, 0), "Time to refactor the code."); const QDomNodeList list = elementsByTagName(*strDetail); - for (int i=0; i < list.size(); ++i) + for (int i = 0; i < list.size(); ++i) { QDomElement dom = list.at(i).toElement(); @@ -1689,7 +1653,7 @@ void VPatternConverter::TagDetailToV0_4_0() { switch (tags.indexOf(element.tagName())) { - case 0://strNode + case 0: // strNode { QDomElement tagNode = createElement(*strNode); @@ -1716,13 +1680,13 @@ void VPatternConverter::TagDetailToV0_4_0() break; } - case 1://strData + case 1: // strData tagData = element.cloneNode().toElement(); break; - case 2://strPatternInfo + case 2: // strPatternInfo tagPatternInfo = element.cloneNode().toElement(); break; - case 3://strGrainline + case 3: // strGrainline tagGrainline = element.cloneNode().toElement(); break; default: @@ -1799,20 +1763,21 @@ auto VPatternConverter::GetUnionChildrenNodesV0_4_0(const QDomElement &detail) - void VPatternConverter::LabelTagToV0_4_4(const QString &tagName) { // TODO. Delete if minimal supported version is 0.4.4 - Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 4, 4), - "Time to refactor the code."); + Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 4, 4), "Time to refactor the code."); Unit unit = Unit::Cm; - const QStringList units = QStringList() << "mm" << "cm" << "inch"; + const QStringList units = QStringList() << "mm" + << "cm" + << "inch"; switch (units.indexOf(UniqueTagText(*strUnit))) { - case 0:// mm + case 0: // mm unit = Unit::Mm; break; - case 1:// cm + case 1: // cm unit = Unit::Cm; break; - case 2:// in + case 2: // in unit = Unit::Inch; break; default: @@ -1835,7 +1800,7 @@ void VPatternConverter::LabelTagToV0_4_4(const QString &tagName) }; const QDomNodeList list = elementsByTagName(tagName); - for (int i=0; i < list.size(); ++i) + for (int i = 0; i < list.size(); ++i) { QDomElement dom = list.at(i).toElement(); @@ -1851,27 +1816,18 @@ void VPatternConverter::LabelTagToV0_4_4(const QString &tagName) auto VPatternConverter::AddTagPatternLabelV0_5_1() -> QDomElement { // TODO. Delete if minimal supported version is 0.6.0 - Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 6, 0), - "Time to refactor the code."); + Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 6, 0), "Time to refactor the code."); const QDomNodeList list = elementsByTagName(*strPatternLabel); if (list.isEmpty()) { - const QStringList tags = QStringList() << *strUnit - << *strImage - << *strAuthor - << *strDescription - << *strNotes - << *strGradation - << *strPatternName - << *strPatternNum - << *strCompanyName - << *strCustomerName - << *strPatternLabel; + const QStringList tags = QStringList() << *strUnit << *strImage << *strAuthor << *strDescription << *strNotes + << *strGradation << *strPatternName << *strPatternNum << *strCompanyName + << *strCustomerName << *strPatternLabel; QDomElement element = createElement(*strPatternLabel); 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()) @@ -1889,8 +1845,7 @@ auto VPatternConverter::AddTagPatternLabelV0_5_1() -> QDomElement void VPatternConverter::PortPatternLabeltoV0_6_0(QDomElement &label) { // TODO. Delete if minimal supported version is 0.6.0 - Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 6, 0), - "Time to refactor the code."); + Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 6, 0), "Time to refactor the code."); if (not UniqueTagText(*strCompanyName).isEmpty()) { @@ -1942,8 +1897,7 @@ void VPatternConverter::AddLabelTemplateLineV0_6_0(QDomElement &label, const QSt int alignment, int fontSizeIncrement) { // TODO. Delete if minimal supported version is 0.6.0 - Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 6, 0), - "Time to refactor the code."); + Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 6, 0), "Time to refactor the code."); QDomElement tagLine = createElement(*strLine); @@ -1960,8 +1914,7 @@ void VPatternConverter::AddLabelTemplateLineV0_6_0(QDomElement &label, const QSt void VPatternConverter::PortPieceLabelstoV0_6_0() { // TODO. Delete if minimal supported version is 0.6.0 - Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 6, 0), - "Time to refactor the code."); + Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 6, 0), "Time to refactor the code."); const QDomNodeList nodeList = elementsByTagName(*strData); for (int i = 0; i < nodeList.size(); ++i) @@ -1976,8 +1929,9 @@ void VPatternConverter::PortPieceLabelstoV0_6_0() AddLabelTemplateLineV0_6_0(dataTag, "%pLetter%", true, false, Qt::AlignHCenter, 6); } } - catch(const VExceptionEmptyParameter &) - {} + catch (const VExceptionEmptyParameter &) + { + } AddLabelTemplateLineV0_6_0(dataTag, "%pName%", true, false, Qt::AlignHCenter, 2); @@ -1991,7 +1945,7 @@ void VPatternConverter::PortPieceLabelstoV0_6_0() QString line; const int material = static_cast(GetParametrUInt(domMCP, *strMaterial, QChar('0'))); - switch(material) + switch (material) { case 0: line.append("%mFabric%"); @@ -2048,8 +2002,7 @@ void VPatternConverter::PortPieceLabelstoV0_6_0() void VPatternConverter::RemoveUnusedTagsV0_6_0() { // TODO. Delete if minimal supported version is 0.6.0 - Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 6, 0), - "Time to refactor the code."); + Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 6, 0), "Time to refactor the code."); RemoveUniqueTagV0_6_0(*strAuthor); RemoveUniqueTagV0_6_0(*strSize); @@ -2072,8 +2025,7 @@ void VPatternConverter::RemoveUnusedTagsV0_6_0() void VPatternConverter::RemoveUniqueTagV0_6_0(const QString &tag) { // TODO. Delete if minimal supported version is 0.6.0 - Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 6, 0), - "Time to refactor the code."); + Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 6, 0), "Time to refactor the code."); const QDomNodeList nodeList = elementsByTagName(tag); if (nodeList.isEmpty()) @@ -2089,8 +2041,7 @@ void VPatternConverter::RemoveUniqueTagV0_6_0(const QString &tag) void VPatternConverter::AddTagPreviewCalculationsV0_6_2() { // TODO. Delete if minimal supported version is 0.6.2 - Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 6, 2), - "Time to refactor the code."); + Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 6, 2), "Time to refactor the code."); const QDomNodeList list = elementsByTagName(*strIncrements); if (not list.isEmpty()) @@ -2118,11 +2069,10 @@ void VPatternConverter::RemoveGradationV0_8_8() void VPatternConverter::AddPieceUUIDV0_8_8() { // TODO. Delete if minimal supported version is 0.8.8 - Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 8, 8), - "Time to refactor the code."); + Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 8, 8), "Time to refactor the code."); const QDomNodeList list = elementsByTagName(*strDetail); - for (int i=0; i < list.size(); ++i) + for (int i = 0; i < list.size(); ++i) { QDomElement dom = list.at(i).toElement(); @@ -2137,8 +2087,7 @@ void VPatternConverter::AddPieceUUIDV0_8_8() void VPatternConverter::ConvertImageToV0_9_0() { // TODO. Delete if minimal supported version is 0.9.0 - Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 9, 0), - "Time to refactor the code."); + Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 9, 0), "Time to refactor the code."); const QDomNodeList list = elementsByTagName(*strImage); if (not list.isEmpty()) @@ -2151,11 +2100,7 @@ void VPatternConverter::ConvertImageToV0_9_0() if (not extension.isEmpty()) { - QMap mimeTypes{ - {"BMP", "image/bmp"}, - {"JPG", "image/jpeg"}, - {"PNG", "image/png"} - }; + QMap mimeTypes{{"BMP", "image/bmp"}, {"JPG", "image/jpeg"}, {"PNG", "image/png"}}; if (mimeTypes.contains(extension)) { @@ -2192,8 +2137,7 @@ void VPatternConverter::ConvertImageToV0_9_0() void VPatternConverter::ConvertMeasurementsPathToV0_9_1() { // TODO. Delete if minimal supported version is 0.9.1 - Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 9, 1), - "Time to refactor the code."); + Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 9, 1), "Time to refactor the code."); const QDomNodeList nodeList = this->elementsByTagName(*strMeasurements); if (nodeList.isEmpty()) @@ -2225,11 +2169,10 @@ void VPatternConverter::ConvertMeasurementsPathToV0_9_1() void VPatternConverter::ConvertPathAttributesToV0_9_2() { // TODO. Delete if minimal supported version is 0.9.2 - Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 9, 2), - "Time to refactor the code."); + Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 9, 2), "Time to refactor the code."); const QDomNodeList paths = this->elementsByTagName(*strPath); - for (int i=0; i < paths.size(); ++i) + for (int i = 0; i < paths.size(); ++i) { QDomElement domElement = paths.at(i).toElement(); @@ -2256,11 +2199,10 @@ void VPatternConverter::ConvertPathAttributesToV0_9_2() void VPatternConverter::TagUnionDetailsToV0_4_0() { // TODO. Delete if minimal supported version is 0.4.0 - Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 4, 0), - "Time to refactor the code."); + Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 4, 0), "Time to refactor the code."); const QDomNodeList list = elementsByTagName(*strTools); - for (int i=0; i < list.size(); ++i) + for (int i = 0; i < list.size(); ++i) { // Tag 'tools' used only for union details, so no need to check any additional attributes QDomElement toolDOM = list.at(i).toElement(); @@ -2279,10 +2221,10 @@ void VPatternConverter::TagUnionDetailsToV0_4_0() { switch (tags.indexOf(element.tagName())) { - case 0://strDet + case 0: // strDet nodes.append(GetUnionDetailNodesV0_4_0(element)); break; - case 1://strChildren + case 1: // strChildren tagChildrenNodes.appendChild(GetUnionChildrenNodesV0_4_0(element)); break; default: diff --git a/src/libs/ifc/xml/vvitconverter.cpp b/src/libs/ifc/xml/vvitconverter.cpp index 24cde02db..1940dd837 100644 --- a/src/libs/ifc/xml/vvitconverter.cpp +++ b/src/libs/ifc/xml/vvitconverter.cpp @@ -32,16 +32,18 @@ #include #include #include +#include #include #include #include #include -#include -#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 { - static auto schemas = QHash - { + static auto schemas = QHash{ 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 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 list = names.values( key ); - for(const auto &val : list) + const QList 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 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(); diff --git a/src/libs/ifc/xml/vvstconverter.cpp b/src/libs/ifc/xml/vvstconverter.cpp index ebd2376d2..5eeb2c804 100644 --- a/src/libs/ifc/xml/vvstconverter.cpp +++ b/src/libs/ifc/xml/vvstconverter.cpp @@ -32,16 +32,19 @@ #include #include #include +#include #include #include #include #include -#include -#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 { - static auto schemas = QHash - { + static auto schemas = QHash{ 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 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 list = names.values( key ); - for(const auto &val : list) + const QList 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 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(); diff --git a/src/libs/vdxf/vdxfengine.cpp b/src/libs/vdxf/vdxfengine.cpp index 7529548ac..df689eff2 100644 --- a/src/libs/vdxf/vdxfengine.cpp +++ b/src/libs/vdxf/vdxfengine.cpp @@ -1,30 +1,30 @@ - /************************************************************************ - ** - ** @file vdxfengine.cpp - ** @author Valentina Zhuravska - ** @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 - ** 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 . - ** - *************************************************************************/ +/************************************************************************ +** +** @file vdxfengine.cpp +** @author Valentina Zhuravska +** @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 +** 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 . +** +*************************************************************************/ #include "vdxfengine.h" #include @@ -54,83 +54,86 @@ #include #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 - { - QVector 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 +{ + QVector 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(new dx_iface(GetFileNameForLocale(), m_version, m_varMeasurement, - m_varInsunits)); + m_input = + QSharedPointer(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 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 &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 &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 &detailBlock } const QVector> 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 &detailBlock } const QVector 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 &detailBlock void VDxfEngine::ExportAAMAIntcut(const QSharedPointer &detailBlock, const VLayoutPiece &detail) { QVector> 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 &detailBloc if (detail.IsSeamAllowance()) { const QVector passmarks = detail.GetMappedPassmarks(); - for(const auto &passmark : passmarks) + for (const auto &passmark : passmarks) { std::unique_ptr notch(new DRW_ASTMNotch()); const QPointF center = passmark.baseLine.p1(); @@ -885,7 +889,7 @@ void VDxfEngine::ExportPieceText(const QSharedPointer &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(list.size()) - i-1)); + QPointF pos(startPos.x(), startPos.y() - height * (static_cast(list.size()) - i - 1)); detailBlock->ent.push_back(AAMAText(pos, list.at(i), *layer1)); } } @@ -893,7 +897,7 @@ void VDxfEngine::ExportPieceText(const QSharedPointer &detailBloc //--------------------------------------------------------------------------------------------------------------------- void VDxfEngine::ExportStyleSystemText(const QSharedPointer &input, const QVector &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 &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(strings.size()) - j-1)); + QPointF pos(0, GetSize().height() - height * (static_cast(strings.size()) - j - 1)); input->AddEntity(AAMAText(pos, strings.at(j), *layer1)); } return; @@ -914,10 +918,10 @@ void VDxfEngine::ExportAAMADrill(const QSharedPointer &detailBloc { const QVector 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 &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(new dx_iface(GetFileNameForLocale(), m_version, m_varMeasurement, - m_varInsunits)); + m_input = + QSharedPointer(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 &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 &detailBl void VDxfEngine::ExportASTMInternalLine(const QSharedPointer &detailBlock, const VLayoutPiece &detail) { const QVector> 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 &det } const QVector 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 &det void VDxfEngine::ExportASTMInternalCutout(const QSharedPointer &detailBlock, const VLayoutPiece &detail) { QVector> 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 &detailBloc { const QVector 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 &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 &detailBloc if (detail.IsSeamAllowance()) { const QVector 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 &detailBloc void VDxfEngine::ExportTurnPoints(const QSharedPointer &detailBlock, const QVector &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 &detailBlo void VDxfEngine::ExportCurvePoints(const QSharedPointer &detailBlock, const QVector &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 &detailBl } //--------------------------------------------------------------------------------------------------------------------- -auto VDxfEngine::AAMAPolygon(const QVector &polygon, const UTF8STRING &layer, - bool forceClosed) -> DRW_Entity * +auto VDxfEngine::AAMAPolygon(const QVector &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 -auto VDxfEngine::CreateAAMAPolygon(const QVector &polygon, const UTF8STRING &layer, - bool forceClosed) -> P * +template +auto VDxfEngine::CreateAAMAPolygon(const QVector &polygon, const UTF8STRING &layer, bool forceClosed) -> P * { auto *poly = new P(); poly->layer = layer; @@ -1355,8 +1358,7 @@ auto VDxfEngine::CreateAAMAPolygon(const QVector &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; diff --git a/src/libs/vdxf/vdxfengine.h b/src/libs/vdxf/vdxfengine.h index 8c7e31f10..0507d625c 100644 --- a/src/libs/vdxf/vdxfengine.h +++ b/src/libs/vdxf/vdxfengine.h @@ -29,13 +29,13 @@ #ifndef VDXFENGINE_H #define VDXFENGINE_H -#include #include #include #include #include #include #include +#include #include #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 &detailBlock, const VLayoutPiece &detail); void ExportASTMNotch(const QSharedPointer &detailBlock, const VLayoutPiece &detail); - void ExportTurnPoints(const QSharedPointer &detailBlock, - const QVector &points) const; - void ExportCurvePoints(const QSharedPointer &detailBlock, - const QVector &points) const; + void ExportTurnPoints(const QSharedPointer &detailBlock, const QVector &points) const; + void ExportCurvePoints(const QSharedPointer &detailBlock, const QVector &points) const; - Q_REQUIRED_RESULT auto AAMAPolygon(const QVector &polygon, const UTF8STRING &layer, - bool forceClosed) -> DRW_Entity *; + Q_REQUIRED_RESULT auto AAMAPolygon(const QVector &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 - Q_REQUIRED_RESULT auto CreateAAMAPolygon(const QVector &polygon, const UTF8STRING &layer, - bool forceClosed) -> P *; + template + Q_REQUIRED_RESULT auto CreateAAMAPolygon(const QVector &polygon, const UTF8STRING &layer, bool forceClosed) + -> P *; static auto FromUnicodeToCodec(const QString &str, VTextCodec *codec) -> std::string; auto GetFileNameForLocale() const -> std::string; diff --git a/src/libs/vdxf/vdxfpaintdevice.cpp b/src/libs/vdxf/vdxfpaintdevice.cpp index c4e7657da..358303fa8 100644 --- a/src/libs/vdxf/vdxfpaintdevice.cpp +++ b/src/libs/vdxf/vdxfpaintdevice.cpp @@ -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()) diff --git a/src/libs/vdxf/vdxfpaintdevice.h b/src/libs/vdxf/vdxfpaintdevice.h index 437088a31..f8a1f6f25 100644 --- a/src/libs/vdxf/vdxfpaintdevice.h +++ b/src/libs/vdxf/vdxfpaintdevice.h @@ -29,11 +29,11 @@ #ifndef VDXFPAINTDEVICE_H #define VDXFPAINTDEVICE_H -#include #include #include #include #include +#include #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 diff --git a/src/libs/vformat/vmeasurements.cpp b/src/libs/vformat/vmeasurements.cpp index 25149df7a..27decb041 100644 --- a/src/libs/vformat/vmeasurements.cpp +++ b/src/libs/vformat/vmeasurements.cpp @@ -28,109 +28,113 @@ #include "vmeasurements.h" -#include #include #include #include #include +#include #include #include #include #include #include -#include +#include -#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 &dimensions, - VContainer *data) - : data(data), - type(MeasurementsType::Multisize) +VMeasurements::VMeasurements(Unit unit, const QVector &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::create(static_cast(i), name, - convertedBaseA, convertedBaseB, convertedBaseC, base); + meash = QSharedPointer::create(static_cast(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(dimenstionsTag, AttrFullCircumference, fc, [](bool fc) noexcept {return not fc;}); + SetAttributeOrRemoveIf(dimenstionsTag, AttrFullCircumference, fc, + [](bool fc) noexcept { return not fc; }); } else { - qDebug()<<"Can't save full circumference "<(node, AttrSpecialUnits, special, [](bool special) noexcept {return not special;}); + SetAttributeOrRemoveIf(node, AttrSpecialUnits, special, + [](bool special) noexcept { return not special; }); } else { @@ -873,7 +878,7 @@ void VMeasurements::SetMDimension(const QString &name, IMD type) { SetAttributeOrRemoveIf(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 +auto VMeasurements::GetRestrictions() const -> QMap { - QMap restrictions; + QMap 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 & SetAttribute(restrictionTag, AttrCoordinates, i.key()); SetAttributeOrRemoveIf(restrictionTag, AttrMin, i.value().GetMin(), - [](qreal min) noexcept {return qFuzzyIsNull(min);}); + [](qreal min) noexcept { return qFuzzyIsNull(min); }); SetAttributeOrRemoveIf(restrictionTag, AttrMax, i.value().GetMax(), - [](qreal max) noexcept {return qFuzzyIsNull(max);}); + [](qreal max) noexcept { return qFuzzyIsNull(max); }); SetAttributeOrRemoveIf(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 & //--------------------------------------------------------------------------------------------------------------------- auto VMeasurements::Restriction(qreal base, qreal base2) const -> VDimensionRestriction { - const QMap restrictions = GetRestrictions(); + const QMap 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 &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 &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(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 &dimensions) +void VMeasurements::CreateEmptyMultisizeFile(Unit unit, const QVector &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 &dimensions) -> QDomElement +auto VMeasurements::CreateDimensions(const QVector &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 &dim SetAttribute(dimensionTag, AttrMax, dimension->MaxValue()); SetAttribute(dimensionTag, AttrStep, dimension->Step()); SetAttributeOrRemoveIf(dimensionTag, AttrMeasurement, dimension->IsBodyMeasurement(), - [](bool m) noexcept {return m;}); + [](bool m) noexcept { return m; }); SetAttributeOrRemoveIf(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) diff --git a/src/libs/vlayout/vlayoutexporter.cpp b/src/libs/vlayout/vlayoutexporter.cpp index 300715f5d..795df4b39 100644 --- a/src/libs/vlayout/vlayoutexporter.cpp +++ b/src/libs/vlayout/vlayoutexporter.cpp @@ -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 QListtype() == QGraphicsSimpleTextItem::Type) { - if(auto *textItem = qgraphicsitem_cast(child)) + if (auto *textItem = qgraphicsitem_cast(child)) { textItem->setText(textItem->text() + placeholder); } @@ -104,7 +113,7 @@ void RestoreDetailsAfterDXF(const QString &placeholder, const QListtype() == QGraphicsSimpleTextItem::Type) { - if(auto *textItem = qgraphicsitem_cast(child)) + if (auto *textItem = qgraphicsitem_cast(child)) { QString text = textItem->text(); text.replace(placeholder, QString()); @@ -114,7 +123,7 @@ void RestoreDetailsAfterDXF(const QString &placeholder, const QList bool @@ -283,7 +292,7 @@ void VLayoutExporter::ExportToFlatDXF(QGraphicsScene *scene, const QList(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 QListrender(&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 &details) cons generator.SetResolution(PrintDPI); generator.SetVersion(static_cast(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 &details) cons generator.SetResolution(PrintDPI); generator.SetVersion(static_cast(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 &details) const QVector 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 ¶ms) QFile f(ConstLast(params)); if (not f.exists()) { - qCritical() << qUtf8Printable(tr("Creating file '%1' failed! %2") - .arg(ConstLast(params), proc.errorString())); + qCritical() << qUtf8Printable( + tr("Creating file '%1' failed! %2").arg(ConstLast(params), proc.errorString())); } } @@ -453,8 +459,8 @@ void VLayoutExporter::ExportToPDF(QGraphicsScene *scene, const QList(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"); diff --git a/src/libs/vlayout/vlayoutexporter.h b/src/libs/vlayout/vlayoutexporter.h index 71f19074a..6e8ed1c7d 100644 --- a/src/libs/vlayout/vlayoutexporter.h +++ b/src/libs/vlayout/vlayoutexporter.h @@ -28,11 +28,11 @@ #ifndef VLAYOUTEXPORTER_H #define VLAYOUTEXPORTER_H +#include #include #include #include #include -#include #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 &details, const QString &filename) const; }; diff --git a/src/libs/vlayout/vlayoutpaper.cpp b/src/libs/vlayout/vlayoutpaper.cpp index 6d4168cc2..709c3640e 100644 --- a/src/libs/vlayout/vlayoutpaper.cpp +++ b/src/libs/vlayout/vlayoutpaper.cpp @@ -333,7 +333,7 @@ auto VLayoutPaper::GetPaperItem(bool autoCropLength, bool autoCropWidth, bool te { QScopedPointer scene(new QGraphicsScene()); QList 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 list; list.reserve(d->details.count()); - for (auto &detail : d->details) + for (const auto &detail : d->details) { list.append(detail.GetItem(textAsPaths)); } diff --git a/src/libs/vlayout/vlayoutpiece.cpp b/src/libs/vlayout/vlayoutpiece.cpp index 180195902..70b9b3e5e 100644 --- a/src/libs/vlayout/vlayoutpiece.cpp +++ b/src/libs/vlayout/vlayoutpiece.cpp @@ -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 +#include namespace { @@ -195,16 +195,19 @@ auto RotatePoint(const QPointF &ptCenter, const QPointF &pt, qreal dAng) -> QPoi //--------------------------------------------------------------------------------------------------------------------- auto PieceLabelText(const QVector &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); diff --git a/src/libs/vlayout/vlayoutpiece.h b/src/libs/vlayout/vlayoutpiece.h index 526aa5d72..2968d64af 100644 --- a/src/libs/vlayout/vlayoutpiece.h +++ b/src/libs/vlayout/vlayoutpiece.h @@ -29,7 +29,7 @@ #ifndef VLAYOUTDETAIL_H #define VLAYOUTDETAIL_H -#include +#include #include #include #include @@ -39,7 +39,6 @@ #include #include #include -#include #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; void SetPlaceLabels(const QVector &labels); - auto MappedInternalPathsForCut(bool cut) const -> QVector >; + auto MappedInternalPathsForCut(bool cut) const -> QVector>; auto GetInternalPaths() const -> QVector; void SetInternalPaths(const QVector &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; void SetPieceLabelRect(const QVector &rect); - auto GetPieceLabelData() const ->VTextManager; + auto GetPieceLabelData() const -> VTextManager; void SetPieceLabelData(const VTextManager &data); auto GetPatternLabelRect() const -> QVector; void SetPatternLabelRect(const QVector &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 - auto Map(QVector points) const -> QVector; + template auto Map(QVector points) const -> QVector; auto Map(const GrainlineShape &shape) const -> GrainlineShape; auto Edge(const QVector &path, int i) const -> QLineF; diff --git a/src/libs/vlayout/vtextmanager.cpp b/src/libs/vlayout/vtextmanager.cpp index fc9db2061..eb885842a 100644 --- a/src/libs/vlayout/vtextmanager.cpp +++ b/src/libs/vlayout/vtextmanager.cpp @@ -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, 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, m_patternLabelLinesCache) // NOLINT -} - // Friend functions //--------------------------------------------------------------------------------------------------------------------- auto operator<<(QDataStream &dataStream, const VTextManager &data) -> QDataStream & diff --git a/src/libs/vmisc/def.cpp b/src/libs/vmisc/def.cpp index 1377b44aa..e9421c1be 100644 --- a/src/libs/vmisc/def.cpp +++ b/src/libs/vmisc/def.cpp @@ -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 { diff --git a/src/libs/vmisc/vcommonsettings.cpp b/src/libs/vmisc/vcommonsettings.cpp index 055daaaae..90e09d655 100644 --- a/src/libs/vmisc/vcommonsettings.cpp +++ b/src/libs/vmisc/vcommonsettings.cpp @@ -27,6 +27,7 @@ *************************************************************************/ #include "vcommonsettings.h" +#include #include #include @@ -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 ¤tPath, 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 {','}; } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vmisc/vvalentinasettings.cpp b/src/libs/vmisc/vvalentinasettings.cpp index dd0c894e7..2635675ca 100644 --- a/src/libs/vmisc/vvalentinasettings.cpp +++ b/src/libs/vmisc/vvalentinasettings.cpp @@ -29,132 +29,175 @@ #include "vvalentinasettings.h" #include -#include -#include -#include -#include -#include -#include -#include #include +#include #include #include +#include +#include +#include +#include +#include -#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(*this, *settingLayoutPaperHeight, UnitConvertor(1189/*A0*/, Unit::Mm, Unit::Px)); + return ValueOrDef(*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(*this, *settingLayoutPaperWidth, UnitConvertor(841/*A0*/, Unit::Mm, Unit::Px)); + return ValueOrDef(*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())); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vmisc/vvalentinasettings.h b/src/libs/vmisc/vvalentinasettings.h index 79d184aad..d8be8ebe7 100644 --- a/src/libs/vmisc/vvalentinasettings.h +++ b/src/libs/vmisc/vvalentinasettings.h @@ -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; diff --git a/src/libs/vtest/abstracttest.cpp b/src/libs/vtest/abstracttest.cpp index ed0bfd404..1c2c4742f 100644 --- a/src/libs/vtest/abstracttest.cpp +++ b/src/libs/vtest/abstracttest.cpp @@ -28,7 +28,6 @@ #include "abstracttest.h" -#include #include #include #include @@ -36,15 +35,16 @@ #include #include #include +#include +#include +#include #include #include #include #include #include #include -#include -#include -#include +#include #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 &path, qreal accuracy) -> QVector QVector 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 &path, qreal accuracy) -> QVector 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 &path, qreal accuracy) -> QVector 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 &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 &actual, const QVector= 2, "Not enough points"); QVERIFY2(expected.size() >= 2, "Not enough points"); - const qreal accuracy = accuracyPointOnLine*4.; + const qreal accuracy = accuracyPointOnLine * 4.; QVector actualFilled = FillPath(actual, accuracy); bool onLine = false; QSet 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 &actual, const QVector &ekv, const QVector &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 &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 &result, const QVector &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::value>::type*> +template ::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::value>::type*> +template ::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::value>::type*> +template ::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(objectType)); + const QString error = + QStringLiteral("Not supported item type '%1'.").arg(static_cast(objectType)); QFAIL(qUtf8Printable(error)); } } diff --git a/src/libs/vtools/dialogs/tools/piece/dialogpatternmaterials.h b/src/libs/vtools/dialogs/tools/piece/dialogpatternmaterials.h index e4ee657de..6771a3909 100644 --- a/src/libs/vtools/dialogs/tools/piece/dialogpatternmaterials.h +++ b/src/libs/vtools/dialogs/tools/piece/dialogpatternmaterials.h @@ -31,11 +31,13 @@ #include +#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) #include "../vmisc/defglobal.h" +#endif namespace Ui { - class DialogPatternMaterials; +class DialogPatternMaterials; } class VComboBoxDelegate; diff --git a/src/libs/vwidgets/global.cpp b/src/libs/vwidgets/global.cpp index 57df64649..9e86b25b0 100644 --- a/src/libs/vwidgets/global.cpp +++ b/src/libs/vwidgets/global.cpp @@ -27,9 +27,9 @@ *************************************************************************/ #include "global.h" +#include "../vmisc/compatibility.h" #include "../vmisc/def.h" #include "../vmisc/vabstractapplication.h" -#include "../vmisc/compatibility.h" #include #include @@ -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()); } diff --git a/src/libs/vwidgets/global.h b/src/libs/vwidgets/global.h index 4cc0428b6..7ead62263 100644 --- a/src/libs/vwidgets/global.h +++ b/src/libs/vwidgets/global.h @@ -29,8 +29,8 @@ #ifndef GLOBAL_H #define GLOBAL_H -#include #include +#include 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 +template void PaintWithFixItemHighlightSelected(Item *item, QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) { diff --git a/src/libs/vwidgets/vcomboboxdelegate.h b/src/libs/vwidgets/vcomboboxdelegate.h index 87ba8b29b..ff44f0072 100644 --- a/src/libs/vwidgets/vcomboboxdelegate.h +++ b/src/libs/vwidgets/vcomboboxdelegate.h @@ -30,22 +30,25 @@ #include +#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 diff --git a/src/libs/vwidgets/vdecorationaligningdelegate.cpp b/src/libs/vwidgets/vdecorationaligningdelegate.cpp index e023be109..2e1e51cab 100644 --- a/src/libs/vwidgets/vdecorationaligningdelegate.cpp +++ b/src/libs/vwidgets/vdecorationaligningdelegate.cpp @@ -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(index.data(Qt::DecorationRole))); + auto icon(qvariant_cast(index.data(Qt::DecorationRole))); if ((option.state & QStyle::State_Selected) != 0U) { diff --git a/src/libs/vwidgets/vdecorationaligningdelegate.h b/src/libs/vwidgets/vdecorationaligningdelegate.h index 310422e83..aeb6a1788 100644 --- a/src/libs/vwidgets/vdecorationaligningdelegate.h +++ b/src/libs/vwidgets/vdecorationaligningdelegate.h @@ -30,7 +30,9 @@ #include +#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) #include "../vmisc/defglobal.h" +#endif class VDecorationAligningDelegate : public QStyledItemDelegate { diff --git a/src/test/CollectionTest/tst_tapecommandline.cpp b/src/test/CollectionTest/tst_tapecommandline.cpp index 88cd31048..52b00bf18 100644 --- a/src/test/CollectionTest/tst_tapecommandline.cpp +++ b/src/test/CollectionTest/tst_tapecommandline.cpp @@ -29,17 +29,26 @@ #include "tst_tapecommandline.h" #include "../vmisc/vsysexits.h" -#include +#if QT_VERSION < QT_VERSION_CHECK(5, 5, 0) +#include "../vmisc/diagnostic.h" +#endif // QT_VERSION < QT_VERSION_CHECK(5, 5, 0) + #include +#include 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("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))); } diff --git a/src/test/CollectionTest/tst_valentinacommandline.cpp b/src/test/CollectionTest/tst_valentinacommandline.cpp index 96344fe7e..c4654af40 100644 --- a/src/test/CollectionTest/tst_valentinacommandline.cpp +++ b/src/test/CollectionTest/tst_valentinacommandline.cpp @@ -29,17 +29,27 @@ #include "tst_valentinacommandline.h" #include "../vmisc/vsysexits.h" -#include +#if QT_VERSION < QT_VERSION_CHECK(5, 5, 0) +#include "../vmisc/diagnostic.h" +#endif // QT_VERSION < QT_VERSION_CHECK(5, 5, 0) + #include +#include 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("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))); diff --git a/src/test/ValentinaTest/qttestmainlambda.cpp b/src/test/ValentinaTest/qttestmainlambda.cpp index 3475f26bf..276c0b823 100644 --- a/src/test/ValentinaTest/qttestmainlambda.cpp +++ b/src/test/ValentinaTest/qttestmainlambda.cpp @@ -32,34 +32,35 @@ #include #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"));