Refactoring.

This commit is contained in:
Roman Telezhynskyi 2022-08-12 18:50:13 +03:00
parent 8dafc0e157
commit 0ab0edc654
595 changed files with 8727 additions and 8081 deletions

View File

@ -32,7 +32,9 @@
#include <QScrollBar> #include <QScrollBar>
#include <QFontMetrics> #include <QFontMetrics>
#if QT_VERSION < QT_VERSION_CHECK(5, 7, 0)
#include "../vmisc/backport/qoverload.h" #include "../vmisc/backport/qoverload.h"
#endif // QT_VERSION < QT_VERSION_CHECK(5, 7, 0)
#include "../layout/vpsheet.h" #include "../layout/vpsheet.h"
#include "../layout/vplayout.h" #include "../layout/vplayout.h"
@ -40,7 +42,13 @@
#include <QMenu> #include <QMenu>
#include <QPainter> #include <QPainter>
Q_LOGGING_CATEGORY(pCarrousel, "p.carrousel") QT_WARNING_PUSH
QT_WARNING_DISABLE_CLANG("-Wmissing-prototypes")
QT_WARNING_DISABLE_INTEL(1418)
Q_LOGGING_CATEGORY(pCarrousel, "p.carrousel") // NOLINT
QT_WARNING_POP
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VPCarrousel::VPCarrousel(const VPLayoutPtr &layout, QWidget *parent) : VPCarrousel::VPCarrousel(const VPLayoutPtr &layout, QWidget *parent) :
@ -108,7 +116,7 @@ void VPCarrousel::Refresh()
ui->comboBoxPieceList->blockSignals(true); ui->comboBoxPieceList->blockSignals(true);
for (const auto& sheet: m_pieceLists) for (const auto& sheet: qAsConst(m_pieceLists))
{ {
ui->comboBoxPieceList->addItem(GetSheetName(sheet), sheet.sheetUuid); ui->comboBoxPieceList->addItem(GetSheetName(sheet), sheet.sheetUuid);
} }
@ -227,7 +235,7 @@ void VPCarrousel::on_ActivePieceListChanged(int index)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VPLayoutWeakPtr VPCarrousel::Layout() const auto VPCarrousel::Layout() const -> VPLayoutWeakPtr
{ {
return m_layout; return m_layout;
} }

View File

@ -32,8 +32,10 @@
#include <QWidget> #include <QWidget>
#include <QComboBox> #include <QComboBox>
#include <QScrollArea> #include <QScrollArea>
#include "../layout/vppiece.h" #include <QUuid>
#include "../layout/layoutdef.h" #include "../layout/layoutdef.h"
#include "../vmisc/defglobal.h"
namespace Ui namespace Ui
{ {
@ -51,10 +53,10 @@ struct VPCarrouselSheet
class VPCarrousel : public QWidget class VPCarrousel : public QWidget
{ {
Q_OBJECT Q_OBJECT // NOLINT
public: public:
explicit VPCarrousel(const VPLayoutPtr &layout, QWidget *parent = nullptr); explicit VPCarrousel(const VPLayoutPtr &layout, QWidget *parent = nullptr);
virtual ~VPCarrousel() = default; ~VPCarrousel() override = default;
/** /**
* @brief SetOrientation Sets the orientation to the given value and refreshes * @brief SetOrientation Sets the orientation to the given value and refreshes
@ -76,7 +78,7 @@ public:
*/ */
void Clear(); void Clear();
VPLayoutWeakPtr Layout() const; auto Layout() const -> VPLayoutWeakPtr;
public slots: public slots:
/** /**
@ -86,7 +88,7 @@ public slots:
void on_ActiveSheetChanged(const VPSheetPtr &sheet); void on_ActiveSheetChanged(const VPSheetPtr &sheet);
protected: protected:
virtual void changeEvent(QEvent* event) override; void changeEvent(QEvent* event) override;
private slots: private slots:
@ -97,7 +99,8 @@ private slots:
void on_ActivePieceListChanged(int index); void on_ActivePieceListChanged(int index);
private: private:
Q_DISABLE_COPY(VPCarrousel) // cppcheck-suppress unknownMacro
Q_DISABLE_COPY_MOVE(VPCarrousel) // NOLINT
Ui::VPCarrousel *ui; Ui::VPCarrousel *ui;
VPLayoutWeakPtr m_layout{}; VPLayoutWeakPtr m_layout{};

View File

@ -32,15 +32,17 @@
#include <QMenu> #include <QMenu>
#include <QPainter> #include <QPainter>
#include "vpmimedatapiece.h"
#include "vpcarrouselpiecelist.h"
#include "vpcarrousel.h"
#include "../layout/vpsheet.h"
#include "../layout/vppiece.h" #include "../layout/vppiece.h"
#include <QLoggingCategory> #include <QLoggingCategory>
Q_LOGGING_CATEGORY(pCarrouselPiece, "p.carrouselPiece") QT_WARNING_PUSH
QT_WARNING_DISABLE_CLANG("-Wmissing-prototypes")
QT_WARNING_DISABLE_INTEL(1418)
Q_LOGGING_CATEGORY(pCarrouselPiece, "p.carrouselPiece") // NOLINT
QT_WARNING_POP
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View File

@ -32,6 +32,7 @@
#include <QListWidgetItem> #include <QListWidgetItem>
#include "../layout/layoutdef.h" #include "../layout/layoutdef.h"
#include "../vmisc/defglobal.h"
class VPCarrouselPiece : public QListWidgetItem class VPCarrouselPiece : public QListWidgetItem
{ {
@ -39,7 +40,7 @@ public:
enum { Type = UserType + 1}; enum { Type = UserType + 1};
explicit VPCarrouselPiece(const VPPiecePtr &piece, QListWidget* parent); explicit VPCarrouselPiece(const VPPiecePtr &piece, QListWidget* parent);
virtual ~VPCarrouselPiece() = default; ~VPCarrouselPiece() override = default;
/** /**
* @brief GetPiece Returns the corresponding layout piece * @brief GetPiece Returns the corresponding layout piece
@ -61,7 +62,8 @@ public:
private: private:
Q_DISABLE_COPY(VPCarrouselPiece) // cppcheck-suppress unknownMacro
Q_DISABLE_COPY_MOVE(VPCarrouselPiece) // NOLINT
VPPieceWeakPtr m_piece; VPPieceWeakPtr m_piece;
}; };

View File

@ -35,15 +35,24 @@
#include "vpcarrousel.h" #include "vpcarrousel.h"
#include "vpcarrouselpiece.h" #include "vpcarrouselpiece.h"
#if QT_VERSION < QT_VERSION_CHECK(5, 7, 0)
#include "../vmisc/backport/qoverload.h" #include "../vmisc/backport/qoverload.h"
#endif // QT_VERSION < QT_VERSION_CHECK(5, 7, 0)
#include "vpmimedatapiece.h" #include "vpmimedatapiece.h"
#include "../layout/vpsheet.h" #include "../layout/vpsheet.h"
#include "../layout/vplayout.h" #include "../layout/vplayout.h"
#include "../undocommands/vpundomovepieceonsheet.h" #include "../undocommands/vpundomovepieceonsheet.h"
#include "../layout/vppiece.h"
#include <QLoggingCategory> #include <QLoggingCategory>
Q_LOGGING_CATEGORY(pCarrouselPieceList, "p.carrouselPieceList") QT_WARNING_PUSH
QT_WARNING_DISABLE_CLANG("-Wmissing-prototypes")
QT_WARNING_DISABLE_INTEL(1418)
Q_LOGGING_CATEGORY(pCarrouselPieceList, "p.carrouselPieceList") // NOLINT
QT_WARNING_POP
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VPCarrouselPieceList::VPCarrouselPieceList(QWidget* parent) : VPCarrouselPieceList::VPCarrouselPieceList(QWidget* parent) :
@ -70,7 +79,7 @@ void VPCarrouselPieceList::Refresh()
if(not m_pieceList.isEmpty()) if(not m_pieceList.isEmpty())
{ {
// create the corresponding carrousel pieces // create the corresponding carrousel pieces
for (auto piece : m_pieceList) for (const auto &piece : qAsConst(m_pieceList)) // NOLINT(clang-analyzer-cplusplus.NewDeleteLeaks)
{ {
if (not piece.isNull()) if (not piece.isNull())
{ {
@ -102,7 +111,8 @@ void VPCarrouselPieceList::mousePressEvent(QMouseEvent *event)
if (!(event->modifiers() & Qt::ControlModifier)) if (!(event->modifiers() & Qt::ControlModifier))
{ {
// clearSelection doesn't work properly here so we go through the elements. // clearSelection doesn't work properly here so we go through the elements.
for(auto *item: selectedItems()) const QList<QListWidgetItem*> items = selectedItems();
for(auto *item: items)
{ {
item->setSelected(false); item->setSelected(false);
} }
@ -135,7 +145,8 @@ void VPCarrouselPieceList::startDrag(Qt::DropActions supportedActions)
QListWidgetItem* _item = currentItem(); QListWidgetItem* _item = currentItem();
if(_item->type() == VPCarrouselPiece::Type) if(_item->type() == VPCarrouselPiece::Type)
{ {
auto *pieceItem = static_cast<VPCarrouselPiece *> (_item); auto *pieceItem = dynamic_cast<VPCarrouselPiece *> (_item);
SCASSERT(pieceItem != nullptr)
if (m_carrousel == nullptr) if (m_carrousel == nullptr)
{ {
@ -183,9 +194,13 @@ void VPCarrouselPieceList::dragMoveEvent(QDragMoveEvent* e)
void VPCarrouselPieceList::contextMenuEvent(QContextMenuEvent *event) void VPCarrouselPieceList::contextMenuEvent(QContextMenuEvent *event)
{ {
QListWidgetItem* _item = currentItem(); QListWidgetItem* _item = currentItem();
if(_item != nullptr && _item->type() == VPCarrouselPiece::Type) if(_item == nullptr || _item->type() != VPCarrouselPiece::Type)
{ {
auto *pieceItem = static_cast<VPCarrouselPiece *> (_item); return;
}
auto *pieceItem = dynamic_cast<VPCarrouselPiece *> (_item);
SCASSERT(pieceItem != nullptr)
VPPiecePtr piece = pieceItem->GetPiece(); VPPiecePtr piece = pieceItem->GetPiece();
VPLayoutPtr layout = piece->Layout(); VPLayoutPtr layout = piece->Layout();
@ -270,7 +285,6 @@ void VPCarrouselPieceList::contextMenuEvent(QContextMenuEvent *event)
auto *command = new VPUndoMovePieceOnSheet(qvariant_cast<VPSheetPtr>(selectedAction->data()), piece); auto *command = new VPUndoMovePieceOnSheet(qvariant_cast<VPSheetPtr>(selectedAction->data()), piece);
layout->UndoStack()->push(command); layout->UndoStack()->push(command);
} }
}
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -282,7 +296,8 @@ void VPCarrouselPieceList::on_SelectionChangedExternal()
QListWidgetItem* _item = item(i); QListWidgetItem* _item = item(i);
if(_item->type() == VPCarrouselPiece::Type) if(_item->type() == VPCarrouselPiece::Type)
{ {
auto *itemPiece = static_cast<VPCarrouselPiece *> (_item); auto *itemPiece = dynamic_cast<VPCarrouselPiece *> (_item);
SCASSERT(itemPiece != nullptr)
itemPiece->RefreshSelection(); itemPiece->RefreshSelection();
} }
} }

View File

@ -36,10 +36,10 @@
class VPCarrouselPieceList : public QListWidget class VPCarrouselPieceList : public QListWidget
{ {
Q_OBJECT Q_OBJECT // NOLINT
public: public:
explicit VPCarrouselPieceList(QWidget* parent); explicit VPCarrouselPieceList(QWidget* parent);
virtual ~VPCarrouselPieceList() = default; ~VPCarrouselPieceList() override = default;
/** /**
* @brief Refresh refreshes the items of the carrousel piece list * @brief Refresh refreshes the items of the carrousel piece list
@ -74,7 +74,7 @@ protected:
void contextMenuEvent(QContextMenuEvent *event) override; void contextMenuEvent(QContextMenuEvent *event) override;
private: private:
Q_DISABLE_COPY(VPCarrouselPieceList) Q_DISABLE_COPY_MOVE(VPCarrouselPieceList) // NOLINT
QList<VPPiecePtr> m_pieceList{}; QList<VPPiecePtr> m_pieceList{};
QPoint m_dragStart{}; QPoint m_dragStart{};

View File

@ -33,7 +33,7 @@
#include "../layout/vppiece.h" #include "../layout/vppiece.h"
const QString VPMimeDataPiece::mineFormatPiecePtr = QStringLiteral("application/vnd.puzzle.piece.ptr"); const QString VPMimeDataPiece::mineFormatPiecePtr = QStringLiteral("application/vnd.puzzle.piece.ptr"); // NOLINT(cert-err58-cpp)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VPMimeDataPiece::VPMimeDataPiece(const QUuid &layoutUuid) VPMimeDataPiece::VPMimeDataPiece(const QUuid &layoutUuid)
@ -65,14 +65,14 @@ auto VPMimeDataPiece::DragCursor(const QPixmap &piecePixmap) -> QPixmap
dragCursor.fill(Qt::transparent); dragCursor.fill(Qt::transparent);
QPainter painter(&dragCursor); QPainter painter(&dragCursor);
painter.drawPixmap(dragCursor.width()/2, dragCursor.height()/2, piecePixmap); painter.drawPixmap(dragCursor.width()/2, dragCursor.height()/2, piecePixmap);
QPixmap cursor = QPixmap("://cursor/collect.png"); QPixmap cursor(QStringLiteral("://cursor/collect.png"));
painter.drawPixmap(dragCursor.width()/2 - cursor.width()/2, dragCursor.height()/2 - cursor.height()/2, cursor); painter.drawPixmap(dragCursor.width()/2 - cursor.width()/2, dragCursor.height()/2 - cursor.height()/2, cursor);
painter.end(); painter.end();
return dragCursor; return dragCursor;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
const QUuid &VPMimeDataPiece::LayoutUuid() const auto VPMimeDataPiece::LayoutUuid() const -> const QUuid &
{ {
return m_layoutUuid; return m_layoutUuid;
} }

View File

@ -34,16 +34,17 @@
#include <QUuid> #include <QUuid>
#include "../layout/layoutdef.h" #include "../layout/layoutdef.h"
#include "../vmisc/defglobal.h"
class VPMimeDataPiece : public QMimeData class VPMimeDataPiece : public QMimeData
{ {
Q_OBJECT Q_OBJECT // NOLINT
public: public:
explicit VPMimeDataPiece(const QUuid &layoutUuid); explicit VPMimeDataPiece(const QUuid &layoutUuid);
virtual ~VPMimeDataPiece() = default; ~VPMimeDataPiece() override = default;
virtual auto formats() const -> QStringList override; auto formats() const -> QStringList override;
/** /**
* @brief GetPiecePtr Returns the piece pointer of the mime data * @brief GetPiecePtr Returns the piece pointer of the mime data
@ -61,10 +62,11 @@ public:
static const QString mineFormatPiecePtr; static const QString mineFormatPiecePtr;
const QUuid &LayoutUuid() const; auto LayoutUuid() const -> const QUuid &;
private: private:
Q_DISABLE_COPY(VPMimeDataPiece) // cppcheck-suppress unknownMacro
Q_DISABLE_COPY_MOVE(VPMimeDataPiece) // NOLINT
VPPieceWeakPtr m_piece{}; VPPieceWeakPtr m_piece{};

View File

@ -113,12 +113,12 @@ auto PuzzlePreferencesConfigurationPage::Apply() -> QStringList
if (m_langChanged) if (m_langChanged)
{ {
const QString locale = qvariant_cast<QString>(ui->langCombo->currentData()); const auto locale = qvariant_cast<QString>(ui->langCombo->currentData());
settings->SetLocale(locale); settings->SetLocale(locale);
m_langChanged = false; m_langChanged = false;
VAbstractApplication::VApp()->LoadTranslation(locale); VAbstractApplication::VApp()->LoadTranslation(locale);
qApp->processEvents();// force to call changeEvent QCoreApplication::processEvents();// force to call changeEvent
} }
/* Maximum number of commands in undo stack may only be set when the undo stack is empty, since setting it on a /* Maximum number of commands in undo stack may only be set when the undo stack is empty, since setting it on a

View File

@ -30,6 +30,8 @@
#include <QWidget> #include <QWidget>
#include "../vmisc/defglobal.h"
namespace Ui namespace Ui
{ {
class PuzzlePreferencesConfigurationPage; class PuzzlePreferencesConfigurationPage;
@ -37,19 +39,20 @@ namespace Ui
class PuzzlePreferencesConfigurationPage : public QWidget class PuzzlePreferencesConfigurationPage : public QWidget
{ {
Q_OBJECT Q_OBJECT // NOLINT
public: public:
explicit PuzzlePreferencesConfigurationPage(QWidget *parent = nullptr); explicit PuzzlePreferencesConfigurationPage(QWidget *parent = nullptr);
virtual ~PuzzlePreferencesConfigurationPage(); ~PuzzlePreferencesConfigurationPage() override;
QStringList Apply(); auto Apply() -> QStringList;
protected: protected:
virtual void changeEvent(QEvent* event) override; void changeEvent(QEvent* event) override;
private: private:
Q_DISABLE_COPY(PuzzlePreferencesConfigurationPage) // cppcheck-suppress unknownMacro
Q_DISABLE_COPY_MOVE(PuzzlePreferencesConfigurationPage) // NOLINT
Ui::PuzzlePreferencesConfigurationPage *ui; Ui::PuzzlePreferencesConfigurationPage *ui;
bool m_langChanged{false}; bool m_langChanged{false};
}; };

View File

@ -399,7 +399,7 @@ void PuzzlePreferencesLayoutPage::InitLayoutUnits()
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QSizeF PuzzlePreferencesLayoutPage::Template(VAbstractLayoutDialog::PaperSizeTemplate t) const auto PuzzlePreferencesLayoutPage::Template(VAbstractLayoutDialog::PaperSizeTemplate t) const -> QSizeF
{ {
const Unit layoutUnit = LayoutUnit(); const Unit layoutUnit = LayoutUnit();
@ -413,7 +413,6 @@ QSizeF PuzzlePreferencesLayoutPage::Template(VAbstractLayoutDialog::PaperSizeTem
case VAbstractLayoutDialog::PaperSizeTemplate::Letter: case VAbstractLayoutDialog::PaperSizeTemplate::Letter:
case VAbstractLayoutDialog::PaperSizeTemplate::Legal: case VAbstractLayoutDialog::PaperSizeTemplate::Legal:
case VAbstractLayoutDialog::PaperSizeTemplate::Tabloid: case VAbstractLayoutDialog::PaperSizeTemplate::Tabloid:
return VAbstractLayoutDialog::GetTemplateSize(t, layoutUnit);
case VAbstractLayoutDialog::PaperSizeTemplate::Roll24in: case VAbstractLayoutDialog::PaperSizeTemplate::Roll24in:
case VAbstractLayoutDialog::PaperSizeTemplate::Roll30in: case VAbstractLayoutDialog::PaperSizeTemplate::Roll30in:
case VAbstractLayoutDialog::PaperSizeTemplate::Roll36in: case VAbstractLayoutDialog::PaperSizeTemplate::Roll36in:
@ -422,13 +421,12 @@ QSizeF PuzzlePreferencesLayoutPage::Template(VAbstractLayoutDialog::PaperSizeTem
case VAbstractLayoutDialog::PaperSizeTemplate::Roll48in: case VAbstractLayoutDialog::PaperSizeTemplate::Roll48in:
case VAbstractLayoutDialog::PaperSizeTemplate::Roll62in: case VAbstractLayoutDialog::PaperSizeTemplate::Roll62in:
case VAbstractLayoutDialog::PaperSizeTemplate::Roll72in: case VAbstractLayoutDialog::PaperSizeTemplate::Roll72in:
return VAbstractLayoutDialog::GetTemplateSize(t, layoutUnit);
case VAbstractLayoutDialog::PaperSizeTemplate::Custom: case VAbstractLayoutDialog::PaperSizeTemplate::Custom:
return VAbstractLayoutDialog::GetTemplateSize(t, layoutUnit); return VAbstractLayoutDialog::GetTemplateSize(t, layoutUnit);
default: default:
break; break;
} }
return QSizeF(); return {};
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View File

@ -40,16 +40,16 @@ namespace Ui
class PuzzlePreferencesLayoutPage : public QWidget class PuzzlePreferencesLayoutPage : public QWidget
{ {
Q_OBJECT Q_OBJECT // NOLINT
public: public:
explicit PuzzlePreferencesLayoutPage(QWidget *parent = nullptr); explicit PuzzlePreferencesLayoutPage(QWidget *parent = nullptr);
~PuzzlePreferencesLayoutPage(); ~PuzzlePreferencesLayoutPage() override;
QStringList Apply(); auto Apply() -> QStringList;
protected: protected:
virtual void changeEvent(QEvent* event) override; void changeEvent(QEvent* event) override;
private slots: private slots:
void ConvertPaperSize(); void ConvertPaperSize();
@ -62,21 +62,22 @@ private slots:
void SwapTileOrientation(bool checked); void SwapTileOrientation(bool checked);
private: private:
Q_DISABLE_COPY(PuzzlePreferencesLayoutPage) // cppcheck-suppress unknownMacro
Q_DISABLE_COPY_MOVE(PuzzlePreferencesLayoutPage) // NOLINT
Ui::PuzzlePreferencesLayoutPage *ui; Ui::PuzzlePreferencesLayoutPage *ui;
Unit m_oldLayoutUnit{Unit::Mm}; Unit m_oldLayoutUnit{Unit::Mm};
bool m_settingsChanged{false}; bool m_settingsChanged{false};
void InitLayoutUnits(); void InitLayoutUnits();
QSizeF Template(VAbstractLayoutDialog::PaperSizeTemplate t) const; auto Template(VAbstractLayoutDialog::PaperSizeTemplate t) const -> QSizeF;
QSizeF SheetTemplate() const; auto SheetTemplate() const -> QSizeF;
QSizeF TileTemplate() const; auto TileTemplate() const -> QSizeF;
void MinimumSheetPaperSize(); void MinimumSheetPaperSize();
void MinimumTilePaperSize(); void MinimumTilePaperSize();
Unit LayoutUnit() const; auto LayoutUnit() const -> Unit;
void SetLayoutUnit(Unit unit); void SetLayoutUnit(Unit unit);
void SheetSize(const QSizeF &size); void SheetSize(const QSizeF &size);
@ -87,10 +88,10 @@ private:
void SheetPaperSizeChanged(); void SheetPaperSizeChanged();
void TilePaperSizeChanged(); void TilePaperSizeChanged();
QMarginsF GetSheetMargins() const; auto GetSheetMargins() const -> QMarginsF;
void SetSheetMargins(const QMarginsF &value); void SetSheetMargins(const QMarginsF &value);
QMarginsF GetTileMargins() const; auto GetTileMargins() const -> QMarginsF;
void SetTileMargins(const QMarginsF &value); void SetTileMargins(const QMarginsF &value);
void SetPieceGap(qreal gap); void SetPieceGap(qreal gap);

View File

@ -180,35 +180,35 @@ void PuzzlePreferencesPathPage::InitTable()
{ {
ui->pathTable->setItem(0, 0, new QTableWidgetItem(tr("My Individual Measurements"))); ui->pathTable->setItem(0, 0, new QTableWidgetItem(tr("My Individual Measurements")));
QTableWidgetItem *item = new QTableWidgetItem(settings->GetPathIndividualMeasurements()); auto *item = new QTableWidgetItem(settings->GetPathIndividualMeasurements());
item->setToolTip(settings->GetPathIndividualMeasurements()); item->setToolTip(settings->GetPathIndividualMeasurements());
ui->pathTable->setItem(0, 1, item); ui->pathTable->setItem(0, 1, item);
} }
{ {
ui->pathTable->setItem(1, 0, new QTableWidgetItem(tr("My Multisize Measurements"))); ui->pathTable->setItem(1, 0, new QTableWidgetItem(tr("My Multisize Measurements")));
QTableWidgetItem *item = new QTableWidgetItem(settings->GetPathMultisizeMeasurements()); auto *item = new QTableWidgetItem(settings->GetPathMultisizeMeasurements());
item->setToolTip(settings->GetPathMultisizeMeasurements()); item->setToolTip(settings->GetPathMultisizeMeasurements());
ui->pathTable->setItem(1, 1, item); ui->pathTable->setItem(1, 1, item);
} }
{ {
ui->pathTable->setItem(2, 0, new QTableWidgetItem(tr("My Patterns"))); ui->pathTable->setItem(2, 0, new QTableWidgetItem(tr("My Patterns")));
QTableWidgetItem *item = new QTableWidgetItem(settings->GetPathPattern()); auto *item = new QTableWidgetItem(settings->GetPathPattern());
item->setToolTip(settings->GetPathPattern()); item->setToolTip(settings->GetPathPattern());
ui->pathTable->setItem(2, 1, item); ui->pathTable->setItem(2, 1, item);
} }
{ {
ui->pathTable->setItem(3, 0, new QTableWidgetItem(tr("My Templates"))); ui->pathTable->setItem(3, 0, new QTableWidgetItem(tr("My Templates")));
QTableWidgetItem *item = new QTableWidgetItem(settings->GetPathTemplate()); auto *item = new QTableWidgetItem(settings->GetPathTemplate());
item->setToolTip(settings->GetPathTemplate()); item->setToolTip(settings->GetPathTemplate());
ui->pathTable->setItem(3, 1, item); ui->pathTable->setItem(3, 1, item);
} }
{ {
ui->pathTable->setItem(4, 0, new QTableWidgetItem(tr("My Layouts"))); ui->pathTable->setItem(4, 0, new QTableWidgetItem(tr("My Layouts")));
QTableWidgetItem *item = new QTableWidgetItem(settings->GetPathManualLayouts()); auto *item = new QTableWidgetItem(settings->GetPathManualLayouts());
item->setToolTip(settings->GetPathManualLayouts()); item->setToolTip(settings->GetPathManualLayouts());
ui->pathTable->setItem(4, 1, item); ui->pathTable->setItem(4, 1, item);
} }

View File

@ -30,6 +30,8 @@
#include <QWidget> #include <QWidget>
#include "../vmisc/defglobal.h"
namespace Ui namespace Ui
{ {
class PuzzlePreferencesPathPage; class PuzzlePreferencesPathPage;
@ -37,23 +39,24 @@ namespace Ui
class PuzzlePreferencesPathPage : public QWidget class PuzzlePreferencesPathPage : public QWidget
{ {
Q_OBJECT Q_OBJECT // NOLINT
public: public:
explicit PuzzlePreferencesPathPage(QWidget *parent = nullptr); explicit PuzzlePreferencesPathPage(QWidget *parent = nullptr);
virtual ~PuzzlePreferencesPathPage(); ~PuzzlePreferencesPathPage() override;
void Apply(); void Apply();
protected: protected:
virtual void changeEvent(QEvent* event) override; void changeEvent(QEvent* event) override;
private slots: private slots:
void DefaultPath(); void DefaultPath();
void EditPath(); void EditPath();
private: private:
Q_DISABLE_COPY(PuzzlePreferencesPathPage) // cppcheck-suppress unknownMacro
Q_DISABLE_COPY_MOVE(PuzzlePreferencesPathPage) // NOLINT
Ui::PuzzlePreferencesPathPage *ui; Ui::PuzzlePreferencesPathPage *ui;
void InitTable(); void InitTable();

View File

@ -30,6 +30,8 @@
#include <QDialog> #include <QDialog>
#include "../vmisc/defglobal.h"
namespace Ui namespace Ui
{ {
class DialogPuzzlePreferences; class DialogPuzzlePreferences;
@ -42,19 +44,19 @@ class PuzzlePreferencesLayoutPage;
class DialogPuzzlePreferences : public QDialog class DialogPuzzlePreferences : public QDialog
{ {
Q_OBJECT Q_OBJECT // NOLINT
public: public:
explicit DialogPuzzlePreferences(QWidget *parent = nullptr); explicit DialogPuzzlePreferences(QWidget *parent = nullptr);
virtual ~DialogPuzzlePreferences(); ~DialogPuzzlePreferences() override;
signals: signals:
void UpdateProperties(); void UpdateProperties();
protected: protected:
virtual void showEvent(QShowEvent *event) override; void showEvent(QShowEvent *event) override;
virtual void resizeEvent(QResizeEvent *event) override; void resizeEvent(QResizeEvent *event) override;
virtual void changeEvent(QEvent* event) override; void changeEvent(QEvent* event) override;
private slots: private slots:
void Apply(); void Apply();
@ -62,7 +64,8 @@ private slots:
void PageChanged(QListWidgetItem *current, QListWidgetItem *previous); void PageChanged(QListWidgetItem *current, QListWidgetItem *previous);
private: private:
Q_DISABLE_COPY(DialogPuzzlePreferences) // cppcheck-suppress unknownMacro
Q_DISABLE_COPY_MOVE(DialogPuzzlePreferences) // NOLINT
Ui::DialogPuzzlePreferences *ui; Ui::DialogPuzzlePreferences *ui;
bool m_isInitialized{false}; bool m_isInitialized{false};
PuzzlePreferencesConfigurationPage *m_configurationPage; PuzzlePreferencesConfigurationPage *m_configurationPage;

View File

@ -36,14 +36,11 @@
#include <QtDebug> #include <QtDebug>
#ifndef Q_OS_WIN #ifndef Q_OS_WIN
Q_GLOBAL_STATIC_WITH_ARGS(const QString, baseFilenameRegExp, (QLatin1String("^[^\\/]+$"))) Q_GLOBAL_STATIC_WITH_ARGS(const QString, baseFilenameRegExp, (QLatin1String("^[^\\/]+$"))) // NOLINT
#else #else
Q_GLOBAL_STATIC_WITH_ARGS(const QString, baseFilenameRegExp, (QLatin1String("^[^\\:?\"*|\\/<>]+$"))) Q_GLOBAL_STATIC_WITH_ARGS(const QString, baseFilenameRegExp, (QLatin1String("^[^\\:?\"*|\\/<>]+$"))) // NOLINT
#endif #endif
bool DialogSaveManualLayout::havePdf = false;
bool DialogSaveManualLayout::tested = false;
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
DialogSaveManualLayout::DialogSaveManualLayout(int count, bool consoleExport, const QString &fileName, QWidget *parent) DialogSaveManualLayout::DialogSaveManualLayout(int count, bool consoleExport, const QString &fileName, QWidget *parent)
: VAbstractLayoutDialog(parent), : VAbstractLayoutDialog(parent),
@ -334,7 +331,7 @@ void DialogSaveManualLayout::SetTilesScheme(bool value)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool DialogSaveManualLayout::IsTilesScheme() const auto DialogSaveManualLayout::IsTilesScheme() const -> bool
{ {
switch(Format()) switch(Format())
{ {
@ -500,6 +497,8 @@ void DialogSaveManualLayout::ShowExample()
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto DialogSaveManualLayout::SupportPSTest() -> bool auto DialogSaveManualLayout::SupportPSTest() -> bool
{ {
static bool havePdf = false;
static bool tested = false;
if (!tested) if (!tested)
{ {
havePdf = VLayoutExporter::SupportPDFConversion(); havePdf = VLayoutExporter::SupportPDFConversion();

View File

@ -38,12 +38,12 @@ class DialogSaveManualLayout;
class DialogSaveManualLayout : public VAbstractLayoutDialog class DialogSaveManualLayout : public VAbstractLayoutDialog
{ {
Q_OBJECT Q_OBJECT // NOLINT
public: public:
explicit DialogSaveManualLayout(int count, bool consoleExport, const QString &fileName = QString(), explicit DialogSaveManualLayout(int count, bool consoleExport, const QString &fileName = QString(),
QWidget *parent = nullptr); QWidget *parent = nullptr);
virtual ~DialogSaveManualLayout(); ~DialogSaveManualLayout() override;
auto Path() const -> QString; auto Path() const -> QString;
auto FileName() const -> QString; auto FileName() const -> QString;
@ -66,7 +66,7 @@ public:
auto IsTilesScheme() const -> bool; auto IsTilesScheme() const -> bool;
protected: protected:
virtual void showEvent(QShowEvent *event) override; void showEvent(QShowEvent *event) override;
private slots: private slots:
void Save(); void Save();
@ -74,17 +74,16 @@ private slots:
void ShowExample(); void ShowExample();
private: private:
Q_DISABLE_COPY(DialogSaveManualLayout) // cppcheck-suppress unknownMacro
Q_DISABLE_COPY_MOVE(DialogSaveManualLayout) // NOLINT
Ui::DialogSaveManualLayout *ui; Ui::DialogSaveManualLayout *ui;
int m_count; int m_count;
bool m_isInitialized{false}; bool m_isInitialized{false};
bool m_scaleConnected{true}; bool m_scaleConnected{true};
bool m_consoleExport; bool m_consoleExport;
static bool havePdf; static auto SupportPSTest() -> bool;
static bool tested; static auto InitFormats() -> QVector<std::pair<QString, LayoutExportFormats> >;
static bool SupportPSTest();
static QVector<std::pair<QString, LayoutExportFormats> > InitFormats();
void RemoveFormatFromList(LayoutExportFormats format); void RemoveFormatFromList(LayoutExportFormats format);

View File

@ -28,7 +28,7 @@
#include "vpdialogabout.h" #include "vpdialogabout.h"
#include "ui_vpdialogabout.h" #include "ui_vpdialogabout.h"
#include "../version.h" #include "../vmisc/projectversion.h"
#include "../vmisc/def.h" #include "../vmisc/def.h"
#include "../fervor/fvupdater.h" #include "../fervor/fvupdater.h"
@ -43,7 +43,7 @@
VPDialogAbout::VPDialogAbout(QWidget *parent) VPDialogAbout::VPDialogAbout(QWidget *parent)
:QDialog(parent), :QDialog(parent),
ui(new Ui::VPDialogAbout), ui(new Ui::VPDialogAbout),
isInitialized(false) m_isInitialized(false)
{ {
ui->setupUi(this); ui->setupUi(this);
@ -52,7 +52,7 @@ VPDialogAbout::VPDialogAbout(QWidget *parent)
RetranslateUi(); RetranslateUi();
connect(ui->pushButton_Web_Site, &QPushButton::clicked, this, []() connect(ui->pushButton_Web_Site, &QPushButton::clicked, this, []()
{ {
if ( not QDesktopServices::openUrl(QUrl(VER_COMPANYDOMAIN_STR))) if ( not QDesktopServices::openUrl(QUrl(QStringLiteral(VER_COMPANYDOMAIN_STR))))
{ {
qWarning() << tr("Cannot open your default browser"); qWarning() << tr("Cannot open your default browser");
} }
@ -100,7 +100,7 @@ void VPDialogAbout::showEvent(QShowEvent *event)
return; return;
} }
if (isInitialized) if (m_isInitialized)
{ {
return; return;
} }
@ -109,7 +109,7 @@ void VPDialogAbout::showEvent(QShowEvent *event)
setMaximumSize(size()); setMaximumSize(size());
setMinimumSize(size()); setMinimumSize(size());
isInitialized = true;//first show windows are held m_isInitialized = true;//first show windows are held
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -125,17 +125,17 @@ void VPDialogAbout::FontPointSize(QWidget *w, int pointSize)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPDialogAbout::RetranslateUi() void VPDialogAbout::RetranslateUi()
{ {
ui->label_Puzzle_Version->setText(QString("Puzzle %1").arg(APP_VERSION_STR)); ui->label_Puzzle_Version->setText(QStringLiteral("Puzzle %1").arg(APP_VERSION_STR));
ui->labelBuildRevision->setText(tr("Build revision: %1").arg(BUILD_REVISION)); ui->labelBuildRevision->setText(tr("Build revision: %1").arg(QStringLiteral(BUILD_REVISION)));
ui->label_QT_Version->setText(buildCompatibilityString()); ui->label_QT_Version->setText(buildCompatibilityString());
const QDate date = QLocale::c().toDate(QString(__DATE__).simplified(), QLatin1String("MMM d yyyy")); const QDate date = QLocale::c().toDate(QStringLiteral(__DATE__).simplified(), QStringLiteral("MMM d yyyy"));
ui->label_Puzzle_Built->setText(tr("Built on %1 at %2").arg(date.toString(), __TIME__)); ui->label_Puzzle_Built->setText(tr("Built on %1 at %2").arg(date.toString(), QStringLiteral(__TIME__)));
ui->label_Legal_Stuff->setText(QApplication::translate("InternalStrings", ui->label_Legal_Stuff->setText(QApplication::translate("InternalStrings",
"The program is provided AS IS with NO WARRANTY OF ANY " "The program is provided AS IS with NO WARRANTY OF ANY "
"KIND, INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY " "KIND, INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY "
"AND FITNESS FOR A PARTICULAR PURPOSE.")); "AND FITNESS FOR A PARTICULAR PURPOSE."));
ui->pushButton_Web_Site->setText(tr("Web site : %1").arg(VER_COMPANYDOMAIN_STR)); ui->pushButton_Web_Site->setText(tr("Web site : %1").arg(QStringLiteral(VER_COMPANYDOMAIN_STR)));
} }

View File

@ -31,6 +31,8 @@
#include <QDialog> #include <QDialog>
#include "../vmisc/defglobal.h"
namespace Ui namespace Ui
{ {
class VPDialogAbout; class VPDialogAbout;
@ -38,22 +40,23 @@ namespace Ui
class VPDialogAbout : public QDialog class VPDialogAbout : public QDialog
{ {
Q_OBJECT Q_OBJECT // NOLINT
public: public:
explicit VPDialogAbout(QWidget *parent = nullptr); explicit VPDialogAbout(QWidget *parent = nullptr);
virtual ~VPDialogAbout(); ~VPDialogAbout() override;
protected: protected:
virtual void changeEvent(QEvent* event) override; void changeEvent(QEvent* event) override;
virtual void showEvent(QShowEvent *event) override; void showEvent(QShowEvent *event) override;
private: private:
Q_DISABLE_COPY(VPDialogAbout) // cppcheck-suppress unknownMacro
Q_DISABLE_COPY_MOVE(VPDialogAbout) // NOLINT
Ui::VPDialogAbout *ui; Ui::VPDialogAbout *ui;
bool isInitialized; bool m_isInitialized;
void FontPointSize(QWidget *w, int pointSize); static void FontPointSize(QWidget *w, int pointSize);
void RetranslateUi(); void RetranslateUi();
}; };

View File

@ -80,13 +80,13 @@ auto StrToGrainlineType(const QString &string) -> GrainlineType
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool VPTransformationOrigon::operator==(const VPTransformationOrigon &origin) const auto VPTransformationOrigon::operator==(const VPTransformationOrigon &origin) const -> bool
{ {
return this->origin == origin.origin && custom == origin.custom; return this->origin == origin.origin && custom == origin.custom;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool VPTransformationOrigon::operator!=(const VPTransformationOrigon &origin) const auto VPTransformationOrigon::operator!=(const VPTransformationOrigon &origin) const -> bool
{ {
return !VPTransformationOrigon::operator==(origin); return !VPTransformationOrigon::operator==(origin);
} }

View File

@ -55,11 +55,11 @@ auto StrToGrainlineType(const QString &string) -> GrainlineType;
struct VPTransformationOrigon struct VPTransformationOrigon
{ {
QPointF origin{}; QPointF origin{}; // NOLINT(misc-non-private-member-variables-in-classes)
bool custom{false}; bool custom{false}; // NOLINT(misc-non-private-member-variables-in-classes)
bool operator==(const VPTransformationOrigon &origin) const; auto operator==(const VPTransformationOrigon &origin) const -> bool;
bool operator!=(const VPTransformationOrigon &origin) const; auto operator!=(const VPTransformationOrigon &origin) const -> bool;
}; };
#endif // LAYOUTDEF_H #endif // LAYOUTDEF_H

View File

@ -39,7 +39,13 @@
#include <QUndoStack> #include <QUndoStack>
#include <QPixmapCache> #include <QPixmapCache>
Q_LOGGING_CATEGORY(pLayout, "p.layout") QT_WARNING_PUSH
QT_WARNING_DISABLE_CLANG("-Wmissing-prototypes")
QT_WARNING_DISABLE_INTEL(1418)
Q_LOGGING_CATEGORY(pLayout, "p.layout") // NOLINT
QT_WARNING_POP
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VPLayout::VPLayout(QUndoStack *undoStack) : VPLayout::VPLayout(QUndoStack *undoStack) :
@ -118,13 +124,13 @@ void VPLayout::AddPiece(const VPPiecePtr &piece)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
const QUuid &VPLayout::Uuid() const auto VPLayout::Uuid() const -> const QUuid &
{ {
return m_uuid; return m_uuid;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VPTileFactory *VPLayout::TileFactory() const auto VPLayout::TileFactory() const -> VPTileFactory *
{ {
return m_tileFactory; return m_tileFactory;
} }
@ -166,7 +172,7 @@ auto VPLayout::WatermarkData() const -> VWatermarkData
data.invalidFile = true; data.invalidFile = true;
data.opacity = 20; data.opacity = 20;
data.showImage = true; data.showImage = true;
data.path = "fake.png"; data.path = QStringLiteral("fake.png");
data.showText = false; data.showText = false;
return data; return data;
} }
@ -254,7 +260,7 @@ auto VPLayout::AddSheet(const VPSheetPtr &sheet) -> VPSheetPtr
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QList<VPSheetPtr> VPLayout::GetAllSheets() const auto VPLayout::GetAllSheets() const -> QList<VPSheetPtr>
{ {
return m_sheets; return m_sheets;
} }

View File

@ -32,7 +32,6 @@
#include <QMap> #include <QMap>
#include <QUuid> #include <QUuid>
#include "def.h"
#include "vplayoutsettings.h" #include "vplayoutsettings.h"
#include "layoutdef.h" #include "layoutdef.h"
@ -44,9 +43,9 @@ struct VWatermarkData;
class VPLayout : public QObject class VPLayout : public QObject
{ {
Q_OBJECT Q_OBJECT // NOLINT
public: public:
virtual ~VPLayout() = default; ~VPLayout() override = default;
static auto CreateLayout(QUndoStack *undoStack) -> VPLayoutPtr; static auto CreateLayout(QUndoStack *undoStack) -> VPLayoutPtr;
static void AddPiece(const VPLayoutPtr &layout, const VPPiecePtr &piece); static void AddPiece(const VPLayoutPtr &layout, const VPPiecePtr &piece);
@ -83,7 +82,7 @@ public:
auto PiecesForSheet(const VPSheetPtr &sheet) const -> QList<VPPiecePtr>; auto PiecesForSheet(const VPSheetPtr &sheet) const -> QList<VPPiecePtr>;
auto PiecesForSheet(const QUuid &uuid) const -> QList<VPPiecePtr>; auto PiecesForSheet(const QUuid &uuid) const -> QList<VPPiecePtr>;
QUndoStack *UndoStack() const; auto UndoStack() const -> QUndoStack *;
void SetUndoStack(QUndoStack *newUndoStack); void SetUndoStack(QUndoStack *newUndoStack);
@ -100,7 +99,7 @@ public:
auto IsSheetsUniform() const -> bool; auto IsSheetsUniform() const -> bool;
const QUuid &Uuid() const; auto Uuid() const -> const QUuid &;
signals: signals:
void PieceSheetChanged(const VPPiecePtr &piece); void PieceSheetChanged(const VPPiecePtr &piece);
@ -119,7 +118,8 @@ protected:
void AddPiece(const VPPiecePtr &piece); void AddPiece(const VPPiecePtr &piece);
private: private:
Q_DISABLE_COPY(VPLayout) // cppcheck-suppress unknownMacro
Q_DISABLE_COPY_MOVE(VPLayout) // NOLINT
QMap<QString, VPPiecePtr> m_pieces{}; QMap<QString, VPPiecePtr> m_pieces{};
@ -137,6 +137,6 @@ private:
QUuid m_uuid{QUuid::createUuid()}; QUuid m_uuid{QUuid::createUuid()};
}; };
Q_DECLARE_METATYPE(VPLayoutPtr) Q_DECLARE_METATYPE(VPLayoutPtr) // NOLINT
#endif // VPLAYOUT_H #endif // VPLAYOUT_H

View File

@ -29,7 +29,6 @@
#include <QtMath> #include <QtMath>
#include "../vmisc/def.h"
#include "vpsheet.h" #include "vpsheet.h"
#include "vplayout.h" #include "vplayout.h"
#include "../vlayout/vtextmanager.h" #include "../vlayout/vtextmanager.h"
@ -40,7 +39,13 @@
#include <QPainter> #include <QPainter>
#include <QPainterPath> #include <QPainterPath>
Q_LOGGING_CATEGORY(pPiece, "p.piece") QT_WARNING_PUSH
QT_WARNING_DISABLE_CLANG("-Wmissing-prototypes")
QT_WARNING_DISABLE_INTEL(1418)
Q_LOGGING_CATEGORY(pPiece, "p.piece") // NOLINT
QT_WARNING_POP
namespace namespace
{ {
@ -207,7 +212,7 @@ void VPPiece::SetPosition(QPointF point)
auto VPPiece::GetPosition() -> QPointF auto VPPiece::GetPosition() -> QPointF
{ {
QTransform matrix = GetMatrix(); QTransform matrix = GetMatrix();
return QPointF(matrix.dx(), matrix.dy()); return {matrix.dx(), matrix.dy()};
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View File

@ -30,8 +30,6 @@
#include <QTimer> #include <QTimer>
#include "vpapplication.h" #include "vpapplication.h"
#include "../fervor/fvupdater.h"
#include "../vmisc/vsysexits.h"
#include "../vmisc/def.h" #include "../vmisc/def.h"
@ -44,7 +42,7 @@
# include "../vmisc/appimage.h" # include "../vmisc/appimage.h"
#endif // defined(APPIMAGE) && defined(Q_OS_LINUX) #endif // defined(APPIMAGE) && defined(Q_OS_LINUX)
int main(int argc, char *argv[]) auto main(int argc, char *argv[]) -> int
{ {
#if defined(APPIMAGE) && defined(Q_OS_LINUX) #if defined(APPIMAGE) && defined(Q_OS_LINUX)
/* Fix path to ICU_DATA when run AppImage.*/ /* Fix path to ICU_DATA when run AppImage.*/
@ -52,15 +50,15 @@ int main(int argc, char *argv[])
auto FreeMemory = qScopeGuard([exe_dir] {free(exe_dir);}); auto FreeMemory = qScopeGuard([exe_dir] {free(exe_dir);});
#endif // defined(APPIMAGE) && defined(Q_OS_LINUX) #endif // defined(APPIMAGE) && defined(Q_OS_LINUX)
Q_INIT_RESOURCE(puzzleicon); Q_INIT_RESOURCE(puzzleicon); // NOLINT
Q_INIT_RESOURCE(theme); Q_INIT_RESOURCE(theme); // NOLINT
Q_INIT_RESOURCE(icon); Q_INIT_RESOURCE(icon); // NOLINT
Q_INIT_RESOURCE(schema); Q_INIT_RESOURCE(schema); // NOLINT
Q_INIT_RESOURCE(flags); Q_INIT_RESOURCE(flags); // NOLINT
Q_INIT_RESOURCE(style); Q_INIT_RESOURCE(style); // NOLINT
Q_INIT_RESOURCE(cursor); Q_INIT_RESOURCE(cursor); // NOLINT
QT_REQUIRE_VERSION(argc, argv, "5.4.0")// clazy:exclude=qstring-arg,qstring-allocations QT_REQUIRE_VERSION(argc, argv, "5.4.0")// clazy:exclude=qstring-arg,qstring-allocations NOLINT
#if defined(Q_OS_WIN) #if defined(Q_OS_WIN)
VAbstractApplication::WinAttachConsole(); VAbstractApplication::WinAttachConsole();
@ -82,5 +80,5 @@ int main(int argc, char *argv[])
} }
#endif // defined(APPIMAGE) && defined(Q_OS_LINUX) #endif // defined(APPIMAGE) && defined(Q_OS_LINUX)
return app.exec(); return VPApplication::exec();
} }

