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 <QFontMetrics>
#if QT_VERSION < QT_VERSION_CHECK(5, 7, 0)
#include "../vmisc/backport/qoverload.h"
#endif // QT_VERSION < QT_VERSION_CHECK(5, 7, 0)
#include "../layout/vpsheet.h"
#include "../layout/vplayout.h"
@ -40,7 +42,13 @@
#include <QMenu>
#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) :
@ -108,7 +116,7 @@ void VPCarrousel::Refresh()
ui->comboBoxPieceList->blockSignals(true);
for (const auto& sheet: m_pieceLists)
for (const auto& sheet: qAsConst(m_pieceLists))
{
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;
}

View File

@ -32,8 +32,10 @@
#include <QWidget>
#include <QComboBox>
#include <QScrollArea>
#include "../layout/vppiece.h"
#include <QUuid>
#include "../layout/layoutdef.h"
#include "../vmisc/defglobal.h"
namespace Ui
{
@ -51,10 +53,10 @@ struct VPCarrouselSheet
class VPCarrousel : public QWidget
{
Q_OBJECT
Q_OBJECT // NOLINT
public:
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
@ -76,7 +78,7 @@ public:
*/
void Clear();
VPLayoutWeakPtr Layout() const;
auto Layout() const -> VPLayoutWeakPtr;
public slots:
/**
@ -86,7 +88,7 @@ public slots:
void on_ActiveSheetChanged(const VPSheetPtr &sheet);
protected:
virtual void changeEvent(QEvent* event) override;
void changeEvent(QEvent* event) override;
private slots:
@ -97,7 +99,8 @@ private slots:
void on_ActivePieceListChanged(int index);
private:
Q_DISABLE_COPY(VPCarrousel)
// cppcheck-suppress unknownMacro
Q_DISABLE_COPY_MOVE(VPCarrousel) // NOLINT
Ui::VPCarrousel *ui;
VPLayoutWeakPtr m_layout{};

View File

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

View File

@ -35,15 +35,24 @@
#include "vpcarrousel.h"
#include "vpcarrouselpiece.h"
#if QT_VERSION < QT_VERSION_CHECK(5, 7, 0)
#include "../vmisc/backport/qoverload.h"
#endif // QT_VERSION < QT_VERSION_CHECK(5, 7, 0)
#include "vpmimedatapiece.h"
#include "../layout/vpsheet.h"
#include "../layout/vplayout.h"
#include "../undocommands/vpundomovepieceonsheet.h"
#include "../layout/vppiece.h"
#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) :
@ -70,7 +79,7 @@ void VPCarrouselPieceList::Refresh()
if(not m_pieceList.isEmpty())
{
// 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())
{
@ -102,7 +111,8 @@ void VPCarrouselPieceList::mousePressEvent(QMouseEvent *event)
if (!(event->modifiers() & Qt::ControlModifier))
{
// 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);
}
@ -135,7 +145,8 @@ void VPCarrouselPieceList::startDrag(Qt::DropActions supportedActions)
QListWidgetItem* _item = currentItem();
if(_item->type() == VPCarrouselPiece::Type)
{
auto *pieceItem = static_cast<VPCarrouselPiece *> (_item);
auto *pieceItem = dynamic_cast<VPCarrouselPiece *> (_item);
SCASSERT(pieceItem != nullptr)
if (m_carrousel == nullptr)
{
@ -183,9 +194,13 @@ void VPCarrouselPieceList::dragMoveEvent(QDragMoveEvent* e)
void VPCarrouselPieceList::contextMenuEvent(QContextMenuEvent *event)
{
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();
VPLayoutPtr layout = piece->Layout();
@ -271,7 +286,6 @@ void VPCarrouselPieceList::contextMenuEvent(QContextMenuEvent *event)
layout->UndoStack()->push(command);
}
}
}
//---------------------------------------------------------------------------------------------------------------------
void VPCarrouselPieceList::on_SelectionChangedExternal()
@ -282,7 +296,8 @@ void VPCarrouselPieceList::on_SelectionChangedExternal()
QListWidgetItem* _item = item(i);
if(_item->type() == VPCarrouselPiece::Type)
{
auto *itemPiece = static_cast<VPCarrouselPiece *> (_item);
auto *itemPiece = dynamic_cast<VPCarrouselPiece *> (_item);
SCASSERT(itemPiece != nullptr)
itemPiece->RefreshSelection();
}
}

View File

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

View File

@ -33,7 +33,7 @@
#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)
@ -65,14 +65,14 @@ auto VPMimeDataPiece::DragCursor(const QPixmap &piecePixmap) -> QPixmap
dragCursor.fill(Qt::transparent);
QPainter painter(&dragCursor);
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.end();
return dragCursor;
}
//---------------------------------------------------------------------------------------------------------------------
const QUuid &VPMimeDataPiece::LayoutUuid() const
auto VPMimeDataPiece::LayoutUuid() const -> const QUuid &
{
return m_layoutUuid;
}

View File

@ -34,16 +34,17 @@
#include <QUuid>
#include "../layout/layoutdef.h"
#include "../vmisc/defglobal.h"
class VPMimeDataPiece : public QMimeData
{
Q_OBJECT
Q_OBJECT // NOLINT
public:
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
@ -61,10 +62,11 @@ public:
static const QString mineFormatPiecePtr;
const QUuid &LayoutUuid() const;
auto LayoutUuid() const -> const QUuid &;
private:
Q_DISABLE_COPY(VPMimeDataPiece)
// cppcheck-suppress unknownMacro
Q_DISABLE_COPY_MOVE(VPMimeDataPiece) // NOLINT
VPPieceWeakPtr m_piece{};

View File

@ -113,12 +113,12 @@ auto PuzzlePreferencesConfigurationPage::Apply() -> QStringList
if (m_langChanged)
{
const QString locale = qvariant_cast<QString>(ui->langCombo->currentData());
const auto locale = qvariant_cast<QString>(ui->langCombo->currentData());
settings->SetLocale(locale);
m_langChanged = false;
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

View File

@ -30,6 +30,8 @@
#include <QWidget>
#include "../vmisc/defglobal.h"
namespace Ui
{
class PuzzlePreferencesConfigurationPage;
@ -37,19 +39,20 @@ namespace Ui
class PuzzlePreferencesConfigurationPage : public QWidget
{
Q_OBJECT
Q_OBJECT // NOLINT
public:
explicit PuzzlePreferencesConfigurationPage(QWidget *parent = nullptr);
virtual ~PuzzlePreferencesConfigurationPage();
~PuzzlePreferencesConfigurationPage() override;
QStringList Apply();
auto Apply() -> QStringList;
protected:
virtual void changeEvent(QEvent* event) override;
void changeEvent(QEvent* event) override;
private:
Q_DISABLE_COPY(PuzzlePreferencesConfigurationPage)
// cppcheck-suppress unknownMacro
Q_DISABLE_COPY_MOVE(PuzzlePreferencesConfigurationPage) // NOLINT
Ui::PuzzlePreferencesConfigurationPage *ui;
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();
@ -413,7 +413,6 @@ QSizeF PuzzlePreferencesLayoutPage::Template(VAbstractLayoutDialog::PaperSizeTem
case VAbstractLayoutDialog::PaperSizeTemplate::Letter:
case VAbstractLayoutDialog::PaperSizeTemplate::Legal:
case VAbstractLayoutDialog::PaperSizeTemplate::Tabloid:
return VAbstractLayoutDialog::GetTemplateSize(t, layoutUnit);
case VAbstractLayoutDialog::PaperSizeTemplate::Roll24in:
case VAbstractLayoutDialog::PaperSizeTemplate::Roll30in:
case VAbstractLayoutDialog::PaperSizeTemplate::Roll36in:
@ -422,13 +421,12 @@ QSizeF PuzzlePreferencesLayoutPage::Template(VAbstractLayoutDialog::PaperSizeTem
case VAbstractLayoutDialog::PaperSizeTemplate::Roll48in:
case VAbstractLayoutDialog::PaperSizeTemplate::Roll62in:
case VAbstractLayoutDialog::PaperSizeTemplate::Roll72in:
return VAbstractLayoutDialog::GetTemplateSize(t, layoutUnit);
case VAbstractLayoutDialog::PaperSizeTemplate::Custom:
return VAbstractLayoutDialog::GetTemplateSize(t, layoutUnit);
default:
break;
}
return QSizeF();
return {};
}
//---------------------------------------------------------------------------------------------------------------------

View File

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

View File

@ -180,35 +180,35 @@ void PuzzlePreferencesPathPage::InitTable()
{
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());
ui->pathTable->setItem(0, 1, item);
}
{
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());
ui->pathTable->setItem(1, 1, item);
}
{
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());
ui->pathTable->setItem(2, 1, item);
}
{
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());
ui->pathTable->setItem(3, 1, item);
}
{
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());
ui->pathTable->setItem(4, 1, item);
}

View File

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

View File

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

View File

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

View File

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

View File

@ -28,7 +28,7 @@
#include "vpdialogabout.h"
#include "ui_vpdialogabout.h"
#include "../version.h"
#include "../vmisc/projectversion.h"
#include "../vmisc/def.h"
#include "../fervor/fvupdater.h"
@ -43,7 +43,7 @@
VPDialogAbout::VPDialogAbout(QWidget *parent)
:QDialog(parent),
ui(new Ui::VPDialogAbout),
isInitialized(false)
m_isInitialized(false)
{
ui->setupUi(this);
@ -52,7 +52,7 @@ VPDialogAbout::VPDialogAbout(QWidget *parent)
RetranslateUi();
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");
}
@ -100,7 +100,7 @@ void VPDialogAbout::showEvent(QShowEvent *event)
return;
}
if (isInitialized)
if (m_isInitialized)
{
return;
}
@ -109,7 +109,7 @@ void VPDialogAbout::showEvent(QShowEvent *event)
setMaximumSize(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()
{
ui->label_Puzzle_Version->setText(QString("Puzzle %1").arg(APP_VERSION_STR));
ui->labelBuildRevision->setText(tr("Build revision: %1").arg(BUILD_REVISION));
ui->label_Puzzle_Version->setText(QStringLiteral("Puzzle %1").arg(APP_VERSION_STR));
ui->labelBuildRevision->setText(tr("Build revision: %1").arg(QStringLiteral(BUILD_REVISION)));
ui->label_QT_Version->setText(buildCompatibilityString());
const QDate date = QLocale::c().toDate(QString(__DATE__).simplified(), QLatin1String("MMM d yyyy"));
ui->label_Puzzle_Built->setText(tr("Built on %1 at %2").arg(date.toString(), __TIME__));
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(), QStringLiteral(__TIME__)));
ui->label_Legal_Stuff->setText(QApplication::translate("InternalStrings",
"The program is provided AS IS with NO WARRANTY OF ANY "
"KIND, INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY "
"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 "../vmisc/defglobal.h"
namespace Ui
{
class VPDialogAbout;
@ -38,22 +40,23 @@ namespace Ui
class VPDialogAbout : public QDialog
{
Q_OBJECT
Q_OBJECT // NOLINT
public:
explicit VPDialogAbout(QWidget *parent = nullptr);
virtual ~VPDialogAbout();
~VPDialogAbout() override;
protected:
virtual void changeEvent(QEvent* event) override;
virtual void showEvent(QShowEvent *event) override;
void changeEvent(QEvent* event) override;
void showEvent(QShowEvent *event) override;
private:
Q_DISABLE_COPY(VPDialogAbout)
// cppcheck-suppress unknownMacro
Q_DISABLE_COPY_MOVE(VPDialogAbout) // NOLINT
Ui::VPDialogAbout *ui;
bool isInitialized;
bool m_isInitialized;
void FontPointSize(QWidget *w, int pointSize);
static void FontPointSize(QWidget *w, int pointSize);
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;
}
//---------------------------------------------------------------------------------------------------------------------
bool VPTransformationOrigon::operator!=(const VPTransformationOrigon &origin) const
auto VPTransformationOrigon::operator!=(const VPTransformationOrigon &origin) const -> bool
{
return !VPTransformationOrigon::operator==(origin);
}

View File

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

View File

@ -39,7 +39,13 @@
#include <QUndoStack>
#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) :
@ -118,13 +124,13 @@ void VPLayout::AddPiece(const VPPiecePtr &piece)
}
//---------------------------------------------------------------------------------------------------------------------
const QUuid &VPLayout::Uuid() const
auto VPLayout::Uuid() const -> const QUuid &
{
return m_uuid;
}
//---------------------------------------------------------------------------------------------------------------------
VPTileFactory *VPLayout::TileFactory() const
auto VPLayout::TileFactory() const -> VPTileFactory *
{
return m_tileFactory;
}
@ -166,7 +172,7 @@ auto VPLayout::WatermarkData() const -> VWatermarkData
data.invalidFile = true;
data.opacity = 20;
data.showImage = true;
data.path = "fake.png";
data.path = QStringLiteral("fake.png");
data.showText = false;
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;
}

View File

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

View File

@ -29,7 +29,6 @@
#include <QtMath>
#include "../vmisc/def.h"
#include "vpsheet.h"
#include "vplayout.h"
#include "../vlayout/vtextmanager.h"
@ -40,7 +39,13 @@
#include <QPainter>
#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
{
@ -207,7 +212,7 @@ void VPPiece::SetPosition(QPointF point)
auto VPPiece::GetPosition() -> QPointF
{
QTransform matrix = GetMatrix();
return QPointF(matrix.dx(), matrix.dy());
return {matrix.dx(), matrix.dy()};
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -30,8 +30,6 @@
#include <QTimer>
#include "vpapplication.h"
#include "../fervor/fvupdater.h"
#include "../vmisc/vsysexits.h"
#include "../vmisc/def.h"
@ -44,7 +42,7 @@
# include "../vmisc/appimage.h"
#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)
/* 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);});
#endif // defined(APPIMAGE) && defined(Q_OS_LINUX)
Q_INIT_RESOURCE(puzzleicon);
Q_INIT_RESOURCE(theme);
Q_INIT_RESOURCE(icon);
Q_INIT_RESOURCE(schema);
Q_INIT_RESOURCE(flags);
Q_INIT_RESOURCE(style);
Q_INIT_RESOURCE(cursor);
Q_INIT_RESOURCE(puzzleicon); // NOLINT
Q_INIT_RESOURCE(theme); // NOLINT
Q_INIT_RESOURCE(icon); // NOLINT
Q_INIT_RESOURCE(schema); // NOLINT
Q_INIT_RESOURCE(flags); // NOLINT
Q_INIT_RESOURCE(style); // NOLINT
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)
VAbstractApplication::WinAttachConsole();
@ -82,5 +80,5 @@ int main(int argc, char *argv[])
}
#endif // defined(APPIMAGE) && defined(Q_OS_LINUX)
return app.exec();
return VPApplication::exec();
}

View File

@ -55,12 +55,19 @@
#include "undocommands/vpundomovepieceonsheet.h"
#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
{
QColor mainColor = Qt::black;
QColor errorColor = Qt::red;
Q_GLOBAL_STATIC_WITH_ARGS(QColor, mainColor, (Qt::black)) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(QColor, errorColor, (Qt::red)) // NOLINT
//---------------------------------------------------------------------------------------------------------------------
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;
}
//---------------------------------------------------------------------------------------------------------------------
inline auto SelectionBrush() -> QBrush
{
return {QColor(255, 160, 160, 60)};
}
} // namespace
//---------------------------------------------------------------------------------------------------------------------
@ -229,7 +242,7 @@ void VPGraphicsPiece::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
GroupMove(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)
{
auto *command = new VPUndoPieceMove(piece, m_stickyTranslateX, m_stickyTranslateY,
allowChangeMerge);
m_allowChangeMerge);
layout->UndoStack()->push(command);
SetStickyPoints(QVector<QPointF>());
@ -261,7 +274,7 @@ void VPGraphicsPiece::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
}
}
allowChangeMerge = false;
m_allowChangeMerge = false;
m_hasStickyPosition = false;
}
}
@ -441,9 +454,6 @@ void VPGraphicsPiece::InitPieceLabel(const QVector<QPointF> &labelShape, const V
//---------------------------------------------------------------------------------------------------------------------
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_cuttingLine = QPainterPath();
m_grainline = QPainterPath();
@ -459,6 +469,29 @@ void VPGraphicsPiece::PaintPiece(QPainter *painter)
}
// 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())
{
QVector<QPointF> seamLinePoints = piece->GetMappedContourPoints();
@ -473,14 +506,17 @@ void VPGraphicsPiece::PaintPiece(QPainter *painter)
if (painter != nullptr)
{
painter->save();
painter->setBrush(piece->IsSelected() ? selectionBrush : noBrush);
painter->setBrush(piece->IsSelected() ? SelectionBrush() : NoBrush());
painter->drawPath(m_seamLine);
painter->restore();
}
}
}
}
// initiliases the cutting line
//---------------------------------------------------------------------------------------------------------------------
void VPGraphicsPiece::PaintCuttingLine(QPainter *painter, const VPPiecePtr &piece)
{
if (piece->IsSeamAllowance() && not piece->IsSeamAllowanceBuiltIn())
{
QVector<QPointF> cuttingLinepoints = piece->GetMappedSeamAllowancePoints();
@ -495,14 +531,17 @@ void VPGraphicsPiece::PaintPiece(QPainter *painter)
if (painter != nullptr)
{
painter->save();
painter->setBrush(piece->IsSelected() ? selectionBrush : noBrush);
painter->setBrush(piece->IsSelected() ? SelectionBrush() : NoBrush());
painter->drawPath(m_cuttingLine);
painter->restore();
}
}
}
}
// initialises the grainline
//---------------------------------------------------------------------------------------------------------------------
void VPGraphicsPiece::PaintGrainline(QPainter *painter, const VPPiecePtr &piece)
{
if(piece->IsGrainlineEnabled())
{
QVector<QPointF> grainLinepoints = piece->GetMappedGrainline();
@ -521,14 +560,17 @@ void VPGraphicsPiece::PaintPiece(QPainter *painter)
// later maybe if it's configurable
// painter->setBrush(blackBrush);
painter->setBrush(noBrush);
painter->setBrush(NoBrush());
painter->drawPath(m_grainline);
painter->restore();
}
}
}
}
// initialises the internal paths
//---------------------------------------------------------------------------------------------------------------------
void VPGraphicsPiece::PaintInternalPaths(QPainter *painter, const VPPiecePtr &piece)
{
QVector<VLayoutPiecePath> internalPaths = piece->GetInternalPaths();
for (const auto& piecePath : internalPaths)
{
@ -545,8 +587,11 @@ void VPGraphicsPiece::PaintPiece(QPainter *painter)
}
m_internalPaths.addPath(path);
}
}
// initialises the passmarks
//---------------------------------------------------------------------------------------------------------------------
void VPGraphicsPiece::PaintPassmarks(QPainter *painter, const VPPiecePtr &piece)
{
QVector<VLayoutPassmark> passmarks = piece->GetMappedPassmarks();
for(auto &passmark : passmarks)
{
@ -560,15 +605,18 @@ void VPGraphicsPiece::PaintPiece(QPainter *painter)
if (painter != nullptr)
{
painter->save();
painter->setBrush(noBrush);
painter->setBrush(NoBrush());
painter->drawPath(passmarkPath);
painter->restore();
}
m_passmarks.addPath(passmarkPath);
}
}
// initialises the place labels (buttons etc)
//---------------------------------------------------------------------------------------------------------------------
void VPGraphicsPiece::PaintPlaceLabels(QPainter *painter, const VPPiecePtr &piece)
{
QVector<VLayoutPlaceLabel> placeLabels = piece->GetMappedPlaceLabels();
for(auto &placeLabel : placeLabels)
{
@ -577,14 +625,18 @@ void VPGraphicsPiece::PaintPiece(QPainter *painter)
if (painter != nullptr)
{
painter->save();
painter->setBrush(noBrush);
painter->setBrush(NoBrush());
painter->drawPath(path);
painter->restore();
}
m_placeLabels.addPath(path);
}
}
//---------------------------------------------------------------------------------------------------------------------
void VPGraphicsPiece::PaintStickyPath(QPainter *painter)
{
if (not m_stickyPoints.isEmpty())
{
m_stickyPath.moveTo(ConstFirst(m_stickyPoints));
@ -600,7 +652,7 @@ void VPGraphicsPiece::PaintPiece(QPainter *painter)
QPen pen = painter->pen();
pen.setStyle(Qt::DashLine);
pen.setColor(mainColor);
pen.setColor(*mainColor);
painter->setPen(pen);
painter->drawPath(m_stickyPath);
@ -648,7 +700,7 @@ void VPGraphicsPiece::GroupMove(const QPointF &pos)
if (pieces.size() == 1)
{
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);
if (layout->LayoutSettings().GetStickyEdges())
@ -672,7 +724,7 @@ void VPGraphicsPiece::GroupMove(const QPointF &pos)
}
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);
}
}
@ -683,13 +735,13 @@ auto VPGraphicsPiece::PieceColor() const -> QColor
VPPiecePtr piece = m_piece.toStrongRef();
if (piece.isNull())
{
return mainColor;
return *mainColor;
}
VPLayoutPtr layout = piece->Layout();
if (layout.isNull())
{
return mainColor;
return *mainColor;
}
bool outOfBound = false;
@ -706,10 +758,16 @@ auto VPGraphicsPiece::PieceColor() const -> QColor
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_rotationStartPoint{};
bool allowChangeMerge{false};
bool m_allowChangeMerge{false};
QVector<QPointF> m_stickyPoints{};
QPainterPath m_stickyPath{};
@ -119,10 +119,19 @@ private:
void InitLabels();
void InitPieceLabel(const QVector<QPointF> &labelShape, const VTextManager &tm);
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);
auto PieceColor() const -> QColor;
auto NoBrush() const -> QBrush;
};
#endif // VPGRAPHICSPIECE_H

View File

@ -40,6 +40,7 @@
#include "../vwidgets/global.h"
#include "../layout/vplayout.h"
#include "../layout/vppiece.h"
#include "../layout/vpsheet.h"
#include "../undocommands/vpundopiecerotate.h"
#include "../undocommands/vpundooriginmove.h"
#include "qgraphicsscene.h"
@ -53,8 +54,8 @@ constexpr qreal penWidth = 2;
const qreal centerRadius1 = 5;
const qreal centerRadius2 = 10;
const QColor defaultColor = Qt::black;
const QColor hoverColor = Qt::green;
Q_GLOBAL_STATIC_WITH_ARGS(const QColor, defaultColor, (Qt::black)) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QColor, hoverColor, (Qt::green)) // NOLINT
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)
: QGraphicsObject(parent),
m_layout(layout),
m_color(defaultColor)
m_color(*defaultColor)
{
SCASSERT(m_layout != nullptr)
setCursor(Qt::OpenHandCursor);
@ -209,14 +210,14 @@ void VPGraphicsTransformationOrigin::mouseReleaseEvent(QGraphicsSceneMouseEvent
//---------------------------------------------------------------------------------------------------------------------
void VPGraphicsTransformationOrigin::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
{
m_color = hoverColor;
m_color = *hoverColor;
QGraphicsObject::hoverEnterEvent(event);
}
//---------------------------------------------------------------------------------------------------------------------
void VPGraphicsTransformationOrigin::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
{
m_color = defaultColor;
m_color = *defaultColor;
QGraphicsObject::hoverEnterEvent(event);
}
@ -419,7 +420,7 @@ void VPGraphicsPieceControls::mousePressEvent(QGraphicsSceneMouseEvent *event)
QGraphicsView *view = ItemView();
if (view != nullptr)
{
setCursor(view->viewport()->cursor());
setCursor(view->viewport()->cursor()); // clazy:exclude=clazy-qt6-deprecated-api-fixes
}
event->ignore();
}
@ -502,7 +503,7 @@ void VPGraphicsPieceControls::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
QGraphicsView *view = ItemView();
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();
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 "scenedef.h"
#include "../layout/vpsheet.h"
#include "../layout/layoutdef.h"
#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0)
#include "../vmisc/defglobal.h"
@ -64,6 +64,7 @@ class VPGraphicsTransformationOrigin : public QGraphicsObject
Q_OBJECT // NOLINT
public:
explicit VPGraphicsTransformationOrigin(const VPLayoutPtr &layout, QGraphicsItem * parent = nullptr);
~VPGraphicsTransformationOrigin() override = default;
auto type() const -> int override {return Type;}
enum { Type = UserType + static_cast<int>(PGraphicsItem::TransformationOrigin)};
@ -86,6 +87,7 @@ protected:
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event) override;
private:
// cppcheck-suppress unknownMacro
Q_DISABLE_COPY_MOVE(VPGraphicsTransformationOrigin) // NOLINT
bool m_originVisible{true};
@ -103,6 +105,7 @@ class VPGraphicsPieceControls : public QGraphicsObject
Q_OBJECT // NOLINT
public:
explicit VPGraphicsPieceControls(const VPLayoutPtr &layout, QGraphicsItem * parent = nullptr);
~VPGraphicsPieceControls() override = default;
auto type() const -> int override {return Type;}
enum { Type = UserType + static_cast<int>(PGraphicsItem::Handles)};

View File

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

View File

@ -34,14 +34,12 @@
#include <QMenu>
#include <QUndoStack>
#include "../vptilefactory.h"
#include "../carousel/vpmimedatapiece.h"
#include "../layout/vplayout.h"
#include "../layout/vpsheet.h"
#include "../layout/vppiece.h"
#include "../vwidgets/vmaingraphicsscene.h"
#include "undocommands/vpundopiecezvaluemove.h"
#include "vptilefactory.h"
#include "vpgraphicspiece.h"
#include "vpgraphicspiececontrols.h"
@ -53,14 +51,21 @@
#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
{
QT_WARNING_PUSH
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
}
@ -82,7 +87,7 @@ VPMainGraphicsView::VPMainGraphicsView(const VPLayoutPtr &layout, QWidget *paren
connect(layout.data(), &VPLayout::ActiveSheetChanged, this, &VPMainGraphicsView::on_ActiveSheetChanged);
auto *restoreOrigin = new QAction(this);
restoreOrigin->setShortcut(restoreOriginShortcut);
restoreOrigin->setShortcut(*restoreOriginShortcut);
connect(restoreOrigin, &QAction::triggered, this, &VPMainGraphicsView::RestoreOrigin);
this->addAction(restoreOrigin);
}
@ -205,91 +210,34 @@ void VPMainGraphicsView::dropEvent(QDropEvent *event)
//---------------------------------------------------------------------------------------------------------------------
void VPMainGraphicsView::keyPressEvent(QKeyEvent *event)
{
if(event->key() == Qt::Key_Backspace || event->key() == Qt::Key_Delete)
{
VPLayoutPtr layout = m_layout.toStrongRef();
if (layout.isNull())
{
return;
}
const bool shiftModifier = (event->modifiers() & Qt::ShiftModifier) != 0U;
const bool controlModifier = (event->modifiers() & Qt::ControlModifier) != 0U;
const bool altModifier = (event->modifiers() & Qt::AltModifier) != 0U;
VPSheetPtr sheet = layout->GetFocusedSheet();
if (sheet.isNull())
switch(event->key())
{
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);
}
}
}
}
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)
case Qt::Key_Backspace:
case Qt::Key_Delete:
RemovePiece();
break;
case Qt::Key_Left:
shiftModifier ? TranslatePiecesOn(-10, 0) : TranslatePiecesOn(-1, 0);
break;
case Qt::Key_Right:
shiftModifier ? TranslatePiecesOn(10, 0) : TranslatePiecesOn(1, 0);
break;
case Qt::Key_Up:
shiftModifier ? TranslatePiecesOn(0, -10) : TranslatePiecesOn(0, -1);
break;
case Qt::Key_Down:
shiftModifier ? TranslatePiecesOn(0, 10) : TranslatePiecesOn(0, 1);
break;
case Qt::Key_BracketLeft:
if(controlModifier)
{
RotatePiecesByAngle(90);
}
else if((event->modifiers() & Qt::AltModifier) != 0U)
else if(altModifier)
{
RotatePiecesByAngle(1);
}
@ -297,14 +245,13 @@ void VPMainGraphicsView::keyPressEvent(QKeyEvent *event)
{
RotatePiecesByAngle(15);
}
}
else if (event->key() == Qt::Key_BracketRight)
{
if((event->modifiers() & Qt::ControlModifier) != 0U)
break;
case Qt::Key_BracketRight:
if(controlModifier)
{
RotatePiecesByAngle(-90);
}
else if((event->modifiers() & Qt::AltModifier) != 0U)
else if(altModifier)
{
RotatePiecesByAngle(-1);
}
@ -312,87 +259,39 @@ void VPMainGraphicsView::keyPressEvent(QKeyEvent *event)
{
RotatePiecesByAngle(-15);
}
}
else if (event->key() == Qt::Key_Home)
{
break;
case Qt::Key_Home:
ZValueMove(static_cast<int>(ML::ZValueMove::Top));
}
else if (event->key() == Qt::Key_PageUp)
{
break;
case Qt::Key_PageUp:
ZValueMove(static_cast<int>(ML::ZValueMove::Up));
}
else if (event->key() == Qt::Key_PageDown)
{
break;
case Qt::Key_PageDown:
ZValueMove(static_cast<int>(ML::ZValueMove::Down));
}
else if (event->key() == Qt::Key_End)
{
break;
case Qt::Key_End:
ZValueMove(static_cast<int>(ML::ZValueMove::Bottom));
break;
default:
break;
}
}
//---------------------------------------------------------------------------------------------------------------------
void VPMainGraphicsView::keyReleaseEvent(QKeyEvent *event)
{
if (event->key() == Qt::Key_Left ||
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)
switch(event->key())
{
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;
}
case Qt::Key_Left:
case Qt::Key_Right:
case Qt::Key_Up:
case Qt::Key_Down:
case Qt::Key_BracketLeft:
case Qt::Key_BracketRight:
MovePiece(event);
break;
default:
break;
}
if (event->key() == Qt::Key_BracketLeft || event->key() == Qt::Key_BracketRight)
@ -440,7 +339,7 @@ void VPMainGraphicsView::contextMenuEvent(QContextMenuEvent *event)
QMenu menu;
QAction *restoreOriginAction = menu.addAction(tr("Restore transformation origin"));
restoreOriginAction->setShortcut(restoreOriginShortcut);
restoreOriginAction->setShortcut(*restoreOriginShortcut);
restoreOriginAction->setEnabled(not sheet.isNull() && sheet->TransformationOrigin().custom);
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)
{

View File

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

View File

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

View File

@ -27,7 +27,13 @@
*************************************************************************/
#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)

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -61,7 +61,7 @@ QT_WARNING_POP
#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
// 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)
{
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()));
exit(V_EX_DATAERR);
}
@ -534,7 +534,7 @@ auto VPApplication::event(QEvent *e) -> bool
// Mac specific).
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();
if(not macFileOpen.isEmpty())
{
@ -670,7 +670,7 @@ auto VPApplication::StartWithFiles(const VPCommandLinePtr &cmd, const QStringLis
cmd.get()->parser.showHelp(V_EX_USAGE);
}
for (const auto &arg : args)
for (const auto &arg : args) // NOLINT(readability-use-anyofallof)
{
NewMainWindow(cmd);
if (not MainWindow()->LoadFile(arg))

View File

@ -31,12 +31,12 @@
#include "../vmisc/literals.h"
#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);
int argSize = parser.positionalArguments().size();
@ -49,7 +49,7 @@ bool VPCommandLine::IsExportEnabled() const
}
//----------------------------------------------------------------------------------------------
QString VPCommandLine::OptionExportFile() const
auto VPCommandLine::OptionExportFile() const -> QString
{
QString path;
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);
}
//--------------------------------------------------------------------------------------------
bool VPCommandLine::IsTestModeEnabled() const
auto VPCommandLine::IsTestModeEnabled() const -> bool
{
const bool r = IsOptionSet(LONG_OPTION_TEST);
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;
}
//--------------------------------------------------------------------------------------------
QStringList VPCommandLine::OptionFileNames() const
auto VPCommandLine::OptionFileNames() const -> QStringList
{
return parser.positionalArguments();
}
//-------------------------------------------------------------------------------------------
bool VPCommandLine::IsNoScalingEnabled() const
auto VPCommandLine::IsNoScalingEnabled() const -> bool
{
return IsOptionSet(LONG_OPTION_NO_HDPI_SCALING);
}
@ -103,9 +103,7 @@ void VPCommandLine::ShowHelp(int exitCode)
}
//----------------------------------------------------------------------------------------------
VPCommandLine::VPCommandLine():
parser(),
isGuiEnabled(false)
VPCommandLine::VPCommandLine()
{
parser.setApplicationDescription(translate("Puzzle", "Valentina's manual layout editor."));
parser.addHelpOption();
@ -116,7 +114,7 @@ VPCommandLine::VPCommandLine():
}
//-------------------------------------------------------------------------------------------
VPCommandLinePtr VPCommandLine::Instance()
auto VPCommandLine::Instance() -> VPCommandLinePtr
{
VPCommandLine::ProcessInstance(instance, QCoreApplication::arguments());
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);
}
//-------------------------------------------------------------------------------------------
QString VPCommandLine::OptionValue(const QString &option) const
auto VPCommandLine::OptionValue(const QString &option) const -> QString
{
return parser.value(option);
}
//--------------------------------------------------------------------------------------------
QStringList VPCommandLine::OptionValues(const QString &option) const
auto VPCommandLine::OptionValues(const QString &option) const -> QStringList
{
return parser.values(option);
}