View File

@ -55,12 +55,19 @@
#include "undocommands/vpundomovepieceonsheet.h" #include "undocommands/vpundomovepieceonsheet.h"
#include <QLoggingCategory> #include <QLoggingCategory>
Q_LOGGING_CATEGORY(pGraphicsPiece, "p.graphicsPiece")
QT_WARNING_PUSH
QT_WARNING_DISABLE_CLANG("-Wmissing-prototypes")
QT_WARNING_DISABLE_INTEL(1418)
Q_LOGGING_CATEGORY(pGraphicsPiece, "p.graphicsPiece") // NOLINT
QT_WARNING_POP
namespace namespace
{ {
QColor mainColor = Qt::black; Q_GLOBAL_STATIC_WITH_ARGS(QColor, mainColor, (Qt::black)) // NOLINT
QColor errorColor = Qt::red; Q_GLOBAL_STATIC_WITH_ARGS(QColor, errorColor, (Qt::red)) // NOLINT
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
inline auto LineMatrix(const VPPiecePtr &piece, const QPointF &topLeft, qreal angle, const QPointF &linePos, inline auto LineMatrix(const VPPiecePtr &piece, const QPointF &topLeft, qreal angle, const QPointF &linePos,
@ -135,6 +142,12 @@ inline auto LineAlign(const TextLine& tl, const QString &text, const QFontMetric
return dX; return dX;
} }
//---------------------------------------------------------------------------------------------------------------------
inline auto SelectionBrush() -> QBrush
{
return {QColor(255, 160, 160, 60)};
}
} // namespace } // namespace
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -229,7 +242,7 @@ void VPGraphicsPiece::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
GroupMove(event->pos()); GroupMove(event->pos());
m_moveStartPoint = event->pos(); m_moveStartPoint = event->pos();
allowChangeMerge = true; m_allowChangeMerge = true;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -253,7 +266,7 @@ void VPGraphicsPiece::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
if (layout->LayoutSettings().GetStickyEdges() && m_hasStickyPosition) if (layout->LayoutSettings().GetStickyEdges() && m_hasStickyPosition)
{ {
auto *command = new VPUndoPieceMove(piece, m_stickyTranslateX, m_stickyTranslateY, auto *command = new VPUndoPieceMove(piece, m_stickyTranslateX, m_stickyTranslateY,
allowChangeMerge); m_allowChangeMerge);
layout->UndoStack()->push(command); layout->UndoStack()->push(command);
SetStickyPoints(QVector<QPointF>()); SetStickyPoints(QVector<QPointF>());
@ -261,7 +274,7 @@ void VPGraphicsPiece::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
} }
} }
allowChangeMerge = false; m_allowChangeMerge = false;
m_hasStickyPosition = false; m_hasStickyPosition = false;
} }
} }
@ -441,9 +454,6 @@ void VPGraphicsPiece::InitPieceLabel(const QVector<QPointF> &labelShape, const V
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPGraphicsPiece::PaintPiece(QPainter *painter) void VPGraphicsPiece::PaintPiece(QPainter *painter)
{ {
QBrush noBrush = m_hoverMode ? QBrush(QColor(199, 244, 249, 60)) : QBrush(Qt::NoBrush);
QBrush selectionBrush(QColor(255, 160, 160, 60));
m_seamLine = QPainterPath(); m_seamLine = QPainterPath();
m_cuttingLine = QPainterPath(); m_cuttingLine = QPainterPath();
m_grainline = QPainterPath(); m_grainline = QPainterPath();
@ -459,6 +469,29 @@ void VPGraphicsPiece::PaintPiece(QPainter *painter)
} }
// initialises the seam line // initialises the seam line
PaintSeamLine(painter, piece);
// initiliases the cutting line
PaintCuttingLine(painter, piece);
// initialises the grainline
PaintGrainline(painter, piece);
// initialises the internal paths
PaintInternalPaths(painter, piece);
// initialises the passmarks
PaintPassmarks(painter, piece);
// initialises the place labels (buttons etc)
PaintPlaceLabels(painter, piece);
PaintStickyPath(painter);
}
//---------------------------------------------------------------------------------------------------------------------
void VPGraphicsPiece::PaintSeamLine(QPainter *painter, const VPPiecePtr &piece)
{
if (not piece->IsHideMainPath() || not piece->IsSeamAllowance()) if (not piece->IsHideMainPath() || not piece->IsSeamAllowance())
{ {
QVector<QPointF> seamLinePoints = piece->GetMappedContourPoints(); QVector<QPointF> seamLinePoints = piece->GetMappedContourPoints();
@ -473,14 +506,17 @@ void VPGraphicsPiece::PaintPiece(QPainter *painter)
if (painter != nullptr) if (painter != nullptr)
{ {
painter->save(); painter->save();
painter->setBrush(piece->IsSelected() ? selectionBrush : noBrush); painter->setBrush(piece->IsSelected() ? SelectionBrush() : NoBrush());
painter->drawPath(m_seamLine); painter->drawPath(m_seamLine);
painter->restore(); painter->restore();
} }
} }
} }
}
// initiliases the cutting line //---------------------------------------------------------------------------------------------------------------------
void VPGraphicsPiece::PaintCuttingLine(QPainter *painter, const VPPiecePtr &piece)
{
if (piece->IsSeamAllowance() && not piece->IsSeamAllowanceBuiltIn()) if (piece->IsSeamAllowance() && not piece->IsSeamAllowanceBuiltIn())
{ {
QVector<QPointF> cuttingLinepoints = piece->GetMappedSeamAllowancePoints(); QVector<QPointF> cuttingLinepoints = piece->GetMappedSeamAllowancePoints();
@ -495,14 +531,17 @@ void VPGraphicsPiece::PaintPiece(QPainter *painter)
if (painter != nullptr) if (painter != nullptr)
{ {
painter->save(); painter->save();
painter->setBrush(piece->IsSelected() ? selectionBrush : noBrush); painter->setBrush(piece->IsSelected() ? SelectionBrush() : NoBrush());
painter->drawPath(m_cuttingLine); painter->drawPath(m_cuttingLine);
painter->restore(); painter->restore();
} }
} }
} }
}
// initialises the grainline //---------------------------------------------------------------------------------------------------------------------
void VPGraphicsPiece::PaintGrainline(QPainter *painter, const VPPiecePtr &piece)
{
if(piece->IsGrainlineEnabled()) if(piece->IsGrainlineEnabled())
{ {
QVector<QPointF> grainLinepoints = piece->GetMappedGrainline(); QVector<QPointF> grainLinepoints = piece->GetMappedGrainline();
@ -519,16 +558,19 @@ void VPGraphicsPiece::PaintPiece(QPainter *painter)
painter->save(); painter->save();
// here to fill the grainlines arrow. Not wanted for mvp // here to fill the grainlines arrow. Not wanted for mvp
// later maybe if it's configurable // later maybe if it's configurable
// painter->setBrush(blackBrush); // painter->setBrush(blackBrush);
painter->setBrush(noBrush); painter->setBrush(NoBrush());
painter->drawPath(m_grainline); painter->drawPath(m_grainline);
painter->restore(); painter->restore();
} }
} }
} }
}
// initialises the internal paths //---------------------------------------------------------------------------------------------------------------------
void VPGraphicsPiece::PaintInternalPaths(QPainter *painter, const VPPiecePtr &piece)
{
QVector<VLayoutPiecePath> internalPaths = piece->GetInternalPaths(); QVector<VLayoutPiecePath> internalPaths = piece->GetInternalPaths();
for (const auto& piecePath : internalPaths) for (const auto& piecePath : internalPaths)
{ {
@ -545,8 +587,11 @@ void VPGraphicsPiece::PaintPiece(QPainter *painter)
} }
m_internalPaths.addPath(path); m_internalPaths.addPath(path);
} }
}
// initialises the passmarks //---------------------------------------------------------------------------------------------------------------------
void VPGraphicsPiece::PaintPassmarks(QPainter *painter, const VPPiecePtr &piece)
{
QVector<VLayoutPassmark> passmarks = piece->GetMappedPassmarks(); QVector<VLayoutPassmark> passmarks = piece->GetMappedPassmarks();
for(auto &passmark : passmarks) for(auto &passmark : passmarks)
{ {
@ -560,15 +605,18 @@ void VPGraphicsPiece::PaintPiece(QPainter *painter)
if (painter != nullptr) if (painter != nullptr)
{ {
painter->save(); painter->save();
painter->setBrush(noBrush); painter->setBrush(NoBrush());
painter->drawPath(passmarkPath); painter->drawPath(passmarkPath);
painter->restore(); painter->restore();
} }
m_passmarks.addPath(passmarkPath); m_passmarks.addPath(passmarkPath);
} }
}
// initialises the place labels (buttons etc) //---------------------------------------------------------------------------------------------------------------------
void VPGraphicsPiece::PaintPlaceLabels(QPainter *painter, const VPPiecePtr &piece)
{
QVector<VLayoutPlaceLabel> placeLabels = piece->GetMappedPlaceLabels(); QVector<VLayoutPlaceLabel> placeLabels = piece->GetMappedPlaceLabels();
for(auto &placeLabel : placeLabels) for(auto &placeLabel : placeLabels)
{ {
@ -577,14 +625,18 @@ void VPGraphicsPiece::PaintPiece(QPainter *painter)
if (painter != nullptr) if (painter != nullptr)
{ {
painter->save(); painter->save();
painter->setBrush(noBrush); painter->setBrush(NoBrush());
painter->drawPath(path); painter->drawPath(path);
painter->restore(); painter->restore();
} }
m_placeLabels.addPath(path); m_placeLabels.addPath(path);
} }
}
//---------------------------------------------------------------------------------------------------------------------
void VPGraphicsPiece::PaintStickyPath(QPainter *painter)
{
if (not m_stickyPoints.isEmpty()) if (not m_stickyPoints.isEmpty())
{ {
m_stickyPath.moveTo(ConstFirst(m_stickyPoints)); m_stickyPath.moveTo(ConstFirst(m_stickyPoints));
@ -600,7 +652,7 @@ void VPGraphicsPiece::PaintPiece(QPainter *painter)
QPen pen = painter->pen(); QPen pen = painter->pen();
pen.setStyle(Qt::DashLine); pen.setStyle(Qt::DashLine);
pen.setColor(mainColor); pen.setColor(*mainColor);
painter->setPen(pen); painter->setPen(pen);
painter->drawPath(m_stickyPath); painter->drawPath(m_stickyPath);
@ -648,7 +700,7 @@ void VPGraphicsPiece::GroupMove(const QPointF &pos)
if (pieces.size() == 1) if (pieces.size() == 1)
{ {
const VPPiecePtr &p = ConstFirst(pieces); const VPPiecePtr &p = ConstFirst(pieces);
auto *command = new VPUndoPieceMove(piece, newPos.x(), newPos.y(), allowChangeMerge); auto *command = new VPUndoPieceMove(piece, newPos.x(), newPos.y(), m_allowChangeMerge);
layout->UndoStack()->push(command); layout->UndoStack()->push(command);
if (layout->LayoutSettings().GetStickyEdges()) if (layout->LayoutSettings().GetStickyEdges())
@ -672,7 +724,7 @@ void VPGraphicsPiece::GroupMove(const QPointF &pos)
} }
else if (pieces.size() > 1) else if (pieces.size() > 1)
{ {
auto *command = new VPUndoPiecesMove(pieces, newPos.x(), newPos.y(), allowChangeMerge); auto *command = new VPUndoPiecesMove(pieces, newPos.x(), newPos.y(), m_allowChangeMerge);
layout->UndoStack()->push(command); layout->UndoStack()->push(command);
} }
} }
@ -683,13 +735,13 @@ auto VPGraphicsPiece::PieceColor() const -> QColor
VPPiecePtr piece = m_piece.toStrongRef(); VPPiecePtr piece = m_piece.toStrongRef();
if (piece.isNull()) if (piece.isNull())
{ {
return mainColor; return *mainColor;
} }
VPLayoutPtr layout = piece->Layout(); VPLayoutPtr layout = piece->Layout();
if (layout.isNull()) if (layout.isNull())
{ {
return mainColor; return *mainColor;
} }
bool outOfBound = false; bool outOfBound = false;
@ -706,10 +758,16 @@ auto VPGraphicsPiece::PieceColor() const -> QColor
if (outOfBound || superposition) if (outOfBound || superposition)
{ {
return errorColor; return *errorColor;
} }
return mainColor; return *mainColor;
}
//---------------------------------------------------------------------------------------------------------------------
auto VPGraphicsPiece::NoBrush() const -> QBrush
{
return m_hoverMode ? QBrush(QColor(199, 244, 249, 60)) : QBrush(Qt::NoBrush);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View File

@ -100,7 +100,7 @@ private:
QPointF m_moveStartPoint{}; QPointF m_moveStartPoint{};
QPointF m_rotationStartPoint{}; QPointF m_rotationStartPoint{};
bool allowChangeMerge{false}; bool m_allowChangeMerge{false};
QVector<QPointF> m_stickyPoints{}; QVector<QPointF> m_stickyPoints{};
QPainterPath m_stickyPath{}; QPainterPath m_stickyPath{};
@ -119,10 +119,19 @@ private:
void InitLabels(); void InitLabels();
void InitPieceLabel(const QVector<QPointF> &labelShape, const VTextManager &tm); void InitPieceLabel(const QVector<QPointF> &labelShape, const VTextManager &tm);
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 PaintGrainline(QPainter *painter, const VPPiecePtr &piece);
void PaintInternalPaths(QPainter *painter, const VPPiecePtr &piece);
void PaintPassmarks(QPainter *painter, const VPPiecePtr &piece);
void PaintPlaceLabels(QPainter *painter, const VPPiecePtr &piece);
void PaintStickyPath(QPainter *painter);
void GroupMove(const QPointF &pos); void GroupMove(const QPointF &pos);
auto PieceColor() const -> QColor; auto PieceColor() const -> QColor;
auto NoBrush() const -> QBrush;
}; };
#endif // VPGRAPHICSPIECE_H #endif // VPGRAPHICSPIECE_H

View File

@ -40,6 +40,7 @@
#include "../vwidgets/global.h" #include "../vwidgets/global.h"
#include "../layout/vplayout.h" #include "../layout/vplayout.h"
#include "../layout/vppiece.h" #include "../layout/vppiece.h"
#include "../layout/vpsheet.h"
#include "../undocommands/vpundopiecerotate.h" #include "../undocommands/vpundopiecerotate.h"
#include "../undocommands/vpundooriginmove.h" #include "../undocommands/vpundooriginmove.h"
#include "qgraphicsscene.h" #include "qgraphicsscene.h"
@ -53,8 +54,8 @@ constexpr qreal penWidth = 2;
const qreal centerRadius1 = 5; const qreal centerRadius1 = 5;
const qreal centerRadius2 = 10; const qreal centerRadius2 = 10;
const QColor defaultColor = Qt::black; Q_GLOBAL_STATIC_WITH_ARGS(const QColor, defaultColor, (Qt::black)) // NOLINT
const QColor hoverColor = Qt::green; Q_GLOBAL_STATIC_WITH_ARGS(const QColor, hoverColor, (Qt::green)) // NOLINT
auto TransformationOrigin(const VPLayoutPtr &layout, const QRectF &boundingRect) -> VPTransformationOrigon auto TransformationOrigin(const VPLayoutPtr &layout, const QRectF &boundingRect) -> VPTransformationOrigon
{ {
@ -83,7 +84,7 @@ auto TransformationOrigin(const VPLayoutPtr &layout, const QRectF &boundingRect)
VPGraphicsTransformationOrigin::VPGraphicsTransformationOrigin(const VPLayoutPtr &layout, QGraphicsItem *parent) VPGraphicsTransformationOrigin::VPGraphicsTransformationOrigin(const VPLayoutPtr &layout, QGraphicsItem *parent)
: QGraphicsObject(parent), : QGraphicsObject(parent),
m_layout(layout), m_layout(layout),
m_color(defaultColor) m_color(*defaultColor)
{ {
SCASSERT(m_layout != nullptr) SCASSERT(m_layout != nullptr)
setCursor(Qt::OpenHandCursor); setCursor(Qt::OpenHandCursor);
@ -209,14 +210,14 @@ void VPGraphicsTransformationOrigin::mouseReleaseEvent(QGraphicsSceneMouseEvent
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPGraphicsTransformationOrigin::hoverEnterEvent(QGraphicsSceneHoverEvent *event) void VPGraphicsTransformationOrigin::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
{ {
m_color = hoverColor; m_color = *hoverColor;
QGraphicsObject::hoverEnterEvent(event); QGraphicsObject::hoverEnterEvent(event);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPGraphicsTransformationOrigin::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) void VPGraphicsTransformationOrigin::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
{ {
m_color = defaultColor; m_color = *defaultColor;
QGraphicsObject::hoverEnterEvent(event); QGraphicsObject::hoverEnterEvent(event);
} }
@ -419,7 +420,7 @@ void VPGraphicsPieceControls::mousePressEvent(QGraphicsSceneMouseEvent *event)
QGraphicsView *view = ItemView(); QGraphicsView *view = ItemView();
if (view != nullptr) if (view != nullptr)
{ {
setCursor(view->viewport()->cursor()); setCursor(view->viewport()->cursor()); // clazy:exclude=clazy-qt6-deprecated-api-fixes
} }
event->ignore(); event->ignore();
} }
@ -502,7 +503,7 @@ void VPGraphicsPieceControls::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
QGraphicsView *view = ItemView(); QGraphicsView *view = ItemView();
if (view != nullptr) if (view != nullptr)
{ {
setCursor(view->viewport()->cursor()); setCursor(view->viewport()->cursor()); // clazy:exclude=clazy-qt6-deprecated-api-fixes
} }
} }
@ -782,7 +783,7 @@ void VPGraphicsPieceControls::UpdateCursor(VPHandleCorner corner)
QGraphicsView *view = ItemView(); QGraphicsView *view = ItemView();
if (view != nullptr) if (view != nullptr)
{ {
setCursor(view->viewport()->cursor()); setCursor(view->viewport()->cursor()); // clazy:exclude=clazy-qt6-deprecated-api-fixes
} }
} }
} }

View File

@ -32,7 +32,7 @@
#include <QGraphicsObject> #include <QGraphicsObject>
#include "scenedef.h" #include "scenedef.h"
#include "../layout/vpsheet.h" #include "../layout/layoutdef.h"
#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) #if QT_VERSION < QT_VERSION_CHECK(5, 13, 0)
#include "../vmisc/defglobal.h" #include "../vmisc/defglobal.h"
@ -64,6 +64,7 @@ class VPGraphicsTransformationOrigin : public QGraphicsObject
Q_OBJECT // NOLINT Q_OBJECT // NOLINT
public: public:
explicit VPGraphicsTransformationOrigin(const VPLayoutPtr &layout, QGraphicsItem * parent = nullptr); explicit VPGraphicsTransformationOrigin(const VPLayoutPtr &layout, QGraphicsItem * parent = nullptr);
~VPGraphicsTransformationOrigin() override = default;
auto type() const -> int override {return Type;} auto type() const -> int override {return Type;}
enum { Type = UserType + static_cast<int>(PGraphicsItem::TransformationOrigin)}; enum { Type = UserType + static_cast<int>(PGraphicsItem::TransformationOrigin)};
@ -86,6 +87,7 @@ protected:
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event) override; void hoverLeaveEvent(QGraphicsSceneHoverEvent *event) override;
private: private:
// cppcheck-suppress unknownMacro
Q_DISABLE_COPY_MOVE(VPGraphicsTransformationOrigin) // NOLINT Q_DISABLE_COPY_MOVE(VPGraphicsTransformationOrigin) // NOLINT
bool m_originVisible{true}; bool m_originVisible{true};
@ -103,6 +105,7 @@ class VPGraphicsPieceControls : public QGraphicsObject
Q_OBJECT // NOLINT Q_OBJECT // NOLINT
public: public:
explicit VPGraphicsPieceControls(const VPLayoutPtr &layout, QGraphicsItem * parent = nullptr); explicit VPGraphicsPieceControls(const VPLayoutPtr &layout, QGraphicsItem * parent = nullptr);
~VPGraphicsPieceControls() override = default;
auto type() const -> int override {return Type;} auto type() const -> int override {return Type;}
enum { Type = UserType + static_cast<int>(PGraphicsItem::Handles)}; enum { Type = UserType + static_cast<int>(PGraphicsItem::Handles)};

View File