View File

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

View File

@ -29,41 +29,41 @@
#include <QStringList>
const QString LONG_OPTION_EXPORT_FILE = QStringLiteral("exportFile");
const QString SINGLE_OPTION_EXPORT_FILE = QStringLiteral("e");
const QString LONG_OPTION_EXPORT_FILE = QStringLiteral("exportFile"); // NOLINT
const QString SINGLE_OPTION_EXPORT_FILE = QStringLiteral("e"); // NOLINT
const QString LONG_OPTION_TEST = QStringLiteral("test");
const QString SINGLE_OPTION_TEST = QStringLiteral("t");
const QString LONG_OPTION_TEST = QStringLiteral("test"); // NOLINT
const QString SINGLE_OPTION_TEST = QStringLiteral("t"); // NOLINT
const QString LONG_OPTION_RAW_LAYOUT = QStringLiteral("rawLayout");
const QString SINGLE_OPTION_RAW_LAYOUT = QStringLiteral("r");
const QString LONG_OPTION_RAW_LAYOUT = QStringLiteral("rawLayout"); // NOLINT
const QString SINGLE_OPTION_RAW_LAYOUT = QStringLiteral("r"); // NOLINT
const QString LONG_OPTION_EXP2FORMAT = QStringLiteral("format");
const QString SINGLE_OPTION_EXP2FORMAT = QStringLiteral("f");
const QString LONG_OPTION_EXP2FORMAT = QStringLiteral("format"); // NOLINT
const QString SINGLE_OPTION_EXP2FORMAT = QStringLiteral("f"); // NOLINT
const QString LONG_OPTION_BINARYDXF = QStringLiteral("bdxf");
const QString LONG_OPTION_TEXT2PATHS = QStringLiteral("text2paths");
const QString LONG_OPTION_BINARYDXF = QStringLiteral("bdxf"); // NOLINT
const QString LONG_OPTION_TEXT2PATHS = QStringLiteral("text2paths"); // NOLINT
const QString LONG_OPTION_CROP_LENGTH = QStringLiteral("crop");
const QString SINGLE_OPTION_CROP_LENGTH = QStringLiteral("c");
const QString LONG_OPTION_CROP_LENGTH = QStringLiteral("crop"); // NOLINT
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_LEFT_MARGIN = QStringLiteral("tiledlmargin");
const QString LONG_OPTION_TILED_PDF_RIGHT_MARGIN = QStringLiteral("tiledrmargin");
const QString LONG_OPTION_TILED_PDF_TOP_MARGIN = QStringLiteral("tiledtmargin");
const QString LONG_OPTION_TILED_PDF_BOTTOM_MARGIN = QStringLiteral("tiledbmargin");
const QString LONG_OPTION_TILED_PDF_LANDSCAPE = QStringLiteral("tiledLandscape");
const QString LONG_OPTION_TILED_PDF_PAGE_TEMPLATE = QStringLiteral("tiledPageformat"); // NOLINT
const QString LONG_OPTION_TILED_PDF_LEFT_MARGIN = QStringLiteral("tiledlmargin"); // NOLINT
const QString LONG_OPTION_TILED_PDF_RIGHT_MARGIN = QStringLiteral("tiledrmargin"); // NOLINT
const QString LONG_OPTION_TILED_PDF_TOP_MARGIN = QStringLiteral("tiledtmargin"); // NOLINT
const QString LONG_OPTION_TILED_PDF_BOTTOM_MARGIN = QStringLiteral("tiledbmargin"); // NOLINT
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.
* @return list with all command line keys
*/
QStringList AllKeys()
auto AllKeys() -> QStringList
{
return QStringList
return
{
LONG_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_LANDSCAPE;
QStringList AllKeys();
auto AllKeys() -> QStringList;
#endif // VPCOMMANDS_H

File diff suppressed because it is too large Load Diff

View File

@ -37,11 +37,8 @@
#include "carousel/vpcarrousel.h"
#include "scene/vpmaingraphicsview.h"
#include "layout/vplayout.h"
#include "layout/vppiece.h"
#include "../vlayout/vlayoutpiece.h"
#include "vptilefactory.h"
#include "vpcommandline.h"
#include "../vlayout/vlayoutdef.h"
#include "../vwidgets/vabstractmainwindow.h"
#include "../vmisc/vlockguard.h"
#include "../vlayout/dialogs/vabstractlayoutdialog.h"
@ -59,13 +56,13 @@ class WatermarkWindow;
class VPMainWindow : public VAbstractMainWindow
{
Q_OBJECT
Q_OBJECT // NOLINT
public:
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.
@ -73,7 +70,7 @@ public:
* @param path path to layout
* @return true if success
*/
bool LoadFile(QString path);
auto LoadFile(const QString& path) -> bool;
void LayoutWasSaved(bool saved);
void SetCurrentFile(const QString &fileName);
@ -83,7 +80,7 @@ public:
* @param path path to layout file
* @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
@ -105,12 +102,12 @@ public slots:
*/
void on_actionNew_triggered();
virtual void ShowToolTip(const QString &toolTip) override;
void ShowToolTip(const QString &toolTip) override;
protected:
virtual void closeEvent(QCloseEvent *event) override;
virtual void changeEvent(QEvent* event) override;
virtual QStringList RecentFileList() const override;
void closeEvent(QCloseEvent *event) override;
void changeEvent(QEvent* event) override;
auto RecentFileList() const -> QStringList override;
private slots:
/**
@ -125,14 +122,14 @@ private slots:
* triggered.
* 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
* is triggered.
* 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
@ -291,8 +288,14 @@ private slots:
void SetDefaultGUILanguage();
void HorizontalScaleChanged(double value);
void VerticalScaleChanged(double value);
void LayoutWarningPiecesSuperposition_toggled(bool checked);
void LayoutWarningPiecesOutOfBound_toggled(bool checked);
private:
Q_DISABLE_COPY(VPMainWindow)
Q_DISABLE_COPY_MOVE(VPMainWindow) // NOLINT
Ui::VPMainWindow *ui;
VPCarrousel *m_carrousel{nullptr};
@ -336,6 +339,14 @@ private:
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 ...)
*/
@ -356,6 +367,9 @@ private:
*/
void InitPropertyTabCurrentSheet();
void InitPaperSizeData(const QString &suffix);
void InitMarginsData(const QString &suffix);
/**
* @brief InitPropertyTabLayout Inits the layout tab in the properties
*/
@ -432,9 +446,9 @@ private:
auto TranslateUnit() const -> Unit;
auto LayoutUnit() const -> Unit;
QSizeF Template(VAbstractLayoutDialog::PaperSizeTemplate t) const;
QSizeF SheetTemplate() const;
QSizeF TileTemplate() const;
auto Template(VAbstractLayoutDialog::PaperSizeTemplate t) const -> QSizeF;
auto SheetTemplate() const -> QSizeF;
auto TileTemplate() const -> QSizeF;
void SheetSize(const QSizeF &size);
void TileSize(const QSizeF &size);
@ -458,12 +472,12 @@ private:
void RotatePiecesToGrainline();
void ExportData(const VPExportData &data);
void ExportApparelLayout(const VPExportData &data, const QVector<VLayoutPiece> &details, const QString &name,
const QSize &size) const;
static void ExportApparelLayout(const VPExportData &data, const QVector<VLayoutPiece> &details, const QString &name,
const QSize &size) ;
void ExportFlatLayout(const VPExportData &data);
void ExportScene(const VPExportData &data);
void ExportUnifiedPdfFile(const VPExportData &data);
void GenerateUnifiedPdfFile(const VPExportData &data, const QString &name);
static void ExportUnifiedPdfFile(const VPExportData &data);
static void GenerateUnifiedPdfFile(const VPExportData &data, const QString &name);
void ExportPdfTiledFile(const VPExportData &data);
void GeneratePdfTiledFile(const VPSheetPtr &sheet, bool showTilesScheme, QPainter *painter,
const QSharedPointer<QPrinter> &printer, bool &firstPage);
@ -473,14 +487,28 @@ private:
void OpenWatermark(const QString &path = QString());
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 CheckPiecesOutOfBound(const VPPiecePtr &piece, bool &outOfBoundChecked) -> bool;
auto CheckSuperpositionOfPieces(const VPPiecePtr &piece, bool &pieceSuperpositionChecked) -> bool;
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);
auto PrepareLayoutTilePages(const QList<VPSheetPtr> &sheets) -> QVector<VPLayoutPrinterPage>;
auto PrintLayoutTiledSheetPage(QPrinter *printer, QPainter &painter, const VPLayoutPrinterPage &page,
bool firstPage) -> bool;
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

View File

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

View File

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

View File

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

View File

@ -31,18 +31,22 @@
#include <QXmlStreamReader>
#include "../ifc/xml/vabstractconverter.h"
#include "../layout/vplayout.h"
#include "../layout/vppiece.h"
#include "../layout/layoutdef.h"
#include "../vmisc/defglobal.h"
#include <QLoggingCategory>
Q_DECLARE_LOGGING_CATEGORY(MLReader)
Q_DECLARE_LOGGING_CATEGORY(MLReader) // NOLINT
struct TextLine;
struct VLayoutPassmark;
struct VLayoutPlaceLabel;
class VLayoutPiecePath;
class VTextManager;
class VPLayoutFileReader : public QXmlStreamReader
{
Q_DECLARE_TR_FUNCTIONS(VPLayoutFileReader)
Q_DECLARE_TR_FUNCTIONS(VPLayoutFileReader) // NOLINT
public:
VPLayoutFileReader()=default;
~VPLayoutFileReader()=default;
@ -50,7 +54,8 @@ public:
auto ReadFile(const VPLayoutPtr &layout, QFile *file) -> bool;
private:
Q_DISABLE_COPY(VPLayoutFileReader)
// cppcheck-suppress unknownMacro
Q_DISABLE_COPY_MOVE(VPLayoutFileReader) // NOLINT
void ReadLayout(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
{
QStringList path;
path.reserve(pathPoints.size());
for (auto point : pathPoints)
{
@ -96,6 +97,7 @@ auto RectToString(const QRectF &r) -> QString
auto MarkerShapeToString(const PlaceLabelImg &shape) -> QString
{
QStringList s;
s.reserve(shape.size());
for (const auto& path : shape)
{
s.append(PathToString(path));
@ -113,6 +115,7 @@ auto LineToString(const QLineF &line) -> QString
auto LinesToString(const QVector<QLineF> &lines) -> QString
{
QStringList l;
l.reserve(lines.size());
for (auto line : lines)
{
l.append(LineToString(line));

View File

@ -36,6 +36,7 @@
#include <ciso646>
#include "../vmisc/literals.h"
#include "../vmisc/defglobal.h"
#include "../layout/layoutdef.h"
class VPLayout;
@ -48,7 +49,7 @@ class VTextManager;
class VPLayoutFileWriter : public QXmlStreamWriter
{
Q_DECLARE_TR_FUNCTIONS(VPLayoutFileWriter)
Q_DECLARE_TR_FUNCTIONS(VPLayoutFileWriter) // NOLINT
public:
VPLayoutFileWriter()= default;
~VPLayoutFileWriter()= default;
@ -56,6 +57,8 @@ public:
void WriteFile(const VPLayoutPtr &layout, QIODevice *file);
private:
// cppcheck-suppress unknownMacro
Q_DISABLE_COPY_MOVE(VPLayoutFileWriter) // NOLINT
void WriteLayout(const VPLayoutPtr &layout);
void WriteLayoutProperties(const VPLayoutPtr &layout);
void WriteSheets(const VPLayoutPtr &layout);
@ -73,7 +76,7 @@ private:
void SetAttribute(const QString &name, const T &value);
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>
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>
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));
}

View File

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

View File

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

View File

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

View File

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

View File

@ -185,35 +185,35 @@ void TapePreferencesPathPage::InitTable()
{
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());
ui->pathTable->setItem(0, 1, item);
}
{
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());
ui->pathTable->setItem(1, 1, item);
}
{
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());
ui->pathTable->setItem(2, 1, item);
}
{
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());
ui->pathTable->setItem(3, 1, item);
}
{
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());
ui->pathTable->setItem(4, 1, item);
}

View File

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

View File

@ -28,8 +28,8 @@
#include "dialogabouttape.h"
#include "ui_dialogabouttape.h"
#include "../version.h"
#include "../vmisc/def.h"
#include "../vmisc/projectversion.h"
#include "../fervor/fvupdater.h"
#include <QDate>
@ -43,7 +43,7 @@
DialogAboutTape::DialogAboutTape(QWidget *parent)
:QDialog(parent),
ui(new Ui::DialogAboutTape),
isInitialized(false)
m_isInitialized(false)
{
ui->setupUi(this);
@ -52,7 +52,8 @@ DialogAboutTape::DialogAboutTape(QWidget *parent)
RetranslateUi();
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");
}
@ -100,7 +101,7 @@ void DialogAboutTape::showEvent(QShowEvent *event)
return;
}
if (isInitialized)
if (m_isInitialized)
{
return;
}
@ -109,7 +110,7 @@ void DialogAboutTape::showEvent(QShowEvent *event)
setMaximumSize(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()
{
ui->label_Tape_Version->setText(QString("Tape %1").arg(APP_VERSION_STR));
ui->labelBuildRevision->setText(tr("Build revision: %1").arg(BUILD_REVISION));
ui->label_Tape_Version->setText(QStringLiteral("Tape %1").arg(APP_VERSION_STR));
ui->labelBuildRevision->setText(tr("Build revision: %1").arg(QStringLiteral(BUILD_REVISION)));
ui->label_QT_Version->setText(buildCompatibilityString());
const QDate date = QLocale::c().toDate(QString(__DATE__).simplified(), QLatin1String("MMM d yyyy"));
ui->label_Tape_Built->setText(tr("Built on %1 at %2").arg(date.toString(), __TIME__));
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(), QStringLiteral(__TIME__)));
ui->label_Legal_Stuff->setText(QApplication::translate("InternalStrings",
"The program is provided AS IS with NO WARRANTY OF ANY "
"KIND, INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY "
"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 "../vmisc/defglobal.h"
namespace Ui
{
class DialogAboutTape;
@ -38,22 +40,23 @@ namespace Ui
class DialogAboutTape : public QDialog
{
Q_OBJECT
Q_OBJECT // NOLINT
public:
explicit DialogAboutTape(QWidget *parent = nullptr);
virtual ~DialogAboutTape();
~DialogAboutTape() override;
protected:
virtual void changeEvent(QEvent* event) override;
virtual void showEvent(QShowEvent *event) override;
void changeEvent(QEvent* event) override;
void showEvent(QShowEvent *event) override;
private:
Q_DISABLE_COPY(DialogAboutTape)
// cppcheck-suppress unknownMacro
Q_DISABLE_COPY_MOVE(DialogAboutTape) // NOLINT
Ui::DialogAboutTape *ui;
bool isInitialized;
bool m_isInitialized;
void FontPointSize(QWidget *w, int pointSize);
static void FontPointSize(QWidget *w, int pointSize);
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;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -29,17 +29,13 @@
#include "dialognewmeasurements.h"
#include "ui_dialognewmeasurements.h"
#include "../vpatterndb/variables/vmeasurement.h"
#include "../vtapesettings.h"
#include "../mapplication.h"
#include <QShowEvent>
//---------------------------------------------------------------------------------------------------------------------
DialogNewMeasurements::DialogNewMeasurements(QWidget *parent)
:QDialog(parent),
ui(new Ui::DialogNewMeasurements),
isInitialized(false)
m_isInitialized(false)
{
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());
}
//---------------------------------------------------------------------------------------------------------------------
Unit DialogNewMeasurements::MUnit() const
auto DialogNewMeasurements::MUnit() const -> Unit
{
return static_cast<Unit>(ui->comboBoxUnit->currentData().toInt());
}
@ -89,7 +85,7 @@ void DialogNewMeasurements::showEvent(QShowEvent *event)
return;
}
if (isInitialized)
if (m_isInitialized)
{
return;
}
@ -98,7 +94,7 @@ void DialogNewMeasurements::showEvent(QShowEvent *event)
setMaximumSize(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
{
Q_OBJECT
Q_OBJECT // NOLINT
public:
explicit DialogNewMeasurements(QWidget *parent = nullptr);
~DialogNewMeasurements();
~DialogNewMeasurements() override;
MeasurementsType Type() const;
Unit MUnit() const;
auto Type() const -> MeasurementsType;
auto MUnit() const -> Unit;
protected:
virtual void changeEvent(QEvent* event) override;
virtual void showEvent(QShowEvent *event) override;
void changeEvent(QEvent* event) override;
void showEvent(QShowEvent *event) override;
private:
Q_DISABLE_COPY(DialogNewMeasurements)
// cppcheck-suppress unknownMacro
Q_DISABLE_COPY_MOVE(DialogNewMeasurements) // NOLINT
Ui::DialogNewMeasurements *ui;
bool isInitialized;
bool m_isInitialized;
void InitMTypes();
void InitUnits();

View File

@ -76,6 +76,53 @@ auto FilterByMaximum(const QVector<qreal> &base, qreal restriction) -> QVector<q
}
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
//---------------------------------------------------------------------------------------------------------------------
@ -299,57 +346,50 @@ void DialogRestrictDimension::MaxRestrictionChanged()
void DialogRestrictDimension::CellContextMenu(QPoint 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;
QString coordinates;
MeasurementDimension_p dimension;
if (m_restrictionType == RestrictDimension::First)
{
if (not m_dimensions.empty())
{
columnValue = m_dimensions.at(0)->ValidBases().at(item->column());
coordinates = QChar('0');
}
else
if (m_dimensions.empty())
{
return;
}
columnValue = m_dimensions.at(0)->ValidBases().at(item->column());
coordinates = QChar('0');
}
else if (m_restrictionType == RestrictDimension::Second)
{
if (m_dimensions.size() >= 2)
if (m_dimensions.size() < 2)
{
return;
}
dimension = m_dimensions.at(1);
columnValue = dimension->ValidBases().at(item->column());
qreal base1 = m_dimensions.at(0)->ValidBases().at(item->row());
coordinates = VMeasurement::CorrectionHash(base1);
}
else
else if (m_restrictionType == RestrictDimension::Third)
{
if (m_dimensions.size() < 3)
{
return;
}
}
else if (m_restrictionType == RestrictDimension::Third)
{
if (m_dimensions.size() >= 3)
{
dimension = m_dimensions.at(2);
columnValue = dimension->ValidBases().at(item->column());
qreal base1 = ui->comboBoxDimensionA->currentData().toDouble();
qreal base2 = m_dimensions.at(1)->ValidBases().at(item->row());
coordinates = VMeasurement::CorrectionHash(base1, base2);
}
else
{
return;
}
}
else
{
return;
}
VDimensionRestriction restriction = m_restrictions.value(coordinates);
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 (dimension != nullptr)
if (dimension.isNull())
{
return;
}
qreal min = restriction.GetMin();
if (qFuzzyIsNull(min))
{
@ -374,11 +417,6 @@ void DialogRestrictDimension::CellContextMenu(QPoint pos)
actionExclude->setEnabled(columnValue >= min && columnValue <= max);
}
else
{
return;
}
}
QAction *selectedAction = menu->exec(ui->tableWidget->viewport()->mapToGlobal(pos));
if (selectedAction == actionExclude)
@ -398,7 +436,6 @@ void DialogRestrictDimension::CellContextMenu(QPoint pos)
m_restrictions[coordinates] = restriction;
}
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogRestrictDimension::InitDimensionsBaseValues()
@ -611,14 +648,9 @@ void DialogRestrictDimension::AddCell(int row, int column, qreal rowValue, qreal
if (m_restrictionType == RestrictDimension::First)
{
VDimensionRestriction restriction = m_restrictions.value(QChar('0'));
if (restriction.GetExcludeValues().contains(columnValue))
{
item->setIcon(QIcon(QStringLiteral("://icon/24x24/close.png")));
}
else
{
item->setIcon(QIcon(QStringLiteral("://icon/24x24/star.png")));
}
item->setIcon(QIcon(restriction.GetExcludeValues().contains(columnValue)
? QStringLiteral("://icon/24x24/close.png")
: QStringLiteral("://icon/24x24/star.png")));
}
else
{
@ -656,47 +688,8 @@ void DialogRestrictDimension::AddCell(int row, int column, qreal rowValue, qreal
qreal min = INT32_MIN;
qreal max = INT32_MAX;
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();
}
}
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);
}
InitMinMax(min, max, dimension, bases, restriction);
SetCellIcon(item, validRows, rowValue, columnValue, restriction, min, max);
}
// 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,
const MeasurementDimension_p &dimension) const -> QStringList
auto DialogRestrictDimension::FillDimensionXBases(const QVector<qreal> &bases,
const MeasurementDimension_p &dimension) -> QStringList
{
const bool showUnits = dimension->IsBodyMeasurement() || dimension->Type() == MeasurementDimension::X;
const QString units = showUnits ? UnitsToStr(dimension->Units(), true) : QString();
@ -794,8 +787,6 @@ auto DialogRestrictDimension::DimensionLabels(const QVector<qreal> &bases,
QStringList labels;
if (dimension->Type() == MeasurementDimension::X)
{
for(auto base : bases)
{
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));
}
}
return labels;
}
else if (dimension->Type() == MeasurementDimension::Y)
//---------------------------------------------------------------------------------------------------------------------
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)
{
if (dimensionLabels.contains(base) && not dimensionLabels.value(base).isEmpty())
@ -828,9 +830,20 @@ auto DialogRestrictDimension::DimensionLabels(const QVector<qreal> &bases,
}
}
}
return labels;
}
else if (dimension->Type() == MeasurementDimension::W || dimension->Type() == MeasurementDimension::Z)
//---------------------------------------------------------------------------------------------------------------------
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)
{
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));
}
}
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;