@ -33,6 +33,7 @@
#include <QPainter> #include <QPainter>
#include "../layout/layoutdef.h" #include "../layout/layoutdef.h"
#include "../vmisc/defglobal.h"
class VPLayout; class VPLayout;
@ -40,7 +41,7 @@ class VPGraphicsSheet : public QGraphicsItem
{ {
public: public:
explicit VPGraphicsSheet(const VPLayoutPtr &layout, QGraphicsItem *parent = nullptr); explicit VPGraphicsSheet(const VPLayoutPtr &layout, QGraphicsItem *parent = nullptr);
~VPGraphicsSheet()=default; ~VPGraphicsSheet() override =default;
auto boundingRect() const -> QRectF override; auto boundingRect() const -> QRectF override;
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override; void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
@ -63,7 +64,8 @@ public:
void RefreshBoundingRect(); void RefreshBoundingRect();
private: private:
Q_DISABLE_COPY(VPGraphicsSheet) // cppcheck-suppress unknownMacro
Q_DISABLE_COPY_MOVE(VPGraphicsSheet) // NOLINT
VPLayoutWeakPtr m_layout{}; VPLayoutWeakPtr m_layout{};

View File

@ -34,14 +34,12 @@
#include <QMenu> #include <QMenu>
#include <QUndoStack> #include <QUndoStack>
#include "../vptilefactory.h"
#include "../carousel/vpmimedatapiece.h" #include "../carousel/vpmimedatapiece.h"
#include "../layout/vplayout.h" #include "../layout/vplayout.h"
#include "../layout/vpsheet.h" #include "../layout/vpsheet.h"
#include "../layout/vppiece.h" #include "../layout/vppiece.h"
#include "../vwidgets/vmaingraphicsscene.h" #include "../vwidgets/vmaingraphicsscene.h"
#include "undocommands/vpundopiecezvaluemove.h" #include "undocommands/vpundopiecezvaluemove.h"
#include "vptilefactory.h"
#include "vpgraphicspiece.h" #include "vpgraphicspiece.h"
#include "vpgraphicspiececontrols.h" #include "vpgraphicspiececontrols.h"
@ -53,14 +51,21 @@
#include <QLoggingCategory> #include <QLoggingCategory>
Q_LOGGING_CATEGORY(pMainGraphicsView, "p.mainGraphicsView") QT_WARNING_PUSH
QT_WARNING_DISABLE_CLANG("-Wmissing-prototypes")
QT_WARNING_DISABLE_INTEL(1418)
Q_LOGGING_CATEGORY(pMainGraphicsView, "p.mainGraphicsView") // NOLINT
QT_WARNING_POP
namespace namespace
{ {
QT_WARNING_PUSH QT_WARNING_PUSH
QT_WARNING_DISABLE_CLANG("-Wenum-enum-conversion") QT_WARNING_DISABLE_CLANG("-Wenum-enum-conversion")
const QKeySequence restoreOriginShortcut = QKeySequence(Qt::ControlModifier + Qt::Key_Asterisk); Q_GLOBAL_STATIC_WITH_ARGS(const QKeySequence, restoreOriginShortcut, // NOLINT
(QKeySequence(Qt::ControlModifier + Qt::Key_Asterisk)))
QT_WARNING_POP QT_WARNING_POP
} }
@ -82,7 +87,7 @@ VPMainGraphicsView::VPMainGraphicsView(const VPLayoutPtr &layout, QWidget *paren
connect(layout.data(), &VPLayout::ActiveSheetChanged, this, &VPMainGraphicsView::on_ActiveSheetChanged); connect(layout.data(), &VPLayout::ActiveSheetChanged, this, &VPMainGraphicsView::on_ActiveSheetChanged);
auto *restoreOrigin = new QAction(this); auto *restoreOrigin = new QAction(this);
restoreOrigin->setShortcut(restoreOriginShortcut); restoreOrigin->setShortcut(*restoreOriginShortcut);
connect(restoreOrigin, &QAction::triggered, this, &VPMainGraphicsView::RestoreOrigin); connect(restoreOrigin, &QAction::triggered, this, &VPMainGraphicsView::RestoreOrigin);
this->addAction(restoreOrigin); this->addAction(restoreOrigin);
} }
@ -205,91 +210,34 @@ void VPMainGraphicsView::dropEvent(QDropEvent *event)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPMainGraphicsView::keyPressEvent(QKeyEvent *event) void VPMainGraphicsView::keyPressEvent(QKeyEvent *event)
{ {
if(event->key() == Qt::Key_Backspace || event->key() == Qt::Key_Delete) const bool shiftModifier = (event->modifiers() & Qt::ShiftModifier) != 0U;
{ const bool controlModifier = (event->modifiers() & Qt::ControlModifier) != 0U;
VPLayoutPtr layout = m_layout.toStrongRef(); const bool altModifier = (event->modifiers() & Qt::AltModifier) != 0U;
if (layout.isNull())
{
return;
}
VPSheetPtr sheet = layout->GetFocusedSheet(); switch(event->key())
if (sheet.isNull())
{ {
return ; case Qt::Key_Backspace:
} case Qt::Key_Delete:
RemovePiece();
const QList<VPGraphicsPiece *> &graphicsPieces = sheet->SceneData()->GraphicsPieces(); break;
for(auto *graphicsPiece : graphicsPieces) case Qt::Key_Left:
{ shiftModifier ? TranslatePiecesOn(-10, 0) : TranslatePiecesOn(-1, 0);
VPPiecePtr piece = graphicsPiece->GetPiece(); break;
case Qt::Key_Right:
if(not piece.isNull() && piece->IsSelected()) shiftModifier ? TranslatePiecesOn(10, 0) : TranslatePiecesOn(1, 0);
{ break;
piece->SetSelected(false); case Qt::Key_Up:
shiftModifier ? TranslatePiecesOn(0, -10) : TranslatePiecesOn(0, -1);
VPLayoutPtr layout = m_layout.toStrongRef(); break;
if (not layout.isNull()) case Qt::Key_Down:
{ shiftModifier ? TranslatePiecesOn(0, 10) : TranslatePiecesOn(0, 1);
emit layout->PieceSelectionChanged(piece); break;
case Qt::Key_BracketLeft:
auto *command = new VPUndoMovePieceOnSheet(VPSheetPtr(), piece); if(controlModifier)
layout->UndoStack()->push(command);
}
}
}
}
else if (event->key() == Qt::Key_Left)
{
if((event->modifiers() & Qt::ShiftModifier) != 0U)
{
TranslatePiecesOn(-10, 0);
}
else
{
TranslatePiecesOn(-1, 0);
}
}
else if (event->key() == Qt::Key_Right)
{
if((event->modifiers() & Qt::ShiftModifier) != 0U)
{
TranslatePiecesOn(10, 0);
}
else
{
TranslatePiecesOn(1, 0);
}
}
else if (event->key() == Qt::Key_Up)
{
if((event->modifiers() & Qt::ShiftModifier) != 0U)
{
TranslatePiecesOn(0, -10);
}
else
{
TranslatePiecesOn(0, -1);
}
}
else if (event->key() == Qt::Key_Down)
{
if((event->modifiers() & Qt::ShiftModifier) != 0U)
{
TranslatePiecesOn(0, 10);
}
else
{
TranslatePiecesOn(0, 1);
}
}
else if (event->key() == Qt::Key_BracketLeft)
{
if((event->modifiers() & Qt::ControlModifier) != 0U)
{ {
RotatePiecesByAngle(90); RotatePiecesByAngle(90);
} }
else if((event->modifiers() & Qt::AltModifier) != 0U) else if(altModifier)
{ {
RotatePiecesByAngle(1); RotatePiecesByAngle(1);
} }
@ -297,14 +245,13 @@ void VPMainGraphicsView::keyPressEvent(QKeyEvent *event)
{ {
RotatePiecesByAngle(15); RotatePiecesByAngle(15);
} }
} break;
else if (event->key() == Qt::Key_BracketRight) case Qt::Key_BracketRight:
{ if(controlModifier)
if((event->modifiers() & Qt::ControlModifier) != 0U)
{ {
RotatePiecesByAngle(-90); RotatePiecesByAngle(-90);
} }
else if((event->modifiers() & Qt::AltModifier) != 0U) else if(altModifier)
{ {
RotatePiecesByAngle(-1); RotatePiecesByAngle(-1);
} }
@ -312,87 +259,39 @@ void VPMainGraphicsView::keyPressEvent(QKeyEvent *event)
{ {
RotatePiecesByAngle(-15); RotatePiecesByAngle(-15);
} }
} break;
else if (event->key() == Qt::Key_Home) case Qt::Key_Home:
{
ZValueMove(static_cast<int>(ML::ZValueMove::Top)); ZValueMove(static_cast<int>(ML::ZValueMove::Top));
} break;
else if (event->key() == Qt::Key_PageUp) case Qt::Key_PageUp:
{
ZValueMove(static_cast<int>(ML::ZValueMove::Up)); ZValueMove(static_cast<int>(ML::ZValueMove::Up));
} break;
else if (event->key() == Qt::Key_PageDown) case Qt::Key_PageDown:
{
ZValueMove(static_cast<int>(ML::ZValueMove::Down)); ZValueMove(static_cast<int>(ML::ZValueMove::Down));
} break;
else if (event->key() == Qt::Key_End) case Qt::Key_End:
{
ZValueMove(static_cast<int>(ML::ZValueMove::Bottom)); ZValueMove(static_cast<int>(ML::ZValueMove::Bottom));
break;
default:
break;
} }
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPMainGraphicsView::keyReleaseEvent(QKeyEvent *event) void VPMainGraphicsView::keyReleaseEvent(QKeyEvent *event)
{ {
if (event->key() == Qt::Key_Left || switch(event->key())
event->key() == Qt::Key_Right ||
event->key() == Qt::Key_Up ||
event->key() == Qt::Key_Down ||
event->key() == Qt::Key_BracketLeft ||
event->key() == Qt::Key_BracketRight)
{ {
if (not event->isAutoRepeat()) case Qt::Key_Left:
{ case Qt::Key_Right:
VPLayoutPtr layout = m_layout.toStrongRef(); case Qt::Key_Up:
if (layout.isNull()) case Qt::Key_Down:
{ case Qt::Key_BracketLeft:
return; case Qt::Key_BracketRight:
} MovePiece(event);
break;
VPSheetPtr sheet = layout->GetFocusedSheet(); default:
if (sheet.isNull()) break;
{
return;
}
const QList<VPGraphicsPiece *> &graphicsPieces = sheet->SceneData()->GraphicsPieces();
if (m_hasStickyPosition && not graphicsPieces.isEmpty())
{
if (layout->LayoutSettings().GetStickyEdges())
{
auto PreparePieces = [layout]()
{
QList<VPPiecePtr> pieces;
VPSheetPtr sheet = layout->GetFocusedSheet();
if (not sheet.isNull())
{
pieces = sheet->GetSelectedPieces();
}
return pieces;
};
QList<VPPiecePtr> pieces = PreparePieces();
if (pieces.size() == 1)
{
const VPPiecePtr &p = ConstFirst(pieces);
auto *command = new VPUndoPieceMove(p, m_stickyTranslateX, m_stickyTranslateY,
m_allowChangeMerge);
layout->UndoStack()->push(command);
VPGraphicsPiece * gPiece = sheet->SceneData()->ScenePiece(p);
if (gPiece != nullptr)
{
gPiece->SetStickyPoints(QVector<QPointF>());
}
}
}
}
m_allowChangeMerge = false;
m_hasStickyPosition = false;
}
} }
if (event->key() == Qt::Key_BracketLeft || event->key() == Qt::Key_BracketRight) if (event->key() == Qt::Key_BracketLeft || event->key() == Qt::Key_BracketRight)
@ -440,7 +339,7 @@ void VPMainGraphicsView::contextMenuEvent(QContextMenuEvent *event)
QMenu menu; QMenu menu;
QAction *restoreOriginAction = menu.addAction(tr("Restore transformation origin")); QAction *restoreOriginAction = menu.addAction(tr("Restore transformation origin"));
restoreOriginAction->setShortcut(restoreOriginShortcut); restoreOriginAction->setShortcut(*restoreOriginShortcut);
restoreOriginAction->setEnabled(not sheet.isNull() && sheet->TransformationOrigin().custom); restoreOriginAction->setEnabled(not sheet.isNull() && sheet->TransformationOrigin().custom);
QAction *removeSheetAction = menu.addAction(QIcon::fromTheme(QStringLiteral("edit-delete")), tr("Remove sheet")); QAction *removeSheetAction = menu.addAction(QIcon::fromTheme(QStringLiteral("edit-delete")), tr("Remove sheet"));
@ -723,6 +622,99 @@ void VPMainGraphicsView::ZValueMove(int move)
} }
} }
//---------------------------------------------------------------------------------------------------------------------
void VPMainGraphicsView::RemovePiece() const
{
VPLayoutPtr layout = m_layout.toStrongRef();
if (layout.isNull())
{
return;
}
VPSheetPtr sheet = layout->GetFocusedSheet();
if (sheet.isNull())
{
return ;
}
const QList<VPGraphicsPiece *> &graphicsPieces = sheet->SceneData()->GraphicsPieces();
for(auto *graphicsPiece : graphicsPieces)
{
VPPiecePtr piece = graphicsPiece->GetPiece();
if(not piece.isNull() && piece->IsSelected())
{
piece->SetSelected(false);
VPLayoutPtr layout = m_layout.toStrongRef();
if (not layout.isNull())
{
emit layout->PieceSelectionChanged(piece);
auto *command = new VPUndoMovePieceOnSheet(VPSheetPtr(), piece);
layout->UndoStack()->push(command);
}
}
}
}
//---------------------------------------------------------------------------------------------------------------------
void VPMainGraphicsView::MovePiece(QKeyEvent *event)
{
if (not event->isAutoRepeat())
{
VPLayoutPtr layout = m_layout.toStrongRef();
if (layout.isNull())
{
return;
}
VPSheetPtr sheet = layout->GetFocusedSheet();
if (sheet.isNull())
{
return;
}
const QList<VPGraphicsPiece *> &graphicsPieces = sheet->SceneData()->GraphicsPieces();
if (m_hasStickyPosition && not graphicsPieces.isEmpty())
{
if (layout->LayoutSettings().GetStickyEdges())
{
auto PreparePieces = [layout]()
{
QList<VPPiecePtr> pieces;
VPSheetPtr sheet = layout->GetFocusedSheet();
if (not sheet.isNull())
{
pieces = sheet->GetSelectedPieces();
}
return pieces;
};
QList<VPPiecePtr> pieces = PreparePieces();
if (pieces.size() == 1)
{
const VPPiecePtr &p = ConstFirst(pieces);
auto *command = new VPUndoPieceMove(p, m_stickyTranslateX, m_stickyTranslateY,
m_allowChangeMerge);
layout->UndoStack()->push(command);
VPGraphicsPiece * gPiece = sheet->SceneData()->ScenePiece(p);
if (gPiece != nullptr)
{
gPiece->SetStickyPoints(QVector<QPointF>());
}
}
}
}
m_allowChangeMerge = false;
m_hasStickyPosition = false;
}
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPMainGraphicsView::on_PieceSheetChanged(const VPPiecePtr &piece) void VPMainGraphicsView::on_PieceSheetChanged(const VPPiecePtr &piece)
{ {

View File

@ -44,10 +44,10 @@ class VPPiece;
class VPMainGraphicsView : public VMainGraphicsView class VPMainGraphicsView : public VMainGraphicsView
{ {
Q_OBJECT Q_OBJECT // NOLINT
public: public:
VPMainGraphicsView(const VPLayoutPtr &layout, QWidget *parent); VPMainGraphicsView(const VPLayoutPtr &layout, QWidget *parent);
~VPMainGraphicsView() = default; ~VPMainGraphicsView() override = default;
/** /**
* @brief RefreshLayout Refreshes the rectangles for the layout border and the margin * @brief RefreshLayout Refreshes the rectangles for the layout border and the margin
@ -91,7 +91,8 @@ private slots:
void on_SceneMouseMove(const QPointF &scenePos); void on_SceneMouseMove(const QPointF &scenePos);
private: private:
Q_DISABLE_COPY(VPMainGraphicsView) // cppcheck-suppress unknownMacro
Q_DISABLE_COPY_MOVE(VPMainGraphicsView) // NOLINT
VPLayoutWeakPtr m_layout; VPLayoutWeakPtr m_layout;
@ -110,6 +111,9 @@ private:
void ClearSelection(); void ClearSelection();
void ZValueMove(int move); void ZValueMove(int move);
void RemovePiece() const;
void MovePiece(QKeyEvent *event);
}; };
#endif // VPMAINGRAPHICSVIEW_H #endif // VPMAINGRAPHICSVIEW_H

View File

@ -34,17 +34,17 @@
class VPUndoAddSheet : public VPUndoCommand class VPUndoAddSheet : public VPUndoCommand
{ {
Q_OBJECT Q_OBJECT // NOLINT
public: public:
explicit VPUndoAddSheet(const VPSheetPtr &sheet, QUndoCommand *parent = nullptr); explicit VPUndoAddSheet(const VPSheetPtr &sheet, QUndoCommand *parent = nullptr);
virtual ~VPUndoAddSheet()=default; ~VPUndoAddSheet() override =default;
virtual void undo() override; void undo() override;
virtual void redo() override; void redo() override;
virtual auto id() const -> int override; auto id() const -> int override;
private: private:
Q_DISABLE_COPY(VPUndoAddSheet) Q_DISABLE_COPY_MOVE(VPUndoAddSheet) // NOLINT
VPSheetWeakPtr m_sheet; VPSheetWeakPtr m_sheet;
}; };

View File

@ -27,7 +27,13 @@
*************************************************************************/ *************************************************************************/
#include "vpundocommand.h" #include "vpundocommand.h"
Q_LOGGING_CATEGORY(vpUndo, "vp.undo") QT_WARNING_PUSH
QT_WARNING_DISABLE_CLANG("-Wmissing-prototypes")
QT_WARNING_DISABLE_INTEL(1418)
Q_LOGGING_CATEGORY(vpUndo, "vp.undo") // NOLINT
QT_WARNING_POP
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VPUndoCommand::VPUndoCommand(QUndoCommand *parent) VPUndoCommand::VPUndoCommand(QUndoCommand *parent)

View File

@ -34,17 +34,17 @@
class VPUndoMovePieceOnSheet : public VPUndoCommand class VPUndoMovePieceOnSheet : public VPUndoCommand
{ {
Q_OBJECT Q_OBJECT // NOLINT
public: public:
VPUndoMovePieceOnSheet(const VPSheetPtr &sheet, const VPPiecePtr &piece, QUndoCommand *parent = nullptr); VPUndoMovePieceOnSheet(const VPSheetPtr &sheet, const VPPiecePtr &piece, QUndoCommand *parent = nullptr);
virtual ~VPUndoMovePieceOnSheet()=default; ~VPUndoMovePieceOnSheet() override =default;
virtual void undo() override; void undo() override;
virtual void redo() override; void redo() override;
virtual auto id() const -> int override; auto id() const -> int override;
private: private:
Q_DISABLE_COPY(VPUndoMovePieceOnSheet) Q_DISABLE_COPY_MOVE(VPUndoMovePieceOnSheet) // NOLINT
VPSheetWeakPtr m_oldSheet{}; VPSheetWeakPtr m_oldSheet{};
VPSheetWeakPtr m_sheet; VPSheetWeakPtr m_sheet;

View File

@ -65,7 +65,7 @@ void VPUndoOriginMove::undo()
} }
sheet->SetTransformationOrigin(m_oldOrigin); sheet->SetTransformationOrigin(m_oldOrigin);
layout->TransformationOriginChanged(); emit layout->TransformationOriginChanged();
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View File

@ -34,23 +34,23 @@
class VPUndoOriginMove : public VPUndoCommand class VPUndoOriginMove : public VPUndoCommand
{ {
Q_OBJECT Q_OBJECT // NOLINT
public: public:
VPUndoOriginMove(const VPSheetPtr &sheet, const VPTransformationOrigon &origin, bool allowMerge = false, VPUndoOriginMove(const VPSheetPtr &sheet, const VPTransformationOrigon &origin, bool allowMerge = false,
QUndoCommand *parent = nullptr); QUndoCommand *parent = nullptr);
virtual ~VPUndoOriginMove()=default; ~VPUndoOriginMove() override =default;
virtual void undo() override; void undo() override;
virtual void redo() override; void redo() override;
// cppcheck-suppress unusedFunction // cppcheck-suppress unusedFunction
virtual auto mergeWith(const QUndoCommand *command) -> bool override; auto mergeWith(const QUndoCommand *command) -> bool override;
virtual auto id() const -> int override; auto id() const -> int override;
auto Sheet() const -> VPSheetWeakPtr; auto Sheet() const -> VPSheetWeakPtr;
auto Origin() const -> const VPTransformationOrigon &; auto Origin() const -> const VPTransformationOrigon &;
private: private:
Q_DISABLE_COPY(VPUndoOriginMove) Q_DISABLE_COPY_MOVE(VPUndoOriginMove) // NOLINT
VPSheetWeakPtr m_sheet; VPSheetWeakPtr m_sheet;
VPTransformationOrigon m_oldOrigin{}; VPTransformationOrigon m_oldOrigin{};

View File

@ -162,7 +162,7 @@ void VPUndoPiecesMove::undo()
layout->SetFocusedSheet(sheet); layout->SetFocusedSheet(sheet);
} }
for (const auto& piece : m_pieces) for (const auto& piece : qAsConst(m_pieces))
{ {
VPPiecePtr p = piece.toStrongRef(); VPPiecePtr p = piece.toStrongRef();
if (not p.isNull()) if (not p.isNull())
@ -196,7 +196,7 @@ void VPUndoPiecesMove::redo()
layout->SetFocusedSheet(sheet); layout->SetFocusedSheet(sheet);
} }
for (const auto& piece : m_pieces) for (const auto& piece : qAsConst(m_pieces))
{ {
VPPiecePtr p = piece.toStrongRef(); VPPiecePtr p = piece.toStrongRef();
if (not p.isNull()) if (not p.isNull())

View File

@ -36,24 +36,24 @@
class VPUndoPieceMove : public VPUndoCommand class VPUndoPieceMove : public VPUndoCommand
{ {
Q_OBJECT Q_OBJECT // NOLINT
public: public:
explicit VPUndoPieceMove(const VPPiecePtr &piece, qreal dx, qreal dy, bool allowMerge = false, explicit VPUndoPieceMove(const VPPiecePtr &piece, qreal dx, qreal dy, bool allowMerge = false,
QUndoCommand *parent = nullptr); QUndoCommand *parent = nullptr);
virtual ~VPUndoPieceMove()=default; ~VPUndoPieceMove() override =default;
virtual void undo() override; void undo() override;
virtual void redo() override; void redo() override;
// cppcheck-suppress unusedFunction // cppcheck-suppress unusedFunction
virtual auto mergeWith(const QUndoCommand *command) -> bool override; auto mergeWith(const QUndoCommand *command) -> bool override;
virtual auto id() const -> int override ; auto id() const -> int override;
auto Piece() const -> VPPiecePtr; auto Piece() const -> VPPiecePtr;
auto Dx() const -> qreal; auto Dx() const -> qreal;
auto Dy() const -> qreal; auto Dy() const -> qreal;
private: private:
Q_DISABLE_COPY(VPUndoPieceMove) Q_DISABLE_COPY_MOVE(VPUndoPieceMove) // NOLINT
VPPieceWeakPtr m_piece; VPPieceWeakPtr m_piece;
QTransform m_oldTransform{}; QTransform m_oldTransform{};
@ -82,24 +82,24 @@ inline auto VPUndoPieceMove::Dy() const -> qreal
// Move pieces // Move pieces
class VPUndoPiecesMove : public VPUndoCommand class VPUndoPiecesMove : public VPUndoCommand
{ {
Q_OBJECT Q_OBJECT // NOLINT
public: public:
explicit VPUndoPiecesMove(const QList<VPPiecePtr> &pieces, qreal dx, qreal dy, bool allowMerge = false, explicit VPUndoPiecesMove(const QList<VPPiecePtr> &pieces, qreal dx, qreal dy, bool allowMerge = false,
QUndoCommand *parent = nullptr); QUndoCommand *parent = nullptr);
virtual ~VPUndoPiecesMove()=default; ~VPUndoPiecesMove() override =default;
virtual void undo() override; void undo() override;
virtual void redo() override; void redo() override;
// cppcheck-suppress unusedFunction // cppcheck-suppress unusedFunction
virtual auto mergeWith(const QUndoCommand *command) -> bool override; auto mergeWith(const QUndoCommand *command) -> bool override;
virtual auto id() const -> int override ; auto id() const -> int override ;
auto PieceIds() const -> QSet<QString>; auto PieceIds() const -> QSet<QString>;
auto Dx() const -> qreal; auto Dx() const -> qreal;
auto Dy() const -> qreal; auto Dy() const -> qreal;
private: private:
Q_DISABLE_COPY(VPUndoPiecesMove) Q_DISABLE_COPY_MOVE(VPUndoPiecesMove) // NOLINT
QVector<VPPieceWeakPtr> m_pieces{}; QVector<VPPieceWeakPtr> m_pieces{};
QMap<QString, QTransform> m_oldTransforms{}; QMap<QString, QTransform> m_oldTransforms{};

View File

@ -213,7 +213,7 @@ void VPUndoPiecesRotate::undo()
layout->SetFocusedSheet(sheet); layout->SetFocusedSheet(sheet);
} }
for (const auto& piece : m_pieces) for (const auto& piece : qAsConst(m_pieces))
{ {
VPPiecePtr p = piece.toStrongRef(); VPPiecePtr p = piece.toStrongRef();
if (not p.isNull()) if (not p.isNull())
@ -247,7 +247,7 @@ void VPUndoPiecesRotate::redo()
layout->SetFocusedSheet(sheet); layout->SetFocusedSheet(sheet);
} }
for (const auto& piece : m_pieces) for (const auto& piece : qAsConst(m_pieces))
{ {
VPPiecePtr p = piece.toStrongRef(); VPPiecePtr p = piece.toStrongRef();
if (not p.isNull()) if (not p.isNull())

View File

@ -36,27 +36,27 @@
class VPUndoPieceRotate : public VPUndoCommand class VPUndoPieceRotate : public VPUndoCommand
{ {
Q_OBJECT Q_OBJECT // NOLINT
public: public:
VPUndoPieceRotate(const VPPiecePtr &piece, const VPTransformationOrigon &origin, qreal angle, qreal angleSum, VPUndoPieceRotate(const VPPiecePtr &piece, const VPTransformationOrigon &origin, qreal angle, qreal angleSum,
bool allowMerge = false, QUndoCommand *parent = nullptr); bool allowMerge = false, QUndoCommand *parent = nullptr);
virtual ~VPUndoPieceRotate()=default; ~VPUndoPieceRotate() override =default;
virtual void undo() override; void undo() override;
virtual void redo() override; void redo() override;
// cppcheck-suppress unusedFunction // cppcheck-suppress unusedFunction
virtual auto mergeWith(const QUndoCommand *command) -> bool override; auto mergeWith(const QUndoCommand *command) -> bool override;
virtual auto id() const -> int override ; auto id() const -> int override;
auto Piece() const -> VPPiecePtr; auto Piece() const -> VPPiecePtr;
auto Origin() const -> VPTransformationOrigon; auto Origin() const -> VPTransformationOrigon;
auto Angle() const -> qreal; auto Angle() const -> qreal;
bool FollowGrainline() const; auto FollowGrainline() const -> bool;
private: private:
Q_DISABLE_COPY(VPUndoPieceRotate) Q_DISABLE_COPY_MOVE(VPUndoPieceRotate) // NOLINT
bool m_firstCall{true}; bool m_firstCall{true};
VPPieceWeakPtr m_piece; VPPieceWeakPtr m_piece;
@ -94,17 +94,17 @@ inline auto VPUndoPieceRotate::FollowGrainline() const -> bool
// Rotate pieces // Rotate pieces
class VPUndoPiecesRotate : public VPUndoCommand class VPUndoPiecesRotate : public VPUndoCommand
{ {
Q_OBJECT Q_OBJECT // NOLINT
public: public:
explicit VPUndoPiecesRotate(const QList<VPPiecePtr> &pieces, const VPTransformationOrigon &origin, qreal angle, explicit VPUndoPiecesRotate(const QList<VPPiecePtr> &pieces, const VPTransformationOrigon &origin, qreal angle,
qreal angleSum, bool allowMerge = false, QUndoCommand *parent = nullptr); qreal angleSum, bool allowMerge = false, QUndoCommand *parent = nullptr);
virtual ~VPUndoPiecesRotate()=default; ~VPUndoPiecesRotate() override =default;
virtual void undo() override; void undo() override;
virtual void redo() override; void redo() override;
// cppcheck-suppress unusedFunction // cppcheck-suppress unusedFunction
virtual auto mergeWith(const QUndoCommand *command) -> bool override; auto mergeWith(const QUndoCommand *command) -> bool override;
virtual auto id() const -> int override ; auto id() const -> int override;
auto PieceIds() const -> QSet<QString>; auto PieceIds() const -> QSet<QString>;
auto Origin() const -> VPTransformationOrigon; auto Origin() const -> VPTransformationOrigon;
@ -112,7 +112,7 @@ public:
auto FollowGrainline() const -> bool; auto FollowGrainline() const -> bool;
private: private:
Q_DISABLE_COPY(VPUndoPiecesRotate) Q_DISABLE_COPY_MOVE(VPUndoPiecesRotate) // NOLINT
bool m_firstCall{true}; bool m_firstCall{true};
QVector<VPPieceWeakPtr> m_pieces{}; QVector<VPPieceWeakPtr> m_pieces{};

View File

@ -254,7 +254,7 @@ auto VPUndoPieceZValueMove::Levels(const QList<VPPiecePtr> &pieces, bool skip) c
} }
} }
return levels.values(); return levels.values(); // clazy:exclude=clazy-qt6-deprecated-api-fixes
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -497,11 +497,11 @@ auto VPUndoPiecesZValueMove::Levels(const QList<VPPiecePtr> &allPieces, const QV
} }
} }
return levels.values(); return levels.values(); // clazy:exclude=clazy-qt6-deprecated-api-fixes
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VPUndoPiecesZValueMove::LevelStep(const QList<VPPiecePtr> &pieces) const -> qreal auto VPUndoPiecesZValueMove::LevelStep(const QList<VPPiecePtr> &pieces) -> qreal
{ {
QList<QVector<QString>> levels = Levels(pieces, QVector<QString>(), false); QList<QVector<QString>> levels = Levels(pieces, QVector<QString>(), false);
if (levels.isEmpty()) if (levels.isEmpty())

View File

@ -48,6 +48,7 @@ enum class ZValueMove
class VPUndoPieceZValueMove : public VPUndoCommand class VPUndoPieceZValueMove : public VPUndoCommand
{ {
Q_OBJECT // NOLINT
public: public:
VPUndoPieceZValueMove(const VPPiecePtr &piece, ML::ZValueMove move, QUndoCommand *parent = nullptr); VPUndoPieceZValueMove(const VPPiecePtr &piece, ML::ZValueMove move, QUndoCommand *parent = nullptr);
~VPUndoPieceZValueMove() override =default; ~VPUndoPieceZValueMove() override =default;
@ -72,6 +73,7 @@ private:
class VPUndoPiecesZValueMove : public VPUndoCommand class VPUndoPiecesZValueMove : public VPUndoCommand
{ {
Q_OBJECT // NOLINT
public: public:
VPUndoPiecesZValueMove(const QList<VPPiecePtr> &pieces, ML::ZValueMove move, QUndoCommand *parent = nullptr); VPUndoPiecesZValueMove(const QList<VPPiecePtr> &pieces, ML::ZValueMove move, QUndoCommand *parent = nullptr);
~VPUndoPiecesZValueMove() override =default; ~VPUndoPiecesZValueMove() override =default;
@ -93,7 +95,7 @@ private:
auto PieceIds() const -> QVector<QString>; auto PieceIds() const -> QVector<QString>;
static auto Levels(const QList<VPPiecePtr> &allPieces, const QVector<QString> &skipPieces, static auto Levels(const QList<VPPiecePtr> &allPieces, const QVector<QString> &skipPieces,
bool skip) -> QList<QVector<QString>>; bool skip) -> QList<QVector<QString>>;
auto LevelStep(const QList<VPPiecePtr> &pieces) const -> qreal; static auto LevelStep(const QList<VPPiecePtr> &pieces) -> qreal;
}; };
#endif // VPUNDOPIECEZVALUEMOVE_H #endif // VPUNDOPIECEZVALUEMOVE_H

View File

@ -39,7 +39,8 @@ VPUndoRemoveSheet::VPUndoRemoveSheet(const VPSheetPtr &sheet, QUndoCommand *pare
SCASSERT(not sheet.isNull()) SCASSERT(not sheet.isNull())
QList<VPPiecePtr> pieces = sheet->GetPieces(); QList<VPPiecePtr> pieces = sheet->GetPieces();
for (auto piece : pieces) m_pieces.reserve(pieces.size());
for (const auto &piece : pieces)
{ {
m_pieces.append(piece); m_pieces.append(piece);
} }
@ -60,7 +61,7 @@ void VPUndoRemoveSheet::undo()
{ {
sheet->SetVisible(true); sheet->SetVisible(true);
for (const auto &piece : m_pieces) for (const auto &piece : qAsConst(m_pieces))
{ {
VPPiecePtr p = piece.toStrongRef(); VPPiecePtr p = piece.toStrongRef();
if (not p.isNull()) if (not p.isNull())
@ -93,7 +94,7 @@ void VPUndoRemoveSheet::redo()
{ {
sheet->SetVisible(false); sheet->SetVisible(false);
for (const auto &piece : m_pieces) for (const auto &piece : qAsConst(m_pieces))
{ {
VPPiecePtr p = piece.toStrongRef(); VPPiecePtr p = piece.toStrongRef();
if (not p.isNull()) if (not p.isNull())

View File

@ -34,17 +34,17 @@
class VPUndoRemoveSheet : public VPUndoCommand class VPUndoRemoveSheet : public VPUndoCommand
{ {
Q_OBJECT Q_OBJECT // NOLINT
public: public:
explicit VPUndoRemoveSheet(const VPSheetPtr &sheet, QUndoCommand *parent = nullptr); explicit VPUndoRemoveSheet(const VPSheetPtr &sheet, QUndoCommand *parent = nullptr);
virtual ~VPUndoRemoveSheet()=default; ~VPUndoRemoveSheet() override =default;
virtual void undo() override; void undo() override;
virtual void redo() override; void redo() override;
virtual auto id() const -> int override; auto id() const -> int override;
private: private:
Q_DISABLE_COPY(VPUndoRemoveSheet) Q_DISABLE_COPY_MOVE(VPUndoRemoveSheet) // NOLINT
QList<VPPieceWeakPtr> m_pieces{}; QList<VPPieceWeakPtr> m_pieces{};
VPSheetWeakPtr m_sheet; VPSheetWeakPtr m_sheet;

View File

@ -61,7 +61,7 @@ QT_WARNING_POP
#include <QPixmapCache> #include <QPixmapCache>
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
inline void noisyFailureMsgHandler(QtMsgType type, const QMessageLogContext &context, const QString &msg) inline void noisyFailureMsgHandler(QtMsgType type, const QMessageLogContext &context, const QString &msg) // NOLINT(readability-function-cognitive-complexity)
{ {
// only the GUI thread should display message boxes. If you are // only the GUI thread should display message boxes. If you are
// writing a multithreaded application and the error happens on // writing a multithreaded application and the error happens on
@ -315,7 +315,7 @@ auto VPApplication::notify(QObject *receiver, QEvent *event) -> bool
catch (const VExceptionToolWasDeleted &e) catch (const VExceptionToolWasDeleted &e)
{ {
qCCritical(pApp, "%s\n\n%s\n\n%s", qCCritical(pApp, "%s\n\n%s\n\n%s",
qUtf8Printable("Unhadled deleting tool. Continue use object after deleting!"), qUtf8Printable(QStringLiteral("Unhadled deleting tool. Continue use object after deleting!")),
qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation())); qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation()));
exit(V_EX_DATAERR); exit(V_EX_DATAERR);
} }
@ -534,7 +534,7 @@ auto VPApplication::event(QEvent *e) -> bool
// Mac specific). // Mac specific).
case QEvent::FileOpen: case QEvent::FileOpen:
{ {
auto *fileOpenEvent = static_cast<QFileOpenEvent *>(e); auto *fileOpenEvent = static_cast<QFileOpenEvent *>(e); // NOLINT(cppcoreguidelines-pro-type-static-cast-downcast)
const QString macFileOpen = fileOpenEvent->file(); const QString macFileOpen = fileOpenEvent->file();
if(not macFileOpen.isEmpty()) if(not macFileOpen.isEmpty())
{ {
@ -670,7 +670,7 @@ auto VPApplication::StartWithFiles(const VPCommandLinePtr &cmd, const QStringLis
cmd.get()->parser.showHelp(V_EX_USAGE); cmd.get()->parser.showHelp(V_EX_USAGE);
} }
for (const auto &arg : args) for (const auto &arg : args) // NOLINT(readability-use-anyofallof)
{ {
NewMainWindow(cmd); NewMainWindow(cmd);
if (not MainWindow()->LoadFile(arg)) if (not MainWindow()->LoadFile(arg))

View File

@ -31,12 +31,12 @@
#include "../vmisc/literals.h" #include "../vmisc/literals.h"
#include <QDebug> #include <QDebug>
std::shared_ptr<VPCommandLine> VPCommandLine::instance = nullptr; std::shared_ptr<VPCommandLine> VPCommandLine::instance = nullptr; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)
#define translate(context, source) QCoreApplication::translate((context), source) #define translate(context, source) QCoreApplication::translate((context), source)// NOLINT(cppcoreguidelines-macro-usage)
//------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------
bool VPCommandLine::IsExportEnabled() const auto VPCommandLine::IsExportEnabled() const -> bool
{ {
const bool result = IsOptionSet(LONG_OPTION_EXPORT_FILE); const bool result = IsOptionSet(LONG_OPTION_EXPORT_FILE);
int argSize = parser.positionalArguments().size(); int argSize = parser.positionalArguments().size();
@ -49,7 +49,7 @@ bool VPCommandLine::IsExportEnabled() const
} }
//---------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------
QString VPCommandLine::OptionExportFile() const auto VPCommandLine::OptionExportFile() const -> QString
{ {
QString path; QString path;
if (IsExportEnabled()) if (IsExportEnabled())
@ -61,13 +61,13 @@ QString VPCommandLine::OptionExportFile() const
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QStringList VPCommandLine::OptionRawLayouts() const auto VPCommandLine::OptionRawLayouts() const -> QStringList
{ {
return OptionValues(LONG_OPTION_RAW_LAYOUT); return OptionValues(LONG_OPTION_RAW_LAYOUT);
} }
//-------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------
bool VPCommandLine::IsTestModeEnabled() const auto VPCommandLine::IsTestModeEnabled() const -> bool
{ {
const bool r = IsOptionSet(LONG_OPTION_TEST); const bool r = IsOptionSet(LONG_OPTION_TEST);
if (r && parser.positionalArguments().size() != 1) if (r && parser.positionalArguments().size() != 1)
@ -79,19 +79,19 @@ bool VPCommandLine::IsTestModeEnabled() const
} }
//-------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------
bool VPCommandLine::IsGuiEnabled() const auto VPCommandLine::IsGuiEnabled() const -> bool
{ {
return isGuiEnabled; return isGuiEnabled;
} }
//-------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------
QStringList VPCommandLine::OptionFileNames() const auto VPCommandLine::OptionFileNames() const -> QStringList
{ {
return parser.positionalArguments(); return parser.positionalArguments();
} }
//------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------
bool VPCommandLine::IsNoScalingEnabled() const auto VPCommandLine::IsNoScalingEnabled() const -> bool
{ {
return IsOptionSet(LONG_OPTION_NO_HDPI_SCALING); return IsOptionSet(LONG_OPTION_NO_HDPI_SCALING);
} }
@ -103,9 +103,7 @@ void VPCommandLine::ShowHelp(int exitCode)
} }
//---------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------
VPCommandLine::VPCommandLine(): VPCommandLine::VPCommandLine()
parser(),
isGuiEnabled(false)
{ {
parser.setApplicationDescription(translate("Puzzle", "Valentina's manual layout editor.")); parser.setApplicationDescription(translate("Puzzle", "Valentina's manual layout editor."));
parser.addHelpOption(); parser.addHelpOption();
@ -116,7 +114,7 @@ VPCommandLine::VPCommandLine():
} }
//------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------
VPCommandLinePtr VPCommandLine::Instance() auto VPCommandLine::Instance() -> VPCommandLinePtr
{ {
VPCommandLine::ProcessInstance(instance, QCoreApplication::arguments()); VPCommandLine::ProcessInstance(instance, QCoreApplication::arguments());
return instance; return instance;
@ -193,19 +191,19 @@ void VPCommandLine::InitCommandLineOptions()
} }
//-------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------
bool VPCommandLine::IsOptionSet(const QString &option) const auto VPCommandLine::IsOptionSet(const QString &option) const -> bool
{ {
return parser.isSet(option); return parser.isSet(option);
} }
//------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------
QString VPCommandLine::OptionValue(const QString &option) const auto VPCommandLine::OptionValue(const QString &option) const -> QString
{ {
return parser.value(option); return parser.value(option);
} }
//-------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------
QStringList VPCommandLine::OptionValues(const QString &option) const auto VPCommandLine::OptionValues(const QString &option) const -> QStringList
{ {
return parser.values(option); return parser.values(option);
} }

View File

@ -33,56 +33,59 @@
#include <QCommandLineParser> #include <QCommandLineParser>
#include <ciso646> #include <ciso646>
#include "../vmisc/defglobal.h"
class VPCommandLine; class VPCommandLine;
using VPCommandLinePtr = std::shared_ptr<VPCommandLine>; using VPCommandLinePtr = std::shared_ptr<VPCommandLine>;
class VPCommandLine: public QObject class VPCommandLine: public QObject
{ {
Q_OBJECT Q_OBJECT // NOLINT
public: public:
virtual ~VPCommandLine() = default; ~VPCommandLine() override = default;
/** @brief if user enabled export from cmd */ /** @brief if user enabled export from cmd */
bool IsExportEnabled() const; auto IsExportEnabled() const -> bool;
/** @brief path to export file or empty string if not */ /** @brief path to export file or empty string if not */
QString OptionExportFile() const; auto OptionExportFile() const -> QString;
/** @brief list with paths to the raw layout data files */ /** @brief list with paths to the raw layout data files */
QStringList OptionRawLayouts() const; auto OptionRawLayouts() const -> QStringList;
/** @brief if user enabled test mode from cmd */ /** @brief if user enabled test mode from cmd */
bool IsTestModeEnabled() const; auto IsTestModeEnabled() const -> bool;
/** @brief if gui enabled or not */ /** @brief if gui enabled or not */
bool IsGuiEnabled() const; auto IsGuiEnabled() const -> bool;
/** @brief the file name which should be loaded */ /** @brief the file name which should be loaded */
QStringList OptionFileNames() const; auto OptionFileNames() const -> QStringList;
/** @brief if high dpi scaling is enabled */ /** @brief if high dpi scaling is enabled */
bool IsNoScalingEnabled() const; auto IsNoScalingEnabled() const -> bool;
Q_NORETURN void ShowHelp(int exitCode = 0); Q_NORETURN void ShowHelp(int exitCode = 0);
protected: protected:
VPCommandLine(); VPCommandLine();
/** @brief create the single instance of the class inside vpapplication */ /** @brief create the single instance of the class inside vpapplication */
static VPCommandLinePtr Instance(); static auto Instance() -> VPCommandLinePtr;
static void ProcessInstance(VPCommandLinePtr &instance, const QStringList &arguments); static void ProcessInstance(VPCommandLinePtr &instance, const QStringList &arguments);
private: private:
Q_DISABLE_COPY(VPCommandLine) // cppcheck-suppress unknownMacro
static VPCommandLinePtr instance; Q_DISABLE_COPY_MOVE(VPCommandLine) // NOLINT
QCommandLineParser parser; static VPCommandLinePtr instance; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)
bool isGuiEnabled; QCommandLineParser parser{};
bool isGuiEnabled{false};
friend class VPApplication; friend class VPApplication;
/** @brief add options to the QCommandLineParser that there are in the cmd can be */ /** @brief add options to the QCommandLineParser that there are in the cmd can be */
void InitCommandLineOptions(); void InitCommandLineOptions();
bool IsOptionSet(const QString &option)const; auto IsOptionSet(const QString &option)const -> bool;
QString OptionValue(const QString &option) const; auto OptionValue(const QString &option) const -> QString;
QStringList OptionValues(const QString &option) const; auto OptionValues(const QString &option) const -> QStringList;
}; };
#endif // VPCOMMANDLINE_H #endif // VPCOMMANDLINE_H

View File

@ -29,41 +29,41 @@
#include <QStringList> #include <QStringList>
const QString LONG_OPTION_EXPORT_FILE = QStringLiteral("exportFile"); const QString LONG_OPTION_EXPORT_FILE = QStringLiteral("exportFile"); // NOLINT
const QString SINGLE_OPTION_EXPORT_FILE = QStringLiteral("e"); const QString SINGLE_OPTION_EXPORT_FILE = QStringLiteral("e"); // NOLINT
const QString LONG_OPTION_TEST = QStringLiteral("test"); const QString LONG_OPTION_TEST = QStringLiteral("test"); // NOLINT
const QString SINGLE_OPTION_TEST = QStringLiteral("t"); const QString SINGLE_OPTION_TEST = QStringLiteral("t"); // NOLINT
const QString LONG_OPTION_RAW_LAYOUT = QStringLiteral("rawLayout"); const QString LONG_OPTION_RAW_LAYOUT = QStringLiteral("rawLayout"); // NOLINT
const QString SINGLE_OPTION_RAW_LAYOUT = QStringLiteral("r"); const QString SINGLE_OPTION_RAW_LAYOUT = QStringLiteral("r"); // NOLINT
const QString LONG_OPTION_EXP2FORMAT = QStringLiteral("format"); const QString LONG_OPTION_EXP2FORMAT = QStringLiteral("format"); // NOLINT
const QString SINGLE_OPTION_EXP2FORMAT = QStringLiteral("f"); const QString SINGLE_OPTION_EXP2FORMAT = QStringLiteral("f"); // NOLINT
const QString LONG_OPTION_BINARYDXF = QStringLiteral("bdxf"); const QString LONG_OPTION_BINARYDXF = QStringLiteral("bdxf"); // NOLINT
const QString LONG_OPTION_TEXT2PATHS = QStringLiteral("text2paths"); const QString LONG_OPTION_TEXT2PATHS = QStringLiteral("text2paths"); // NOLINT
const QString LONG_OPTION_CROP_LENGTH = QStringLiteral("crop"); const QString LONG_OPTION_CROP_LENGTH = QStringLiteral("crop"); // NOLINT
const QString SINGLE_OPTION_CROP_LENGTH = QStringLiteral("c"); const QString SINGLE_OPTION_CROP_LENGTH = QStringLiteral("c"); // NOLINT
const QString LONG_OPTION_CROP_WIDTH = QStringLiteral("cropWidth"); const QString LONG_OPTION_CROP_WIDTH = QStringLiteral("cropWidth"); // NOLINT
const QString LONG_OPTION_TILED_PDF_PAGE_TEMPLATE = QStringLiteral("tiledPageformat"); const QString LONG_OPTION_TILED_PDF_PAGE_TEMPLATE = QStringLiteral("tiledPageformat"); // NOLINT
const QString LONG_OPTION_TILED_PDF_LEFT_MARGIN = QStringLiteral("tiledlmargin"); const QString LONG_OPTION_TILED_PDF_LEFT_MARGIN = QStringLiteral("tiledlmargin"); // NOLINT
const QString LONG_OPTION_TILED_PDF_RIGHT_MARGIN = QStringLiteral("tiledrmargin"); const QString LONG_OPTION_TILED_PDF_RIGHT_MARGIN = QStringLiteral("tiledrmargin"); // NOLINT
const QString LONG_OPTION_TILED_PDF_TOP_MARGIN = QStringLiteral("tiledtmargin"); const QString LONG_OPTION_TILED_PDF_TOP_MARGIN = QStringLiteral("tiledtmargin"); // NOLINT
const QString LONG_OPTION_TILED_PDF_BOTTOM_MARGIN = QStringLiteral("tiledbmargin"); const QString LONG_OPTION_TILED_PDF_BOTTOM_MARGIN = QStringLiteral("tiledbmargin"); // NOLINT
const QString LONG_OPTION_TILED_PDF_LANDSCAPE = QStringLiteral("tiledLandscape"); const QString LONG_OPTION_TILED_PDF_LANDSCAPE = QStringLiteral("tiledLandscape"); // NOLINT
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief AllKeys return list with all command line keys (short and long forms). Used for testing on conflicts. * @brief AllKeys return list with all command line keys (short and long forms). Used for testing on conflicts.
* @return list with all command line keys * @return list with all command line keys
*/ */
QStringList AllKeys() auto AllKeys() -> QStringList
{ {
return QStringList return
{ {
LONG_OPTION_EXPORT_FILE, LONG_OPTION_EXPORT_FILE,
SINGLE_OPTION_EXPORT_FILE, SINGLE_OPTION_EXPORT_FILE,

View File

@ -58,6 +58,6 @@ extern const QString LONG_OPTION_TILED_PDF_TOP_MARGIN;
extern const QString LONG_OPTION_TILED_PDF_BOTTOM_MARGIN; extern const QString LONG_OPTION_TILED_PDF_BOTTOM_MARGIN;
extern const QString LONG_OPTION_TILED_PDF_LANDSCAPE; extern const QString LONG_OPTION_TILED_PDF_LANDSCAPE;
QStringList AllKeys(); auto AllKeys() -> QStringList;
#endif // VPCOMMANDS_H #endif // VPCOMMANDS_H

File diff suppressed because it is too large Load Diff

View File

@ -37,11 +37,8 @@
#include "carousel/vpcarrousel.h" #include "carousel/vpcarrousel.h"
#include "scene/vpmaingraphicsview.h" #include "scene/vpmaingraphicsview.h"
#include "layout/vplayout.h" #include "layout/vplayout.h"
#include "layout/vppiece.h"
#include "../vlayout/vlayoutpiece.h" #include "../vlayout/vlayoutpiece.h"
#include "vptilefactory.h"
#include "vpcommandline.h" #include "vpcommandline.h"
#include "../vlayout/vlayoutdef.h"
#include "../vwidgets/vabstractmainwindow.h" #include "../vwidgets/vabstractmainwindow.h"
#include "../vmisc/vlockguard.h" #include "../vmisc/vlockguard.h"
#include "../vlayout/dialogs/vabstractlayoutdialog.h" #include "../vlayout/dialogs/vabstractlayoutdialog.h"
@ -59,13 +56,13 @@ class WatermarkWindow;
class VPMainWindow : public VAbstractMainWindow class VPMainWindow : public VAbstractMainWindow
{ {
Q_OBJECT Q_OBJECT // NOLINT
public: public:
explicit VPMainWindow(const VPCommandLinePtr &cmd, QWidget *parent = nullptr); explicit VPMainWindow(const VPCommandLinePtr &cmd, QWidget *parent = nullptr);
virtual ~VPMainWindow(); ~VPMainWindow() override;
QString CurrentFile() const; auto CurrentFile() const -> QString;
/** /**
* @brief LoadFile Loads the layout file of given path in m_layout. * @brief LoadFile Loads the layout file of given path in m_layout.
@ -73,7 +70,7 @@ public:
* @param path path to layout * @param path path to layout
* @return true if success * @return true if success
*/ */
bool LoadFile(QString path); auto LoadFile(const QString& path) -> bool;
void LayoutWasSaved(bool saved); void LayoutWasSaved(bool saved);
void SetCurrentFile(const QString &fileName); void SetCurrentFile(const QString &fileName);
@ -83,7 +80,7 @@ public:
* @param path path to layout file * @param path path to layout file
* @return true if success * @return true if success
*/ */
bool SaveLayout(const QString &path, QString &error); auto SaveLayout(const QString &path, QString &error) -> bool;
/** /**
* @brief ImportRawLayouts The function imports the raw layouts of given paths * @brief ImportRawLayouts The function imports the raw layouts of given paths
@ -105,12 +102,12 @@ public slots:
*/ */
void on_actionNew_triggered(); void on_actionNew_triggered();
virtual void ShowToolTip(const QString &toolTip) override; void ShowToolTip(const QString &toolTip) override;
protected: protected:
virtual void closeEvent(QCloseEvent *event) override; void closeEvent(QCloseEvent *event) override;
virtual void changeEvent(QEvent* event) override; void changeEvent(QEvent* event) override;
virtual QStringList RecentFileList() const override; auto RecentFileList() const -> QStringList override;
private slots: private slots:
/** /**
@ -125,14 +122,14 @@ private slots:
* triggered. * triggered.
* The slot is automatically connected through name convention. * The slot is automatically connected through name convention.
*/ */
bool on_actionSave_triggered(); bool on_actionSave_triggered(); //NOLINT(modernize-use-trailing-return-type)
/** /**
* @brief on_actionSaveAs_triggered When the menu action File > Save As * @brief on_actionSaveAs_triggered When the menu action File > Save As
* is triggered. * is triggered.
* The slot is automatically connected through name convention. * The slot is automatically connected through name convention.
*/ */
bool on_actionSaveAs_triggered(); bool on_actionSaveAs_triggered(); //NOLINT(modernize-use-trailing-return-type)
/** /**
* @brief on_actionImportRawLayout_triggered When the menu action * @brief on_actionImportRawLayout_triggered When the menu action
@ -291,8 +288,14 @@ private slots:
void SetDefaultGUILanguage(); void SetDefaultGUILanguage();
void HorizontalScaleChanged(double value);
void VerticalScaleChanged(double value);
void LayoutWarningPiecesSuperposition_toggled(bool checked);
void LayoutWarningPiecesOutOfBound_toggled(bool checked);
private: private:
Q_DISABLE_COPY(VPMainWindow) Q_DISABLE_COPY_MOVE(VPMainWindow) // NOLINT
Ui::VPMainWindow *ui; Ui::VPMainWindow *ui;
VPCarrousel *m_carrousel{nullptr}; VPCarrousel *m_carrousel{nullptr};
@ -336,6 +339,14 @@ private:
QFileSystemWatcher *m_watermarkWatcher{nullptr}; QFileSystemWatcher *m_watermarkWatcher{nullptr};
struct VPLayoutPrinterPage
{
VPSheetPtr sheet{};
bool tilesScheme{false};
int tileRow{-1};
int tileCol{-1};
};
/** /**
* @brief InitMenuBar Inits the menu bar (File, Edit, Help ...) * @brief InitMenuBar Inits the menu bar (File, Edit, Help ...)
*/ */
@ -356,6 +367,9 @@ private:
*/ */
void InitPropertyTabCurrentSheet(); void InitPropertyTabCurrentSheet();
void InitPaperSizeData(const QString &suffix);
void InitMarginsData(const QString &suffix);
/** /**
* @brief InitPropertyTabLayout Inits the layout tab in the properties * @brief InitPropertyTabLayout Inits the layout tab in the properties
*/ */
@ -432,9 +446,9 @@ private:
auto TranslateUnit() const -> Unit; auto TranslateUnit() const -> Unit;
auto LayoutUnit() const -> Unit; auto LayoutUnit() const -> Unit;
QSizeF Template(VAbstractLayoutDialog::PaperSizeTemplate t) const; auto Template(VAbstractLayoutDialog::PaperSizeTemplate t) const -> QSizeF;
QSizeF SheetTemplate() const; auto SheetTemplate() const -> QSizeF;
QSizeF TileTemplate() const; auto TileTemplate() const -> QSizeF;
void SheetSize(const QSizeF &size); void SheetSize(const QSizeF &size);
void TileSize(const QSizeF &size); void TileSize(const QSizeF &size);
@ -458,12 +472,12 @@ private:
void RotatePiecesToGrainline(); void RotatePiecesToGrainline();
void ExportData(const VPExportData &data); void ExportData(const VPExportData &data);
void ExportApparelLayout(const VPExportData &data, const QVector<VLayoutPiece> &details, const QString &name, static void ExportApparelLayout(const VPExportData &data, const QVector<VLayoutPiece> &details, const QString &name,
const QSize &size) const; const QSize &size) ;
void ExportFlatLayout(const VPExportData &data); void ExportFlatLayout(const VPExportData &data);
void ExportScene(const VPExportData &data); void ExportScene(const VPExportData &data);
void ExportUnifiedPdfFile(const VPExportData &data); static void ExportUnifiedPdfFile(const VPExportData &data);
void GenerateUnifiedPdfFile(const VPExportData &data, const QString &name); static void GenerateUnifiedPdfFile(const VPExportData &data, const QString &name);
void ExportPdfTiledFile(const VPExportData &data); void ExportPdfTiledFile(const VPExportData &data);
void GeneratePdfTiledFile(const VPSheetPtr &sheet, bool showTilesScheme, QPainter *painter, void GeneratePdfTiledFile(const VPSheetPtr &sheet, bool showTilesScheme, QPainter *painter,
const QSharedPointer<QPrinter> &printer, bool &firstPage); const QSharedPointer<QPrinter> &printer, bool &firstPage);
@ -473,14 +487,28 @@ private:
void OpenWatermark(const QString &path = QString()); void OpenWatermark(const QString &path = QString());
void CleanWaterkmarkEditors(); void CleanWaterkmarkEditors();
void DrawTilesScheme(QPrinter *printer, QPainter *painter, const VPSheetPtr &sheet, bool &firstPage); auto DrawTilesScheme(QPrinter *printer, QPainter *painter, const VPSheetPtr &sheet, bool firstPage) -> bool;
auto AskLayoutIsInvalid(const QList<VPSheetPtr> &sheets) -> bool; auto AskLayoutIsInvalid(const QList<VPSheetPtr> &sheets) -> bool;
auto CheckPiecesOutOfBound(const VPPiecePtr &piece, bool &outOfBoundChecked) -> bool;
auto CheckSuperpositionOfPieces(const VPPiecePtr &piece, bool &pieceSuperpositionChecked) -> bool;
void PrintLayoutSheets(QPrinter *printer, const QList<VPSheetPtr> &sheets); void PrintLayoutSheets(QPrinter *printer, const QList<VPSheetPtr> &sheets);
static auto PrintLayoutSheetPage(QPrinter *printer, QPainter &painter, const VPSheetPtr& sheet) -> bool;
void PrintLayoutTiledSheets(QPrinter *printer, const QList<VPSheetPtr> &sheets); void PrintLayoutTiledSheets(QPrinter *printer, const QList<VPSheetPtr> &sheets);
auto PrepareLayoutTilePages(const QList<VPSheetPtr> &sheets) -> QVector<VPLayoutPrinterPage>;
auto PrintLayoutTiledSheetPage(QPrinter *printer, QPainter &painter, const VPLayoutPrinterPage &page,
bool firstPage) -> bool;
void ZValueMove(int move); void ZValueMove(int move);
auto ImportRawLayout(const QString &rawLayout) -> bool;
auto AddLayoutPieces(const QVector<VLayoutPiece> &pieces) -> bool;
void TranslatePieces();
void TranslatePieceRelatively(const VPPiecePtr &piece, const QRectF &rect, int selectedPiecesCount, qreal dx,
qreal dy);
void RotatePieces();
}; };
#endif // VPMAINWINDOW_H #endif // VPMAINWINDOW_H

View File

@ -26,34 +26,33 @@
** **
*************************************************************************/ *************************************************************************/
#include "vpsettings.h" #include "vpsettings.h"
#include "qglobal.h"
#include <QMarginsF> #include <QMarginsF>
namespace namespace
{ {
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingDockWidgetPropertiesActive, (QLatin1String("dockWidget/properties"))) Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingDockWidgetPropertiesActive, (QLatin1String("dockWidget/properties"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingDockPropertiesContentsActive, (QLatin1String("dockWidget/contents"))) Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingDockPropertiesContentsActive, (QLatin1String("dockWidget/contents"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutUnit, (QLatin1String("layout/unit"))) Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutUnit, (QLatin1String("layout/unit"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutSheetPaperWidth, (QLatin1String("layout/sheetPaperWidth"))) Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutSheetPaperWidth, (QLatin1String("layout/sheetPaperWidth"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutSheetPaperHeight, (QLatin1String("layout/sheetPaperHeight"))) Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutSheetPaperHeight, (QLatin1String("layout/sheetPaperHeight"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutTilePaperWidth, (QLatin1String("layout/tilePaperWidth"))) Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutTilePaperWidth, (QLatin1String("layout/tilePaperWidth"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutTilePaperHeight, (QLatin1String("layout/tilePaperHeight"))) Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutTilePaperHeight, (QLatin1String("layout/tilePaperHeight"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutSheetMargins, (QLatin1String("layout/sheetMargins"))) Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutSheetMargins, (QLatin1String("layout/sheetMargins"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutTileMargins, (QLatin1String("layout/tileMargins"))) Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutTileMargins, (QLatin1String("layout/tileMargins"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutSheetIgnoreMargins, (QLatin1String("layout/sheetIgnoreMargins"))) Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutSheetIgnoreMargins, (QLatin1String("layout/sheetIgnoreMargins"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutTileIgnoreMargins, (QLatin1String("layout/tileIgnoreMargins"))) Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutTileIgnoreMargins, (QLatin1String("layout/tileIgnoreMargins"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutTileShowTiles, (QLatin1String("layout/tileShowTiles"))) Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutTileShowTiles, (QLatin1String("layout/tileShowTiles"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutTileShowWatermark, (QLatin1String("layout/tileShowWatermark"))) Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutTileShowWatermark, (QLatin1String("layout/tileShowWatermark"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutWarningPiecesSuperposition, Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutWarningPiecesSuperposition, // NOLINT
(QLatin1String("layout/warningPiecesSuperposition"))) (QLatin1String("layout/warningPiecesSuperposition")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutStickyEdges, (QLatin1String("layout/stickyEdges"))) Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutStickyEdges, (QLatin1String("layout/stickyEdges"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutWarningPiecesOutOfBound, Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutWarningPiecesOutOfBound, // NOLINT
(QLatin1String("layout/warningPiecesOutOfBound"))) (QLatin1String("layout/warningPiecesOutOfBound")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutFollowGrainline, (QLatin1String("layout/followGrainline"))) Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutFollowGrainline, (QLatin1String("layout/followGrainline"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutPieceGap, (QLatin1String("layout/pieceGap"))) Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutPieceGap, (QLatin1String("layout/pieceGap"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutExportFormat, (QLatin1String("layout/exportFormat"))) Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutExportFormat, (QLatin1String("layout/exportFormat"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutLineWidth, (QLatin1String("layout/lineWidth"))) Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutLineWidth, (QLatin1String("layout/lineWidth"))) // NOLINT
int cachedLineWidth = -1; int cachedLineWidth = -1;
} // namespace } // namespace

View File

@ -34,7 +34,7 @@
class VPSettings : public VCommonSettings class VPSettings : public VCommonSettings
{ {
Q_OBJECT Q_OBJECT // NOLINT
public: public:
VPSettings(Format format, Scope scope, const QString &organization, const QString &application = QString(), VPSettings(Format format, Scope scope, const QString &organization, const QString &application = QString(),
QObject *parent = nullptr); QObject *parent = nullptr);
@ -104,7 +104,7 @@ public:
void SetLayoutLineWidth(int width); void SetLayoutLineWidth(int width);
private: private:
Q_DISABLE_COPY(VPSettings) Q_DISABLE_COPY_MOVE(VPSettings) // NOLINT
}; };
#endif // VPSETTINGS_H #endif // VPSETTINGS_H

View File

@ -31,19 +31,22 @@
#include <QXmlStreamAttributes> #include <QXmlStreamAttributes>
#include <ciso646> #include <ciso646>
#include "vplayoutfilereader.h" #include "vplayoutfilereader.h"
#include "vplayoutfilewriter.h"
#include "vplayoutliterals.h" #include "vplayoutliterals.h"
#include "../layout/vpsheet.h" #include "../layout/vpsheet.h"
#include "../vlayout/vlayoutpiecepath.h" #include "../vlayout/vlayoutpiecepath.h"
#include "../vlayout/vtextmanager.h" #include "../vlayout/vtextmanager.h"
#include "../ifc/exception/vexception.h" #include "../ifc/exception/vexception.h"
#include "../ifc/exception/vexceptionconversionerror.h" #include "../ifc/exception/vexceptionconversionerror.h"
#include "../vpatterndb/floatItemData/floatitemdef.h"
#include "../vgeometry/vgeometrydef.h"
#include "../layout/vplayout.h"
#include "../layout/vppiece.h"
QT_WARNING_PUSH QT_WARNING_PUSH
QT_WARNING_DISABLE_CLANG("-Wmissing-prototypes") QT_WARNING_DISABLE_CLANG("-Wmissing-prototypes")
QT_WARNING_DISABLE_INTEL(1418) QT_WARNING_DISABLE_INTEL(1418)
Q_LOGGING_CATEGORY(MLReader, "mlReader") Q_LOGGING_CATEGORY(MLReader, "mlReader") // NOLINT
QT_WARNING_POP QT_WARNING_POP
@ -88,6 +91,7 @@ auto StringToPath(const QString &path) -> QVector<QPointF>
{ {
QVector<QPointF> p; QVector<QPointF> p;
QStringList points = path.split(ML::pointsSep); QStringList points = path.split(ML::pointsSep);
p.reserve(points.size());
for (const auto& point : points) for (const auto& point : points)
{ {
p.append(StringToPoint(point)); p.append(StringToPoint(point));
@ -140,6 +144,7 @@ auto StringToLines(const QString &string) -> QVector<QLineF>
{ {
QStringList lines = string.split(ML::itemsSep); QStringList lines = string.split(ML::itemsSep);
QVector<QLineF> path; QVector<QLineF> path;
path.reserve(lines.size());
for (const auto& line : lines) for (const auto& line : lines)
{ {
@ -170,6 +175,7 @@ auto StringToMarkerShape(const QString &string) -> PlaceLabelImg
{ {
PlaceLabelImg shape; PlaceLabelImg shape;
QStringList paths = string.split(ML::itemsSep); QStringList paths = string.split(ML::itemsSep);
shape.reserve(paths.size());
for (const auto& path : paths) for (const auto& path : paths)
{ {
shape.append(StringToPath(path)); shape.append(StringToPath(path));
@ -956,7 +962,7 @@ auto VPLayoutFileReader::ReadAttributeBool(const QXmlStreamAttributes &attribs,
{ {
VExceptionConversionError excep(message, name); VExceptionConversionError excep(message, name);
excep.AddMoreInformation(e.ErrorMessage()); excep.AddMoreInformation(e.ErrorMessage());
throw excep; throw excep; // NOLINT(cert-err09-cpp)
} }
return val; return val;
@ -983,7 +989,7 @@ auto VPLayoutFileReader::ReadAttributeDouble(const QXmlStreamAttributes &attribs
{ {
VExceptionConversionError excep(message, name); VExceptionConversionError excep(message, name);
excep.AddMoreInformation(e.ErrorMessage()); excep.AddMoreInformation(e.ErrorMessage());
throw excep; throw excep; // NOLINT(cert-err09-cpp)
} }
return param; return param;
} }
@ -1009,7 +1015,7 @@ auto VPLayoutFileReader::ReadAttributeUInt(const QXmlStreamAttributes &attribs,
{ {
VExceptionConversionError excep(message, name); VExceptionConversionError excep(message, name);
excep.AddMoreInformation(e.ErrorMessage()); excep.AddMoreInformation(e.ErrorMessage());
throw excep; throw excep; // NOLINT(cert-err09-cpp)
} }
return param; return param;
} }
@ -1035,7 +1041,7 @@ auto VPLayoutFileReader::ReadAttributeInt(const QXmlStreamAttributes &attribs, c
{ {
VExceptionConversionError excep(message, name); VExceptionConversionError excep(message, name);
excep.AddMoreInformation(e.ErrorMessage()); excep.AddMoreInformation(e.ErrorMessage());
throw excep; throw excep; // NOLINT(cert-err09-cpp)
} }
return param; return param;
} }

View File

@ -31,18 +31,22 @@
#include <QXmlStreamReader> #include <QXmlStreamReader>
#include "../ifc/xml/vabstractconverter.h" #include "../ifc/xml/vabstractconverter.h"
#include "../layout/vplayout.h" #include "../layout/layoutdef.h"
#include "../layout/vppiece.h" #include "../vmisc/defglobal.h"
#include <QLoggingCategory> #include <QLoggingCategory>
Q_DECLARE_LOGGING_CATEGORY(MLReader) Q_DECLARE_LOGGING_CATEGORY(MLReader) // NOLINT
struct TextLine; struct TextLine;
struct VLayoutPassmark;
struct VLayoutPlaceLabel;
class VLayoutPiecePath;
class VTextManager;
class VPLayoutFileReader : public QXmlStreamReader class VPLayoutFileReader : public QXmlStreamReader
{ {
Q_DECLARE_TR_FUNCTIONS(VPLayoutFileReader) Q_DECLARE_TR_FUNCTIONS(VPLayoutFileReader) // NOLINT
public: public:
VPLayoutFileReader()=default; VPLayoutFileReader()=default;
~VPLayoutFileReader()=default; ~VPLayoutFileReader()=default;
@ -50,7 +54,8 @@ public:
auto ReadFile(const VPLayoutPtr &layout, QFile *file) -> bool; auto ReadFile(const VPLayoutPtr &layout, QFile *file) -> bool;
private: private:
Q_DISABLE_COPY(VPLayoutFileReader) // cppcheck-suppress unknownMacro
Q_DISABLE_COPY_MOVE(VPLayoutFileReader) // NOLINT
void ReadLayout(const VPLayoutPtr &layout); void ReadLayout(const VPLayoutPtr &layout);
void ReadProperties(const VPLayoutPtr &layout); void ReadProperties(const VPLayoutPtr &layout);

View File

@ -74,6 +74,7 @@ auto PointToString(const QPointF &p) -> QString
auto PathToString(const QVector<QPointF> &pathPoints) -> QString auto PathToString(const QVector<QPointF> &pathPoints) -> QString
{ {
QStringList path; QStringList path;
path.reserve(pathPoints.size());
for (auto point : pathPoints) for (auto point : pathPoints)
{ {
@ -96,6 +97,7 @@ auto RectToString(const QRectF &r) -> QString
auto MarkerShapeToString(const PlaceLabelImg &shape) -> QString auto MarkerShapeToString(const PlaceLabelImg &shape) -> QString
{ {
QStringList s; QStringList s;
s.reserve(shape.size());
for (const auto& path : shape) for (const auto& path : shape)
{ {
s.append(PathToString(path)); s.append(PathToString(path));
@ -113,6 +115,7 @@ auto LineToString(const QLineF &line) -> QString
auto LinesToString(const QVector<QLineF> &lines) -> QString auto LinesToString(const QVector<QLineF> &lines) -> QString
{ {
QStringList l; QStringList l;
l.reserve(lines.size());
for (auto line : lines) for (auto line : lines)
{ {
l.append(LineToString(line)); l.append(LineToString(line));

View File

@ -36,6 +36,7 @@
#include <ciso646> #include <ciso646>
#include "../vmisc/literals.h" #include "../vmisc/literals.h"
#include "../vmisc/defglobal.h"
#include "../layout/layoutdef.h" #include "../layout/layoutdef.h"
class VPLayout; class VPLayout;
@ -48,7 +49,7 @@ class VTextManager;
class VPLayoutFileWriter : public QXmlStreamWriter class VPLayoutFileWriter : public QXmlStreamWriter
{ {
Q_DECLARE_TR_FUNCTIONS(VPLayoutFileWriter) Q_DECLARE_TR_FUNCTIONS(VPLayoutFileWriter) // NOLINT
public: public:
VPLayoutFileWriter()= default; VPLayoutFileWriter()= default;
~VPLayoutFileWriter()= default; ~VPLayoutFileWriter()= default;
@ -56,6 +57,8 @@ public:
void WriteFile(const VPLayoutPtr &layout, QIODevice *file); void WriteFile(const VPLayoutPtr &layout, QIODevice *file);
private: private:
// cppcheck-suppress unknownMacro
Q_DISABLE_COPY_MOVE(VPLayoutFileWriter) // NOLINT
void WriteLayout(const VPLayoutPtr &layout); void WriteLayout(const VPLayoutPtr &layout);
void WriteLayoutProperties(const VPLayoutPtr &layout); void WriteLayoutProperties(const VPLayoutPtr &layout);
void WriteSheets(const VPLayoutPtr &layout); void WriteSheets(const VPLayoutPtr &layout);
@ -73,7 +76,7 @@ private:
void SetAttribute(const QString &name, const T &value); void SetAttribute(const QString &name, const T &value);
template <size_t N> template <size_t N>
void SetAttribute(const QString &name, const char (&value)[N]); void SetAttribute(const QString &name, const char (&value)[N]); //NOLINT(cppcoreguidelines-avoid-c-arrays) NOLINT(hicpp-avoid-c-arrays) NOLINT(modernize-avoid-c-arrays)
template <typename T> template <typename T>
void SetAttributeOrRemoveIf(const QString &name, const T &value, void SetAttributeOrRemoveIf(const QString &name, const T &value,
@ -112,7 +115,7 @@ inline void VPLayoutFileWriter::SetAttribute<bool>(const QString &name, const bo
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
template <size_t N> template <size_t N>
inline void VPLayoutFileWriter::SetAttribute(const QString &name, const char (&value)[N]) inline void VPLayoutFileWriter::SetAttribute(const QString &name, const char (&value)[N]) //NOLINT(cppcoreguidelines-avoid-c-arrays) NOLINT(hicpp-avoid-c-arrays) NOLINT(modernize-avoid-c-arrays)
{ {
writeAttribute(name, QString(value)); writeAttribute(name, QString(value));
} }

View File

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

View File

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

View File

@ -30,7 +30,6 @@
#include "ui_tapepreferencesconfigurationpage.h" #include "ui_tapepreferencesconfigurationpage.h"
#include "../../mapplication.h" #include "../../mapplication.h"
#include "../../vtapesettings.h" #include "../../vtapesettings.h"
#include "../vpatterndb/variables/vmeasurement.h"
#include "../vpatterndb/pmsystems.h" #include "../vpatterndb/pmsystems.h"
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -100,7 +99,7 @@ TapePreferencesConfigurationPage::~TapePreferencesConfigurationPage()
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QStringList TapePreferencesConfigurationPage::Apply() auto TapePreferencesConfigurationPage::Apply() -> QStringList
{ {
QStringList preferences; QStringList preferences;
VTapeSettings *settings = MApplication::VApp()->TapeSettings(); VTapeSettings *settings = MApplication::VApp()->TapeSettings();
@ -121,16 +120,16 @@ QStringList TapePreferencesConfigurationPage::Apply()
if (m_langChanged || m_systemChanged) if (m_langChanged || m_systemChanged)
{ {
const QString locale = qvariant_cast<QString>(ui->langCombo->currentData()); const auto locale = qvariant_cast<QString>(ui->langCombo->currentData());
settings->SetLocale(locale); settings->SetLocale(locale);
m_langChanged = false; m_langChanged = false;
const QString code = qvariant_cast<QString>(ui->systemCombo->currentData()); const auto code = qvariant_cast<QString>(ui->systemCombo->currentData());
settings->SetPMSystemCode(code); settings->SetPMSystemCode(code);
m_systemChanged = false; m_systemChanged = false;
VAbstractApplication::VApp()->LoadTranslation(locale); VAbstractApplication::VApp()->LoadTranslation(locale);
qApp->processEvents();// force to call changeEvent QCoreApplication::processEvents();// force to call changeEvent
// Part about measurments will not be updated automatically // Part about measurments will not be updated automatically
MApplication::VApp()->RetranslateTables(); MApplication::VApp()->RetranslateTables();
@ -164,7 +163,7 @@ void TapePreferencesConfigurationPage::RetranslateUi()
ui->osOptionCheck->setText(tr("With OS options") + QStringLiteral(" (%1)").arg(QLocale().decimalPoint())); ui->osOptionCheck->setText(tr("With OS options") + QStringLiteral(" (%1)").arg(QLocale().decimalPoint()));
{ {
const QString code = qvariant_cast<QString>(ui->systemCombo->currentData()); const auto code = qvariant_cast<QString>(ui->systemCombo->currentData());
ui->systemCombo->blockSignals(true); ui->systemCombo->blockSignals(true);
ui->systemCombo->clear(); ui->systemCombo->clear();
InitPMSystems(ui->systemCombo); InitPMSystems(ui->systemCombo);

View File

@ -31,6 +31,8 @@
#include <QWidget> #include <QWidget>
#include "../vmisc/defglobal.h"
namespace Ui namespace Ui
{ {
class TapePreferencesConfigurationPage; class TapePreferencesConfigurationPage;
@ -38,17 +40,18 @@ namespace Ui
class TapePreferencesConfigurationPage : public QWidget class TapePreferencesConfigurationPage : public QWidget
{ {
Q_OBJECT Q_OBJECT // NOLINT
public: public:
explicit TapePreferencesConfigurationPage(QWidget *parent = nullptr); explicit TapePreferencesConfigurationPage(QWidget *parent = nullptr);
virtual ~TapePreferencesConfigurationPage(); ~TapePreferencesConfigurationPage() override;
QStringList Apply(); auto Apply() -> QStringList;
protected: protected:
virtual void changeEvent(QEvent* event) override; void changeEvent(QEvent* event) override;
private: private:
Q_DISABLE_COPY(TapePreferencesConfigurationPage) // cppcheck-suppress unknownMacro
Q_DISABLE_COPY_MOVE(TapePreferencesConfigurationPage) // NOLINT
Ui::TapePreferencesConfigurationPage *ui; Ui::TapePreferencesConfigurationPage *ui;
bool m_langChanged; bool m_langChanged;
bool m_systemChanged; bool m_systemChanged;

View File

@ -185,35 +185,35 @@ void TapePreferencesPathPage::InitTable()
{ {
ui->pathTable->setItem(0, 0, new QTableWidgetItem(tr("My Individual Measurements"))); ui->pathTable->setItem(0, 0, new QTableWidgetItem(tr("My Individual Measurements")));
QTableWidgetItem *item = new QTableWidgetItem(settings->GetPathIndividualMeasurements()); auto *item = new QTableWidgetItem(settings->GetPathIndividualMeasurements());
item->setToolTip(settings->GetPathIndividualMeasurements()); item->setToolTip(settings->GetPathIndividualMeasurements());
ui->pathTable->setItem(0, 1, item); ui->pathTable->setItem(0, 1, item);
} }
{ {
ui->pathTable->setItem(1, 0, new QTableWidgetItem(tr("My Multisize Measurements"))); ui->pathTable->setItem(1, 0, new QTableWidgetItem(tr("My Multisize Measurements")));
QTableWidgetItem *item = new QTableWidgetItem(settings->GetPathMultisizeMeasurements()); auto *item = new QTableWidgetItem(settings->GetPathMultisizeMeasurements());
item->setToolTip(settings->GetPathMultisizeMeasurements()); item->setToolTip(settings->GetPathMultisizeMeasurements());
ui->pathTable->setItem(1, 1, item); ui->pathTable->setItem(1, 1, item);
} }
{ {
ui->pathTable->setItem(2, 0, new QTableWidgetItem(tr("My Patterns"))); ui->pathTable->setItem(2, 0, new QTableWidgetItem(tr("My Patterns")));
QTableWidgetItem *item = new QTableWidgetItem(settings->GetPathPattern()); auto *item = new QTableWidgetItem(settings->GetPathPattern());
item->setToolTip(settings->GetPathPattern()); item->setToolTip(settings->GetPathPattern());
ui->pathTable->setItem(2, 1, item); ui->pathTable->setItem(2, 1, item);
} }
{ {
ui->pathTable->setItem(3, 0, new QTableWidgetItem(tr("My Templates"))); ui->pathTable->setItem(3, 0, new QTableWidgetItem(tr("My Templates")));
QTableWidgetItem *item = new QTableWidgetItem(settings->GetPathTemplate()); auto *item = new QTableWidgetItem(settings->GetPathTemplate());
item->setToolTip(settings->GetPathTemplate()); item->setToolTip(settings->GetPathTemplate());
ui->pathTable->setItem(3, 1, item); ui->pathTable->setItem(3, 1, item);
} }
{ {
ui->pathTable->setItem(4, 0, new QTableWidgetItem(tr("My Layouts"))); ui->pathTable->setItem(4, 0, new QTableWidgetItem(tr("My Layouts")));
QTableWidgetItem *item = new QTableWidgetItem(settings->GetPathManualLayouts()); auto *item = new QTableWidgetItem(settings->GetPathManualLayouts());
item->setToolTip(settings->GetPathManualLayouts()); item->setToolTip(settings->GetPathManualLayouts());
ui->pathTable->setItem(4, 1, item); ui->pathTable->setItem(4, 1, item);
} }

View File

@ -31,6 +31,8 @@
#include <QWidget> #include <QWidget>
#include "../vmisc/defglobal.h"
namespace Ui namespace Ui
{ {
class TapePreferencesPathPage; class TapePreferencesPathPage;
@ -38,20 +40,21 @@ namespace Ui
class TapePreferencesPathPage : public QWidget class TapePreferencesPathPage : public QWidget
{ {
Q_OBJECT Q_OBJECT // NOLINT
public: public:
explicit TapePreferencesPathPage(QWidget *parent = nullptr); explicit TapePreferencesPathPage(QWidget *parent = nullptr);
virtual ~TapePreferencesPathPage(); ~TapePreferencesPathPage() override;
void Apply(); void Apply();
protected: protected:
virtual void changeEvent(QEvent* event) override; void changeEvent(QEvent* event) override;
private slots: private slots:
void DefaultPath(); void DefaultPath();
void EditPath(); void EditPath();
private: private:
Q_DISABLE_COPY(TapePreferencesPathPage) // cppcheck-suppress unknownMacro
Q_DISABLE_COPY_MOVE(TapePreferencesPathPage) // NOLINT
Ui::TapePreferencesPathPage *ui; Ui::TapePreferencesPathPage *ui;
void InitTable(); void InitTable();

View File

@ -28,8 +28,8 @@
#include "dialogabouttape.h" #include "dialogabouttape.h"
#include "ui_dialogabouttape.h" #include "ui_dialogabouttape.h"
#include "../version.h"
#include "../vmisc/def.h" #include "../vmisc/def.h"
#include "../vmisc/projectversion.h"
#include "../fervor/fvupdater.h" #include "../fervor/fvupdater.h"
#include <QDate> #include <QDate>
@ -43,7 +43,7 @@
DialogAboutTape::DialogAboutTape(QWidget *parent) DialogAboutTape::DialogAboutTape(QWidget *parent)
:QDialog(parent), :QDialog(parent),
ui(new Ui::DialogAboutTape), ui(new Ui::DialogAboutTape),
isInitialized(false) m_isInitialized(false)
{ {
ui->setupUi(this); ui->setupUi(this);
@ -52,7 +52,8 @@ DialogAboutTape::DialogAboutTape(QWidget *parent)
RetranslateUi(); RetranslateUi();
connect(ui->pushButton_Web_Site, &QPushButton::clicked, this, []() connect(ui->pushButton_Web_Site, &QPushButton::clicked, this, []()
{ {
if (not QDesktopServices::openUrl(QUrl(QStringLiteral("https://%1").arg(VER_COMPANYDOMAIN_STR)))) if (not QDesktopServices::openUrl(
QUrl(QStringLiteral("https://%1").arg(QStringLiteral(VER_COMPANYDOMAIN_STR)))))
{ {
qWarning() << tr("Cannot open your default browser"); qWarning() << tr("Cannot open your default browser");
} }
@ -100,7 +101,7 @@ void DialogAboutTape::showEvent(QShowEvent *event)
return; return;
} }
if (isInitialized) if (m_isInitialized)
{ {
return; return;
} }
@ -109,7 +110,7 @@ void DialogAboutTape::showEvent(QShowEvent *event)
setMaximumSize(size()); setMaximumSize(size());
setMinimumSize(size()); setMinimumSize(size());
isInitialized = true;//first show windows are held m_isInitialized = true;//first show windows are held
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -125,17 +126,17 @@ void DialogAboutTape::FontPointSize(QWidget *w, int pointSize)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogAboutTape::RetranslateUi() void DialogAboutTape::RetranslateUi()
{ {
ui->label_Tape_Version->setText(QString("Tape %1").arg(APP_VERSION_STR)); ui->label_Tape_Version->setText(QStringLiteral("Tape %1").arg(APP_VERSION_STR));
ui->labelBuildRevision->setText(tr("Build revision: %1").arg(BUILD_REVISION)); ui->labelBuildRevision->setText(tr("Build revision: %1").arg(QStringLiteral(BUILD_REVISION)));
ui->label_QT_Version->setText(buildCompatibilityString()); ui->label_QT_Version->setText(buildCompatibilityString());
const QDate date = QLocale::c().toDate(QString(__DATE__).simplified(), QLatin1String("MMM d yyyy")); const QDate date = QLocale::c().toDate(QStringLiteral(__DATE__).simplified(), QStringLiteral("MMM d yyyy"));
ui->label_Tape_Built->setText(tr("Built on %1 at %2").arg(date.toString(), __TIME__)); ui->label_Tape_Built->setText(tr("Built on %1 at %2").arg(date.toString(), QStringLiteral(__TIME__)));
ui->label_Legal_Stuff->setText(QApplication::translate("InternalStrings", ui->label_Legal_Stuff->setText(QApplication::translate("InternalStrings",
"The program is provided AS IS with NO WARRANTY OF ANY " "The program is provided AS IS with NO WARRANTY OF ANY "
"KIND, INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY " "KIND, INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY "
"AND FITNESS FOR A PARTICULAR PURPOSE.")); "AND FITNESS FOR A PARTICULAR PURPOSE."));
ui->pushButton_Web_Site->setText(tr("Web site : %1").arg(VER_COMPANYDOMAIN_STR)); ui->pushButton_Web_Site->setText(tr("Web site : %1").arg(QStringLiteral(VER_COMPANYDOMAIN_STR)));
} }

View File

@ -31,6 +31,8 @@
#include <QDialog> #include <QDialog>
#include "../vmisc/defglobal.h"
namespace Ui namespace Ui
{ {
class DialogAboutTape; class DialogAboutTape;
@ -38,22 +40,23 @@ namespace Ui
class DialogAboutTape : public QDialog class DialogAboutTape : public QDialog
{ {
Q_OBJECT Q_OBJECT // NOLINT
public: public:
explicit DialogAboutTape(QWidget *parent = nullptr); explicit DialogAboutTape(QWidget *parent = nullptr);
virtual ~DialogAboutTape(); ~DialogAboutTape() override;
protected: protected:
virtual void changeEvent(QEvent* event) override; void changeEvent(QEvent* event) override;
virtual void showEvent(QShowEvent *event) override; void showEvent(QShowEvent *event) override;
private: private:
Q_DISABLE_COPY(DialogAboutTape) // cppcheck-suppress unknownMacro
Q_DISABLE_COPY_MOVE(DialogAboutTape) // NOLINT
Ui::DialogAboutTape *ui; Ui::DialogAboutTape *ui;
bool isInitialized; bool m_isInitialized;
void FontPointSize(QWidget *w, int pointSize); static void FontPointSize(QWidget *w, int pointSize);
void RetranslateUi(); void RetranslateUi();
}; };

View File

@ -46,7 +46,7 @@ DialogDimensionCustomNames::~DialogDimensionCustomNames()
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QMap<MeasurementDimension, QString> DialogDimensionCustomNames::CustomNames() const auto DialogDimensionCustomNames::CustomNames() const -> QMap<MeasurementDimension, QString>
{ {
QMap<MeasurementDimension, QString> names; QMap<MeasurementDimension, QString> names;

View File

@ -42,24 +42,25 @@ class QTableWidgetItem;
class DialogDimensionLabels : public QDialog class DialogDimensionLabels : public QDialog
{ {
Q_OBJECT Q_OBJECT // NOLINT
public: public:
explicit DialogDimensionLabels(const QMap<MeasurementDimension, MeasurementDimension_p > &dimensions, explicit DialogDimensionLabels(const QMap<MeasurementDimension, MeasurementDimension_p > &dimensions,
bool fullCircumference, QWidget *parent = nullptr); bool fullCircumference, QWidget *parent = nullptr);
virtual ~DialogDimensionLabels(); ~DialogDimensionLabels() override;
auto Labels() const -> QMap<MeasurementDimension, DimesionLabels>; auto Labels() const -> QMap<MeasurementDimension, DimesionLabels>;
protected: protected:
virtual void changeEvent(QEvent* event) override; void changeEvent(QEvent* event) override;
private slots: private slots:
void DimensionChanged(); void DimensionChanged();
void LabelChanged(QTableWidgetItem *item); void LabelChanged(QTableWidgetItem *item);
private: private:
Q_DISABLE_COPY(DialogDimensionLabels) // cppcheck-suppress unknownMacro
Q_DISABLE_COPY_MOVE(DialogDimensionLabels) // NOLINT
Ui::DialogDimensionLabels *ui; Ui::DialogDimensionLabels *ui;
QMap<MeasurementDimension, MeasurementDimension_p > m_dimensions; QMap<MeasurementDimension, MeasurementDimension_p > m_dimensions;

View File

@ -41,25 +41,7 @@
DialogMDataBase::DialogMDataBase(const QStringList &list, QWidget *parent) DialogMDataBase::DialogMDataBase(const QStringList &list, QWidget *parent)
:QDialog(parent), :QDialog(parent),
ui(new Ui::DialogMDataBase), ui(new Ui::DialogMDataBase),
selectMode(true), m_selectMode(true)
list(list),
groupA(nullptr),
groupB(nullptr),
groupC(nullptr),
groupD(nullptr),
groupE(nullptr),
groupF(nullptr),
groupG(nullptr),
groupH(nullptr),
groupI(nullptr),
groupJ(nullptr),
groupK(nullptr),
groupL(nullptr),
groupM(nullptr),
groupN(nullptr),
groupO(nullptr),
groupP(nullptr),
groupQ(nullptr)
{ {
ui->setupUi(this); ui->setupUi(this);
@ -83,26 +65,7 @@ DialogMDataBase::DialogMDataBase(const QStringList &list, QWidget *parent)
DialogMDataBase::DialogMDataBase(QWidget *parent) DialogMDataBase::DialogMDataBase(QWidget *parent)
:QDialog(parent), :QDialog(parent),
ui(new Ui::DialogMDataBase), ui(new Ui::DialogMDataBase),
selectMode(false), m_selectMode(false)
list(),
groupA(nullptr),
groupB(nullptr),
groupC(nullptr),
groupD(nullptr),
groupE(nullptr),
groupF(nullptr),
groupG(nullptr),
groupH(nullptr),
groupI(nullptr),
groupJ(nullptr),
groupK(nullptr),
groupL(nullptr),
groupM(nullptr),
groupN(nullptr),
groupO(nullptr),
groupP(nullptr),
groupQ(nullptr)
{ {
ui->setupUi(this); ui->setupUi(this);
@ -130,9 +93,9 @@ DialogMDataBase::~DialogMDataBase()
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QStringList DialogMDataBase::GetNewNames() const auto DialogMDataBase::GetNewNames() const -> QStringList
{ {
if (selectMode) if (m_selectMode)
{ {
QStringList newNames; QStringList newNames;
QTreeWidgetItemIterator it(ui->treeWidget, QTreeWidgetItemIterator it(ui->treeWidget,
@ -140,7 +103,7 @@ QStringList DialogMDataBase::GetNewNames() const
while (*it) while (*it)
{ {
const QString name = (*it)->data(0, Qt::UserRole).toString(); const QString name = (*it)->data(0, Qt::UserRole).toString();
if (not list.contains(name)) if (not m_list.contains(name))
{ {
newNames.append(name); newNames.append(name);
} }
@ -148,41 +111,39 @@ QStringList DialogMDataBase::GetNewNames() const
} }
return newNames; return newNames;
} }
else
{ return {};
return QStringList();
}
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogMDataBase::RetranslateGroups() void DialogMDataBase::RetranslateGroups()
{ {
RetranslateGroup(groupA, "A. " + tr("Direct Height", "Measurement section"), ListGroupA()); RetranslateGroup(m_groupA, "A. " + tr("Direct Height", "Measurement section"), ListGroupA());
RetranslateGroup(groupB, "B. " + tr("Direct Width", "Measurement section"), ListGroupB()); RetranslateGroup(m_groupB, "B. " + tr("Direct Width", "Measurement section"), ListGroupB());
RetranslateGroup(groupC, "C. " + tr("Indentation", "Measurement section"), ListGroupC()); RetranslateGroup(m_groupC, "C. " + tr("Indentation", "Measurement section"), ListGroupC());
RetranslateGroup(groupD, "D. " + tr("Hand", "Measurement section"), ListGroupD()); RetranslateGroup(m_groupD, "D. " + tr("Hand", "Measurement section"), ListGroupD());
RetranslateGroup(groupE, "E. " + tr("Foot", "Measurement section"), ListGroupE()); RetranslateGroup(m_groupE, "E. " + tr("Foot", "Measurement section"), ListGroupE());
RetranslateGroup(groupF, "F. " + tr("Head", "Measurement section"), ListGroupF()); RetranslateGroup(m_groupF, "F. " + tr("Head", "Measurement section"), ListGroupF());
RetranslateGroup(groupG, "G. " + tr("Circumference and Arc", "Measurement section"), ListGroupG()); RetranslateGroup(m_groupG, "G. " + tr("Circumference and Arc", "Measurement section"), ListGroupG());
RetranslateGroup(groupH, "H. " + tr("Vertical", "Measurement section"), ListGroupH()); RetranslateGroup(m_groupH, "H. " + tr("Vertical", "Measurement section"), ListGroupH());
RetranslateGroup(groupI, "I. " + tr("Horizontal", "Measurement section"), ListGroupI()); RetranslateGroup(m_groupI, "I. " + tr("Horizontal", "Measurement section"), ListGroupI());
RetranslateGroup(groupJ, "J. " + tr("Bust", "Measurement section"), ListGroupJ()); RetranslateGroup(m_groupJ, "J. " + tr("Bust", "Measurement section"), ListGroupJ());
RetranslateGroup(groupK, "K. " + tr("Balance", "Measurement section"), ListGroupK()); RetranslateGroup(m_groupK, "K. " + tr("Balance", "Measurement section"), ListGroupK());
RetranslateGroup(groupL, "L. " + tr("Arm", "Measurement section"), ListGroupL()); RetranslateGroup(m_groupL, "L. " + tr("Arm", "Measurement section"), ListGroupL());
RetranslateGroup(groupM, "M. " + tr("Leg", "Measurement section"), ListGroupM()); RetranslateGroup(m_groupM, "M. " + tr("Leg", "Measurement section"), ListGroupM());
RetranslateGroup(groupN, "N. " + tr("Crotch and Rise", "Measurement section"), ListGroupN()); RetranslateGroup(m_groupN, "N. " + tr("Crotch and Rise", "Measurement section"), ListGroupN());
RetranslateGroup(groupO, "O. " + tr("Men & Tailoring", "Measurement section"), ListGroupO()); RetranslateGroup(m_groupO, "O. " + tr("Men & Tailoring", "Measurement section"), ListGroupO());
RetranslateGroup(groupP, "P. " + tr("Historical & Specialty", "Measurement section"), ListGroupP()); RetranslateGroup(m_groupP, "P. " + tr("Historical & Specialty", "Measurement section"), ListGroupP());
RetranslateGroup(groupQ, "Q. " + tr("Patternmaking measurements", "Measurement section"), ListGroupQ()); RetranslateGroup(m_groupQ, "Q. " + tr("Patternmaking measurements", "Measurement section"), ListGroupQ());
ShowDescription(ui->treeWidget->currentItem(), 0); ShowDescription(ui->treeWidget->currentItem(), 0);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QString DialogMDataBase::ImgTag(const QString &number) auto DialogMDataBase::ImgTag(const QString &number) -> QString
{ {
QString imgUrl("<img src=\"wrong.png\" align=\"center\"/>"); // In case of error QString imgUrl(QStringLiteral("<img src=\"wrong.png\" align=\"center\"/>")); // In case of error
const QString filePath = QString("://diagrams/%1.svg") const QString filePath = QStringLiteral("://diagrams/%1.svg")
.arg(MapDiagrams(VAbstractApplication::VApp()->TrVars(), number)); .arg(MapDiagrams(VAbstractApplication::VApp()->TrVars(), number));
if (QFileInfo::exists(filePath)) if (QFileInfo::exists(filePath))
{ {
@ -213,7 +174,8 @@ QString DialogMDataBase::ImgTag(const QString &number)
QByteArray byteArray; QByteArray byteArray;
QBuffer buffer(&byteArray); QBuffer buffer(&byteArray);
scaledImg.save(&buffer, "PNG"); scaledImg.save(&buffer, "PNG");
imgUrl = QString("<img src=\"data:image/png;base64,") + byteArray.toBase64() + "\" align=\"center\"/>"; imgUrl = QStringLiteral("<img src=\"data:image/png;base64,") + byteArray.toBase64() +
QStringLiteral("\" align=\"center\"/>");
} }
} }
} }
@ -235,11 +197,11 @@ void DialogMDataBase::changeEvent(QEvent *event)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool DialogMDataBase::eventFilter(QObject *target, QEvent *event) auto DialogMDataBase::eventFilter(QObject *target, QEvent *event) -> bool
{ {
if (target == ui->treeWidget && event->type() == QEvent::KeyPress) if (target == ui->treeWidget && event->type() == QEvent::KeyPress)
{ {
QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event); auto *keyEvent = static_cast<QKeyEvent *>(event); // NOLINT(cppcoreguidelines-pro-type-static-cast-downcast)
switch(keyEvent->key()) switch(keyEvent->key())
{ {
case Qt::Key_Up: case Qt::Key_Up:
@ -278,13 +240,13 @@ void DialogMDataBase::UpdateChecks(QTreeWidgetItem *item, int column)
Qt::CheckState checkState = item->checkState(0); Qt::CheckState checkState = item->checkState(0);
for (int i = 0; i < item->childCount(); ++i) for (int i = 0; i < item->childCount(); ++i)
{ {
if (not list.contains(item->child(i)->data(0, Qt::UserRole).toString())) if (not m_list.contains(item->child(i)->data(0, Qt::UserRole).toString()))
{ {
item->child(i)->setCheckState(0, checkState); item->child(i)->setCheckState(0, checkState);
flag = true; flag = true;
} }
if (flag == false) // All child in the list if (not flag) // All child in the list
{ {
item->setCheckState(0, Qt::Checked); item->setCheckState(0, Qt::Checked);
} }
@ -338,22 +300,22 @@ void DialogMDataBase::TreeMenu(const QPoint &pos)
QTreeWidgetItem *item = ui->treeWidget->currentItem(); QTreeWidgetItem *item = ui->treeWidget->currentItem();
ShowDescription(item, model.column()); ShowDescription(item, model.column());
QAction *actionCollapseAll = new QAction(tr("Collapse All"), this); auto *actionCollapseAll = new QAction(tr("Collapse All"), this);
connect(actionCollapseAll, &QAction::triggered, ui->treeWidget, &QTreeWidget::collapseAll); connect(actionCollapseAll, &QAction::triggered, ui->treeWidget, &QTreeWidget::collapseAll);
QAction *actionExpandeAll = new QAction(tr("Expand All"), this); auto *actionExpandeAll = new QAction(tr("Expand All"), this);
connect(actionExpandeAll, &QAction::triggered, ui->treeWidget, &QTreeWidget::expandAll); connect(actionExpandeAll, &QAction::triggered, ui->treeWidget, &QTreeWidget::expandAll);
QMenu menu(this); QMenu menu(this);
menu.addAction(actionCollapseAll); menu.addAction(actionCollapseAll);
menu.addAction(actionExpandeAll); menu.addAction(actionExpandeAll);
if (selectMode) if (m_selectMode)
{ {
QString actionName; QString actionName;
GlobalCheckState() == Qt::Checked ? actionName = tr("Check all") : actionName = tr("Uncheck all"); GlobalCheckState() == Qt::Checked ? actionName = tr("Check all") : actionName = tr("Uncheck all");
QAction *actionRecheck = new QAction(actionName, this); auto *actionRecheck = new QAction(actionName, this);
connect(actionRecheck, &QAction::triggered, this, &DialogMDataBase::Recheck); connect(actionRecheck, &QAction::triggered, this, &DialogMDataBase::Recheck);
menu.addAction(actionRecheck); menu.addAction(actionRecheck);
@ -364,50 +326,50 @@ void DialogMDataBase::TreeMenu(const QPoint &pos)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogMDataBase::Recheck() void DialogMDataBase::Recheck()
{ {
if (selectMode) if (m_selectMode)
{ {
const Qt::CheckState check = GlobalCheckState(); const Qt::CheckState check = GlobalCheckState();
ChangeCheckState(groupA, check); ChangeCheckState(m_groupA, check);
ChangeCheckState(groupB, check); ChangeCheckState(m_groupB, check);
ChangeCheckState(groupC, check); ChangeCheckState(m_groupC, check);
ChangeCheckState(groupD, check); ChangeCheckState(m_groupD, check);
ChangeCheckState(groupE, check); ChangeCheckState(m_groupE, check);
ChangeCheckState(groupF, check); ChangeCheckState(m_groupF, check);
ChangeCheckState(groupG, check); ChangeCheckState(m_groupG, check);
ChangeCheckState(groupH, check); ChangeCheckState(m_groupH, check);
ChangeCheckState(groupI, check); ChangeCheckState(m_groupI, check);
ChangeCheckState(groupJ, check); ChangeCheckState(m_groupJ, check);
ChangeCheckState(groupK, check); ChangeCheckState(m_groupK, check);
ChangeCheckState(groupL, check); ChangeCheckState(m_groupL, check);
ChangeCheckState(groupM, check); ChangeCheckState(m_groupM, check);
ChangeCheckState(groupN, check); ChangeCheckState(m_groupN, check);
ChangeCheckState(groupO, check); ChangeCheckState(m_groupO, check);
ChangeCheckState(groupP, check); ChangeCheckState(m_groupP, check);
ChangeCheckState(groupQ, check); ChangeCheckState(m_groupQ, check);
} }
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogMDataBase::FilterMeasurements(const QString &search) void DialogMDataBase::FilterMeasurements(const QString &search)
{ {
FilterGroup(groupA, search); FilterGroup(m_groupA, search);
FilterGroup(groupB, search); FilterGroup(m_groupB, search);
FilterGroup(groupC, search); FilterGroup(m_groupC, search);
FilterGroup(groupD, search); FilterGroup(m_groupD, search);
FilterGroup(groupE, search); FilterGroup(m_groupE, search);
FilterGroup(groupF, search); FilterGroup(m_groupF, search);
FilterGroup(groupG, search); FilterGroup(m_groupG, search);
FilterGroup(groupH, search); FilterGroup(m_groupH, search);
FilterGroup(groupI, search); FilterGroup(m_groupI, search);
FilterGroup(groupJ, search); FilterGroup(m_groupJ, search);
FilterGroup(groupK, search); FilterGroup(m_groupK, search);
FilterGroup(groupL, search); FilterGroup(m_groupL, search);
FilterGroup(groupM, search); FilterGroup(m_groupM, search);
FilterGroup(groupN, search); FilterGroup(m_groupN, search);
FilterGroup(groupO, search); FilterGroup(m_groupO, search);
FilterGroup(groupP, search); FilterGroup(m_groupP, search);
FilterGroup(groupQ, search); FilterGroup(m_groupQ, search);
const QList<QTreeWidgetItem *> list = ui->treeWidget->selectedItems(); const QList<QTreeWidgetItem *> list = ui->treeWidget->selectedItems();
list.isEmpty() ? ShowDescription(nullptr, -1) : ShowDescription(ConstFirst(list), 0); list.isEmpty() ? ShowDescription(nullptr, -1) : ShowDescription(ConstFirst(list), 0);
@ -416,23 +378,23 @@ void DialogMDataBase::FilterMeasurements(const QString &search)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogMDataBase::InitDataBase(const QStringList &list) void DialogMDataBase::InitDataBase(const QStringList &list)
{ {
InitGroup(&groupA, "A. " + tr("Direct Height", "Measurement section"), ListGroupA(), list); InitGroup(&m_groupA, "A. " + tr("Direct Height", "Measurement section"), ListGroupA(), list);
InitGroup(&groupB, "B. " + tr("Direct Width", "Measurement section"), ListGroupB(), list); InitGroup(&m_groupB, "B. " + tr("Direct Width", "Measurement section"), ListGroupB(), list);
InitGroup(&groupC, "C. " + tr("Indentation", "Measurement section"), ListGroupC(), list); InitGroup(&m_groupC, "C. " + tr("Indentation", "Measurement section"), ListGroupC(), list);
InitGroup(&groupD, "D. " + tr("Hand", "Measurement section"), ListGroupD(), list); InitGroup(&m_groupD, "D. " + tr("Hand", "Measurement section"), ListGroupD(), list);
InitGroup(&groupE, "E. " + tr("Foot", "Measurement section"), ListGroupE(), list); InitGroup(&m_groupE, "E. " + tr("Foot", "Measurement section"), ListGroupE(), list);
InitGroup(&groupF, "F. " + tr("Head", "Measurement section"), ListGroupF(), list); InitGroup(&m_groupF, "F. " + tr("Head", "Measurement section"), ListGroupF(), list);
InitGroup(&groupG, "G. " + tr("Circumference and Arc", "Measurement section"), ListGroupG(), list); InitGroup(&m_groupG, "G. " + tr("Circumference and Arc", "Measurement section"), ListGroupG(), list);
InitGroup(&groupH, "H. " + tr("Vertical", "Measurement section"), ListGroupH(), list); InitGroup(&m_groupH, "H. " + tr("Vertical", "Measurement section"), ListGroupH(), list);
InitGroup(&groupI, "I. " + tr("Horizontal", "Measurement section"), ListGroupI(), list); InitGroup(&m_groupI, "I. " + tr("Horizontal", "Measurement section"), ListGroupI(), list);
InitGroup(&groupJ, "J. " + tr("Bust", "Measurement section"), ListGroupJ(), list); InitGroup(&m_groupJ, "J. " + tr("Bust", "Measurement section"), ListGroupJ(), list);
InitGroup(&groupK, "K. " + tr("Balance", "Measurement section"), ListGroupK(), list); InitGroup(&m_groupK, "K. " + tr("Balance", "Measurement section"), ListGroupK(), list);
InitGroup(&groupL, "L. " + tr("Arm", "Measurement section"), ListGroupL(), list); InitGroup(&m_groupL, "L. " + tr("Arm", "Measurement section"), ListGroupL(), list);
InitGroup(&groupM, "M. " + tr("Leg", "Measurement section"), ListGroupM(), list); InitGroup(&m_groupM, "M. " + tr("Leg", "Measurement section"), ListGroupM(), list);
InitGroup(&groupN, "N. " + tr("Crotch and Rise", "Measurement section"), ListGroupN(), list); InitGroup(&m_groupN, "N. " + tr("Crotch and Rise", "Measurement section"), ListGroupN(), list);
InitGroup(&groupO, "O. " + tr("Men & Tailoring", "Measurement section"), ListGroupO(), list); InitGroup(&m_groupO, "O. " + tr("Men & Tailoring", "Measurement section"), ListGroupO(), list);
InitGroup(&groupP, "P. " + tr("Historical & Specialty", "Measurement section"), ListGroupP(), list); InitGroup(&m_groupP, "P. " + tr("Historical & Specialty", "Measurement section"), ListGroupP(), list);
InitGroup(&groupQ, "Q. " + tr("Patternmaking measurements", "Measurement section"), ListGroupQ(), list); InitGroup(&m_groupQ, "Q. " + tr("Patternmaking measurements", "Measurement section"), ListGroupQ(), list);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -440,7 +402,7 @@ void DialogMDataBase::InitGroup(QTreeWidgetItem **group, const QString &groupNam
const QStringList &list) const QStringList &list)
{ {
*group = AddGroup(groupName); *group = AddGroup(groupName);
for (auto &m : mList) for (const auto &m : mList)
{ {
AddMeasurement(*group, m, list); AddMeasurement(*group, m, list);
} }
@ -472,13 +434,13 @@ void DialogMDataBase::FilterGroup(QTreeWidgetItem *group, const QString &search)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QTreeWidgetItem *DialogMDataBase::AddGroup(const QString &text) auto DialogMDataBase::AddGroup(const QString &text) -> QTreeWidgetItem *
{ {
QTreeWidgetItem *group = new QTreeWidgetItem(ui->treeWidget); auto *group = new QTreeWidgetItem(ui->treeWidget);
group->setText(0, text); group->setText(0, text);
group->setToolTip(0, text); group->setToolTip(0, text);
group->setExpanded(true); group->setExpanded(true);
if (selectMode) if (m_selectMode)
{ {
group->setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled); group->setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled);
group->setCheckState(0, Qt::Unchecked); group->setCheckState(0, Qt::Unchecked);
@ -492,9 +454,9 @@ void DialogMDataBase::AddMeasurement(QTreeWidgetItem *group, const QString &name
{ {
SCASSERT(group != nullptr) SCASSERT(group != nullptr)
QTreeWidgetItem *m = new QTreeWidgetItem(group); auto *m = new QTreeWidgetItem(group);
if (selectMode) if (m_selectMode)
{ {
if (list.contains(name)) if (list.contains(name))
{ {
@ -530,17 +492,17 @@ void DialogMDataBase::WriteSettings()
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QString DialogMDataBase::ItemFullDescription(QTreeWidgetItem *item, bool showImage) const auto DialogMDataBase::ItemFullDescription(QTreeWidgetItem *item, bool showImage) -> QString
{ {
if (item == nullptr || item->childCount() != 0) if (item == nullptr || item->childCount() != 0)
{ {
return QString(); return {};
} }
const QString name = item->data(0, Qt::UserRole).toString(); const QString name = item->data(0, Qt::UserRole).toString();
if (name.isEmpty()) if (name.isEmpty())
{ {
return QString(); return {};
} }
const QString number = VAbstractApplication::VApp()->TrVars()->MNumber(name); const QString number = VAbstractApplication::VApp()->TrVars()->MNumber(name);
@ -592,65 +554,66 @@ void DialogMDataBase::ChangeCheckState(QTreeWidgetItem *group, Qt::CheckState ch
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
Qt::CheckState DialogMDataBase::GlobalCheckState() const auto DialogMDataBase::GlobalCheckState() const -> Qt::CheckState
{ {
SCASSERT(groupA != nullptr) SCASSERT(m_groupA != nullptr)
SCASSERT(groupB != nullptr) SCASSERT(m_groupB != nullptr)
SCASSERT(groupC != nullptr) SCASSERT(m_groupC != nullptr)
SCASSERT(groupD != nullptr) SCASSERT(m_groupD != nullptr)
SCASSERT(groupE != nullptr) SCASSERT(m_groupE != nullptr)
SCASSERT(groupF != nullptr) SCASSERT(m_groupF != nullptr)
SCASSERT(groupG != nullptr) SCASSERT(m_groupG != nullptr)
SCASSERT(groupH != nullptr) SCASSERT(m_groupH != nullptr)
SCASSERT(groupI != nullptr) SCASSERT(m_groupI != nullptr)
SCASSERT(groupJ != nullptr) SCASSERT(m_groupJ != nullptr)
SCASSERT(groupK != nullptr) SCASSERT(m_groupK != nullptr)
SCASSERT(groupL != nullptr) SCASSERT(m_groupL != nullptr)
SCASSERT(groupM != nullptr) SCASSERT(m_groupM != nullptr)
SCASSERT(groupN != nullptr) SCASSERT(m_groupN != nullptr)
SCASSERT(groupO != nullptr) SCASSERT(m_groupO != nullptr)
SCASSERT(groupP != nullptr) SCASSERT(m_groupP != nullptr)
SCASSERT(groupQ != nullptr) SCASSERT(m_groupQ != nullptr)
if (selectMode) if (m_selectMode)
{ {
if (groupA->checkState(0) == Qt::Unchecked && if (m_groupA->checkState(0) == Qt::Unchecked &&
groupB->checkState(0) == Qt::Unchecked && m_groupB->checkState(0) == Qt::Unchecked &&
groupC->checkState(0) == Qt::Unchecked && m_groupC->checkState(0) == Qt::Unchecked &&
groupD->checkState(0) == Qt::Unchecked && m_groupD->checkState(0) == Qt::Unchecked &&
groupE->checkState(0) == Qt::Unchecked && m_groupE->checkState(0) == Qt::Unchecked &&
groupF->checkState(0) == Qt::Unchecked && m_groupF->checkState(0) == Qt::Unchecked &&
groupG->checkState(0) == Qt::Unchecked && m_groupG->checkState(0) == Qt::Unchecked &&
groupH->checkState(0) == Qt::Unchecked && m_groupH->checkState(0) == Qt::Unchecked &&
groupI->checkState(0) == Qt::Unchecked && m_groupI->checkState(0) == Qt::Unchecked &&
groupJ->checkState(0) == Qt::Unchecked && m_groupJ->checkState(0) == Qt::Unchecked &&
groupK->checkState(0) == Qt::Unchecked && m_groupK->checkState(0) == Qt::Unchecked &&
groupL->checkState(0) == Qt::Unchecked && m_groupL->checkState(0) == Qt::Unchecked &&
groupM->checkState(0) == Qt::Unchecked && m_groupM->checkState(0) == Qt::Unchecked &&
groupN->checkState(0) == Qt::Unchecked && m_groupN->checkState(0) == Qt::Unchecked &&
groupO->checkState(0) == Qt::Unchecked && m_groupO->checkState(0) == Qt::Unchecked &&
groupP->checkState(0) == Qt::Unchecked && m_groupP->checkState(0) == Qt::Unchecked &&
groupQ->checkState(0) == Qt::Unchecked) m_groupQ->checkState(0) == Qt::Unchecked)
{ {
return Qt::Checked; return Qt::Checked;
} }
else if (groupA->checkState(0) == Qt::Checked &&
groupB->checkState(0) == Qt::Checked && if (m_groupA->checkState(0) == Qt::Checked &&
groupC->checkState(0) == Qt::Checked && m_groupB->checkState(0) == Qt::Checked &&
groupD->checkState(0) == Qt::Checked && m_groupC->checkState(0) == Qt::Checked &&
groupE->checkState(0) == Qt::Checked && m_groupD->checkState(0) == Qt::Checked &&
groupF->checkState(0) == Qt::Checked && m_groupE->checkState(0) == Qt::Checked &&
groupG->checkState(0) == Qt::Checked && m_groupF->checkState(0) == Qt::Checked &&
groupH->checkState(0) == Qt::Checked && m_groupG->checkState(0) == Qt::Checked &&
groupI->checkState(0) == Qt::Checked && m_groupH->checkState(0) == Qt::Checked &&
groupJ->checkState(0) == Qt::Checked && m_groupI->checkState(0) == Qt::Checked &&
groupK->checkState(0) == Qt::Checked && m_groupJ->checkState(0) == Qt::Checked &&
groupL->checkState(0) == Qt::Checked && m_groupK->checkState(0) == Qt::Checked &&
groupM->checkState(0) == Qt::Checked && m_groupL->checkState(0) == Qt::Checked &&
groupN->checkState(0) == Qt::Checked && m_groupM->checkState(0) == Qt::Checked &&
groupO->checkState(0) == Qt::Checked && m_groupN->checkState(0) == Qt::Checked &&
groupP->checkState(0) == Qt::Checked && m_groupO->checkState(0) == Qt::Checked &&
groupQ->checkState(0) == Qt::Checked) m_groupP->checkState(0) == Qt::Checked &&
m_groupQ->checkState(0) == Qt::Checked)
{ {
return Qt::Unchecked; return Qt::Unchecked;
} }

View File

@ -31,6 +31,8 @@
#include <QDialog> #include <QDialog>
#include "../vmisc/defglobal.h"
namespace Ui namespace Ui
{ {
class DialogMDataBase; class DialogMDataBase;
@ -40,22 +42,22 @@ class QTreeWidgetItem;
class DialogMDataBase : public QDialog class DialogMDataBase : public QDialog
{ {
Q_OBJECT Q_OBJECT // NOLINT
public: public:
explicit DialogMDataBase(const QStringList &list, QWidget *parent = nullptr); explicit DialogMDataBase(const QStringList &list, QWidget *parent = nullptr);
explicit DialogMDataBase(QWidget *parent = nullptr); explicit DialogMDataBase(QWidget *parent = nullptr);
virtual ~DialogMDataBase() override; ~DialogMDataBase() override;
QStringList GetNewNames() const; auto GetNewNames() const -> QStringList;
void RetranslateGroups(); void RetranslateGroups();
static QString ImgTag(const QString &number); static auto ImgTag(const QString &number) -> QString;
protected: protected:
virtual void changeEvent(QEvent* event) override; void changeEvent(QEvent* event) override;
virtual bool eventFilter(QObject *target, QEvent *event) override; auto eventFilter(QObject *target, QEvent *event) -> bool override;
private slots: private slots:
void UpdateChecks(QTreeWidgetItem *item, int column); void UpdateChecks(QTreeWidgetItem *item, int column);
@ -65,48 +67,49 @@ private slots:
void FilterMeasurements(const QString &search); void FilterMeasurements(const QString &search);
private: private:
Q_DISABLE_COPY(DialogMDataBase) // cppcheck-suppress unknownMacro
Q_DISABLE_COPY_MOVE(DialogMDataBase) // NOLINT
Ui::DialogMDataBase *ui; Ui::DialogMDataBase *ui;
bool selectMode; bool m_selectMode;
QStringList list; QStringList m_list{};
QTreeWidgetItem *groupA; QTreeWidgetItem *m_groupA{nullptr};
QTreeWidgetItem *groupB; QTreeWidgetItem *m_groupB{nullptr};
QTreeWidgetItem *groupC; QTreeWidgetItem *m_groupC{nullptr};
QTreeWidgetItem *groupD; QTreeWidgetItem *m_groupD{nullptr};
QTreeWidgetItem *groupE; QTreeWidgetItem *m_groupE{nullptr};
QTreeWidgetItem *groupF; QTreeWidgetItem *m_groupF{nullptr};
QTreeWidgetItem *groupG; QTreeWidgetItem *m_groupG{nullptr};
QTreeWidgetItem *groupH; QTreeWidgetItem *m_groupH{nullptr};
QTreeWidgetItem *groupI; QTreeWidgetItem *m_groupI{nullptr};
QTreeWidgetItem *groupJ; QTreeWidgetItem *m_groupJ{nullptr};
QTreeWidgetItem *groupK; QTreeWidgetItem *m_groupK{nullptr};
QTreeWidgetItem *groupL; QTreeWidgetItem *m_groupL{nullptr};
QTreeWidgetItem *groupM; QTreeWidgetItem *m_groupM{nullptr};
QTreeWidgetItem *groupN; QTreeWidgetItem *m_groupN{nullptr};
QTreeWidgetItem *groupO; QTreeWidgetItem *m_groupO{nullptr};
QTreeWidgetItem *groupP; QTreeWidgetItem *m_groupP{nullptr};
QTreeWidgetItem *groupQ; QTreeWidgetItem *m_groupQ{nullptr};
void InitDataBase(const QStringList &list = QStringList()); void InitDataBase(const QStringList &list = QStringList());
void InitGroup(QTreeWidgetItem **group, const QString &groupName, const QStringList &mList, void InitGroup(QTreeWidgetItem **group, const QString &groupName, const QStringList &mList,
const QStringList &list = QStringList()); const QStringList &list = QStringList());
void FilterGroup(QTreeWidgetItem *group, const QString &search); static void FilterGroup(QTreeWidgetItem *group, const QString &search);
Q_REQUIRED_RESULT QTreeWidgetItem *AddGroup(const QString &text); Q_REQUIRED_RESULT auto AddGroup(const QString &text) -> QTreeWidgetItem *;
void AddMeasurement(QTreeWidgetItem *group, const QString &name, const QStringList &list); void AddMeasurement(QTreeWidgetItem *group, const QString &name, const QStringList &list);
void ReadSettings(); void ReadSettings();
void WriteSettings(); void WriteSettings();
QString ItemFullDescription(QTreeWidgetItem *item, bool showImage = true) const; static auto ItemFullDescription(QTreeWidgetItem *item, bool showImage = true) -> QString;
void RetranslateGroup(QTreeWidgetItem *group, const QString &groupText, const QStringList &list); static void RetranslateGroup(QTreeWidgetItem *group, const QString &groupText, const QStringList &list);
void RetranslateMeasurement(QTreeWidgetItem *group, int index, const QString &name); static void RetranslateMeasurement(QTreeWidgetItem *group, int index, const QString &name);
void ChangeCheckState(QTreeWidgetItem *group, Qt::CheckState check); static void ChangeCheckState(QTreeWidgetItem *group, Qt::CheckState check);
Qt::CheckState GlobalCheckState() const; auto GlobalCheckState() const -> Qt::CheckState;
}; };
#endif // DIALOGMDATABASE_H #endif // DIALOGMDATABASE_H

View File

@ -120,7 +120,7 @@ void DialogMeasurementsCSVColumns::showEvent(QShowEvent *event)
if (m_type == MeasurementsType::Multisize) if (m_type == MeasurementsType::Multisize)
{ {
if (m_dimensions.size() > 0) if (not m_dimensions.empty())
{ {
connect(ui->comboBoxShiftA, QOverload<int>::of(&QComboBox::currentIndexChanged), connect(ui->comboBoxShiftA, QOverload<int>::of(&QComboBox::currentIndexChanged),
this, &DialogMeasurementsCSVColumns::ColumnChanged); this, &DialogMeasurementsCSVColumns::ColumnChanged);
@ -203,14 +203,13 @@ void DialogMeasurementsCSVColumns::ColumnChanged()
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool DialogMeasurementsCSVColumns::ColumnMandatory(int column) const auto DialogMeasurementsCSVColumns::ColumnMandatory(int column) const -> bool
{ {
if (m_type == MeasurementsType::Individual) if (m_type == MeasurementsType::Individual)
{ {
return column < static_cast<int>(IndividualMeasurementsColumns::FullName); return column < static_cast<int>(IndividualMeasurementsColumns::FullName);
} }
else
{
int mandatory = 3; int mandatory = 3;
if (m_dimensions.size() > 1) if (m_dimensions.size() > 1)
@ -219,11 +218,10 @@ bool DialogMeasurementsCSVColumns::ColumnMandatory(int column) const
} }
return static_cast<int>(column) < mandatory; return static_cast<int>(column) < mandatory;
}
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QString DialogMeasurementsCSVColumns::ColumnHeader(int column) const auto DialogMeasurementsCSVColumns::ColumnHeader(int column) const -> QString
{ {
if (m_type == MeasurementsType::Individual) if (m_type == MeasurementsType::Individual)
{ {
@ -239,7 +237,7 @@ QString DialogMeasurementsCSVColumns::ColumnHeader(int column) const
case IndividualMeasurementsColumns::Description: case IndividualMeasurementsColumns::Description:
return tr("Description", "measurement column"); return tr("Description", "measurement column");
default: default:
return QString(); return {};
} }
} }
else else
@ -252,14 +250,14 @@ QString DialogMeasurementsCSVColumns::ColumnHeader(int column) const
case MultisizeMeasurementsColumns::BaseValue: case MultisizeMeasurementsColumns::BaseValue:
return tr("Base value", "measurement column"); return tr("Base value", "measurement column");
case MultisizeMeasurementsColumns::ShiftA: case MultisizeMeasurementsColumns::ShiftA:
if (m_dimensions.size() > 0) if (not m_dimensions.empty())
{ {
MeasurementDimension_p dimension = m_dimensions.at(0); MeasurementDimension_p dimension = m_dimensions.at(0);
return tr("Shift (%1):", "measurement column").arg(dimension->Name()); return tr("Shift (%1):", "measurement column").arg(dimension->Name());
} }
else else
{ {
return "Shift A"; return QStringLiteral("Shift A");
} }
case MultisizeMeasurementsColumns::ShiftB: case MultisizeMeasurementsColumns::ShiftB:
if (m_dimensions.size() > 1) if (m_dimensions.size() > 1)
@ -269,7 +267,7 @@ QString DialogMeasurementsCSVColumns::ColumnHeader(int column) const
} }
else else
{ {
return "Shift B"; return QStringLiteral("Shift B");
} }
case MultisizeMeasurementsColumns::ShiftC: case MultisizeMeasurementsColumns::ShiftC:
if (m_dimensions.size() > 2) if (m_dimensions.size() > 2)
@ -279,7 +277,7 @@ QString DialogMeasurementsCSVColumns::ColumnHeader(int column) const
} }
else else
{ {
return "Shift C"; return QStringLiteral("Shift C");
} }
case MultisizeMeasurementsColumns::FullName: case MultisizeMeasurementsColumns::FullName:
return tr("Full name", "measurement column"); return tr("Full name", "measurement column");
@ -292,27 +290,24 @@ QString DialogMeasurementsCSVColumns::ColumnHeader(int column) const
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
int DialogMeasurementsCSVColumns::ImportColumnCount() const auto DialogMeasurementsCSVColumns::ImportColumnCount() const -> int
{ {
if (m_type == MeasurementsType::Individual) if (m_type == MeasurementsType::Individual)
{ {
return static_cast<int>(IndividualMeasurementsColumns::LAST_DO_NOT_USE); return static_cast<int>(IndividualMeasurementsColumns::LAST_DO_NOT_USE);
} }
else
{
return static_cast<int>(MultisizeMeasurementsColumns::LAST_DO_NOT_USE); return static_cast<int>(MultisizeMeasurementsColumns::LAST_DO_NOT_USE);
}
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
int DialogMeasurementsCSVColumns::MinimumColumns() const auto DialogMeasurementsCSVColumns::MinimumColumns() const -> int
{ {
if (m_type == MeasurementsType::Individual) if (m_type == MeasurementsType::Individual)
{ {
return 2; return 2;
} }
else
{
int mandatory = 3; int mandatory = 3;
if (m_dimensions.size() > 1) if (m_dimensions.size() > 1)
@ -321,33 +316,12 @@ int DialogMeasurementsCSVColumns::MinimumColumns() const
} }
return mandatory; return mandatory;
}
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto DialogMeasurementsCSVColumns::ColumnsValid() -> bool auto DialogMeasurementsCSVColumns::ColumnsValid() -> bool
{ {
ChangeColor(ui->labelName, OkColor(this)); ClearColumnCollor();
ChangeColor(ui->labelValue, OkColor(this));
if (m_type == MeasurementsType::Multisize)
{
if (not m_dimensions.empty())
{
ChangeColor(ui->labelShiftA, OkColor(this));
}
if (m_dimensions.size() > 1)
{
ChangeColor(ui->labelShiftB, OkColor(this));
}
if (m_dimensions.size() > 2)
{
ChangeColor(ui->labelShiftC, OkColor(this));
}
}
ChangeColor(ui->labelFullName, OkColor(this));
ChangeColor(ui->labelDescription, OkColor(this));
bool columnNameFlag = true; bool columnNameFlag = true;
bool columnValueFlag = true; bool columnValueFlag = true;
@ -359,20 +333,22 @@ auto DialogMeasurementsCSVColumns::ColumnsValid() -> bool
const QColor errorColor = Qt::red; const QColor errorColor = Qt::red;
if (m_type == MeasurementsType::Multisize ? not ColumnValid(MultisizeMeasurementsColumns::Name) auto ChangeColumnColor = [this, errorColor]
: not ColumnValid(IndividualMeasurementsColumns::Name)) (QLabel *label, bool &columnFlag, MultisizeMeasurementsColumns multisizeColumn,
IndividualMeasurementsColumns individualColumn)
{ {
ChangeColor(ui->labelName, errorColor); if (m_type == MeasurementsType::Multisize ? not ColumnValid(multisizeColumn)
columnNameFlag = false; : not ColumnValid(individualColumn))
}
if (m_type == MeasurementsType::Multisize ? not ColumnValid(MultisizeMeasurementsColumns::BaseValue)
: not ColumnValid(IndividualMeasurementsColumns::Value))
{ {
ChangeColor(ui->labelValue, errorColor); ChangeColor(label, errorColor);
columnValueFlag = false; columnFlag = false;
} }
};
ChangeColumnColor(ui->labelName, columnNameFlag, MultisizeMeasurementsColumns::Name,
IndividualMeasurementsColumns::Name);
ChangeColumnColor(ui->labelValue, columnValueFlag, MultisizeMeasurementsColumns::BaseValue,
IndividualMeasurementsColumns::Value);
if (m_type == MeasurementsType::Multisize) if (m_type == MeasurementsType::Multisize)
{ {
@ -404,24 +380,41 @@ auto DialogMeasurementsCSVColumns::ColumnsValid() -> bool
} }
} }
if (m_type == MeasurementsType::Multisize ? not ColumnValid(MultisizeMeasurementsColumns::FullName) ChangeColumnColor(ui->labelFullName, columnFullNameFlag, MultisizeMeasurementsColumns::FullName,
: not ColumnValid(IndividualMeasurementsColumns::FullName)) IndividualMeasurementsColumns::FullName);
{ ChangeColumnColor(ui->labelDescription, columnDescriptionFlag, MultisizeMeasurementsColumns::Description,
ChangeColor(ui->labelFullName, errorColor); IndividualMeasurementsColumns::Description);
columnFullNameFlag = false;
}
if (m_type == MeasurementsType::Multisize ? not ColumnValid(MultisizeMeasurementsColumns::Description)
: not ColumnValid(IndividualMeasurementsColumns::Description))
{
ChangeColor(ui->labelDescription, errorColor);
columnDescriptionFlag = false;
}
return columnNameFlag && columnValueFlag && columnShiftAFlag && columnShiftBFlag && columnShiftCFlag && return columnNameFlag && columnValueFlag && columnShiftAFlag && columnShiftBFlag && columnShiftCFlag &&
columnFullNameFlag && columnDescriptionFlag; columnFullNameFlag && columnDescriptionFlag;
} }
//---------------------------------------------------------------------------------------------------------------------
void DialogMeasurementsCSVColumns::ClearColumnCollor()
{
ChangeColor(ui->labelName, OkColor(this));
ChangeColor(ui->labelValue, OkColor(this));
if (m_type == MeasurementsType::Multisize)
{
if (not m_dimensions.empty())
{
ChangeColor(ui->labelShiftA, OkColor(this));
}
if (m_dimensions.size() > 1)
{
ChangeColor(ui->labelShiftB, OkColor(this));
}
if (m_dimensions.size() > 2)
{
ChangeColor(ui->labelShiftC, OkColor(this));
}
}
ChangeColor(ui->labelFullName, OkColor(this));
ChangeColor(ui->labelDescription, OkColor(this));
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogMeasurementsCSVColumns::InitColumnsMap() void DialogMeasurementsCSVColumns::InitColumnsMap()
{ {
@ -537,7 +530,7 @@ void DialogMeasurementsCSVColumns::InitColumnsControls()
InitControl(ui->comboBoxName, static_cast<int>(MultisizeMeasurementsColumns::Name)); InitControl(ui->comboBoxName, static_cast<int>(MultisizeMeasurementsColumns::Name));
InitControl(ui->comboBoxValue, static_cast<int>(MultisizeMeasurementsColumns::BaseValue)); InitControl(ui->comboBoxValue, static_cast<int>(MultisizeMeasurementsColumns::BaseValue));
if (m_dimensions.size() > 0) if (not m_dimensions.empty())
{ {
InitControl(ui->comboBoxShiftA, static_cast<int>(MultisizeMeasurementsColumns::ShiftA)); InitControl(ui->comboBoxShiftA, static_cast<int>(MultisizeMeasurementsColumns::ShiftA));
} }
@ -572,7 +565,7 @@ void DialogMeasurementsCSVColumns::InitImportHeaders()
auto AddHeader = [this](int column, bool visible=true) auto AddHeader = [this](int column, bool visible=true)
{ {
QTableWidgetItem *header = new QTableWidgetItem(ColumnHeader(column)); auto *header = new QTableWidgetItem(ColumnHeader(column));
ui->tableWidgetImport->setHorizontalHeaderItem(column, header); ui->tableWidgetImport->setHorizontalHeaderItem(column, header);
ui->tableWidgetImport->setColumnHidden(column, not visible); ui->tableWidgetImport->setColumnHidden(column, not visible);
}; };
@ -588,7 +581,7 @@ void DialogMeasurementsCSVColumns::InitImportHeaders()
{ {
AddHeader(static_cast<int>(MultisizeMeasurementsColumns::Name)); AddHeader(static_cast<int>(MultisizeMeasurementsColumns::Name));
AddHeader(static_cast<int>(MultisizeMeasurementsColumns::BaseValue)); AddHeader(static_cast<int>(MultisizeMeasurementsColumns::BaseValue));
AddHeader(static_cast<int>(MultisizeMeasurementsColumns::ShiftA), m_dimensions.size() > 0); AddHeader(static_cast<int>(MultisizeMeasurementsColumns::ShiftA), not m_dimensions.empty());
AddHeader(static_cast<int>(MultisizeMeasurementsColumns::ShiftB), m_dimensions.size() > 1); AddHeader(static_cast<int>(MultisizeMeasurementsColumns::ShiftB), m_dimensions.size() > 1);
AddHeader(static_cast<int>(MultisizeMeasurementsColumns::ShiftC), m_dimensions.size() > 2); AddHeader(static_cast<int>(MultisizeMeasurementsColumns::ShiftC), m_dimensions.size() > 2);
AddHeader(static_cast<int>(MultisizeMeasurementsColumns::FullName)); AddHeader(static_cast<int>(MultisizeMeasurementsColumns::FullName));
@ -597,7 +590,7 @@ void DialogMeasurementsCSVColumns::InitImportHeaders()
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QSharedPointer<QxtCsvModel> DialogMeasurementsCSVColumns::CSVModel() const auto DialogMeasurementsCSVColumns::CSVModel() const -> QSharedPointer<QxtCsvModel>
{ {
return QSharedPointer<QxtCsvModel>::create(m_fileName, nullptr, m_withHeader, m_separator, m_codec); return QSharedPointer<QxtCsvModel>::create(m_fileName, nullptr, m_withHeader, m_separator, m_codec);
} }
@ -624,7 +617,7 @@ void DialogMeasurementsCSVColumns::ShowInputPreview()
{ {
for(int column=0; column<columns; ++column) for(int column=0; column<columns; ++column)
{ {
QTableWidgetItem *header = new QTableWidgetItem(csv->headerText(column)); auto *header = new QTableWidgetItem(csv->headerText(column));
header->setToolTip(QString::number(column+1)); header->setToolTip(QString::number(column+1));
ui->tableWidgetInput->setHorizontalHeaderItem(column, header); ui->tableWidgetInput->setHorizontalHeaderItem(column, header);
} }
@ -635,7 +628,7 @@ void DialogMeasurementsCSVColumns::ShowInputPreview()
for(int column=0; column<columns; ++column) for(int column=0; column<columns; ++column)
{ {
const QString text = csv->text(row, column); const QString text = csv->text(row, column);
QTableWidgetItem *item = new QTableWidgetItem(text); auto *item = new QTableWidgetItem(text);
item->setToolTip(text); item->setToolTip(text);
// set the item non-editable (view only), and non-selectable // set the item non-editable (view only), and non-selectable
@ -676,7 +669,7 @@ void DialogMeasurementsCSVColumns::ShowImportPreview()
if (tableColumn >= 0 && tableColumn < columns) if (tableColumn >= 0 && tableColumn < columns)
{ {
const QString text = csv->text(row, tableColumn); const QString text = csv->text(row, tableColumn);
QTableWidgetItem *item = new QTableWidgetItem(text); auto *item = new QTableWidgetItem(text);
item->setToolTip(text); item->setToolTip(text);
// set the item non-editable (view only), and non-selectable // set the item non-editable (view only), and non-selectable
@ -735,7 +728,7 @@ void DialogMeasurementsCSVColumns::RetranslateLabels()
{ {
ui->labelValue->setText(tr("Base value") + "*:"); ui->labelValue->setText(tr("Base value") + "*:");
if (m_dimensions.size() > 0) if (not m_dimensions.empty())
{ {
MeasurementDimension_p dimension = m_dimensions.at(0); MeasurementDimension_p dimension = m_dimensions.at(0);
ui->labelShiftA->setText(tr("Shift (%1)*:").arg(dimension->Name())); ui->labelShiftA->setText(tr("Shift (%1)*:").arg(dimension->Name()));
@ -781,7 +774,7 @@ void DialogMeasurementsCSVColumns::SetDefaultColumns()
SetDefault(ui->comboBoxName, static_cast<int>(MultisizeMeasurementsColumns::Name)); SetDefault(ui->comboBoxName, static_cast<int>(MultisizeMeasurementsColumns::Name));
SetDefault(ui->comboBoxValue, static_cast<int>(MultisizeMeasurementsColumns::BaseValue)); SetDefault(ui->comboBoxValue, static_cast<int>(MultisizeMeasurementsColumns::BaseValue));
if (m_dimensions.size() > 0) if (not m_dimensions.empty())
{ {
SetDefault(ui->comboBoxShiftA, static_cast<int>(MultisizeMeasurementsColumns::ShiftA)); SetDefault(ui->comboBoxShiftA, static_cast<int>(MultisizeMeasurementsColumns::ShiftA));
} }

View File

@ -62,29 +62,30 @@ class DialogMeasurementsCSVColumns;
class DialogMeasurementsCSVColumns : public QDialog class DialogMeasurementsCSVColumns : public QDialog
{ {
Q_OBJECT Q_OBJECT // NOLINT
public: public:
DialogMeasurementsCSVColumns(const QString &filename, MeasurementsType type, QWidget *parent = nullptr); DialogMeasurementsCSVColumns(const QString &filename, MeasurementsType type, QWidget *parent = nullptr);
DialogMeasurementsCSVColumns(const QString &filename, MeasurementsType type, DialogMeasurementsCSVColumns(const QString &filename, MeasurementsType type,
const QList<MeasurementDimension_p> &dimensions, QWidget *parent = nullptr); const QList<MeasurementDimension_p> &dimensions, QWidget *parent = nullptr);
virtual ~DialogMeasurementsCSVColumns(); ~DialogMeasurementsCSVColumns() override;
QVector<int> ColumnsMap() const; auto ColumnsMap() const -> QVector<int>;
void SetWithHeader(bool withHeader); void SetWithHeader(bool withHeader);
void SetSeparator(const QChar &separator); void SetSeparator(const QChar &separator);
void SetCodec(QTextCodec *codec); void SetCodec(QTextCodec *codec);
protected: protected:
virtual void changeEvent(QEvent* event) override; void changeEvent(QEvent* event) override;
virtual void showEvent(QShowEvent *event) override; void showEvent(QShowEvent *event) override;
private slots: private slots:
void ColumnChanged(); void ColumnChanged();
private: private:
Q_DISABLE_COPY(DialogMeasurementsCSVColumns) // cppcheck-suppress unknownMacro
Q_DISABLE_COPY_MOVE(DialogMeasurementsCSVColumns) // NOLINT
Ui::DialogMeasurementsCSVColumns *ui; Ui::DialogMeasurementsCSVColumns *ui;
bool m_isInitialized{false}; bool m_isInitialized{false};
QString m_fileName; QString m_fileName;
@ -96,17 +97,18 @@ private:
QList<MeasurementDimension_p> m_dimensions{}; QList<MeasurementDimension_p> m_dimensions{};
QVector<QObject *> m_hackedWidgets{}; QVector<QObject *> m_hackedWidgets{};
bool ColumnMandatory(int column) const; auto ColumnMandatory(int column) const -> bool;
QString ColumnHeader(int column) const; auto ColumnHeader(int column) const -> QString;
int ImportColumnCount() const; auto ImportColumnCount() const -> int;
int MinimumColumns() const; auto MinimumColumns() const -> int;
bool ColumnsValid(); auto ColumnsValid() -> bool;
void ClearColumnCollor();
void InitColumnsMap(); void InitColumnsMap();
void InitColumnsControls(); void InitColumnsControls();
void InitImportHeaders(); void InitImportHeaders();
QSharedPointer<QxtCsvModel> CSVModel() const; auto CSVModel() const -> QSharedPointer<QxtCsvModel>;
void ShowInputPreview(); void ShowInputPreview();
void ShowImportPreview(); void ShowImportPreview();
@ -129,7 +131,7 @@ private:
}; };
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
inline QVector<int> DialogMeasurementsCSVColumns::ColumnsMap() const inline auto DialogMeasurementsCSVColumns::ColumnsMap() const -> QVector<int>
{ {
return m_columnsMap; return m_columnsMap;
} }

View File

@ -29,17 +29,13 @@
#include "dialognewmeasurements.h" #include "dialognewmeasurements.h"
#include "ui_dialognewmeasurements.h" #include "ui_dialognewmeasurements.h"
#include "../vpatterndb/variables/vmeasurement.h"
#include "../vtapesettings.h"
#include "../mapplication.h"
#include <QShowEvent> #include <QShowEvent>
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
DialogNewMeasurements::DialogNewMeasurements(QWidget *parent) DialogNewMeasurements::DialogNewMeasurements(QWidget *parent)
:QDialog(parent), :QDialog(parent),
ui(new Ui::DialogNewMeasurements), ui(new Ui::DialogNewMeasurements),
isInitialized(false) m_isInitialized(false)
{ {
ui->setupUi(this); ui->setupUi(this);
@ -54,13 +50,13 @@ DialogNewMeasurements::~DialogNewMeasurements()
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
MeasurementsType DialogNewMeasurements::Type() const auto DialogNewMeasurements::Type() const -> MeasurementsType
{ {
return static_cast<MeasurementsType>(ui->comboBoxMType->currentData().toInt()); return static_cast<MeasurementsType>(ui->comboBoxMType->currentData().toInt());
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
Unit DialogNewMeasurements::MUnit() const auto DialogNewMeasurements::MUnit() const -> Unit
{ {
return static_cast<Unit>(ui->comboBoxUnit->currentData().toInt()); return static_cast<Unit>(ui->comboBoxUnit->currentData().toInt());
} }
@ -89,7 +85,7 @@ void DialogNewMeasurements::showEvent(QShowEvent *event)
return; return;
} }
if (isInitialized) if (m_isInitialized)
{ {
return; return;
} }
@ -98,7 +94,7 @@ void DialogNewMeasurements::showEvent(QShowEvent *event)
setMaximumSize(size()); setMaximumSize(size());
setMinimumSize(size()); setMinimumSize(size());
isInitialized = true;//first show windows are held m_isInitialized = true;//first show windows are held
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View File

@ -40,23 +40,24 @@ namespace Ui
class DialogNewMeasurements : public QDialog class DialogNewMeasurements : public QDialog
{ {
Q_OBJECT Q_OBJECT // NOLINT
public: public:
explicit DialogNewMeasurements(QWidget *parent = nullptr); explicit DialogNewMeasurements(QWidget *parent = nullptr);
~DialogNewMeasurements(); ~DialogNewMeasurements() override;
MeasurementsType Type() const; auto Type() const -> MeasurementsType;
Unit MUnit() const; auto MUnit() const -> Unit;
protected: protected:
virtual void changeEvent(QEvent* event) override; void changeEvent(QEvent* event) override;
virtual void showEvent(QShowEvent *event) override; void showEvent(QShowEvent *event) override;
private: private:
Q_DISABLE_COPY(DialogNewMeasurements) // cppcheck-suppress unknownMacro
Q_DISABLE_COPY_MOVE(DialogNewMeasurements) // NOLINT
Ui::DialogNewMeasurements *ui; Ui::DialogNewMeasurements *ui;
bool isInitialized; bool m_isInitialized;
void InitMTypes(); void InitMTypes();
void InitUnits(); void InitUnits();

View File

@ -76,6 +76,53 @@ auto FilterByMaximum(const QVector<qreal> &base, qreal restriction) -> QVector<q
} }
return filtered; return filtered;
} }
//---------------------------------------------------------------------------------------------------------------------
void InitMinMax(qreal &min, qreal &max, const MeasurementDimension_p &dimension, const QVector<qreal> &bases,
const VDimensionRestriction &restriction)
{
if (not dimension.isNull())
{
min = bases.indexOf(restriction.GetMin()) != -1 ? restriction.GetMin() : dimension->MinValue();
max = bases.indexOf(restriction.GetMax()) != -1 ? restriction.GetMax() : dimension->MaxValue();
if (max < min)
{
min = dimension->MinValue();
max = dimension->MaxValue();
}
}
}
//---------------------------------------------------------------------------------------------------------------------
void SetCellIcon(QTableWidgetItem *item, const QVector<qreal> &validRows, qreal rowValue, qreal columnValue,
const VDimensionRestriction &restriction, qreal min, qreal max)
{
if (validRows.contains(rowValue))
{
const bool leftRestriction = columnValue >= min;
const bool rightRestriction = columnValue <= max;
if (leftRestriction && rightRestriction)
{
item->setIcon(QIcon(restriction.GetExcludeValues().contains(columnValue)
? QStringLiteral("://icon/24x24/close.png")
: QStringLiteral("://icon/24x24/star.png")));
}
else
{
item->setIcon(QIcon(QStringLiteral("://icon/24x24/close.png")));
}
}
else
{
item->setIcon(QIcon(QStringLiteral("://icon/24x24/close.png")));
Qt::ItemFlags flags = item->flags();
flags &= ~(Qt::ItemIsEnabled);
item->setFlags(flags);
}
}
} // namespace } // namespace
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -299,57 +346,50 @@ void DialogRestrictDimension::MaxRestrictionChanged()
void DialogRestrictDimension::CellContextMenu(QPoint pos) void DialogRestrictDimension::CellContextMenu(QPoint pos)
{ {
QTableWidgetItem *item = ui->tableWidget->itemAt(pos); QTableWidgetItem *item = ui->tableWidget->itemAt(pos);
if (item != nullptr && (item->flags() & Qt::ItemIsEnabled) != 0U) if (item == nullptr || not static_cast<bool>((item->flags() & Qt::ItemIsEnabled)))
{ {
return;
}
qreal columnValue = 0; qreal columnValue = 0;
QString coordinates; QString coordinates;
MeasurementDimension_p dimension; MeasurementDimension_p dimension;
if (m_restrictionType == RestrictDimension::First) if (m_restrictionType == RestrictDimension::First)
{ {
if (not m_dimensions.empty()) if (m_dimensions.empty())
{
columnValue = m_dimensions.at(0)->ValidBases().at(item->column());
coordinates = QChar('0');
}
else
{ {
return; return;
} }
columnValue = m_dimensions.at(0)->ValidBases().at(item->column());
coordinates = QChar('0');
} }
else if (m_restrictionType == RestrictDimension::Second) else if (m_restrictionType == RestrictDimension::Second)
{ {
if (m_dimensions.size() >= 2) if (m_dimensions.size() < 2)
{ {
return;
}
dimension = m_dimensions.at(1); dimension = m_dimensions.at(1);
columnValue = dimension->ValidBases().at(item->column()); columnValue = dimension->ValidBases().at(item->column());
qreal base1 = m_dimensions.at(0)->ValidBases().at(item->row()); qreal base1 = m_dimensions.at(0)->ValidBases().at(item->row());
coordinates = VMeasurement::CorrectionHash(base1); coordinates = VMeasurement::CorrectionHash(base1);
} }
else else if (m_restrictionType == RestrictDimension::Third)
{
if (m_dimensions.size() < 3)
{ {
return; return;
} }
}
else if (m_restrictionType == RestrictDimension::Third)
{
if (m_dimensions.size() >= 3)
{
dimension = m_dimensions.at(2); dimension = m_dimensions.at(2);
columnValue = dimension->ValidBases().at(item->column()); columnValue = dimension->ValidBases().at(item->column());
qreal base1 = ui->comboBoxDimensionA->currentData().toDouble(); qreal base1 = ui->comboBoxDimensionA->currentData().toDouble();
qreal base2 = m_dimensions.at(1)->ValidBases().at(item->row()); qreal base2 = m_dimensions.at(1)->ValidBases().at(item->row());
coordinates = VMeasurement::CorrectionHash(base1, base2); coordinates = VMeasurement::CorrectionHash(base1, base2);
} }
else
{
return;
}
}
else
{
return;
}
VDimensionRestriction restriction = m_restrictions.value(coordinates); VDimensionRestriction restriction = m_restrictions.value(coordinates);
bool exclude = not restriction.GetExcludeValues().contains(columnValue); bool exclude = not restriction.GetExcludeValues().contains(columnValue);
@ -358,8 +398,11 @@ void DialogRestrictDimension::CellContextMenu(QPoint pos)
if (m_restrictionType == RestrictDimension::Second || m_restrictionType == RestrictDimension::Third) if (m_restrictionType == RestrictDimension::Second || m_restrictionType == RestrictDimension::Third)
{ {
if (dimension != nullptr) if (dimension.isNull())
{ {
return;
}
qreal min = restriction.GetMin(); qreal min = restriction.GetMin();
if (qFuzzyIsNull(min)) if (qFuzzyIsNull(min))
{ {
@ -374,11 +417,6 @@ void DialogRestrictDimension::CellContextMenu(QPoint pos)
actionExclude->setEnabled(columnValue >= min && columnValue <= max); actionExclude->setEnabled(columnValue >= min && columnValue <= max);
} }
else
{
return;
}
}
QAction *selectedAction = menu->exec(ui->tableWidget->viewport()->mapToGlobal(pos)); QAction *selectedAction = menu->exec(ui->tableWidget->viewport()->mapToGlobal(pos));
if (selectedAction == actionExclude) if (selectedAction == actionExclude)
@ -397,7 +435,6 @@ void DialogRestrictDimension::CellContextMenu(QPoint pos)
restriction.SetExcludeValues(list); restriction.SetExcludeValues(list);
m_restrictions[coordinates] = restriction; m_restrictions[coordinates] = restriction;
} }
}
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -611,14 +648,9 @@ void DialogRestrictDimension::AddCell(int row, int column, qreal rowValue, qreal
if (m_restrictionType == RestrictDimension::First) if (m_restrictionType == RestrictDimension::First)
{ {
VDimensionRestriction restriction = m_restrictions.value(QChar('0')); VDimensionRestriction restriction = m_restrictions.value(QChar('0'));
if (restriction.GetExcludeValues().contains(columnValue)) item->setIcon(QIcon(restriction.GetExcludeValues().contains(columnValue)
{ ? QStringLiteral("://icon/24x24/close.png")
item->setIcon(QIcon(QStringLiteral("://icon/24x24/close.png"))); : QStringLiteral("://icon/24x24/star.png")));
}
else
{
item->setIcon(QIcon(QStringLiteral("://icon/24x24/star.png")));
}
} }
else else
{ {
@ -656,47 +688,8 @@ void DialogRestrictDimension::AddCell(int row, int column, qreal rowValue, qreal
qreal min = INT32_MIN; qreal min = INT32_MIN;
qreal max = INT32_MAX; qreal max = INT32_MAX;
if (not dimension.isNull()) InitMinMax(min, max, dimension, bases, restriction);
{ SetCellIcon(item, validRows, rowValue, columnValue, restriction, min, max);
min = bases.indexOf(restriction.GetMin()) != -1 ? restriction.GetMin() : dimension->MinValue();
max = bases.indexOf(restriction.GetMax()) != -1 ? restriction.GetMax() : dimension->MaxValue();
if (max < min)
{
min = dimension->MinValue();
max = dimension->MaxValue();
}
}
if (validRows.contains(rowValue))
{
const bool leftRestriction = columnValue >= min;
const bool rightRestriction = columnValue <= max;
if (leftRestriction && rightRestriction)
{
if (restriction.GetExcludeValues().contains(columnValue))
{
item->setIcon(QIcon(QStringLiteral("://icon/24x24/close.png")));
}
else
{
item->setIcon(QIcon(QStringLiteral("://icon/24x24/star.png")));
}
}
else
{
item->setIcon(QIcon(QStringLiteral("://icon/24x24/close.png")));
}
}
else
{
item->setIcon(QIcon(QStringLiteral("://icon/24x24/close.png")));
Qt::ItemFlags flags = item->flags();
flags &= ~(Qt::ItemIsEnabled);
item->setFlags(flags);
}
} }
// set the item non-editable (view only), and non-selectable // set the item non-editable (view only), and non-selectable
@ -785,8 +778,8 @@ void DialogRestrictDimension::FillBases(const QVector<qreal> &bases, const Measu
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto DialogRestrictDimension::DimensionLabels(const QVector<qreal> &bases, auto DialogRestrictDimension::FillDimensionXBases(const QVector<qreal> &bases,
const MeasurementDimension_p &dimension) const -> QStringList const MeasurementDimension_p &dimension) -> QStringList
{ {
const bool showUnits = dimension->IsBodyMeasurement() || dimension->Type() == MeasurementDimension::X; const bool showUnits = dimension->IsBodyMeasurement() || dimension->Type() == MeasurementDimension::X;
const QString units = showUnits ? UnitsToStr(dimension->Units(), true) : QString(); const QString units = showUnits ? UnitsToStr(dimension->Units(), true) : QString();
@ -794,8 +787,6 @@ auto DialogRestrictDimension::DimensionLabels(const QVector<qreal> &bases,
QStringList labels; QStringList labels;
if (dimension->Type() == MeasurementDimension::X)
{
for(auto base : bases) for(auto base : bases)
{ {
if (dimensionLabels.contains(base) && not dimensionLabels.value(base).isEmpty()) if (dimensionLabels.contains(base) && not dimensionLabels.value(base).isEmpty())
@ -807,9 +798,20 @@ auto DialogRestrictDimension::DimensionLabels(const QVector<qreal> &bases,
labels.append(QStringLiteral("%1 %2").arg(base).arg(units)); labels.append(QStringLiteral("%1 %2").arg(base).arg(units));
} }
} }
}
else if (dimension->Type() == MeasurementDimension::Y) return labels;
{ }
//---------------------------------------------------------------------------------------------------------------------
auto DialogRestrictDimension::FillDimensionYBases(const QVector<qreal> &bases,
const MeasurementDimension_p &dimension) const -> QStringList
{
const bool showUnits = dimension->IsBodyMeasurement() || dimension->Type() == MeasurementDimension::X;
const QString units = showUnits ? UnitsToStr(dimension->Units(), true) : QString();
const DimesionLabels dimensionLabels = dimension->Labels();
QStringList labels;
for(auto base : bases) for(auto base : bases)
{ {
if (dimensionLabels.contains(base) && not dimensionLabels.value(base).isEmpty()) if (dimensionLabels.contains(base) && not dimensionLabels.value(base).isEmpty())
@ -828,9 +830,20 @@ auto DialogRestrictDimension::DimensionLabels(const QVector<qreal> &bases,
} }
} }
} }
}
else if (dimension->Type() == MeasurementDimension::W || dimension->Type() == MeasurementDimension::Z) return labels;
{ }
//---------------------------------------------------------------------------------------------------------------------
auto DialogRestrictDimension::FillDimensionWZBases(const QVector<qreal> &bases,
const MeasurementDimension_p &dimension) const -> QStringList
{
const bool showUnits = dimension->IsBodyMeasurement() || dimension->Type() == MeasurementDimension::X;
const QString units = showUnits ? UnitsToStr(dimension->Units(), true) : QString();
const DimesionLabels dimensionLabels = dimension->Labels();
QStringList labels;
for(auto base : bases) for(auto base : bases)
{ {
if (dimensionLabels.contains(base) && not dimensionLabels.value(base).isEmpty()) if (dimensionLabels.contains(base) && not dimensionLabels.value(base).isEmpty())
@ -842,6 +855,31 @@ auto DialogRestrictDimension::DimensionLabels(const QVector<qreal> &bases,
labels.append(QStringLiteral("%1 %2").arg(m_fullCircumference ? base*2 : base).arg(units)); labels.append(QStringLiteral("%1 %2").arg(m_fullCircumference ? base*2 : base).arg(units));
} }
} }
return labels;
}
//---------------------------------------------------------------------------------------------------------------------
auto DialogRestrictDimension::DimensionLabels(const QVector<qreal> &bases,
const MeasurementDimension_p &dimension) const -> QStringList
{
const bool showUnits = dimension->IsBodyMeasurement() || dimension->Type() == MeasurementDimension::X;
const QString units = showUnits ? UnitsToStr(dimension->Units(), true) : QString();
const DimesionLabels dimensionLabels = dimension->Labels();
QStringList labels;
if (dimension->Type() == MeasurementDimension::X)
{
labels = FillDimensionXBases(bases, dimension);
}
else if (dimension->Type() == MeasurementDimension::Y)
{
labels = FillDimensionYBases(bases, dimension);
}
else if (dimension->Type() == MeasurementDimension::W || dimension->Type() == MeasurementDimension::Z)
{
labels = FillDimensionWZBases(bases, dimension);
} }
return labels; return labels;

View File

@ -50,18 +50,18 @@ enum class RestrictDimension: qint8
class DialogRestrictDimension : public QDialog class DialogRestrictDimension : public QDialog
{ {
Q_OBJECT Q_OBJECT // NOLINT
public: public:
DialogRestrictDimension(const QList<MeasurementDimension_p> &dimensions, DialogRestrictDimension(const QList<MeasurementDimension_p> &dimensions,
const QMap<QString, VDimensionRestriction> &restrictions, RestrictDimension restrictionType, const QMap<QString, VDimensionRestriction> &restrictions, RestrictDimension restrictionType,
bool fullCircumference, QWidget *parent = nullptr); bool fullCircumference, QWidget *parent = nullptr);
virtual ~DialogRestrictDimension(); ~DialogRestrictDimension() override;
auto Restrictions() const -> QMap<QString, VDimensionRestriction>; auto Restrictions() const -> QMap<QString, VDimensionRestriction>;
protected: protected:
virtual void changeEvent(QEvent* event) override; void changeEvent(QEvent* event) override;
protected slots: protected slots:
void RowSelected(); void RowSelected();
@ -73,7 +73,8 @@ private slots:
void CellContextMenu(QPoint pos); void CellContextMenu(QPoint pos);
private: private:
Q_DISABLE_COPY(DialogRestrictDimension) // cppcheck-suppress unknownMacro
Q_DISABLE_COPY_MOVE(DialogRestrictDimension) // NOLINT
Ui::DialogRestrictDimension *ui; Ui::DialogRestrictDimension *ui;
RestrictDimension m_restrictionType; RestrictDimension m_restrictionType;
@ -92,6 +93,11 @@ private:
void EnableRestrictionControls(bool enable); void EnableRestrictionControls(bool enable);
void FillBases(const QVector<qreal> &bases, const MeasurementDimension_p &dimension, QComboBox *control) const; void FillBases(const QVector<qreal> &bases, const MeasurementDimension_p &dimension, QComboBox *control) const;
static auto FillDimensionXBases(const QVector<qreal> &bases,
const MeasurementDimension_p &dimension) -> QStringList;
auto FillDimensionYBases(const QVector<qreal> &bases, const MeasurementDimension_p &dimension) const -> QStringList;
auto FillDimensionWZBases(const QVector<qreal> &bases,
const MeasurementDimension_p &dimension) const -> QStringList;
auto DimensionLabels(const QVector<qreal> &bases, const MeasurementDimension_p &dimension) const -> QStringList; auto DimensionLabels(const QVector<qreal> &bases, const MeasurementDimension_p &dimension) const -> QStringList;
auto DimensionRestrictedValues(const MeasurementDimension_p &dimension) const -> QVector<qreal>; auto DimensionRestrictedValues(const MeasurementDimension_p &dimension) const -> QVector<qreal>;

View File

@ -32,7 +32,9 @@
#include <QShowEvent> #include <QShowEvent>
#include "../mapplication.h" #include "../mapplication.h"
#if QT_VERSION < QT_VERSION_CHECK(5, 7, 0)
#include "../vmisc/backport/qoverload.h" #include "../vmisc/backport/qoverload.h"
#endif // QT_VERSION < QT_VERSION_CHECK(5, 7, 0)
namespace namespace
{ {

View File

@ -40,7 +40,6 @@
DialogTapePreferences::DialogTapePreferences(QWidget *parent) DialogTapePreferences::DialogTapePreferences(QWidget *parent)
:QDialog(parent), :QDialog(parent),
ui(new Ui::DialogTapePreferences), ui(new Ui::DialogTapePreferences),
m_isInitialized(false),
m_configurationPage(new TapePreferencesConfigurationPage), m_configurationPage(new TapePreferencesConfigurationPage),
m_pathPage(new TapePreferencesPathPage) m_pathPage(new TapePreferencesPathPage)
{ {

View File

@ -31,6 +31,8 @@
#include <QDialog> #include <QDialog>
#include "../vmisc/defglobal.h"
namespace Ui namespace Ui
{ {
class DialogTapePreferences; class DialogTapePreferences;
@ -42,25 +44,26 @@ class QListWidgetItem;
class DialogTapePreferences : public QDialog class DialogTapePreferences : public QDialog
{ {
Q_OBJECT Q_OBJECT // NOLINT
public: public:
explicit DialogTapePreferences(QWidget *parent = nullptr); explicit DialogTapePreferences(QWidget *parent = nullptr);
virtual ~DialogTapePreferences(); ~DialogTapePreferences() override;
signals: signals:
void UpdateProperties(); void UpdateProperties();
protected: protected:
virtual void showEvent(QShowEvent *event) override; void showEvent(QShowEvent *event) override;
virtual void resizeEvent(QResizeEvent *event) override; void resizeEvent(QResizeEvent *event) override;
virtual void changeEvent(QEvent* event) override; void changeEvent(QEvent* event) override;
private slots: private slots:
void Apply(); void Apply();
void Ok(); void Ok();
void PageChanged(QListWidgetItem *current, QListWidgetItem *previous); void PageChanged(QListWidgetItem *current, QListWidgetItem *previous);
private: private:
Q_DISABLE_COPY(DialogTapePreferences) // cppcheck-suppress unknownMacro
Q_DISABLE_COPY_MOVE(DialogTapePreferences) // NOLINT
Ui::DialogTapePreferences *ui; Ui::DialogTapePreferences *ui;
bool m_isInitialized; bool m_isInitialized{false};
TapePreferencesConfigurationPage *m_configurationPage; TapePreferencesConfigurationPage *m_configurationPage;
TapePreferencesPathPage *m_pathPage; TapePreferencesPathPage *m_pathPage;
}; };

View File

@ -26,10 +26,7 @@
** **
*************************************************************************/ *************************************************************************/
#include "tmainwindow.h"
#include "mapplication.h" #include "mapplication.h"
#include "../fervor/fvupdater.h"
#include "../vmisc/vsysexits.h"
#include <QMessageBox> // For QT_REQUIRE_VERSION #include <QMessageBox> // For QT_REQUIRE_VERSION
#include <QTimer> #include <QTimer>
@ -43,7 +40,7 @@
# include "../vmisc/appimage.h" # include "../vmisc/appimage.h"
#endif // defined(APPIMAGE) && defined(Q_OS_LINUX) #endif // defined(APPIMAGE) && defined(Q_OS_LINUX)
int main(int argc, char *argv[]) auto main(int argc, char *argv[]) -> int
{ {
#if defined(APPIMAGE) && defined(Q_OS_LINUX) #if defined(APPIMAGE) && defined(Q_OS_LINUX)
/* Fix path to ICU_DATA when run AppImage.*/ /* Fix path to ICU_DATA when run AppImage.*/
@ -51,14 +48,14 @@ int main(int argc, char *argv[])
auto FreeMemory = qScopeGuard([exe_dir] {free(exe_dir);}); auto FreeMemory = qScopeGuard([exe_dir] {free(exe_dir);});
#endif // defined(APPIMAGE) && defined(Q_OS_LINUX) #endif // defined(APPIMAGE) && defined(Q_OS_LINUX)
Q_INIT_RESOURCE(tapeicon); Q_INIT_RESOURCE(tapeicon); // NOLINT
Q_INIT_RESOURCE(theme); Q_INIT_RESOURCE(theme); // NOLINT
Q_INIT_RESOURCE(icon); Q_INIT_RESOURCE(icon); // NOLINT
Q_INIT_RESOURCE(schema); Q_INIT_RESOURCE(schema); // NOLINT
Q_INIT_RESOURCE(flags); Q_INIT_RESOURCE(flags); // NOLINT
Q_INIT_RESOURCE(style); Q_INIT_RESOURCE(style); // NOLINT
QT_REQUIRE_VERSION(argc, argv, "5.4.0")// clazy:exclude=qstring-arg,qstring-allocations QT_REQUIRE_VERSION(argc, argv, "5.4.0")// clazy:exclude=qstring-arg,qstring-allocations NOLINT
#if defined(Q_OS_WIN) #if defined(Q_OS_WIN)
VAbstractApplication::WinAttachConsole(); VAbstractApplication::WinAttachConsole();
@ -80,5 +77,5 @@ int main(int argc, char *argv[])
} }
#endif // defined(APPIMAGE) && defined(Q_OS_LINUX) #endif // defined(APPIMAGE) && defined(Q_OS_LINUX)
return app.exec(); return MApplication::exec();
} }

View File

@ -35,6 +35,7 @@
#include "../ifc/exception/vexceptionemptyparameter.h" #include "../ifc/exception/vexceptionemptyparameter.h"
#include "../ifc/exception/vexceptionwrongid.h" #include "../ifc/exception/vexceptionwrongid.h"
#include "../vmisc/vsysexits.h" #include "../vmisc/vsysexits.h"
#include "../vmisc/projectversion.h"
#if QT_VERSION < QT_VERSION_CHECK(5, 5, 0) #if QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
#include "../vmisc/diagnostic.h" #include "../vmisc/diagnostic.h"
@ -357,7 +358,7 @@ auto MApplication::notify(QObject *receiver, QEvent *event) -> bool
catch (const VExceptionToolWasDeleted &e) catch (const VExceptionToolWasDeleted &e)
{ {
qCCritical(mApp, "%s\n\n%s\n\n%s", qCCritical(mApp, "%s\n\n%s\n\n%s",
qUtf8Printable("Unhadled deleting tool. Continue use object after deleting!"), qUtf8Printable(QStringLiteral("Unhadled deleting tool. Continue use object after deleting!")),
qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation())); qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation()));
exit(V_EX_DATAERR); exit(V_EX_DATAERR);
} }
@ -473,7 +474,7 @@ void MApplication::ActivateDarkMode()
{ {
f.open(QFile::ReadOnly | QFile::Text); f.open(QFile::ReadOnly | QFile::Text);
QTextStream ts(&f); QTextStream ts(&f);
qApp->setStyleSheet(ts.readAll()); qApp->setStyleSheet(ts.readAll()); // NOLINT(cppcoreguidelines-pro-type-static-cast-downcast)
} }
} }
@ -501,7 +502,7 @@ auto MApplication::event(QEvent *e) -> bool
// Mac specific). // Mac specific).
case QEvent::FileOpen: case QEvent::FileOpen:
{ {
auto *fileOpenEvent = static_cast<QFileOpenEvent *>(e); auto *fileOpenEvent = static_cast<QFileOpenEvent *>(e); // NOLINT(cppcoreguidelines-pro-type-static-cast-downcast)
const QString macFileOpen = fileOpenEvent->file(); const QString macFileOpen = fileOpenEvent->file();
if(not macFileOpen.isEmpty()) if(not macFileOpen.isEmpty())
{ {

File diff suppressed because it is too large Load Diff

View File

@ -48,32 +48,31 @@ class VMeasurement;
class TMainWindow : public VAbstractMainWindow class TMainWindow : public VAbstractMainWindow
{ {
Q_OBJECT Q_OBJECT // NOLINT
public: public:
explicit TMainWindow(QWidget *parent = nullptr); explicit TMainWindow(QWidget *parent = nullptr);
virtual ~TMainWindow() override; ~TMainWindow() override;
QString CurrentFile() const; auto CurrentFile() const -> QString;
void RetranslateTable(); void RetranslateTable();
bool SetDimensionABase(int base); auto SetDimensionABase(int base) -> bool;
bool SetDimensionBBase(int base); auto SetDimensionBBase(int base) -> bool;
bool SetDimensionCBase(int base); auto SetDimensionCBase(int base) -> bool;
void SetPUnit(Unit unit); void SetPUnit(Unit unit);
bool LoadFile(const QString &path); auto LoadFile(const QString &path) -> bool;
void UpdateWindowTitle(); void UpdateWindowTitle();
protected: protected:
virtual void closeEvent(QCloseEvent *event) override; void closeEvent(QCloseEvent *event) override;
virtual void changeEvent(QEvent* event) override; void changeEvent(QEvent* event) override;
virtual bool eventFilter(QObject *object, QEvent *event) override; auto eventFilter(QObject *object, QEvent *event) -> bool override;
virtual void ExportToCSVData(const QString &fileName, bool withHeader, int mib, void ExportToCSVData(const QString &fileName, bool withHeader, int mib, const QChar &separator) final;
const QChar &separator) final; auto RecentFileList() const -> QStringList override;
virtual QStringList RecentFileList() const override;
private slots: private slots:
void FileNew(); void FileNew();
@ -84,8 +83,8 @@ private slots:
void Preferences(); void Preferences();
void ToolBarStyles(); void ToolBarStyles();
bool FileSave(); bool FileSave(); // NOLINT(modernize-use-trailing-return-type)
bool FileSaveAs(); bool FileSaveAs(); // NOLINT(modernize-use-trailing-return-type)
void AboutToShowWindowMenu(); void AboutToShowWindowMenu();
void ShowWindow() const; void ShowWindow() const;
void ImportDataFromCSV(); void ImportDataFromCSV();
@ -150,34 +149,48 @@ private slots:
void SetDefaultGUILanguage(); void SetDefaultGUILanguage();
private: private:
Q_DISABLE_COPY(TMainWindow) // cppcheck-suppress unknownMacro
Q_DISABLE_COPY_MOVE(TMainWindow) // NOLINT
Ui::TMainWindow *ui; Ui::TMainWindow *ui;
VMeasurements *m{nullptr}; VMeasurements *m_m{nullptr};
VContainer *data{nullptr}; VContainer *m_data{nullptr};
Unit mUnit{Unit::Cm}; Unit m_mUnit{Unit::Cm};
Unit pUnit{Unit::Cm}; Unit m_pUnit{Unit::Cm};
MeasurementsType mType{MeasurementsType::Individual}; MeasurementsType m_mType{MeasurementsType::Individual};
qreal currentDimensionA{0}; qreal m_currentDimensionA{0};
qreal currentDimensionB{0}; qreal m_currentDimensionB{0};
qreal currentDimensionC{0}; qreal m_currentDimensionC{0};
QString curFile{}; QString m_curFile{};
QComboBox *gradationDimensionA{nullptr}; QComboBox *m_gradationDimensionA{nullptr};
QComboBox *gradationDimensionB{nullptr}; QComboBox *m_gradationDimensionB{nullptr};
QComboBox *gradationDimensionC{nullptr}; QComboBox *m_gradationDimensionC{nullptr};
QComboBox *comboBoxUnits{nullptr}; QComboBox *m_comboBoxUnits{nullptr};
int formulaBaseHeight; int m_formulaBaseHeight;
QSharedPointer<VLockGuard<char>> lock{nullptr}; QSharedPointer<VLockGuard<char>> m_lock{nullptr};
QSharedPointer<VTableSearch> m_search{}; QSharedPointer<VTableSearch> m_search{};
QLabel *labelGradationDimensionA{nullptr}; QLabel *m_labelGradationDimensionA{nullptr};
QLabel *labelGradationDimensionB{nullptr}; QLabel *m_labelGradationDimensionB{nullptr};
QLabel *labelGradationDimensionC{nullptr}; QLabel *m_labelGradationDimensionC{nullptr};
QLabel *labelPatternUnit{nullptr}; QLabel *m_labelPatternUnit{nullptr};
bool isInitialized{false}; bool m_isInitialized{false};
bool mIsReadOnly{false}; bool m_mIsReadOnly{false};
QTimer *gradation; QTimer *m_gradation;
QMenu *m_searchHistory; QMenu *m_searchHistory;
QVector<QObject *> hackedWidgets{}; QVector<QObject *> m_hackedWidgets{};
struct MultisizeMeasurement
{
MultisizeMeasurement() = default;
QString name{}; // NOLINT(misc-non-private-member-variables-in-classes)
qreal base{0}; // NOLINT(misc-non-private-member-variables-in-classes)
qreal shiftA{0}; // NOLINT(misc-non-private-member-variables-in-classes)
qreal shiftB{0}; // NOLINT(misc-non-private-member-variables-in-classes)
qreal shiftC{0}; // NOLINT(misc-non-private-member-variables-in-classes)
QString fullName{}; // NOLINT(misc-non-private-member-variables-in-classes)
QString description{}; // NOLINT(misc-non-private-member-variables-in-classes)
};
void SetupMenu(); void SetupMenu();
void InitWindow(); void InitWindow();
@ -191,7 +204,7 @@ private:
void InitPatternUnits(); void InitPatternUnits();
void InitComboBoxUnits(); void InitComboBoxUnits();
void InitMeasurementUnits(); void InitMeasurementUnits();
void InitGender(QComboBox *gender); static void InitGender(QComboBox *gender);
void InitMeasurementDimension(); void InitMeasurementDimension();
void InitSearch(); void InitSearch();
@ -203,24 +216,25 @@ private:
void ShowNewMData(bool fresh); void ShowNewMData(bool fresh);
void ShowUnits(); void ShowUnits();
void ShowHeaderUnits(QTableWidget *table, int column, const QString &unit); static void ShowHeaderUnits(QTableWidget *table, int column, const QString &unit);
void MeasurementsWereSaved(bool saved); void MeasurementsWereSaved(bool saved);
void SetCurrentFile(const QString &fileName); void SetCurrentFile(const QString &fileName);
bool SaveMeasurements(const QString &fileName, QString &error); auto SaveMeasurements(const QString &fileName, QString &error) -> bool;
bool MaybeSave(); auto MaybeSave() -> bool;
QTableWidgetItem *AddCell(const QString &text, int row, int column, int aligment, bool ok = true); auto AddCell(const QString &text, int row, int column, int aligment, bool ok = true) -> QTableWidgetItem *;
QTableWidgetItem* AddSeparatorCell(const QString &text, int row, int column, int aligment, bool ok = true); auto AddSeparatorCell(const QString &text, int row, int column, int aligment, bool ok = true) -> QTableWidgetItem*;
void RefreshData(bool freshCall = false); void RefreshData(bool freshCall = false);
void RefreshTable(bool freshCall = false); void RefreshTable(bool freshCall = false);
void RefreshMeasurementData(const QSharedPointer<VMeasurement> &meash, qint32 currentRow);
QString GetCustomName() const; auto GetCustomName() const -> QString;
QString ClearCustomName(const QString &name) const; static auto ClearCustomName(const QString &name) -> QString;
bool EvalFormula(const QString &formula, bool fromUser, VContainer *data, QLabel *label, bool specialUnits); auto EvalFormula(const QString &formula, bool fromUser, VContainer *data, QLabel *label, bool specialUnits) -> bool;
void ShowMDiagram(const QString &name); void ShowMDiagram(const QString &name);
void Open(const QString &pathTo, const QString &filter); void Open(const QString &pathTo, const QString &filter);
@ -232,11 +246,11 @@ private:
void ReadSettings(); void ReadSettings();
void WriteSettings(); void WriteSettings();
QStringList FilterMeasurements(const QStringList &mNew, const QStringList &mFilter); static auto FilterMeasurements(const QStringList &mNew, const QStringList &mFilter) -> QStringList;
void UpdatePatternUnit(); void UpdatePatternUnit();
bool LoadFromExistingFile(const QString &path); auto LoadFromExistingFile(const QString &path) -> bool;
void CreateWindowMenu(QMenu *menu); void CreateWindowMenu(QMenu *menu);
@ -245,12 +259,14 @@ private:
void HackDimensionBaseValue(); void HackDimensionBaseValue();
void HackDimensionShifts(); void HackDimensionShifts();
QString CheckMName(const QString &name, const QSet<QString> &importedNames) const; auto CheckMName(const QString &name, const QSet<QString> &importedNames) const -> QString;
void ShowError(const QString &text); void ShowError(const QString &text);
void RefreshDataAfterImport(); void RefreshDataAfterImport();
void ImportIndividualMeasurements(const QxtCsvModel &csv, const QVector<int> &map); void ImportIndividualMeasurements(const QxtCsvModel &csv, const QVector<int> &map);
void ImportMultisizeMeasurements(const QxtCsvModel &csv, const QVector<int> &map); void ImportMultisizeMeasurements(const QxtCsvModel &csv, const QVector<int> &map);
auto ImportMultisizeMeasurement(const QxtCsvModel &csv, int i, const QVector<int> &map,
int dimensionsCount, QSet<QString> &importedNames) -> MultisizeMeasurement;
void SetCurrentPatternUnit(); void SetCurrentPatternUnit();
@ -258,9 +274,9 @@ private:
void SetDimensionBases(); void SetDimensionBases();
void SetCurrentDimensionValues(); void SetCurrentDimensionValues();
QVector<double> DimensionRestrictedValues(int index, const MeasurementDimension_p &dimension); auto DimensionRestrictedValues(int index, const MeasurementDimension_p &dimension) -> QVector<double>;
QMap<int, QSharedPointer<VMeasurement> > OrderedMeasurments() const; auto OrderedMeasurments() const -> QMap<int, QSharedPointer<VMeasurement> >;
}; };
#endif // TMAINWINDOW_H #endif // TMAINWINDOW_H

View File

@ -29,11 +29,9 @@
#ifndef VERSION_H #ifndef VERSION_H
#define VERSION_H #define VERSION_H
#include "../../libs/vmisc/projectversion.h" #define VER_INTERNALNAME_STR "Tape" // NOLINT(cppcoreguidelines-macro-usage)
#define VER_ORIGINALFILENAME_STR "tape.exe" // NOLINT(cppcoreguidelines-macro-usage)
#define VER_INTERNALNAME_STR "Tape" #define VER_PRODUCTNAME_STR "Tape" // NOLINT(cppcoreguidelines-macro-usage)
#define VER_ORIGINALFILENAME_STR "tape.exe" #define VER_FILEDESCRIPTION_STR "Valentina's measurements editor." // NOLINT(cppcoreguidelines-macro-usage)
#define VER_PRODUCTNAME_STR "Tape"
#define VER_FILEDESCRIPTION_STR "Valentina's measurements editor."
#endif // VERSION_H #endif // VERSION_H

View File

@ -52,17 +52,17 @@ void VLitePattern::DecrementReferens(quint32 id) const
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QString VLitePattern::GenerateLabel(const LabelType &type, const QString &reservedName) const auto VLitePattern::GenerateLabel(const LabelType &type, const QString &reservedName) const -> QString
{ {
Q_UNUSED(type) Q_UNUSED(type)
Q_UNUSED(reservedName) Q_UNUSED(reservedName)
return QString(); return {};
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QString VLitePattern::GenerateSuffix() const auto VLitePattern::GenerateSuffix() const -> QString
{ {
return QString(); return {};
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View File

@ -33,25 +33,26 @@
class VLitePattern : public VAbstractPattern class VLitePattern : public VAbstractPattern
{ {
Q_OBJECT Q_OBJECT // NOLINT
public: public:
explicit VLitePattern(QObject *parent = nullptr); explicit VLitePattern(QObject *parent = nullptr);
~VLitePattern() override = default;
virtual void CreateEmptyFile() override; void CreateEmptyFile() override;
virtual void IncrementReferens(quint32 id) const override; void IncrementReferens(quint32 id) const override;
virtual void DecrementReferens(quint32 id) const override; void DecrementReferens(quint32 id) const override;
virtual QString GenerateLabel(const LabelType &type, const QString &reservedName = QString())const override; auto GenerateLabel(const LabelType &type, const QString &reservedName = QString())const -> QString override;
virtual QString GenerateSuffix() const override; auto GenerateSuffix() const -> QString override;
virtual void UpdateToolData(const quint32 &id, VContainer *data) override; void UpdateToolData(const quint32 &id, VContainer *data) override;
public slots: public slots:
virtual void LiteParseTree(const Document &parse) override; void LiteParseTree(const Document &parse) override;
private: private:
Q_DISABLE_COPY(VLitePattern) Q_DISABLE_COPY_MOVE(VLitePattern) // NOLINT
}; };
#endif // VLITEPATTERN_H #endif // VLITEPATTERN_H

View File

@ -36,15 +36,15 @@
namespace namespace
{ {
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingDataBaseGeometry, (QLatin1String("database/geometry"))) Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingDataBaseGeometry, (QLatin1String("database/geometry"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchHistoryTape, (QLatin1String("searchHistory/tape"))) Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchHistoryTape, (QLatin1String("searchHistory/tape"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsTapeUseUnicodeProperties, Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsTapeUseUnicodeProperties, // NOLINT
(QLatin1String("searchOptions/tapeUseUnicodeProperties"))) (QLatin1String("searchOptions/tapeUseUnicodeProperties")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsTapeWholeWord, Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsTapeWholeWord, // NOLINT
(QLatin1String("searchOptions/tapeWholeWord"))) (QLatin1String("searchOptions/tapeWholeWord")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsTapeRegexp, (QLatin1String("searchOptions/tapeRegexp"))) Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsTapeRegexp, (QLatin1String("searchOptions/tapeRegexp"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsTapeMatchCase, Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsTapeMatchCase, // NOLINT
(QLatin1String("searchOptions/tapeMatchCase"))) (QLatin1String("searchOptions/tapeMatchCase")))
} // namespace } // namespace
@ -56,7 +56,7 @@ VTapeSettings::VTapeSettings(Format format, Scope scope, const QString &organiza
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QByteArray VTapeSettings::GetDataBaseGeometry() const auto VTapeSettings::GetDataBaseGeometry() const -> QByteArray
{ {
return value(*settingDataBaseGeometry).toByteArray(); return value(*settingDataBaseGeometry).toByteArray();
} }

View File

@ -41,12 +41,13 @@
class VTapeSettings : public VCommonSettings class VTapeSettings : public VCommonSettings
{ {
Q_OBJECT Q_OBJECT // NOLINT
public: public:
VTapeSettings(Format format, Scope scope, const QString &organization, const QString &application = QString(), VTapeSettings(Format format, Scope scope, const QString &organization, const QString &application = QString(),
QObject *parent = nullptr); QObject *parent = nullptr);
~VTapeSettings() override = default;
QByteArray GetDataBaseGeometry() const; auto GetDataBaseGeometry() const -> QByteArray;
void SetDataBaseGeometry(const QByteArray &value); void SetDataBaseGeometry(const QByteArray &value);
auto GetTapeSearchHistory() const -> QStringList; auto GetTapeSearchHistory() const -> QStringList;
@ -65,7 +66,7 @@ public:
void SetTapeSearchOptionMatchCase(bool value); void SetTapeSearchOptionMatchCase(bool value);
private: private:
Q_DISABLE_COPY(VTapeSettings) Q_DISABLE_COPY_MOVE(VTapeSettings) // NOLINT
}; };
#endif // VTAPESETTINGS_H #endif // VTAPESETTINGS_H

View File

@ -37,6 +37,7 @@
#include "../qmuparser/qmuparsererror.h" #include "../qmuparser/qmuparsererror.h"
#include "../mainwindow.h" #include "../mainwindow.h"
#include "../vmisc/qt_dispatch/qt_dispatch.h" #include "../vmisc/qt_dispatch/qt_dispatch.h"
#include "../vmisc/vsysexits.h"
#include "vvalentinasettings.h" #include "vvalentinasettings.h"
#include <QtDebug> #include <QtDebug>
@ -66,7 +67,7 @@ namespace
{ {
auto AppFilePath(const QString &appName) -> QString auto AppFilePath(const QString &appName) -> QString
{ {
QString appNameExe = appName; QString appNameExe = appName; // NOLINT(performance-unnecessary-copy-initialization)
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
appNameExe += ".exe"; appNameExe += ".exe";
#endif #endif
@ -417,7 +418,7 @@ auto VApplication::notify(QObject *receiver, QEvent *event) -> bool
catch (const VExceptionToolWasDeleted &e) catch (const VExceptionToolWasDeleted &e)
{ {
qCCritical(vApp, "%s\n\n%s\n\n%s", qCCritical(vApp, "%s\n\n%s\n\n%s",
qUtf8Printable("Unhadled deleting tool. Continue use object after deleting"), qUtf8Printable(QStringLiteral("Unhadled deleting tool. Continue use object after deleting")),
qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation())); qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation()));
exit(V_EX_DATAERR); exit(V_EX_DATAERR);
} }
@ -469,7 +470,7 @@ void VApplication::ActivateDarkMode()
{ {
f.open(QFile::ReadOnly | QFile::Text); f.open(QFile::ReadOnly | QFile::Text);
QTextStream ts(&f); QTextStream ts(&f);
qApp->setStyleSheet(ts.readAll()); qApp->setStyleSheet(ts.readAll()); // NOLINT(cppcoreguidelines-pro-type-static-cast-downcast)
} }
} }
} }
@ -550,9 +551,16 @@ void VApplication::ClearOldLogs()
logsDir.setNameFilters(QStringList(QStringLiteral("*.log"))); logsDir.setNameFilters(QStringList(QStringLiteral("*.log")));
QDir::setCurrent(LogDirPath()); QDir::setCurrent(LogDirPath());
// Restore working directory
auto restore = qScopeGuard([workingDirectory] { QDir::setCurrent(workingDirectory); });
const QStringList allFiles = logsDir.entryList(QDir::NoDotAndDotDot | QDir::Files); const QStringList allFiles = logsDir.entryList(QDir::NoDotAndDotDot | QDir::Files);
if (not allFiles.isEmpty()) if (allFiles.isEmpty())
{ {
qCDebug(vApp, "There are no old logs.");
return;
}
qCDebug(vApp, "Clearing old logs"); qCDebug(vApp, "Clearing old logs");
for (const auto &fn : allFiles) for (const auto &fn : allFiles)
{ {
@ -582,13 +590,6 @@ void VApplication::ClearOldLogs()
} }
} }
} }
}
else
{
qCDebug(vApp, "There are no old logs.");
}
QDir::setCurrent(workingDirectory); // Restore working directory
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View File

@ -43,7 +43,6 @@ class VApplication : public VAbstractValApplication
{ {
Q_OBJECT // NOLINT Q_OBJECT // NOLINT
public: public:
VApplication(int &argc, char ** argv); VApplication(int &argc, char ** argv);
~VApplication() override; ~VApplication() override;

View File

@ -30,36 +30,35 @@
#include "../dialogs/dialoglayoutsettings.h" #include "../dialogs/dialoglayoutsettings.h"
#include "../dialogs/dialogsavelayout.h" #include "../dialogs/dialogsavelayout.h"
#include "../ifc/xml/vdomdocument.h" #include "../ifc/xml/vdomdocument.h"
#include "../vformat/vmeasurements.h"
#include "../vmisc/commandoptions.h" #include "../vmisc/commandoptions.h"
#include "../vmisc/vsysexits.h"
#include "vvalentinasettings.h" #include "vvalentinasettings.h"
#include "../vmisc/dialogs/dialogexporttocsv.h" #include "../vmisc/dialogs/dialogexporttocsv.h"
#include "../vlayout/vlayoutgenerator.h" #include "../vlayout/vlayoutgenerator.h"
#include "../vpatterndb/variables/vmeasurement.h"
#include <QDebug> #include <QDebug>
#include <QTextCodec> #include <QTextCodec>
VCommandLinePtr VCommandLine::instance = nullptr; VCommandLinePtr VCommandLine::instance = nullptr; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)
#define translate(context, source) QCoreApplication::translate((context), (source)) #define translate(context, source) QCoreApplication::translate((context), (source)) // NOLINT(cppcoreguidelines-macro-usage)
namespace namespace
{ {
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
qreal Lo2Px(const QString &src, const DialogLayoutSettings &converter, bool *ok) auto Lo2Px(const QString &src, const DialogLayoutSettings &converter, bool *ok) -> qreal
{ {
return converter.LayoutToPixels(src.toDouble(ok)); return converter.LayoutToPixels(src.toDouble(ok));
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
qreal Pg2Px(const QString& src, const DialogLayoutSettings& converter, bool *ok) auto Pg2Px(const QString& src, const DialogLayoutSettings& converter, bool *ok) -> qreal
{ {
return converter.PageToPixels(src.toDouble(ok)); return converter.PageToPixels(src.toDouble(ok));
} }
} // anonymous namespace } // anonymous namespace
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VCommandLine::VCommandLine() : parser(), isGuiEnabled(false) VCommandLine::VCommandLine()
{ {
parser.setApplicationDescription(translate("VCommandLine", "Pattern making program.")); parser.setApplicationDescription(translate("VCommandLine", "Pattern making program."));
parser.addHelpOption(); parser.addHelpOption();
@ -70,7 +69,7 @@ VCommandLine::VCommandLine() : parser(), isGuiEnabled(false)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VAbstractLayoutDialog::PaperSizeTemplate VCommandLine::FormatSize(const QString &key) const auto VCommandLine::FormatSize(const QString &key) const -> VAbstractLayoutDialog::PaperSizeTemplate
{ {
int ppsize = 0; int ppsize = 0;
if (IsOptionSet(key)) if (IsOptionSet(key))
@ -81,83 +80,16 @@ VAbstractLayoutDialog::PaperSizeTemplate VCommandLine::FormatSize(const QString
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VLayoutGeneratorPtr VCommandLine::DefaultGenerator() const auto VCommandLine::DefaultGenerator() const -> VLayoutGeneratorPtr
{ {
//this functions covers all options found into layout setup dialog, nothing to add here, unless dialog extended //this functions covers all options found into layout setup dialog, nothing to add here, unless dialog extended
VLayoutGeneratorPtr res(new VLayoutGenerator()); VLayoutGeneratorPtr res(new VLayoutGenerator());
DialogLayoutSettings diag(res.get(), nullptr, true); DialogLayoutSettings diag(res.get(), nullptr, true);
{ TestPageformat();
//just anonymous namespace ...don' like to have a,b,c,d everywhere defined TestGapWidth();
bool x = IsOptionSet(LONG_OPTION_PAGETEMPLATE); TestMargins();
bool a = IsOptionSet(LONG_OPTION_PAGEH);
bool b = IsOptionSet(LONG_OPTION_PAGEW);
bool c = IsOptionSet(LONG_OPTION_PAGEUNITS);
if ((a || b) && x)
{
qCritical() << translate("VCommandLine", "Cannot use pageformat and page explicit size together.")
<< "\n";
const_cast<VCommandLine*>(this)->parser.showHelp(V_EX_USAGE);
}
if ((a || b || c) && !(a && b && c))
{
qCritical() << translate("VCommandLine", "Page height, width, units must be used all 3 at once.") << "\n";
const_cast<VCommandLine*>(this)->parser.showHelp(V_EX_USAGE);
}
}
{
//just anonymous namespace ...don' like to have a,b,c,d everywhere defined
bool a = IsOptionSet(LONG_OPTION_GAPWIDTH);
bool b = IsOptionSet(LONG_OPTION_SHIFTUNITS);
if ((a || b) && !(a && b))
{
qCritical() << translate("VCommandLine", "Gap width must be used together with shift units.") << "\n";
const_cast<VCommandLine*>(this)->parser.showHelp(V_EX_USAGE);
}
}
auto CheckKey = [this](const QString &key, const QString &message)
{
bool a = IsOptionSet(key);
bool b = IsOptionSet(LONG_OPTION_PAGEUNITS);
if (a && !(a && b))
{
qCritical() << message << "\n";
const_cast<VCommandLine*>(this)->parser.showHelp(V_EX_USAGE);
}
};
if (not IsOptionSet(LONG_OPTION_IGNORE_MARGINS))
{
CheckKey(LONG_OPTION_LEFT_MARGIN,
translate("VCommandLine", "Left margin must be used together with page units."));
CheckKey(LONG_OPTION_RIGHT_MARGIN,
translate("VCommandLine", "Right margin must be used together with page units."));
CheckKey(LONG_OPTION_TOP_MARGIN,
translate("VCommandLine", "Top margin must be used together with page units."));
CheckKey(LONG_OPTION_BOTTOM_MARGIN,
translate("VCommandLine", "Bottom margin must be used together with page units."));
}
if (static_cast<LayoutExportFormats>(OptExportType()) == LayoutExportFormats::PDFTiled)
{
CheckKey(LONG_OPTION_TILED_PDF_LEFT_MARGIN,
translate("VCommandLine", "Tiled left margin must be used together with page units."));
CheckKey(LONG_OPTION_TILED_PDF_RIGHT_MARGIN,
translate("VCommandLine", "Tiled right margin must be used together with page units."));
CheckKey(LONG_OPTION_TILED_PDF_TOP_MARGIN,
translate("VCommandLine", "Tiled top margin must be used together with page units."));
CheckKey(LONG_OPTION_TILED_PDF_BOTTOM_MARGIN,
translate("VCommandLine", "Tiled bottom margin must be used together with page units."));
}
// if present units MUST be set before any other to keep conversions correct // if present units MUST be set before any other to keep conversions correct
if (!diag.SelectTemplate(OptPaperSize())) if (!diag.SelectTemplate(OptPaperSize()))
@ -234,57 +166,7 @@ VLayoutGeneratorPtr VCommandLine::DefaultGenerator() const
diag.SetIgnoreAllFields(true); diag.SetIgnoreAllFields(true);
} }
QMarginsF margins = diag.GetFields(); diag.SetFields(ParseMargins(diag));
if (IsOptionSet(LONG_OPTION_LEFT_MARGIN))
{
bool ok = false;
qreal margin = Pg2Px(OptionValue(LONG_OPTION_LEFT_MARGIN), diag, &ok);
if (not ok)
{
qCritical() << translate("VCommandLine", "Invalid layout page left margin.") << "\n";
const_cast<VCommandLine*>(this)->parser.showHelp(V_EX_USAGE);
}
margins.setLeft(margin);
}
if (IsOptionSet(LONG_OPTION_RIGHT_MARGIN))
{
bool ok = false;
qreal margin = Pg2Px(OptionValue(LONG_OPTION_RIGHT_MARGIN), diag, &ok);
if (not ok)
{
qCritical() << translate("VCommandLine", "Invalid layout page right margin.") << "\n";
const_cast<VCommandLine*>(this)->parser.showHelp(V_EX_USAGE);
}
margins.setRight(margin);
}
if (IsOptionSet(LONG_OPTION_TOP_MARGIN))
{
bool ok = false;
qreal margin = Pg2Px(OptionValue(LONG_OPTION_TOP_MARGIN), diag, &ok);
if (not ok)
{
qCritical() << translate("VCommandLine", "Invalid layout page top margin.") << "\n";
const_cast<VCommandLine*>(this)->parser.showHelp(V_EX_USAGE);
}
margins.setTop(margin);
}
if (IsOptionSet(LONG_OPTION_BOTTOM_MARGIN))
{
bool ok = false;
qreal margin = Pg2Px(OptionValue(LONG_OPTION_BOTTOM_MARGIN), diag, &ok);
if (not ok)
{
qCritical() << translate("VCommandLine", "Invalid layout page bottom margin.") << "\n";
const_cast<VCommandLine*>(this)->parser.showHelp(V_EX_USAGE);
}
margins.setBottom(margin);
}
diag.SetFields(margins);
diag.SetFollowGrainline(IsOptionSet(LONG_OPTION_FOLLOW_GRAINLINE)); diag.SetFollowGrainline(IsOptionSet(LONG_OPTION_FOLLOW_GRAINLINE));
diag.SetManualPriority(IsOptionSet(LONG_OPTION_MANUAL_PRIORITY)); diag.SetManualPriority(IsOptionSet(LONG_OPTION_MANUAL_PRIORITY));
diag.SetNestQuantity(IsOptionSet(LONG_OPTION_NEST_QUANTITY)); diag.SetNestQuantity(IsOptionSet(LONG_OPTION_NEST_QUANTITY));
@ -296,8 +178,8 @@ VLayoutGeneratorPtr VCommandLine::DefaultGenerator() const
return res; return res;
} }
//------------------------------------------------------------------------------------------------------ //---------------------------------------------------------------------------------------------------------------------
VCommandLinePtr VCommandLine::Get(const QCoreApplication& app) auto VCommandLine::Get(const QCoreApplication& app) -> VCommandLinePtr
{ {
if (instance == nullptr) if (instance == nullptr)
{ {
@ -313,14 +195,14 @@ VCommandLinePtr VCommandLine::Get(const QCoreApplication& app)
return instance; return instance;
} }
//------------------------------------------------------------------------------------------------------ //---------------------------------------------------------------------------------------------------------------------
void VCommandLine::Reset() void VCommandLine::Reset()
{ {
instance.reset(); instance.reset();
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool VCommandLine::IsTestModeEnabled() const auto VCommandLine::IsTestModeEnabled() const -> bool
{ {
const bool r = IsOptionSet(LONG_OPTION_TEST); const bool r = IsOptionSet(LONG_OPTION_TEST);
if (r && parser.positionalArguments().size() != 1) if (r && parser.positionalArguments().size() != 1)
@ -332,20 +214,20 @@ bool VCommandLine::IsTestModeEnabled() const
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool VCommandLine::IsPedantic() const auto VCommandLine::IsPedantic() const -> bool
{ {
// Pedantic doesn't work in GUI mode // Pedantic doesn't work in GUI mode
return IsGuiEnabled() ? false : IsOptionSet(LONG_OPTION_PENDANTIC); return IsGuiEnabled() ? false : IsOptionSet(LONG_OPTION_PENDANTIC);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool VCommandLine::IsNoScalingEnabled() const auto VCommandLine::IsNoScalingEnabled() const -> bool
{ {
return IsOptionSet(LONG_OPTION_NO_HDPI_SCALING); return IsOptionSet(LONG_OPTION_NO_HDPI_SCALING);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool VCommandLine::IsExportEnabled() const auto VCommandLine::IsExportEnabled() const -> bool
{ {
const bool r = IsOptionSet(LONG_OPTION_BASENAME); const bool r = IsOptionSet(LONG_OPTION_BASENAME);
if (r && parser.positionalArguments().size() != 1) if (r && parser.positionalArguments().size() != 1)
@ -357,7 +239,7 @@ bool VCommandLine::IsExportEnabled() const
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool VCommandLine::IsExportFMEnabled() const auto VCommandLine::IsExportFMEnabled() const -> bool
{ {
const bool r = IsOptionSet(LONG_OPTION_CSVEXPORTFM); const bool r = IsOptionSet(LONG_OPTION_CSVEXPORTFM);
if (r && parser.positionalArguments().size() != 1) if (r && parser.positionalArguments().size() != 1)
@ -368,14 +250,14 @@ bool VCommandLine::IsExportFMEnabled() const
return r; return r;
} }
//------------------------------------------------------------------------------------------------------ //---------------------------------------------------------------------------------------------------------------------
VAbstractLayoutDialog::PaperSizeTemplate VCommandLine::OptPaperSize() const auto VCommandLine::OptPaperSize() const -> VAbstractLayoutDialog::PaperSizeTemplate
{ {
return FormatSize(LONG_OPTION_PAGETEMPLATE); return FormatSize(LONG_OPTION_PAGETEMPLATE);
} }
//------------------------------------------------------------------------------------------------------ //---------------------------------------------------------------------------------------------------------------------
Cases VCommandLine::OptGroup() const auto VCommandLine::OptGroup() const -> Cases
{ {
int r = OptionValue(LONG_OPTION_GROUPPING).toInt(); int r = OptionValue(LONG_OPTION_GROUPPING).toInt();
if ( r < 0 || r >= static_cast<int>(Cases::UnknownCase)) if ( r < 0 || r >= static_cast<int>(Cases::UnknownCase))
@ -385,8 +267,8 @@ Cases VCommandLine::OptGroup() const
return static_cast<Cases>(r); return static_cast<Cases>(r);
} }
//------------------------------------------------------------------------------------------------------ //---------------------------------------------------------------------------------------------------------------------
QString VCommandLine::OptMeasurePath() const auto VCommandLine::OptMeasurePath() const -> QString
{ {
QString measure; QString measure;
if (IsOptionSet(LONG_OPTION_MEASUREFILE) if (IsOptionSet(LONG_OPTION_MEASUREFILE)
@ -401,7 +283,7 @@ QString VCommandLine::OptMeasurePath() const
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QString VCommandLine::OptBaseName() const auto VCommandLine::OptBaseName() const -> QString
{ {
QString path; QString path;
if (IsExportEnabled()) if (IsExportEnabled())
@ -413,7 +295,7 @@ QString VCommandLine::OptBaseName() const
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QString VCommandLine::OptDestinationPath() const auto VCommandLine::OptDestinationPath() const -> QString
{ {
QString path; QString path;
if (IsExportEnabled()) if (IsExportEnabled())
@ -425,7 +307,7 @@ QString VCommandLine::OptDestinationPath() const
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
int VCommandLine::OptExportType() const auto VCommandLine::OptExportType() const -> int
{ {
int r = 0; int r = 0;
if (IsOptionSet(LONG_OPTION_EXP2FORMAT)) if (IsOptionSet(LONG_OPTION_EXP2FORMAT))
@ -436,31 +318,31 @@ int VCommandLine::OptExportType() const
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool VCommandLine::IsBinaryDXF() const auto VCommandLine::IsBinaryDXF() const -> bool
{ {
return IsOptionSet(LONG_OPTION_BINARYDXF); return IsOptionSet(LONG_OPTION_BINARYDXF);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool VCommandLine::IsTextAsPaths() const auto VCommandLine::IsTextAsPaths() const -> bool
{ {
return IsOptionSet(LONG_OPTION_TEXT2PATHS); return IsOptionSet(LONG_OPTION_TEXT2PATHS);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool VCommandLine::IsExportOnlyDetails() const auto VCommandLine::IsExportOnlyDetails() const -> bool
{ {
return IsOptionSet(LONG_OPTION_EXPORTONLYDETAILS); return IsOptionSet(LONG_OPTION_EXPORTONLYDETAILS);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool VCommandLine::IsCSVWithHeader() const auto VCommandLine::IsCSVWithHeader() const -> bool
{ {
return IsOptionSet(LONG_OPTION_CSVWITHHEADER); return IsOptionSet(LONG_OPTION_CSVWITHHEADER);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
qreal VCommandLine::ExportXScale() const auto VCommandLine::ExportXScale() const -> qreal
{ {
qreal xs = 1; qreal xs = 1;
if (IsOptionSet(LONG_OPTION_EXPXSCALE)) if (IsOptionSet(LONG_OPTION_EXPXSCALE))
@ -471,7 +353,7 @@ qreal VCommandLine::ExportXScale() const
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
qreal VCommandLine::ExportYScale() const auto VCommandLine::ExportYScale() const -> qreal
{ {
qreal ys = 1; qreal ys = 1;
if (IsOptionSet(LONG_OPTION_EXPYSCALE)) if (IsOptionSet(LONG_OPTION_EXPYSCALE))
@ -482,7 +364,7 @@ qreal VCommandLine::ExportYScale() const
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QString VCommandLine::OptExportSuchDetails() const auto VCommandLine::OptExportSuchDetails() const -> QString
{ {
QString path; QString path;
if (IsExportEnabled()) if (IsExportEnabled())
@ -494,30 +376,30 @@ QString VCommandLine::OptExportSuchDetails() const
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QString VCommandLine::OptCSVCodecName() const auto VCommandLine::OptCSVCodecName() const -> QString
{ {
return OptionValue(LONG_OPTION_CSVCODEC); return OptionValue(LONG_OPTION_CSVCODEC);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QChar VCommandLine::OptCSVSeparator() const auto VCommandLine::OptCSVSeparator() const -> QChar
{ {
const QString value = OptionValue(LONG_OPTION_CSVSEPARATOR); const QString value = OptionValue(LONG_OPTION_CSVSEPARATOR);
return not value.isEmpty() ? value.at(0) : QChar(); return not value.isEmpty() ? value.at(0) : QChar();
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QString VCommandLine::OptExportFMTo() const auto VCommandLine::OptExportFMTo() const -> QString
{ {
return OptionValue(LONG_OPTION_CSVEXPORTFM); return OptionValue(LONG_OPTION_CSVEXPORTFM);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QMap<int, QString> VCommandLine::OptUserMaterials() const auto VCommandLine::OptUserMaterials() const -> QMap<int, QString>
{ {
QMap<int, QString> userMaterials; QMap<int, QString> userMaterials;
const QStringList values = OptionValues(LONG_OPTION_USER_MATERIAL); const QStringList values = OptionValues(LONG_OPTION_USER_MATERIAL);
for(auto &value : values) for(const auto &value : values)
{ {
const QStringList parts = value.split('@'); const QStringList parts = value.split('@');
if (parts.size() != 2) if (parts.size() != 2)
@ -544,37 +426,37 @@ QMap<int, QString> VCommandLine::OptUserMaterials() const
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QStringList VCommandLine::OptInputFileNames() const auto VCommandLine::OptInputFileNames() const -> QStringList
{ {
return parser.positionalArguments(); return parser.positionalArguments();
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool VCommandLine::IsGuiEnabled() const auto VCommandLine::IsGuiEnabled() const -> bool
{ {
return isGuiEnabled; return isGuiEnabled;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool VCommandLine::IsSetDimensionA() const auto VCommandLine::IsSetDimensionA() const -> bool
{ {
return IsOptionSet(LONG_OPTION_DIMENSION_A); return IsOptionSet(LONG_OPTION_DIMENSION_A);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool VCommandLine::IsSetDimensionB() const auto VCommandLine::IsSetDimensionB() const -> bool
{ {
return IsOptionSet(LONG_OPTION_DIMENSION_B); return IsOptionSet(LONG_OPTION_DIMENSION_B);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool VCommandLine::IsSetDimensionC() const auto VCommandLine::IsSetDimensionC() const -> bool
{ {
return IsOptionSet(LONG_OPTION_DIMENSION_C); return IsOptionSet(LONG_OPTION_DIMENSION_C);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
int VCommandLine::OptDimensionA() const auto VCommandLine::OptDimensionA() const -> int
{ {
const QString value = OptionValue(LONG_OPTION_DIMENSION_A); const QString value = OptionValue(LONG_OPTION_DIMENSION_A);
@ -590,7 +472,7 @@ int VCommandLine::OptDimensionA() const
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
int VCommandLine::OptDimensionB() const auto VCommandLine::OptDimensionB() const -> int
{ {
const QString value = OptionValue(LONG_OPTION_DIMENSION_B); const QString value = OptionValue(LONG_OPTION_DIMENSION_B);
@ -606,7 +488,7 @@ int VCommandLine::OptDimensionB() const
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
int VCommandLine::OptDimensionC() const auto VCommandLine::OptDimensionC() const -> int
{ {
const QString value = OptionValue(LONG_OPTION_DIMENSION_C); const QString value = OptionValue(LONG_OPTION_DIMENSION_C);
@ -692,13 +574,13 @@ auto VCommandLine::TiledPageMargins() const -> QMarginsF
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VAbstractLayoutDialog::PaperSizeTemplate VCommandLine::OptTiledPaperSize() const auto VCommandLine::OptTiledPaperSize() const -> VAbstractLayoutDialog::PaperSizeTemplate
{ {
return FormatSize(LONG_OPTION_TILED_PDF_PAGE_TEMPLATE); return FormatSize(LONG_OPTION_TILED_PDF_PAGE_TEMPLATE);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
PageOrientation VCommandLine::OptTiledPageOrientation() const auto VCommandLine::OptTiledPageOrientation() const -> PageOrientation
{ {
return static_cast<PageOrientation>(not IsOptionSet(LONG_OPTION_TILED_PDF_LANDSCAPE)); return static_cast<PageOrientation>(not IsOptionSet(LONG_OPTION_TILED_PDF_LANDSCAPE));
} }
@ -892,25 +774,25 @@ void VCommandLine::InitCommandLineOptions()
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool VCommandLine::IsOptionSet(const QString &option) const auto VCommandLine::IsOptionSet(const QString &option) const -> bool
{ {
return parser.isSet(option); return parser.isSet(option);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QString VCommandLine::OptionValue(const QString &option) const auto VCommandLine::OptionValue(const QString &option) const -> QString
{ {
return parser.value(option); return parser.value(option);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QStringList VCommandLine::OptionValues(const QString &option) const auto VCommandLine::OptionValues(const QString &option) const -> QStringList
{ {
return parser.values(option); return parser.values(option);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
int VCommandLine::OptNestingTime() const auto VCommandLine::OptNestingTime() const -> int
{ {
int time = VValentinaSettings::GetDefNestingTime(); int time = VValentinaSettings::GetDefNestingTime();
if (IsOptionSet(LONG_OPTION_NESTING_TIME)) if (IsOptionSet(LONG_OPTION_NESTING_TIME))
@ -930,7 +812,7 @@ int VCommandLine::OptNestingTime() const
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
qreal VCommandLine::OptEfficiencyCoefficient() const auto VCommandLine::OptEfficiencyCoefficient() const -> qreal
{ {
qreal coefficient = VValentinaSettings::GetDefEfficiencyCoefficient(); qreal coefficient = VValentinaSettings::GetDefEfficiencyCoefficient();
if (IsOptionSet(LONG_OPTION_EFFICIENCY_COEFFICIENT)) if (IsOptionSet(LONG_OPTION_EFFICIENCY_COEFFICIENT))
@ -949,4 +831,136 @@ qreal VCommandLine::OptEfficiencyCoefficient() const
return coefficient; return coefficient;
} }
//---------------------------------------------------------------------------------------------------------------------
void VCommandLine::TestPageformat() const
{
bool x = IsOptionSet(LONG_OPTION_PAGETEMPLATE);
bool a = IsOptionSet(LONG_OPTION_PAGEH);
bool b = IsOptionSet(LONG_OPTION_PAGEW);
bool c = IsOptionSet(LONG_OPTION_PAGEUNITS);
if ((a || b) && x)
{
qCritical() << translate("VCommandLine", "Cannot use pageformat and page explicit size together.")
<< "\n";
const_cast<VCommandLine*>(this)->parser.showHelp(V_EX_USAGE);
}
if ((a || b || c) && !(a && b && c))
{
qCritical() << translate("VCommandLine", "Page height, width, units must be used all 3 at once.") << "\n";
const_cast<VCommandLine*>(this)->parser.showHelp(V_EX_USAGE);
}
}
//---------------------------------------------------------------------------------------------------------------------
void VCommandLine::TestGapWidth() const
{
bool a = IsOptionSet(LONG_OPTION_GAPWIDTH);
bool b = IsOptionSet(LONG_OPTION_SHIFTUNITS);
if ((a || b) && !(a && b))
{
qCritical() << translate("VCommandLine", "Gap width must be used together with shift units.") << "\n";
const_cast<VCommandLine*>(this)->parser.showHelp(V_EX_USAGE);
}
}
//---------------------------------------------------------------------------------------------------------------------
void VCommandLine::TestMargins() const
{
auto CheckKey = [this](const QString &key, const QString &message)
{
bool a = IsOptionSet(key);
bool b = IsOptionSet(LONG_OPTION_PAGEUNITS);
if (a && !(a && b))
{
qCritical() << message << "\n";
const_cast<VCommandLine*>(this)->parser.showHelp(V_EX_USAGE);
}
};
if (not IsOptionSet(LONG_OPTION_IGNORE_MARGINS))
{
CheckKey(LONG_OPTION_LEFT_MARGIN,
translate("VCommandLine", "Left margin must be used together with page units."));
CheckKey(LONG_OPTION_RIGHT_MARGIN,
translate("VCommandLine", "Right margin must be used together with page units."));
CheckKey(LONG_OPTION_TOP_MARGIN,
translate("VCommandLine", "Top margin must be used together with page units."));
CheckKey(LONG_OPTION_BOTTOM_MARGIN,
translate("VCommandLine", "Bottom margin must be used together with page units."));
}
if (static_cast<LayoutExportFormats>(OptExportType()) == LayoutExportFormats::PDFTiled)
{
CheckKey(LONG_OPTION_TILED_PDF_LEFT_MARGIN,
translate("VCommandLine", "Tiled left margin must be used together with page units."));
CheckKey(LONG_OPTION_TILED_PDF_RIGHT_MARGIN,
translate("VCommandLine", "Tiled right margin must be used together with page units."));
CheckKey(LONG_OPTION_TILED_PDF_TOP_MARGIN,
translate("VCommandLine", "Tiled top margin must be used together with page units."));
CheckKey(LONG_OPTION_TILED_PDF_BOTTOM_MARGIN,
translate("VCommandLine", "Tiled bottom margin must be used together with page units."));
}
}
//---------------------------------------------------------------------------------------------------------------------
auto VCommandLine::ParseMargins(const DialogLayoutSettings &diag) const -> QMarginsF
{
QMarginsF margins = diag.GetFields();
if (IsOptionSet(LONG_OPTION_LEFT_MARGIN))
{
bool ok = false;
qreal margin = Pg2Px(OptionValue(LONG_OPTION_LEFT_MARGIN), diag, &ok);
if (not ok)
{
qCritical() << translate("VCommandLine", "Invalid layout page left margin.") << "\n";
const_cast<VCommandLine*>(this)->parser.showHelp(V_EX_USAGE);
}
margins.setLeft(margin);
}
if (IsOptionSet(LONG_OPTION_RIGHT_MARGIN))
{
bool ok = false;
qreal margin = Pg2Px(OptionValue(LONG_OPTION_RIGHT_MARGIN), diag, &ok);
if (not ok)
{
qCritical() << translate("VCommandLine", "Invalid layout page right margin.") << "\n";
const_cast<VCommandLine*>(this)->parser.showHelp(V_EX_USAGE);
}
margins.setRight(margin);
}
if (IsOptionSet(LONG_OPTION_TOP_MARGIN))
{
bool ok = false;
qreal margin = Pg2Px(OptionValue(LONG_OPTION_TOP_MARGIN), diag, &ok);
if (not ok)
{
qCritical() << translate("VCommandLine", "Invalid layout page top margin.") << "\n";
const_cast<VCommandLine*>(this)->parser.showHelp(V_EX_USAGE);
}
margins.setTop(margin);
}
if (IsOptionSet(LONG_OPTION_BOTTOM_MARGIN))
{
bool ok = false;
qreal margin = Pg2Px(OptionValue(LONG_OPTION_BOTTOM_MARGIN), diag, &ok);
if (not ok)
{
qCritical() << translate("VCommandLine", "Invalid layout page bottom margin.") << "\n";
const_cast<VCommandLine*>(this)->parser.showHelp(V_EX_USAGE);
}
margins.setBottom(margin);
}
return margins;
}
#undef translate #undef translate

View File

@ -36,7 +36,6 @@
#include <QCommandLineParser> #include <QCommandLineParser>
#include "../dialogs/dialoglayoutsettings.h" #include "../dialogs/dialoglayoutsettings.h"
#include "../vmisc/vsysexits.h"
class VCommandLine; class VCommandLine;
using VCommandLinePtr = std::shared_ptr<VCommandLine>; using VCommandLinePtr = std::shared_ptr<VCommandLine>;
@ -54,110 +53,116 @@ public:
//@brief tests if user enabled test mode from cmd, throws exception if not exactly 1 input VAL file supplied in //@brief tests if user enabled test mode from cmd, throws exception if not exactly 1 input VAL file supplied in
//case test mode enabled //case test mode enabled
bool IsTestModeEnabled() const; auto IsTestModeEnabled() const -> bool;
//@brief Make all parsing warnings into errors. Have effect only in console mode. Use to force Valentina to //@brief Make all parsing warnings into errors. Have effect only in console mode. Use to force Valentina to
//immediately terminate if a pattern contains a parsing warning. //immediately terminate if a pattern contains a parsing warning.
bool IsPedantic() const; auto IsPedantic() const -> bool;
bool IsNoScalingEnabled() const; auto IsNoScalingEnabled() const -> bool;
//@brief tests if user enabled export from cmd, throws exception if not exactly 1 input VAL file supplied in case //@brief tests if user enabled export from cmd, throws exception if not exactly 1 input VAL file supplied in case
//export enabled //export enabled
bool IsExportEnabled() const; auto IsExportEnabled() const -> bool;
//@brief tests if user enabled export final measurements from cmd, throws exception if not exactly 1 input VAL //@brief tests if user enabled export final measurements from cmd, throws exception if not exactly 1 input VAL
//file supplied in case export enabled //file supplied in case export enabled
bool IsExportFMEnabled() const; auto IsExportFMEnabled() const -> bool;
//@brief returns path to custom measure file or empty string //@brief returns path to custom measure file or empty string
QString OptMeasurePath() const; auto OptMeasurePath() const -> QString;
//@brief returns the base name of layout files or empty string if not set //@brief returns the base name of layout files or empty string if not set
QString OptBaseName() const; auto OptBaseName() const -> QString;
//@brief returns the absolute path to output destination directory or path to application's current directory if //@brief returns the absolute path to output destination directory or path to application's current directory if
//not set //not set
QString OptDestinationPath() const; auto OptDestinationPath() const -> QString;
//@brief returns export type set, defaults 0 - svg //@brief returns export type set, defaults 0 - svg
int OptExportType() const; auto OptExportType() const -> int;
bool IsBinaryDXF() const; auto IsBinaryDXF() const -> bool;
bool IsTextAsPaths() const; auto IsTextAsPaths() const -> bool;
bool IsExportOnlyDetails() const; auto IsExportOnlyDetails() const -> bool;
bool IsCSVWithHeader() const; auto IsCSVWithHeader() const -> bool;
qreal ExportXScale() const; auto ExportXScale() const -> qreal;
qreal ExportYScale() const; auto ExportYScale() const -> qreal;
//@brief returns the piece name regex or empty string if not set //@brief returns the piece name regex or empty string if not set
QString OptExportSuchDetails() const; auto OptExportSuchDetails() const -> QString;
//@brief returns user selected csv codec or empty string if not set //@brief returns user selected csv codec or empty string if not set
QString OptCSVCodecName() const; auto OptCSVCodecName() const -> QString;
//@brief returns user selected csv separator or empty string if not set //@brief returns user selected csv separator or empty string if not set
QChar OptCSVSeparator() const; auto OptCSVSeparator() const -> QChar;
//@brief returns the destination path for export final measurements or empty string if not set //@brief returns the destination path for export final measurements or empty string if not set
QString OptExportFMTo() const; auto OptExportFMTo() const -> QString;
//@brief returns list of user defined materials //@brief returns list of user defined materials
QMap<int, QString> OptUserMaterials() const; auto OptUserMaterials() const -> QMap<int, QString>;
//generator creation is moved here ... because most options are for it only, so no need to create extra getters... //generator creation is moved here ... because most options are for it only, so no need to create extra getters...
//@brief creates VLayoutGenerator //@brief creates VLayoutGenerator
VLayoutGeneratorPtr DefaultGenerator() const; auto DefaultGenerator() const -> VLayoutGeneratorPtr;
//@brief gets filenames which should be loaded //@brief gets filenames which should be loaded
QStringList OptInputFileNames() const; auto OptInputFileNames() const -> QStringList;
bool IsGuiEnabled()const; auto IsGuiEnabled()const -> bool;
bool IsSetDimensionA() const; auto IsSetDimensionA() const -> bool;
bool IsSetDimensionB() const; auto IsSetDimensionB() const -> bool;
bool IsSetDimensionC() const; auto IsSetDimensionC() const -> bool;
int OptDimensionA() const; auto OptDimensionA() const -> int;
int OptDimensionB() const; auto OptDimensionB() const -> int;
int OptDimensionC() const; auto OptDimensionC() const -> int;
QMarginsF TiledPageMargins() const; auto TiledPageMargins() const -> QMarginsF;
VAbstractLayoutDialog::PaperSizeTemplate OptTiledPaperSize() const; auto OptTiledPaperSize() const -> VAbstractLayoutDialog::PaperSizeTemplate;
PageOrientation OptTiledPageOrientation() const; auto OptTiledPageOrientation() const -> PageOrientation;
protected: protected:
VCommandLine(); VCommandLine();
//@brief returns VAbstractLayoutDialog::PaperSizeTemplate //@brief returns VAbstractLayoutDialog::PaperSizeTemplate
VAbstractLayoutDialog::PaperSizeTemplate OptPaperSize() const; auto OptPaperSize() const -> VAbstractLayoutDialog::PaperSizeTemplate;
Cases OptGroup() const; auto OptGroup() const -> Cases;
//@brief: called in destructor of application, so instance destroyed and new maybe created (never happen scenario though) //@brief: called in destructor of application, so instance destroyed and new maybe created (never happen scenario though)
static void Reset(); static void Reset();
//@brief called to create single object, by VApplication only //@brief called to create single object, by VApplication only
static VCommandLinePtr Get(const QCoreApplication& app); static auto Get(const QCoreApplication& app) -> VCommandLinePtr;
private: private:
Q_DISABLE_COPY(VCommandLine) Q_DISABLE_COPY_MOVE(VCommandLine) // NOLINT
static VCommandLinePtr instance; static VCommandLinePtr instance; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)
QCommandLineParser parser; QCommandLineParser parser{};
bool isGuiEnabled; bool isGuiEnabled{false};
friend class VApplication; friend class VApplication;
VAbstractLayoutDialog::PaperSizeTemplate FormatSize(const QString &key) const; auto FormatSize(const QString &key) const -> VAbstractLayoutDialog::PaperSizeTemplate;
void InitCommandLineOptions(); void InitCommandLineOptions();
bool IsOptionSet(const QString &option) const; auto IsOptionSet(const QString &option) const -> bool;
QString OptionValue(const QString &option) const; auto OptionValue(const QString &option) const -> QString;
QStringList OptionValues(const QString &option) const; auto OptionValues(const QString &option) const -> QStringList;
int OptNestingTime() const; auto OptNestingTime() const -> int;
qreal OptEfficiencyCoefficient() const; auto OptEfficiencyCoefficient() const -> qreal;
void TestPageformat() const;
void TestGapWidth() const;
void TestMargins() const;
auto ParseMargins(const DialogLayoutSettings &diag) const -> QMarginsF;
}; };
#endif // VCMDEXPORT_H #endif // VCMDEXPORT_H

View File

@ -30,8 +30,8 @@
#include "vformulapropertyeditor.h" #include "vformulapropertyeditor.h"
#include "../vpropertyexplorer/vproperty_p.h" #include "../vpropertyexplorer/vproperty_p.h"
#include "../vpropertyexplorer/plugins/vstringproperty.h"
#include "vformulapropertyeditor.h" #include "vformulapropertyeditor.h"
#include "../vpropertyexplorer/vproperties.h"
#include "../vpatterndb/vformula.h" #include "../vpatterndb/vformula.h"
#include "../vmisc/vabstractapplication.h" #include "../vmisc/vabstractapplication.h"
@ -41,7 +41,7 @@ VFormulaProperty::VFormulaProperty(const QString &name)
{ {
d_ptr->type = VPE::Property::Complex; d_ptr->type = VPE::Property::Complex;
VPE::VStringProperty* tmpFormula = new VPE::VStringProperty(tr("Formula")); auto* tmpFormula = new VPE::VStringProperty(tr("Formula"));
addChild(tmpFormula); addChild(tmpFormula);
tmpFormula->setClearButtonEnable(true); tmpFormula->setClearButtonEnable(true);
tmpFormula->setUpdateBehaviour(true, false); tmpFormula->setUpdateBehaviour(true, false);
@ -53,41 +53,37 @@ VFormulaProperty::VFormulaProperty(const QString &name)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
//! Get the data how it should be displayed //! Get the data how it should be displayed
QVariant VFormulaProperty::data (int column, int role) const auto VFormulaProperty::data (int column, int role) const -> QVariant
{ {
if (column == DPC_Data && (Qt::DisplayRole == role || Qt::EditRole == role)) if (column == DPC_Data && (Qt::DisplayRole == role || Qt::EditRole == role))
{ {
return getValue(); return getValue();
} }
else
{
return VProperty::data(column, role); return VProperty::data(column, role);
}
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
Qt::ItemFlags VFormulaProperty::flags(int column) const auto VFormulaProperty::flags(int column) const -> Qt::ItemFlags
{ {
if (column == DPC_Name || column == DPC_Data) if (column == DPC_Name || column == DPC_Data)
{ {
return Qt::ItemIsEnabled | Qt::ItemIsSelectable; return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
} }
else
{
return Qt::NoItemFlags; return Qt::NoItemFlags;
}
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
//! Returns an editor widget, or NULL if it doesn't supply one //! Returns an editor widget, or NULL if it doesn't supply one
QWidget* VFormulaProperty::createEditor(QWidget* parent, const QStyleOptionViewItem& options, auto VFormulaProperty::createEditor(QWidget* parent, const QStyleOptionViewItem& options,
const QAbstractItemDelegate* delegate) const QAbstractItemDelegate* delegate) -> QWidget*
{ {
Q_UNUSED(options) Q_UNUSED(options)
Q_UNUSED(delegate) Q_UNUSED(delegate)
VFormula formula = VProperty::d_ptr->VariantValue.value<VFormula>(); auto formula = VProperty::d_ptr->VariantValue.value<VFormula>();
VFormulaPropertyEditor* tmpEditor = new VFormulaPropertyEditor(parent); auto* tmpEditor = new VFormulaPropertyEditor(parent);
tmpEditor->setLocale(parent->locale()); tmpEditor->setLocale(parent->locale());
tmpEditor->SetFormula(formula); tmpEditor->SetFormula(formula);
VProperty::d_ptr->editor = tmpEditor; VProperty::d_ptr->editor = tmpEditor;
@ -96,25 +92,27 @@ QWidget* VFormulaProperty::createEditor(QWidget* parent, const QStyleOptionViewI
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
//! Sets the property's data to the editor (returns false, if the standard delegate should do that) //! Sets the property's data to the editor (returns false, if the standard delegate should do that)
bool VFormulaProperty::setEditorData(QWidget* editor) auto VFormulaProperty::setEditorData(QWidget* editor) -> bool
{ {
VFormulaPropertyEditor* tmpWidget = qobject_cast<VFormulaPropertyEditor*>(editor); auto* tmpWidget = qobject_cast<VFormulaPropertyEditor*>(editor);
if (tmpWidget) if (tmpWidget)
{ {
VFormula formula = VProperty::d_ptr->VariantValue.value<VFormula>(); auto formula = VProperty::d_ptr->VariantValue.value<VFormula>();
tmpWidget->SetFormula(formula); tmpWidget->SetFormula(formula);
} }
else else
{
return false; return false;
}
return true; return true;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
//! Gets the data from the widget //! Gets the data from the widget
QVariant VFormulaProperty::getEditorData(const QWidget *editor) const auto VFormulaProperty::getEditorData(const QWidget *editor) const -> QVariant
{ {
const VFormulaPropertyEditor* tmpWidget = qobject_cast<const VFormulaPropertyEditor*>(editor); const auto* tmpWidget = qobject_cast<const VFormulaPropertyEditor*>(editor);
if (tmpWidget) if (tmpWidget)
{ {
QVariant value; QVariant value;
@ -122,17 +120,17 @@ QVariant VFormulaProperty::getEditorData(const QWidget *editor) const
return value; return value;
} }
return QVariant(); return {};
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QString VFormulaProperty::type() const auto VFormulaProperty::type() const -> QString
{ {
return "formula"; return QStringLiteral("formula");
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VPE::VProperty *VFormulaProperty::clone(bool include_children, VProperty *container) const auto VFormulaProperty::clone(bool include_children, VProperty *container) const -> VPE::VProperty *
{ {
if (!container) if (!container)
{ {
@ -141,7 +139,7 @@ VPE::VProperty *VFormulaProperty::clone(bool include_children, VProperty *contai
if (!include_children) if (!include_children)
{ {
const QList<VProperty*> tmpChildren = container->getChildren(); const QList<VProperty*> tmpChildren = container->getChildren();
for (auto tmpChild : tmpChildren) for (auto *tmpChild : tmpChildren)
{ {
container->removeChild(tmpChild); container->removeChild(tmpChild);
delete tmpChild; delete tmpChild;
@ -156,12 +154,12 @@ VPE::VProperty *VFormulaProperty::clone(bool include_children, VProperty *contai
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VFormulaProperty::setValue(const QVariant &value) void VFormulaProperty::setValue(const QVariant &value)
{ {
VFormula tmpFormula = value.value<VFormula>(); auto tmpFormula = value.value<VFormula>();
SetFormula(tmpFormula); SetFormula(tmpFormula);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QVariant VFormulaProperty::getValue() const auto VFormulaProperty::getValue() const -> QVariant
{ {
VFormula tmpFormula = GetFormula(); VFormula tmpFormula = GetFormula();
QVariant value; QVariant value;
@ -170,7 +168,7 @@ QVariant VFormulaProperty::getValue() const
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VFormula VFormulaProperty::GetFormula() const auto VFormulaProperty::GetFormula() const -> VFormula
{ {
return VProperty::d_ptr->VariantValue.value<VFormula>(); return VProperty::d_ptr->VariantValue.value<VFormula>();
} }
@ -195,7 +193,7 @@ void VFormulaProperty::SetFormula(const VFormula &formula)
if (VProperty::d_ptr->editor != nullptr) if (VProperty::d_ptr->editor != nullptr)
{ {
setEditorData(VProperty::d_ptr->editor); setEditorData(VProperty::d_ptr->editor); // NOLINT(clang-analyzer-optin.cplusplus.VirtualCall)
} }
} }

View File

@ -35,56 +35,55 @@ class VFormula;
class VFormulaProperty : public VPE::VProperty class VFormulaProperty : public VPE::VProperty
{ {
Q_OBJECT Q_OBJECT // NOLINT
public: public:
explicit VFormulaProperty(const QString &name); explicit VFormulaProperty(const QString &name);
//! Get the data how it should be displayed //! Get the data how it should be displayed
virtual QVariant data (int column = DPC_Name, int role = Qt::DisplayRole) const override; auto data (int column = DPC_Name, int role = Qt::DisplayRole) const -> QVariant override;
//! Returns item flags //! Returns item flags
virtual Qt::ItemFlags flags(int column = DPC_Name) const override; auto flags(int column = DPC_Name) const -> Qt::ItemFlags override;
//! Returns an editor widget, or NULL if it doesn't supply one //! Returns an editor widget, or NULL if it doesn't supply one
//! \param parent The widget to which the editor will be added as a child //! \param parent The widget to which the editor will be added as a child
//! \options Render options //! \options Render options
//! \delegate A pointer to the QAbstractItemDelegate requesting the editor. This can be used to connect signals and //! \delegate A pointer to the QAbstractItemDelegate requesting the editor. This can be used to connect signals and
//! slots. //! slots.
virtual QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& options, auto createEditor(QWidget* parent, const QStyleOptionViewItem& options,
const QAbstractItemDelegate* delegate) override; const QAbstractItemDelegate* delegate) -> QWidget* override;
//! Sets the property's data to the editor (returns false, if the standard delegate should do that) //! Sets the property's data to the editor (returns false, if the standard delegate should do that)
virtual bool setEditorData(QWidget* editor) override; auto setEditorData(QWidget* editor) -> bool override;
//! Gets the data from the widget //! Gets the data from the widget
virtual QVariant getEditorData(const QWidget* editor) const override; auto getEditorData(const QWidget* editor) const -> QVariant override;
//! Returns a string containing the type of the property //! Returns a string containing the type of the property
virtual QString type() const override; auto type() const -> QString override;
//! Clones this property //! Clones this property
//! \param include_children Indicates whether to also clone the children //! \param include_children Indicates whether to also clone the children
//! \param container If a property is being passed here, no new VProperty is being created but instead it is tried //! \param container If a property is being passed here, no new VProperty is being created but instead it is tried
//! to fill all the data into container. This can also be used when subclassing this function. //! to fill all the data into container. This can also be used when subclassing this function.
//! \return Returns the newly created property (or container, if it was not NULL) //! \return Returns the newly created property (or container, if it was not NULL)
Q_REQUIRED_RESULT virtual VProperty* clone(bool include_children = true, Q_REQUIRED_RESULT auto clone(bool include_children = true,
VProperty* container = nullptr) const override; VProperty* container = nullptr) const -> VProperty* override;
//! Sets the value of the property //! Sets the value of the property
virtual void setValue(const QVariant& value) override; void setValue(const QVariant& value) override;
//! Returns the value of the property as a QVariant //! Returns the value of the property as a QVariant
virtual QVariant getValue() const override; auto getValue() const -> QVariant override;
//! Returns the formula //! Returns the formula
VFormula GetFormula() const; auto GetFormula() const -> VFormula;
//! Sets the formula //! Sets the formula
void SetFormula(const VFormula &formula); void SetFormula(const VFormula &formula);
public slots: public slots:
virtual void ValueChildChanged(const QVariant &value, int typeForParent) override; void ValueChildChanged(const QVariant &value, int typeForParent) override;
}; };
#endif // VFORMULAPROPERTY_H #endif // VFORMULAPROPERTY_H

View File

@ -39,49 +39,49 @@
#include "../vpropertyexplorer/vproperty.h" #include "../vpropertyexplorer/vproperty.h"
#include "../vtools/dialogs/support/dialogeditwrongformula.h" #include "../vtools/dialogs/support/dialogeditwrongformula.h"
#include "vapplication.h" #include "../vmisc/vabstractvalapplication.h"
// VFormulaPropertyEditor // VFormulaPropertyEditor
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VFormulaPropertyEditor::VFormulaPropertyEditor(QWidget *parent) VFormulaPropertyEditor::VFormulaPropertyEditor(QWidget *parent)
: QWidget(parent), formula(VFormula()), ToolButton(nullptr), TextLabel(nullptr) : QWidget(parent)
{ {
setAutoFillBackground(true); setAutoFillBackground(true);
// Create the tool button // Create the tool button
ToolButton = new QToolButton(this); m_ToolButton = new QToolButton(this);
ToolButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); m_ToolButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
ToolButton->setText("..."); m_ToolButton->setText(QStringLiteral("..."));
ToolButton->setIcon(QIcon("://icon/16x16/fx.png")); m_ToolButton->setIcon(QIcon("://icon/16x16/fx.png"));
ToolButton->setIconSize(QSize(16, 16)); m_ToolButton->setIconSize(QSize(16, 16));
ToolButton->setFixedSize(24, 24); m_ToolButton->setFixedSize(24, 24);
ToolButton->installEventFilter(this); m_ToolButton->installEventFilter(this);
setFocusProxy(ToolButton); // Make the ToolButton the focus proxy setFocusProxy(m_ToolButton); // Make the ToolButton the focus proxy
setFocusPolicy(ToolButton->focusPolicy()); setFocusPolicy(m_ToolButton->focusPolicy());
connect(ToolButton, &QToolButton::clicked, this, &VFormulaPropertyEditor::onToolButtonClicked); connect(m_ToolButton, &QToolButton::clicked, this, &VFormulaPropertyEditor::onToolButtonClicked);
// Create the text label // Create the text label
TextLabel = new QLabel(this); m_TextLabel = new QLabel(this);
TextLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); m_TextLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
TextLabel->setText(formula.getStringValue()); m_TextLabel->setText(m_formula.getStringValue());
// The layout (a horizontal layout) // The layout (a horizontal layout)
QHBoxLayout* layout = new QHBoxLayout(this); auto* layout = new QHBoxLayout(this);
layout->setSpacing(3); layout->setSpacing(3);
layout->setMargin(0); layout->setMargin(0);
layout->addWidget(TextLabel); layout->addWidget(m_TextLabel);
// Spacer (this is needed for proper display of the label and button) // Spacer (this is needed for proper display of the label and button)
layout->addSpacerItem(new QSpacerItem(1000000000, 0, QSizePolicy::Expanding, QSizePolicy::Preferred)); layout->addSpacerItem(new QSpacerItem(1000000000, 0, QSizePolicy::Expanding, QSizePolicy::Preferred));
layout->addWidget(ToolButton); layout->addWidget(m_ToolButton);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VFormulaPropertyEditor::SetFormula(const VFormula& formula) void VFormulaPropertyEditor::SetFormula(const VFormula& formula)
{ {
if (this->formula != formula) if (this->m_formula != formula)
{ {
this->formula = formula; this->m_formula = formula;
TextLabel->setText(this->formula.getStringValue()); m_TextLabel->setText(this->m_formula.getStringValue());
} }
} }
@ -89,26 +89,26 @@ void VFormulaPropertyEditor::SetFormula(const VFormula& formula)
void VFormulaPropertyEditor::onToolButtonClicked() void VFormulaPropertyEditor::onToolButtonClicked()
{ {
QScopedPointer<DialogEditWrongFormula> tmpWidget( QScopedPointer<DialogEditWrongFormula> tmpWidget(
new DialogEditWrongFormula(formula.getData(), formula.getToolId(), new DialogEditWrongFormula(m_formula.getData(), m_formula.getToolId(),
VAbstractValApplication::VApp()->getMainWindow())); VAbstractValApplication::VApp()->getMainWindow()));
tmpWidget->setCheckZero(formula.getCheckZero()); tmpWidget->setCheckZero(m_formula.getCheckZero());
tmpWidget->setPostfix(formula.getPostfix()); tmpWidget->setPostfix(m_formula.getPostfix());
tmpWidget->SetFormula(formula.GetFormula(FormulaType::FromUser)); tmpWidget->SetFormula(m_formula.GetFormula(FormulaType::FromUser));
if (tmpWidget->exec() == QDialog::Accepted) if (tmpWidget->exec() == QDialog::Accepted)
{ {
formula.SetFormula(tmpWidget->GetFormula(), FormulaType::ToUser); m_formula.SetFormula(tmpWidget->GetFormula(), FormulaType::ToUser);
formula.Eval(); m_formula.Eval();
TextLabel->setText(formula.getStringValue()); m_TextLabel->setText(m_formula.getStringValue());
emit dataChangedByUser(formula, this); emit dataChangedByUser(m_formula, this);
QCoreApplication::postEvent(this, new VPE::UserChangeEvent()); QCoreApplication::postEvent(this, new VPE::UserChangeEvent());
} }
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool VFormulaPropertyEditor::eventFilter(QObject *obj, QEvent *ev) auto VFormulaPropertyEditor::eventFilter(QObject *obj, QEvent *ev) -> bool
{ {
if (obj == ToolButton && ev->type() == QEvent::KeyPress) if (obj == m_ToolButton && ev->type() == QEvent::KeyPress)
{ {
// Ignore the event, so that eventually the delegate gets the event. // Ignore the event, so that eventually the delegate gets the event.
ev->ignore(); ev->ignore();
@ -119,7 +119,7 @@ bool VFormulaPropertyEditor::eventFilter(QObject *obj, QEvent *ev)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VFormula VFormulaPropertyEditor::GetFormula() const auto VFormulaPropertyEditor::GetFormula() const -> VFormula
{ {
return formula; return m_formula;
} }

View File

@ -35,23 +35,24 @@
#include <QLabel> #include <QLabel>
#include "../vpatterndb/vformula.h" #include "../vpatterndb/vformula.h"
#include "../vmisc/defglobal.h"
class VFormulaPropertyEditor : public QWidget class VFormulaPropertyEditor : public QWidget
{ {
Q_OBJECT Q_OBJECT // NOLINT
public: public:
//! Constructor taking a widget as parent //! Constructor taking a widget as parent
explicit VFormulaPropertyEditor(QWidget *parent); explicit VFormulaPropertyEditor(QWidget *parent);
//! Destructor //! Destructor
virtual ~VFormulaPropertyEditor() Q_DECL_EQ_DEFAULT; ~VFormulaPropertyEditor() override Q_DECL_EQ_DEFAULT;
//! Returns the formula currently set //! Returns the formula currently set
VFormula GetFormula() const; auto GetFormula() const -> VFormula;
//! Needed for proper event handling //! Needed for proper event handling
virtual bool eventFilter(QObject *obj, QEvent *ev) override; auto eventFilter(QObject *obj, QEvent *ev) -> bool override;
signals: signals:
//! This is emitted, when the user changes the color //! This is emitted, when the user changes the color
@ -67,10 +68,11 @@ private slots:
void onToolButtonClicked(); void onToolButtonClicked();
private: private:
Q_DISABLE_COPY(VFormulaPropertyEditor) // cppcheck-suppress unknownMacro
VFormula formula; Q_DISABLE_COPY_MOVE(VFormulaPropertyEditor) // NOLINT
QToolButton* ToolButton; VFormula m_formula{};
QLabel* TextLabel; QToolButton* m_ToolButton{nullptr};
QLabel* m_TextLabel{nullptr};
}; };

File diff suppressed because it is too large Load Diff

View File

@ -43,9 +43,10 @@ class VFormula;
class VToolOptionsPropertyBrowser : public QObject class VToolOptionsPropertyBrowser : public QObject
{ {
Q_OBJECT Q_OBJECT // NOLINT
public: public:
explicit VToolOptionsPropertyBrowser(QDockWidget *parent); explicit VToolOptionsPropertyBrowser(QDockWidget *parent);
~VToolOptionsPropertyBrowser() override =default;
void ClearPropertyBrowser(); void ClearPropertyBrowser();
public slots: public slots:
void itemClicked(QGraphicsItem *item); void itemClicked(QGraphicsItem *item);
@ -54,14 +55,15 @@ public slots:
private slots: private slots:
void userChangedData(VPE::VProperty* property); void userChangedData(VPE::VProperty* property);
private: private:
Q_DISABLE_COPY(VToolOptionsPropertyBrowser) // cppcheck-suppress unknownMacro
Q_DISABLE_COPY_MOVE(VToolOptionsPropertyBrowser) // NOLINT
VPE::VPropertyModel* PropertyModel; VPE::VPropertyModel* m_PropertyModel{nullptr};
VPE::VPropertyFormView* formView; VPE::VPropertyFormView* m_formView{nullptr};
QGraphicsItem *currentItem; QGraphicsItem *m_currentItem{nullptr};
QMap<VPE::VProperty *, QString> propertyToId; QMap<VPE::VProperty *, QString> m_propertyToId{};
QMap<QString, VPE::VProperty *> idToProperty; QMap<QString, VPE::VProperty *> m_idToProperty{};
void AddProperty(VPE::VProperty *property, const QString &id); void AddProperty(VPE::VProperty *property, const QString &id);
void ShowItemOptions(QGraphicsItem *item); void ShowItemOptions(QGraphicsItem *item);
@ -91,7 +93,7 @@ private:
void SetOperationSuffix(VPE::VProperty *property); void SetOperationSuffix(VPE::VProperty *property);
template<class Type> template<class Type>
Type GetCrossPoint(const QVariant &value); auto GetCrossPoint(const QVariant &value) -> Type;
template<class Tool> template<class Tool>
void SetCrossCirclesPoint(VPE::VProperty *property); void SetCrossCirclesPoint(VPE::VProperty *property);
@ -198,7 +200,7 @@ private:
void AddPropertyText(const QString &propertyName, const QString &text, const QString &attrName); void AddPropertyText(const QString &propertyName, const QString &text, const QString &attrName);
void AddPropertyBool(const QString &propertyName, bool value, const QString &attrName); void AddPropertyBool(const QString &propertyName, bool value, const QString &attrName);
QStringList PropertiesList() const; static auto PropertiesList() -> QStringList;
void ChangeDataToolSinglePoint(VPE::VProperty *property); void ChangeDataToolSinglePoint(VPE::VProperty *property);
void ChangeDataToolEndLine(VPE::VProperty *property); void ChangeDataToolEndLine(VPE::VProperty *property);

View File

@ -40,11 +40,7 @@
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
PreferencesConfigurationPage::PreferencesConfigurationPage(QWidget *parent) PreferencesConfigurationPage::PreferencesConfigurationPage(QWidget *parent)
: QWidget(parent), : QWidget(parent),
ui(new Ui::PreferencesConfigurationPage), ui(new Ui::PreferencesConfigurationPage)
m_langChanged(false),
m_systemChanged(),
m_unitChanged(false),
m_labelLangChanged(false)
{ {
ui->setupUi(this); ui->setupUi(this);
RetranslateUi(); RetranslateUi();
@ -169,7 +165,7 @@ PreferencesConfigurationPage::~PreferencesConfigurationPage()
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QStringList PreferencesConfigurationPage::Apply() auto PreferencesConfigurationPage::Apply() -> QStringList
{ {
// Tab General // Tab General
QStringList preferences; QStringList preferences;
@ -263,7 +259,7 @@ void PreferencesConfigurationPage::changeEvent(QEvent *event)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void PreferencesConfigurationPage::SetLabelComboBox(const QStringList &list) void PreferencesConfigurationPage::SetLabelComboBox(const QStringList &list)
{ {
for (auto &name : list) for (const auto &name : list)
{ {
ui->labelCombo->addItem(QLocale(name).nativeLanguageName(), name); ui->labelCombo->addItem(QLocale(name).nativeLanguageName(), name);
} }
@ -284,7 +280,7 @@ void PreferencesConfigurationPage::RetranslateUi()
{ {
ui->unitCombo->blockSignals(true); ui->unitCombo->blockSignals(true);
const QString unit = qvariant_cast<QString>(ui->unitCombo->currentData()); const auto unit = qvariant_cast<QString>(ui->unitCombo->currentData());
ui->unitCombo->clear(); ui->unitCombo->clear();
InitUnits(); InitUnits();
ui->unitCombo->setCurrentIndex(ui->unitCombo->findData(unit)); ui->unitCombo->setCurrentIndex(ui->unitCombo->findData(unit));
@ -292,7 +288,7 @@ void PreferencesConfigurationPage::RetranslateUi()
} }
{ {
const QString code = qvariant_cast<QString>(ui->systemCombo->currentData()); const auto code = qvariant_cast<QString>(ui->systemCombo->currentData());
ui->systemCombo->blockSignals(true); ui->systemCombo->blockSignals(true);
ui->systemCombo->clear(); ui->systemCombo->clear();
InitPMSystems(ui->systemCombo); InitPMSystems(ui->systemCombo);

View File

@ -31,6 +31,8 @@
#include <QWidget> #include <QWidget>
#include "../vmisc/defglobal.h"
namespace Ui namespace Ui
{ {
class PreferencesConfigurationPage; class PreferencesConfigurationPage;
@ -38,22 +40,23 @@ namespace Ui
class PreferencesConfigurationPage : public QWidget class PreferencesConfigurationPage : public QWidget
{ {
Q_OBJECT Q_OBJECT // NOLINT
public: public:
explicit PreferencesConfigurationPage(QWidget *parent = nullptr); explicit PreferencesConfigurationPage(QWidget *parent = nullptr);
virtual ~PreferencesConfigurationPage(); ~PreferencesConfigurationPage() override;
QStringList Apply(); auto Apply() -> QStringList;
protected: protected:
virtual void changeEvent(QEvent* event) override; void changeEvent(QEvent* event) override;
private: private:
Q_DISABLE_COPY(PreferencesConfigurationPage) // cppcheck-suppress unknownMacro
Q_DISABLE_COPY_MOVE(PreferencesConfigurationPage) // NOLINT
Ui::PreferencesConfigurationPage *ui; Ui::PreferencesConfigurationPage *ui;
bool m_langChanged; bool m_langChanged{false};
bool m_systemChanged; bool m_systemChanged{false};
bool m_unitChanged; bool m_unitChanged{false};
bool m_labelLangChanged; bool m_labelLangChanged{false};
void SetLabelComboBox(const QStringList &list); void SetLabelComboBox(const QStringList &list);
void InitUnits(); void InitUnits();

Some files were not shown because too many files have changed in this diff Show More