View File

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

View File

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

View File

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

View File

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

View File

@ -26,10 +26,7 @@
**
*************************************************************************/
#include "tmainwindow.h"
#include "mapplication.h"
#include "../fervor/fvupdater.h"
#include "../vmisc/vsysexits.h"
#include <QMessageBox> // For QT_REQUIRE_VERSION
#include <QTimer>
@ -43,7 +40,7 @@
# include "../vmisc/appimage.h"
#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)
/* 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);});
#endif // defined(APPIMAGE) && defined(Q_OS_LINUX)
Q_INIT_RESOURCE(tapeicon);
Q_INIT_RESOURCE(theme);
Q_INIT_RESOURCE(icon);
Q_INIT_RESOURCE(schema);
Q_INIT_RESOURCE(flags);
Q_INIT_RESOURCE(style);
Q_INIT_RESOURCE(tapeicon); // NOLINT
Q_INIT_RESOURCE(theme); // NOLINT
Q_INIT_RESOURCE(icon); // NOLINT
Q_INIT_RESOURCE(schema); // NOLINT
Q_INIT_RESOURCE(flags); // NOLINT
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)
VAbstractApplication::WinAttachConsole();
@ -80,5 +77,5 @@ int main(int argc, char *argv[])
}
#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/vexceptionwrongid.h"
#include "../vmisc/vsysexits.h"
#include "../vmisc/projectversion.h"
#if QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
#include "../vmisc/diagnostic.h"
@ -357,7 +358,7 @@ auto MApplication::notify(QObject *receiver, QEvent *event) -> bool
catch (const VExceptionToolWasDeleted &e)
{
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()));
exit(V_EX_DATAERR);
}
@ -473,7 +474,7 @@ void MApplication::ActivateDarkMode()
{
f.open(QFile::ReadOnly | QFile::Text);
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).
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();
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
{
Q_OBJECT
Q_OBJECT // NOLINT
public:
explicit TMainWindow(QWidget *parent = nullptr);
virtual ~TMainWindow() override;
~TMainWindow() override;
QString CurrentFile() const;
auto CurrentFile() const -> QString;
void RetranslateTable();
bool SetDimensionABase(int base);
bool SetDimensionBBase(int base);
bool SetDimensionCBase(int base);
auto SetDimensionABase(int base) -> bool;
auto SetDimensionBBase(int base) -> bool;
auto SetDimensionCBase(int base) -> bool;
void SetPUnit(Unit unit);
bool LoadFile(const QString &path);
auto LoadFile(const QString &path) -> bool;
void UpdateWindowTitle();
protected:
virtual void closeEvent(QCloseEvent *event) override;
virtual void changeEvent(QEvent* event) override;
virtual bool eventFilter(QObject *object, QEvent *event) override;
virtual void ExportToCSVData(const QString &fileName, bool withHeader, int mib,
const QChar &separator) final;
virtual QStringList RecentFileList() const override;
void closeEvent(QCloseEvent *event) override;
void changeEvent(QEvent* event) override;
auto eventFilter(QObject *object, QEvent *event) -> bool override;
void ExportToCSVData(const QString &fileName, bool withHeader, int mib, const QChar &separator) final;
auto RecentFileList() const -> QStringList override;
private slots:
void FileNew();
@ -84,8 +83,8 @@ private slots:
void Preferences();
void ToolBarStyles();
bool FileSave();
bool FileSaveAs();
bool FileSave(); // NOLINT(modernize-use-trailing-return-type)
bool FileSaveAs(); // NOLINT(modernize-use-trailing-return-type)
void AboutToShowWindowMenu();
void ShowWindow() const;
void ImportDataFromCSV();
@ -150,34 +149,48 @@ private slots:
void SetDefaultGUILanguage();
private:
Q_DISABLE_COPY(TMainWindow)
// cppcheck-suppress unknownMacro
Q_DISABLE_COPY_MOVE(TMainWindow) // NOLINT
Ui::TMainWindow *ui;
VMeasurements *m{nullptr};
VContainer *data{nullptr};
Unit mUnit{Unit::Cm};
Unit pUnit{Unit::Cm};
MeasurementsType mType{MeasurementsType::Individual};
qreal currentDimensionA{0};
qreal currentDimensionB{0};
qreal currentDimensionC{0};
QString curFile{};
QComboBox *gradationDimensionA{nullptr};
QComboBox *gradationDimensionB{nullptr};
QComboBox *gradationDimensionC{nullptr};
QComboBox *comboBoxUnits{nullptr};
int formulaBaseHeight;
QSharedPointer<VLockGuard<char>> lock{nullptr};
VMeasurements *m_m{nullptr};
VContainer *m_data{nullptr};
Unit m_mUnit{Unit::Cm};
Unit m_pUnit{Unit::Cm};
MeasurementsType m_mType{MeasurementsType::Individual};
qreal m_currentDimensionA{0};
qreal m_currentDimensionB{0};
qreal m_currentDimensionC{0};
QString m_curFile{};
QComboBox *m_gradationDimensionA{nullptr};
QComboBox *m_gradationDimensionB{nullptr};
QComboBox *m_gradationDimensionC{nullptr};
QComboBox *m_comboBoxUnits{nullptr};
int m_formulaBaseHeight;
QSharedPointer<VLockGuard<char>> m_lock{nullptr};
QSharedPointer<VTableSearch> m_search{};
QLabel *labelGradationDimensionA{nullptr};
QLabel *labelGradationDimensionB{nullptr};
QLabel *labelGradationDimensionC{nullptr};
QLabel *labelPatternUnit{nullptr};
bool isInitialized{false};
bool mIsReadOnly{false};
QTimer *gradation;
QLabel *m_labelGradationDimensionA{nullptr};
QLabel *m_labelGradationDimensionB{nullptr};
QLabel *m_labelGradationDimensionC{nullptr};
QLabel *m_labelPatternUnit{nullptr};
bool m_isInitialized{false};
bool m_mIsReadOnly{false};
QTimer *m_gradation;
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 InitWindow();
@ -191,7 +204,7 @@ private:
void InitPatternUnits();
void InitComboBoxUnits();
void InitMeasurementUnits();
void InitGender(QComboBox *gender);
static void InitGender(QComboBox *gender);
void InitMeasurementDimension();
void InitSearch();
@ -203,24 +216,25 @@ private:
void ShowNewMData(bool fresh);
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 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);
QTableWidgetItem* AddSeparatorCell(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 *;
auto AddSeparatorCell(const QString &text, int row, int column, int aligment, bool ok = true) -> QTableWidgetItem*;
void RefreshData(bool freshCall = false);
void RefreshTable(bool freshCall = false);
void RefreshMeasurementData(const QSharedPointer<VMeasurement> &meash, qint32 currentRow);
QString GetCustomName() const;
QString ClearCustomName(const QString &name) const;
auto GetCustomName() const -> QString;
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 Open(const QString &pathTo, const QString &filter);
@ -232,11 +246,11 @@ private:
void ReadSettings();
void WriteSettings();
QStringList FilterMeasurements(const QStringList &mNew, const QStringList &mFilter);
static auto FilterMeasurements(const QStringList &mNew, const QStringList &mFilter) -> QStringList;
void UpdatePatternUnit();
bool LoadFromExistingFile(const QString &path);
auto LoadFromExistingFile(const QString &path) -> bool;
void CreateWindowMenu(QMenu *menu);
@ -245,12 +259,14 @@ private:
void HackDimensionBaseValue();
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 RefreshDataAfterImport();
void ImportIndividualMeasurements(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();
@ -258,9 +274,9 @@ private:
void SetDimensionBases();
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

View File

@ -29,11 +29,9 @@
#ifndef VERSION_H
#define VERSION_H
#include "../../libs/vmisc/projectversion.h"
#define VER_INTERNALNAME_STR "Tape"
#define VER_ORIGINALFILENAME_STR "tape.exe"
#define VER_PRODUCTNAME_STR "Tape"
#define VER_FILEDESCRIPTION_STR "Valentina's measurements editor."
#define VER_INTERNALNAME_STR "Tape" // NOLINT(cppcoreguidelines-macro-usage)
#define VER_ORIGINALFILENAME_STR "tape.exe" // NOLINT(cppcoreguidelines-macro-usage)
#define VER_PRODUCTNAME_STR "Tape" // NOLINT(cppcoreguidelines-macro-usage)
#define VER_FILEDESCRIPTION_STR "Valentina's measurements editor." // NOLINT(cppcoreguidelines-macro-usage)
#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(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
{
Q_OBJECT
Q_OBJECT // NOLINT
public:
explicit VLitePattern(QObject *parent = nullptr);
~VLitePattern() override = default;
virtual void CreateEmptyFile() override;
void CreateEmptyFile() override;
virtual void IncrementReferens(quint32 id) const override;
virtual void DecrementReferens(quint32 id) const override;
void IncrementReferens(quint32 id) const override;
void DecrementReferens(quint32 id) const override;
virtual QString GenerateLabel(const LabelType &type, const QString &reservedName = QString())const override;
virtual QString GenerateSuffix() const override;
auto GenerateLabel(const LabelType &type, const QString &reservedName = QString())const -> QString 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:
virtual void LiteParseTree(const Document &parse) override;
void LiteParseTree(const Document &parse) override;
private:
Q_DISABLE_COPY(VLitePattern)
Q_DISABLE_COPY_MOVE(VLitePattern) // NOLINT
};
#endif // VLITEPATTERN_H

View File

@ -36,15 +36,15 @@
namespace
{
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingDataBaseGeometry, (QLatin1String("database/geometry")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchHistoryTape, (QLatin1String("searchHistory/tape")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingDataBaseGeometry, (QLatin1String("database/geometry"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchHistoryTape, (QLatin1String("searchHistory/tape"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsTapeUseUnicodeProperties,
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsTapeUseUnicodeProperties, // NOLINT
(QLatin1String("searchOptions/tapeUseUnicodeProperties")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsTapeWholeWord,
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsTapeWholeWord, // NOLINT
(QLatin1String("searchOptions/tapeWholeWord")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsTapeRegexp, (QLatin1String("searchOptions/tapeRegexp")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsTapeMatchCase,
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsTapeRegexp, (QLatin1String("searchOptions/tapeRegexp"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsTapeMatchCase, // NOLINT
(QLatin1String("searchOptions/tapeMatchCase")))
} // 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();
}

View File

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

View File

@ -37,6 +37,7 @@
#include "../qmuparser/qmuparsererror.h"
#include "../mainwindow.h"
#include "../vmisc/qt_dispatch/qt_dispatch.h"
#include "../vmisc/vsysexits.h"
#include "vvalentinasettings.h"
#include <QtDebug>
@ -66,7 +67,7 @@ namespace
{
auto AppFilePath(const QString &appName) -> QString
{
QString appNameExe = appName;
QString appNameExe = appName; // NOLINT(performance-unnecessary-copy-initialization)
#ifdef Q_OS_WIN
appNameExe += ".exe";
#endif
@ -417,7 +418,7 @@ auto VApplication::notify(QObject *receiver, QEvent *event) -> bool
catch (const VExceptionToolWasDeleted &e)
{
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()));
exit(V_EX_DATAERR);
}
@ -469,7 +470,7 @@ void VApplication::ActivateDarkMode()
{
f.open(QFile::ReadOnly | QFile::Text);
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")));
QDir::setCurrent(LogDirPath());
// Restore working directory
auto restore = qScopeGuard([workingDirectory] { QDir::setCurrent(workingDirectory); });
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");
for (const auto &fn : allFiles)
{
@ -583,13 +591,6 @@ void VApplication::ClearOldLogs()
}
}
}
else
{
qCDebug(vApp, "There are no old logs.");
}
QDir::setCurrent(workingDirectory); // Restore working directory
}
//---------------------------------------------------------------------------------------------------------------------
void VApplication::InitOptions()

View File

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

View File

@ -30,36 +30,35 @@
#include "../dialogs/dialoglayoutsettings.h"
#include "../dialogs/dialogsavelayout.h"
#include "../ifc/xml/vdomdocument.h"
#include "../vformat/vmeasurements.h"
#include "../vmisc/commandoptions.h"
#include "../vmisc/vsysexits.h"
#include "vvalentinasettings.h"
#include "../vmisc/dialogs/dialogexporttocsv.h"
#include "../vlayout/vlayoutgenerator.h"
#include "../vpatterndb/variables/vmeasurement.h"
#include <QDebug>
#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
{
//---------------------------------------------------------------------------------------------------------------------
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));
}
//---------------------------------------------------------------------------------------------------------------------
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));
}
} // anonymous namespace
//---------------------------------------------------------------------------------------------------------------------
VCommandLine::VCommandLine() : parser(), isGuiEnabled(false)
VCommandLine::VCommandLine()
{
parser.setApplicationDescription(translate("VCommandLine", "Pattern making program."));
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;
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
VLayoutGeneratorPtr res(new VLayoutGenerator());
DialogLayoutSettings diag(res.get(), nullptr, true);
{
//just anonymous namespace ...don' like to have a,b,c,d everywhere defined
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);
}
}
{
//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."));
}
TestPageformat();
TestGapWidth();
TestMargins();
// if present units MUST be set before any other to keep conversions correct
if (!diag.SelectTemplate(OptPaperSize()))
@ -234,57 +166,7 @@ VLayoutGeneratorPtr VCommandLine::DefaultGenerator() const
diag.SetIgnoreAllFields(true);
}
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);
}
diag.SetFields(margins);
diag.SetFields(ParseMargins(diag));
diag.SetFollowGrainline(IsOptionSet(LONG_OPTION_FOLLOW_GRAINLINE));
diag.SetManualPriority(IsOptionSet(LONG_OPTION_MANUAL_PRIORITY));
diag.SetNestQuantity(IsOptionSet(LONG_OPTION_NEST_QUANTITY));
@ -296,8 +178,8 @@ VLayoutGeneratorPtr VCommandLine::DefaultGenerator() const
return res;
}
//------------------------------------------------------------------------------------------------------
VCommandLinePtr VCommandLine::Get(const QCoreApplication& app)
//---------------------------------------------------------------------------------------------------------------------
auto VCommandLine::Get(const QCoreApplication& app) -> VCommandLinePtr
{
if (instance == nullptr)
{
@ -313,14 +195,14 @@ VCommandLinePtr VCommandLine::Get(const QCoreApplication& app)
return instance;
}
//------------------------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------------------------------
void VCommandLine::Reset()
{
instance.reset();
}
//---------------------------------------------------------------------------------------------------------------------
bool VCommandLine::IsTestModeEnabled() const
auto VCommandLine::IsTestModeEnabled() const -> bool
{
const bool r = IsOptionSet(LONG_OPTION_TEST);
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
return IsGuiEnabled() ? false : IsOptionSet(LONG_OPTION_PENDANTIC);
}
//---------------------------------------------------------------------------------------------------------------------
bool VCommandLine::IsNoScalingEnabled() const
auto VCommandLine::IsNoScalingEnabled() const -> bool
{
return IsOptionSet(LONG_OPTION_NO_HDPI_SCALING);
}
//---------------------------------------------------------------------------------------------------------------------
bool VCommandLine::IsExportEnabled() const
auto VCommandLine::IsExportEnabled() const -> bool
{
const bool r = IsOptionSet(LONG_OPTION_BASENAME);
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);
if (r && parser.positionalArguments().size() != 1)
@ -368,14 +250,14 @@ bool VCommandLine::IsExportFMEnabled() const
return r;
}
//------------------------------------------------------------------------------------------------------
VAbstractLayoutDialog::PaperSizeTemplate VCommandLine::OptPaperSize() const
//---------------------------------------------------------------------------------------------------------------------
auto VCommandLine::OptPaperSize() const -> VAbstractLayoutDialog::PaperSizeTemplate
{
return FormatSize(LONG_OPTION_PAGETEMPLATE);
}
//------------------------------------------------------------------------------------------------------
Cases VCommandLine::OptGroup() const
//---------------------------------------------------------------------------------------------------------------------
auto VCommandLine::OptGroup() const -> Cases
{
int r = OptionValue(LONG_OPTION_GROUPPING).toInt();
if ( r < 0 || r >= static_cast<int>(Cases::UnknownCase))
@ -385,8 +267,8 @@ Cases VCommandLine::OptGroup() const
return static_cast<Cases>(r);
}
//------------------------------------------------------------------------------------------------------
QString VCommandLine::OptMeasurePath() const
//---------------------------------------------------------------------------------------------------------------------
auto VCommandLine::OptMeasurePath() const -> QString
{
QString measure;
if (IsOptionSet(LONG_OPTION_MEASUREFILE)
@ -401,7 +283,7 @@ QString VCommandLine::OptMeasurePath() const
}
//---------------------------------------------------------------------------------------------------------------------
QString VCommandLine::OptBaseName() const
auto VCommandLine::OptBaseName() const -> QString
{
QString path;
if (IsExportEnabled())
@ -413,7 +295,7 @@ QString VCommandLine::OptBaseName() const
}
//---------------------------------------------------------------------------------------------------------------------
QString VCommandLine::OptDestinationPath() const
auto VCommandLine::OptDestinationPath() const -> QString
{
QString path;
if (IsExportEnabled())
@ -425,7 +307,7 @@ QString VCommandLine::OptDestinationPath() const
}
//---------------------------------------------------------------------------------------------------------------------
int VCommandLine::OptExportType() const
auto VCommandLine::OptExportType() const -> int
{
int r = 0;
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);
}
//---------------------------------------------------------------------------------------------------------------------
bool VCommandLine::IsTextAsPaths() const
auto VCommandLine::IsTextAsPaths() const -> bool
{
return IsOptionSet(LONG_OPTION_TEXT2PATHS);
}
//---------------------------------------------------------------------------------------------------------------------
bool VCommandLine::IsExportOnlyDetails() const
auto VCommandLine::IsExportOnlyDetails() const -> bool
{
return IsOptionSet(LONG_OPTION_EXPORTONLYDETAILS);
}
//---------------------------------------------------------------------------------------------------------------------
bool VCommandLine::IsCSVWithHeader() const
auto VCommandLine::IsCSVWithHeader() const -> bool
{
return IsOptionSet(LONG_OPTION_CSVWITHHEADER);
}
//---------------------------------------------------------------------------------------------------------------------
qreal VCommandLine::ExportXScale() const
auto VCommandLine::ExportXScale() const -> qreal
{
qreal xs = 1;
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;
if (IsOptionSet(LONG_OPTION_EXPYSCALE))
@ -482,7 +364,7 @@ qreal VCommandLine::ExportYScale() const
}
//---------------------------------------------------------------------------------------------------------------------
QString VCommandLine::OptExportSuchDetails() const
auto VCommandLine::OptExportSuchDetails() const -> QString
{
QString path;
if (IsExportEnabled())
@ -494,30 +376,30 @@ QString VCommandLine::OptExportSuchDetails() const
}
//---------------------------------------------------------------------------------------------------------------------
QString VCommandLine::OptCSVCodecName() const
auto VCommandLine::OptCSVCodecName() const -> QString
{
return OptionValue(LONG_OPTION_CSVCODEC);
}
//---------------------------------------------------------------------------------------------------------------------
QChar VCommandLine::OptCSVSeparator() const
auto VCommandLine::OptCSVSeparator() const -> QChar
{
const QString value = OptionValue(LONG_OPTION_CSVSEPARATOR);
return not value.isEmpty() ? value.at(0) : QChar();
}
//---------------------------------------------------------------------------------------------------------------------
QString VCommandLine::OptExportFMTo() const
auto VCommandLine::OptExportFMTo() const -> QString
{
return OptionValue(LONG_OPTION_CSVEXPORTFM);
}
//---------------------------------------------------------------------------------------------------------------------
QMap<int, QString> VCommandLine::OptUserMaterials() const
auto VCommandLine::OptUserMaterials() const -> QMap<int, QString>
{
QMap<int, QString> userMaterials;
const QStringList values = OptionValues(LONG_OPTION_USER_MATERIAL);
for(auto &value : values)
for(const auto &value : values)
{
const QStringList parts = value.split('@');
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();
}
//---------------------------------------------------------------------------------------------------------------------
bool VCommandLine::IsGuiEnabled() const
auto VCommandLine::IsGuiEnabled() const -> bool
{
return isGuiEnabled;
}
//---------------------------------------------------------------------------------------------------------------------
bool VCommandLine::IsSetDimensionA() const
auto VCommandLine::IsSetDimensionA() const -> bool
{
return IsOptionSet(LONG_OPTION_DIMENSION_A);
}
//---------------------------------------------------------------------------------------------------------------------
bool VCommandLine::IsSetDimensionB() const
auto VCommandLine::IsSetDimensionB() const -> bool
{
return IsOptionSet(LONG_OPTION_DIMENSION_B);
}
//---------------------------------------------------------------------------------------------------------------------
bool VCommandLine::IsSetDimensionC() const
auto VCommandLine::IsSetDimensionC() const -> bool
{
return IsOptionSet(LONG_OPTION_DIMENSION_C);
}
//---------------------------------------------------------------------------------------------------------------------
int VCommandLine::OptDimensionA() const
auto VCommandLine::OptDimensionA() const -> int
{
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);
@ -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);
@ -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);
}
//---------------------------------------------------------------------------------------------------------------------
PageOrientation VCommandLine::OptTiledPageOrientation() const
auto VCommandLine::OptTiledPageOrientation() const -> PageOrientation
{
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);
}
//---------------------------------------------------------------------------------------------------------------------
QString VCommandLine::OptionValue(const QString &option) const
auto VCommandLine::OptionValue(const QString &option) const -> QString
{
return parser.value(option);
}
//---------------------------------------------------------------------------------------------------------------------
QStringList VCommandLine::OptionValues(const QString &option) const
auto VCommandLine::OptionValues(const QString &option) const -> QStringList
{
return parser.values(option);
}
//---------------------------------------------------------------------------------------------------------------------
int VCommandLine::OptNestingTime() const
auto VCommandLine::OptNestingTime() const -> int
{
int time = VValentinaSettings::GetDefNestingTime();
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();
if (IsOptionSet(LONG_OPTION_EFFICIENCY_COEFFICIENT))
@ -949,4 +831,136 @@ qreal VCommandLine::OptEfficiencyCoefficient() const
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

View File

@ -36,7 +36,6 @@
#include <QCommandLineParser>
#include "../dialogs/dialoglayoutsettings.h"
#include "../vmisc/vsysexits.h"
class 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
//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
//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
//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
//file supplied in case export enabled
bool IsExportFMEnabled() const;
auto IsExportFMEnabled() const -> bool;
//@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
QString OptBaseName() const;
auto OptBaseName() const -> QString;
//@brief returns the absolute path to output destination directory or path to application's current directory if
//not set
QString OptDestinationPath() const;
auto OptDestinationPath() const -> QString;
//@brief returns export type set, defaults 0 - svg
int OptExportType() const;
auto OptExportType() const -> int;
bool IsBinaryDXF() const;
bool IsTextAsPaths() const;
bool IsExportOnlyDetails() const;
bool IsCSVWithHeader() const;
auto IsBinaryDXF() const -> bool;
auto IsTextAsPaths() const -> bool;
auto IsExportOnlyDetails() const -> bool;
auto IsCSVWithHeader() const -> bool;
qreal ExportXScale() const;
qreal ExportYScale() const;
auto ExportXScale() const -> qreal;
auto ExportYScale() const -> qreal;
//@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
QString OptCSVCodecName() const;
auto OptCSVCodecName() const -> QString;
//@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
QString OptExportFMTo() const;
auto OptExportFMTo() const -> QString;
//@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...
//@brief creates VLayoutGenerator
VLayoutGeneratorPtr DefaultGenerator() const;
auto DefaultGenerator() const -> VLayoutGeneratorPtr;
//@brief gets filenames which should be loaded
QStringList OptInputFileNames() const;
auto OptInputFileNames() const -> QStringList;
bool IsGuiEnabled()const;
auto IsGuiEnabled()const -> bool;
bool IsSetDimensionA() const;
bool IsSetDimensionB() const;
bool IsSetDimensionC() const;
auto IsSetDimensionA() const -> bool;
auto IsSetDimensionB() const -> bool;
auto IsSetDimensionC() const -> bool;
int OptDimensionA() const;
int OptDimensionB() const;
int OptDimensionC() const;
auto OptDimensionA() const -> int;
auto OptDimensionB() const -> int;
auto OptDimensionC() const -> int;
QMarginsF TiledPageMargins() const;
VAbstractLayoutDialog::PaperSizeTemplate OptTiledPaperSize() const;
PageOrientation OptTiledPageOrientation() const;
auto TiledPageMargins() const -> QMarginsF;
auto OptTiledPaperSize() const -> VAbstractLayoutDialog::PaperSizeTemplate;
auto OptTiledPageOrientation() const -> PageOrientation;
protected:
VCommandLine();
//@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)
static void Reset();
//@brief called to create single object, by VApplication only
static VCommandLinePtr Get(const QCoreApplication& app);
static auto Get(const QCoreApplication& app) -> VCommandLinePtr;
private:
Q_DISABLE_COPY(VCommandLine)
static VCommandLinePtr instance;
QCommandLineParser parser;
bool isGuiEnabled;
Q_DISABLE_COPY_MOVE(VCommandLine) // NOLINT
static VCommandLinePtr instance; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)
QCommandLineParser parser{};
bool isGuiEnabled{false};
friend class VApplication;
VAbstractLayoutDialog::PaperSizeTemplate FormatSize(const QString &key) const;
auto FormatSize(const QString &key) const -> VAbstractLayoutDialog::PaperSizeTemplate;
void InitCommandLineOptions();
bool IsOptionSet(const QString &option) const;
QString OptionValue(const QString &option) const;
QStringList OptionValues(const QString &option) const;
auto IsOptionSet(const QString &option) const -> bool;
auto OptionValue(const QString &option) const -> QString;
auto OptionValues(const QString &option) const -> QStringList;
int OptNestingTime() const;
qreal OptEfficiencyCoefficient() const;
auto OptNestingTime() const -> int;
auto OptEfficiencyCoefficient() const -> qreal;
void TestPageformat() const;
void TestGapWidth() const;
void TestMargins() const;
auto ParseMargins(const DialogLayoutSettings &diag) const -> QMarginsF;
};
#endif // VCMDEXPORT_H

View File

@ -30,8 +30,8 @@
#include "vformulapropertyeditor.h"
#include "../vpropertyexplorer/vproperty_p.h"
#include "../vpropertyexplorer/plugins/vstringproperty.h"
#include "vformulapropertyeditor.h"
#include "../vpropertyexplorer/vproperties.h"
#include "../vpatterndb/vformula.h"
#include "../vmisc/vabstractapplication.h"
@ -41,7 +41,7 @@ VFormulaProperty::VFormulaProperty(const QString &name)
{
d_ptr->type = VPE::Property::Complex;
VPE::VStringProperty* tmpFormula = new VPE::VStringProperty(tr("Formula"));
auto* tmpFormula = new VPE::VStringProperty(tr("Formula"));
addChild(tmpFormula);
tmpFormula->setClearButtonEnable(true);
tmpFormula->setUpdateBehaviour(true, false);
@ -53,41 +53,37 @@ VFormulaProperty::VFormulaProperty(const QString &name)
//---------------------------------------------------------------------------------------------------------------------
//! 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))
{
return getValue();
}
else
{
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)
{
return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
}
else
{
return Qt::NoItemFlags;
}
}
//---------------------------------------------------------------------------------------------------------------------
//! Returns an editor widget, or NULL if it doesn't supply one
QWidget* VFormulaProperty::createEditor(QWidget* parent, const QStyleOptionViewItem& options,
const QAbstractItemDelegate* delegate)
auto VFormulaProperty::createEditor(QWidget* parent, const QStyleOptionViewItem& options,
const QAbstractItemDelegate* delegate) -> QWidget*
{
Q_UNUSED(options)
Q_UNUSED(delegate)
VFormula formula = VProperty::d_ptr->VariantValue.value<VFormula>();
VFormulaPropertyEditor* tmpEditor = new VFormulaPropertyEditor(parent);
auto formula = VProperty::d_ptr->VariantValue.value<VFormula>();
auto* tmpEditor = new VFormulaPropertyEditor(parent);
tmpEditor->setLocale(parent->locale());
tmpEditor->SetFormula(formula);
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)
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)
{
VFormula formula = VProperty::d_ptr->VariantValue.value<VFormula>();
auto formula = VProperty::d_ptr->VariantValue.value<VFormula>();
tmpWidget->SetFormula(formula);
}
else
{
return false;
}
return true;
}
//---------------------------------------------------------------------------------------------------------------------
//! 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)
{
QVariant value;
@ -122,17 +120,17 @@ QVariant VFormulaProperty::getEditorData(const QWidget *editor) const
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)
{
@ -141,7 +139,7 @@ VPE::VProperty *VFormulaProperty::clone(bool include_children, VProperty *contai
if (!include_children)
{
const QList<VProperty*> tmpChildren = container->getChildren();
for (auto tmpChild : tmpChildren)
for (auto *tmpChild : tmpChildren)
{
container->removeChild(tmpChild);
delete tmpChild;
@ -156,12 +154,12 @@ VPE::VProperty *VFormulaProperty::clone(bool include_children, VProperty *contai
//---------------------------------------------------------------------------------------------------------------------
void VFormulaProperty::setValue(const QVariant &value)
{
VFormula tmpFormula = value.value<VFormula>();
auto tmpFormula = value.value<VFormula>();
SetFormula(tmpFormula);
}
//---------------------------------------------------------------------------------------------------------------------
QVariant VFormulaProperty::getValue() const
auto VFormulaProperty::getValue() const -> QVariant
{
VFormula tmpFormula = GetFormula();
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>();
}
@ -195,7 +193,7 @@ void VFormulaProperty::SetFormula(const VFormula &formula)
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
{
Q_OBJECT
Q_OBJECT // NOLINT
public:
explicit VFormulaProperty(const QString &name);
//! 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
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
//! \param parent The widget to which the editor will be added as a child
//! \options Render options
//! \delegate A pointer to the QAbstractItemDelegate requesting the editor. This can be used to connect signals and
//! slots.
virtual QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& options,
const QAbstractItemDelegate* delegate) override;
auto createEditor(QWidget* parent, const QStyleOptionViewItem& options,
const QAbstractItemDelegate* delegate) -> QWidget* override;
//! 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
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
virtual QString type() const override;
auto type() const -> QString override;
//! Clones this property
//! \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
//! 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)
Q_REQUIRED_RESULT virtual VProperty* clone(bool include_children = true,
VProperty* container = nullptr) const override;
Q_REQUIRED_RESULT auto clone(bool include_children = true,
VProperty* container = nullptr) const -> VProperty* override;
//! 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
virtual QVariant getValue() const override;
auto getValue() const -> QVariant override;
//! Returns the formula
VFormula GetFormula() const;
auto GetFormula() const -> VFormula;
//! Sets the formula
void SetFormula(const VFormula &formula);
public slots:
virtual void ValueChildChanged(const QVariant &value, int typeForParent) override;
void ValueChildChanged(const QVariant &value, int typeForParent) override;
};
#endif // VFORMULAPROPERTY_H

View File

@ -39,49 +39,49 @@
#include "../vpropertyexplorer/vproperty.h"
#include "../vtools/dialogs/support/dialogeditwrongformula.h"
#include "vapplication.h"
#include "../vmisc/vabstractvalapplication.h"
// VFormulaPropertyEditor
//---------------------------------------------------------------------------------------------------------------------
VFormulaPropertyEditor::VFormulaPropertyEditor(QWidget *parent)
: QWidget(parent), formula(VFormula()), ToolButton(nullptr), TextLabel(nullptr)
: QWidget(parent)
{
setAutoFillBackground(true);
// Create the tool button
ToolButton = new QToolButton(this);
ToolButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
ToolButton->setText("...");
ToolButton->setIcon(QIcon("://icon/16x16/fx.png"));
ToolButton->setIconSize(QSize(16, 16));
ToolButton->setFixedSize(24, 24);
ToolButton->installEventFilter(this);
setFocusProxy(ToolButton); // Make the ToolButton the focus proxy
setFocusPolicy(ToolButton->focusPolicy());
connect(ToolButton, &QToolButton::clicked, this, &VFormulaPropertyEditor::onToolButtonClicked);
m_ToolButton = new QToolButton(this);
m_ToolButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
m_ToolButton->setText(QStringLiteral("..."));
m_ToolButton->setIcon(QIcon("://icon/16x16/fx.png"));
m_ToolButton->setIconSize(QSize(16, 16));
m_ToolButton->setFixedSize(24, 24);
m_ToolButton->installEventFilter(this);
setFocusProxy(m_ToolButton); // Make the ToolButton the focus proxy
setFocusPolicy(m_ToolButton->focusPolicy());
connect(m_ToolButton, &QToolButton::clicked, this, &VFormulaPropertyEditor::onToolButtonClicked);
// Create the text label
TextLabel = new QLabel(this);
TextLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
TextLabel->setText(formula.getStringValue());
m_TextLabel = new QLabel(this);
m_TextLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
m_TextLabel->setText(m_formula.getStringValue());
// The layout (a horizontal layout)
QHBoxLayout* layout = new QHBoxLayout(this);
auto* layout = new QHBoxLayout(this);
layout->setSpacing(3);
layout->setMargin(0);
layout->addWidget(TextLabel);
layout->addWidget(m_TextLabel);
// Spacer (this is needed for proper display of the label and button)
layout->addSpacerItem(new QSpacerItem(1000000000, 0, QSizePolicy::Expanding, QSizePolicy::Preferred));
layout->addWidget(ToolButton);
layout->addWidget(m_ToolButton);
}
//---------------------------------------------------------------------------------------------------------------------
void VFormulaPropertyEditor::SetFormula(const VFormula& formula)
{
if (this->formula != formula)
if (this->m_formula != formula)
{
this->formula = formula;
TextLabel->setText(this->formula.getStringValue());
this->m_formula = formula;
m_TextLabel->setText(this->m_formula.getStringValue());
}
}
@ -89,26 +89,26 @@ void VFormulaPropertyEditor::SetFormula(const VFormula& formula)
void VFormulaPropertyEditor::onToolButtonClicked()
{
QScopedPointer<DialogEditWrongFormula> tmpWidget(
new DialogEditWrongFormula(formula.getData(), formula.getToolId(),
new DialogEditWrongFormula(m_formula.getData(), m_formula.getToolId(),
VAbstractValApplication::VApp()->getMainWindow()));
tmpWidget->setCheckZero(formula.getCheckZero());
tmpWidget->setPostfix(formula.getPostfix());
tmpWidget->SetFormula(formula.GetFormula(FormulaType::FromUser));
tmpWidget->setCheckZero(m_formula.getCheckZero());
tmpWidget->setPostfix(m_formula.getPostfix());
tmpWidget->SetFormula(m_formula.GetFormula(FormulaType::FromUser));
if (tmpWidget->exec() == QDialog::Accepted)
{
formula.SetFormula(tmpWidget->GetFormula(), FormulaType::ToUser);
formula.Eval();
TextLabel->setText(formula.getStringValue());
emit dataChangedByUser(formula, this);
m_formula.SetFormula(tmpWidget->GetFormula(), FormulaType::ToUser);
m_formula.Eval();
m_TextLabel->setText(m_formula.getStringValue());
emit dataChangedByUser(m_formula, this);
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.
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 "../vpatterndb/vformula.h"
#include "../vmisc/defglobal.h"
class VFormulaPropertyEditor : public QWidget
{
Q_OBJECT
Q_OBJECT // NOLINT
public:
//! Constructor taking a widget as parent
explicit VFormulaPropertyEditor(QWidget *parent);
//! Destructor
virtual ~VFormulaPropertyEditor() Q_DECL_EQ_DEFAULT;
~VFormulaPropertyEditor() override Q_DECL_EQ_DEFAULT;
//! Returns the formula currently set
VFormula GetFormula() const;
auto GetFormula() const -> VFormula;
//! Needed for proper event handling
virtual bool eventFilter(QObject *obj, QEvent *ev) override;
auto eventFilter(QObject *obj, QEvent *ev) -> bool override;
signals:
//! This is emitted, when the user changes the color
@ -67,10 +68,11 @@ private slots:
void onToolButtonClicked();
private:
Q_DISABLE_COPY(VFormulaPropertyEditor)
VFormula formula;
QToolButton* ToolButton;
QLabel* TextLabel;
// cppcheck-suppress unknownMacro
Q_DISABLE_COPY_MOVE(VFormulaPropertyEditor) // NOLINT
VFormula m_formula{};
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
{
Q_OBJECT
Q_OBJECT // NOLINT
public:
explicit VToolOptionsPropertyBrowser(QDockWidget *parent);
~VToolOptionsPropertyBrowser() override =default;
void ClearPropertyBrowser();
public slots:
void itemClicked(QGraphicsItem *item);
@ -54,14 +55,15 @@ public slots:
private slots:
void userChangedData(VPE::VProperty* property);
private:
Q_DISABLE_COPY(VToolOptionsPropertyBrowser)
// cppcheck-suppress unknownMacro
Q_DISABLE_COPY_MOVE(VToolOptionsPropertyBrowser) // NOLINT
VPE::VPropertyModel* PropertyModel;
VPE::VPropertyFormView* formView;
VPE::VPropertyModel* m_PropertyModel{nullptr};
VPE::VPropertyFormView* m_formView{nullptr};
QGraphicsItem *currentItem;
QMap<VPE::VProperty *, QString> propertyToId;
QMap<QString, VPE::VProperty *> idToProperty;
QGraphicsItem *m_currentItem{nullptr};
QMap<VPE::VProperty *, QString> m_propertyToId{};
QMap<QString, VPE::VProperty *> m_idToProperty{};
void AddProperty(VPE::VProperty *property, const QString &id);
void ShowItemOptions(QGraphicsItem *item);
@ -91,7 +93,7 @@ private:
void SetOperationSuffix(VPE::VProperty *property);
template<class Type>
Type GetCrossPoint(const QVariant &value);
auto GetCrossPoint(const QVariant &value) -> Type;
template<class Tool>
void SetCrossCirclesPoint(VPE::VProperty *property);
@ -198,7 +200,7 @@ private:
void AddPropertyText(const QString &propertyName, const QString &text, 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 ChangeDataToolEndLine(VPE::VProperty *property);

View File

@ -40,11 +40,7 @@
//---------------------------------------------------------------------------------------------------------------------
PreferencesConfigurationPage::PreferencesConfigurationPage(QWidget *parent)
: QWidget(parent),
ui(new Ui::PreferencesConfigurationPage),
m_langChanged(false),
m_systemChanged(),
m_unitChanged(false),
m_labelLangChanged(false)
ui(new Ui::PreferencesConfigurationPage)
{
ui->setupUi(this);
RetranslateUi();
@ -169,7 +165,7 @@ PreferencesConfigurationPage::~PreferencesConfigurationPage()
}
//---------------------------------------------------------------------------------------------------------------------
QStringList PreferencesConfigurationPage::Apply()
auto PreferencesConfigurationPage::Apply() -> QStringList
{
// Tab General
QStringList preferences;
@ -263,7 +259,7 @@ void PreferencesConfigurationPage::changeEvent(QEvent *event)
//---------------------------------------------------------------------------------------------------------------------
void PreferencesConfigurationPage::SetLabelComboBox(const QStringList &list)
{
for (auto &name : list)
for (const auto &name : list)
{
ui->labelCombo->addItem(QLocale(name).nativeLanguageName(), name);
}
@ -284,7 +280,7 @@ void PreferencesConfigurationPage::RetranslateUi()
{
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();
InitUnits();
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->clear();
InitPMSystems(ui->systemCombo);

View File

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

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