From 3027ddb49c46755b7a6788547951fb2d1241f0ff Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Tue, 20 Feb 2024 08:57:48 +0200 Subject: [PATCH] Remove class destructor so that classes follows the rule of Zero. --- src/app/puzzle/carousel/vpcarrousel.cpp | 27 +++---- src/app/puzzle/carousel/vpcarrousel.h | 3 +- .../puzzlepreferencesconfigurationpage.cpp | 10 +-- .../puzzlepreferencesconfigurationpage.h | 3 +- .../puzzlepreferenceslayoutpage.cpp | 8 +-- .../configpages/puzzlepreferenceslayoutpage.h | 9 +-- .../configpages/puzzlepreferencespathpage.cpp | 8 +-- .../configpages/puzzlepreferencespathpage.h | 3 +- .../dialogs/dialogpuzzlepreferences.cpp | 6 +- .../puzzle/dialogs/dialogpuzzlepreferences.h | 3 +- .../puzzle/dialogs/dialogsavemanuallayout.cpp | 6 +- .../puzzle/dialogs/dialogsavemanuallayout.h | 4 +- src/app/puzzle/dialogs/vpdialogabout.cpp | 6 +- src/app/puzzle/dialogs/vpdialogabout.h | 3 +- src/app/puzzle/layout/vplayout.cpp | 23 +++--- src/app/puzzle/layout/vplayout.h | 6 +- src/app/puzzle/layout/vpsheet.cpp | 70 +++++++++---------- src/app/puzzle/layout/vpsheet.h | 8 +-- src/app/puzzle/scene/vpmaingraphicsview.cpp | 6 +- src/app/puzzle/vpmainwindow.cpp | 55 ++++++++------- src/app/puzzle/vpmainwindow.h | 5 +- .../tapepreferencesconfigurationpage.cpp | 12 ++-- .../tapepreferencesconfigurationpage.h | 3 +- .../configpages/tapepreferencespathpage.cpp | 8 +-- .../configpages/tapepreferencespathpage.h | 3 +- src/app/tape/dialogs/dialogabouttape.cpp | 6 +- src/app/tape/dialogs/dialogabouttape.h | 3 +- .../dialogs/dialogdimensioncustomnames.cpp | 14 ++-- .../tape/dialogs/dialogdimensioncustomnames.h | 3 +- .../tape/dialogs/dialogdimensionlabels.cpp | 6 +- src/app/tape/dialogs/dialogdimensionlabels.h | 9 +-- .../dialogknownmeasurementscsvcolumns.cpp | 37 +++++----- .../dialogknownmeasurementscsvcolumns.h | 5 +- 33 files changed, 169 insertions(+), 212 deletions(-) diff --git a/src/app/puzzle/carousel/vpcarrousel.cpp b/src/app/puzzle/carousel/vpcarrousel.cpp index f67a4526b..b8725b4fb 100644 --- a/src/app/puzzle/carousel/vpcarrousel.cpp +++ b/src/app/puzzle/carousel/vpcarrousel.cpp @@ -56,7 +56,6 @@ QT_WARNING_POP //--------------------------------------------------------------------------------------------------------------------- VPCarrousel::VPCarrousel(const VPLayoutPtr &layout, QWidget *parent) : QWidget(parent), - ui(new Ui::VPCarrousel), m_layout(layout) { SCASSERT(not layout.isNull()) @@ -74,11 +73,7 @@ VPCarrousel::VPCarrousel(const VPLayoutPtr &layout, QWidget *parent) Refresh(); } -//--------------------------------------------------------------------------------------------------------------------- -VPCarrousel::~VPCarrousel() -{ - delete ui; -} +VPCarrousel::~VPCarrousel() = default; //--------------------------------------------------------------------------------------------------------------------- void VPCarrousel::Refresh() @@ -94,7 +89,7 @@ void VPCarrousel::Refresh() // Do not rely on m_layout because we do not control it. m_pieceLists = QList(); - VPLayoutPtr layout = m_layout.toStrongRef(); + VPLayoutPtr const layout = m_layout.toStrongRef(); if (not layout.isNull()) { { @@ -107,7 +102,7 @@ void VPCarrousel::Refresh() m_pieceLists.append(carrouselSheet); } - QList sheets = layout->GetSheets(); + QList const sheets = layout->GetSheets(); for (const auto &sheet : sheets) { if (not sheet.isNull()) @@ -137,7 +132,7 @@ void VPCarrousel::Refresh() ui->comboBoxPieceList->setCurrentIndex(-1); ui->comboBoxPieceList->blockSignals(false); - int index = ui->comboBoxPieceList->findData(sheetUuid); + int const index = ui->comboBoxPieceList->findData(sheetUuid); ui->comboBoxPieceList->setCurrentIndex(index != -1 ? index : 0); RefreshOrientation(); @@ -148,7 +143,7 @@ void VPCarrousel::on_ActiveSheetChanged(const VPSheetPtr &sheet) { if (not sheet.isNull()) { - int index = ui->comboBoxPieceList->findData(sheet->Uuid()); + int const index = ui->comboBoxPieceList->findData(sheet->Uuid()); if (index != -1) { ui->comboBoxPieceList->setCurrentIndex(index); @@ -163,7 +158,7 @@ void VPCarrousel::on_ActiveSheetChanged(const VPSheetPtr &sheet) //--------------------------------------------------------------------------------------------------------------------- void VPCarrousel::RefreshSheetNames() { - VPLayoutPtr layout = m_layout.toStrongRef(); + VPLayoutPtr const layout = m_layout.toStrongRef(); if (layout.isNull()) { return; @@ -173,7 +168,7 @@ void VPCarrousel::RefreshSheetNames() { if (not m_pieceLists.at(i).unplaced) { - VPSheetPtr sheet = layout->GetSheet(m_pieceLists.at(i).sheetUuid); + VPSheetPtr const sheet = layout->GetSheet(m_pieceLists.at(i).sheetUuid); if (not sheet.isNull()) { m_pieceLists[i].name = sheet->GetName(); @@ -203,7 +198,7 @@ void VPCarrousel::on_ActivePieceListChanged(int index) { qCDebug(pCarrousel, "index changed %i", index); - VPLayoutPtr layout = m_layout.toStrongRef(); + VPLayoutPtr const layout = m_layout.toStrongRef(); if (layout.isNull()) { return; @@ -215,12 +210,12 @@ void VPCarrousel::on_ActivePieceListChanged(int index) if (index > 0) { - QUuid sheetUuid = ui->comboBoxPieceList->currentData().toUuid(); - VPSheetPtr sheet = layout->GetSheet(sheetUuid); + QUuid const sheetUuid = ui->comboBoxPieceList->currentData().toUuid(); + VPSheetPtr const sheet = layout->GetSheet(sheetUuid); if (not sheet.isNull()) { - VPSheetPtr activeSheet = layout->GetFocusedSheet(); + VPSheetPtr const activeSheet = layout->GetFocusedSheet(); if (not activeSheet.isNull()) { activeSheet->ClearSelection(); diff --git a/src/app/puzzle/carousel/vpcarrousel.h b/src/app/puzzle/carousel/vpcarrousel.h index 33cd47304..f40416258 100644 --- a/src/app/puzzle/carousel/vpcarrousel.h +++ b/src/app/puzzle/carousel/vpcarrousel.h @@ -33,6 +33,7 @@ #include #include #include +#include #include "../layout/layoutdef.h" @@ -102,7 +103,7 @@ private slots: private: // cppcheck-suppress unknownMacro Q_DISABLE_COPY_MOVE(VPCarrousel) // NOLINT - Ui::VPCarrousel *ui; + std::unique_ptr ui{}; VPLayoutWeakPtr m_layout{}; diff --git a/src/app/puzzle/dialogs/configpages/puzzlepreferencesconfigurationpage.cpp b/src/app/puzzle/dialogs/configpages/puzzlepreferencesconfigurationpage.cpp index 958240881..c5be30bbb 100644 --- a/src/app/puzzle/dialogs/configpages/puzzlepreferencesconfigurationpage.cpp +++ b/src/app/puzzle/dialogs/configpages/puzzlepreferencesconfigurationpage.cpp @@ -39,8 +39,7 @@ //--------------------------------------------------------------------------------------------------------------------- PuzzlePreferencesConfigurationPage::PuzzlePreferencesConfigurationPage(QWidget *parent) - : QWidget(parent), - ui(new Ui::PuzzlePreferencesConfigurationPage) + : QWidget(parent) { ui->setupUi(this); @@ -62,7 +61,7 @@ PuzzlePreferencesConfigurationPage::PuzzlePreferencesConfigurationPage(QWidget * // Theme SetThemeModeComboBox(); - int index = ui->comboBoxThemeMode->findData(static_cast(settings->GetThemeMode())); + int const index = ui->comboBoxThemeMode->findData(static_cast(settings->GetThemeMode())); if (index != -1) { ui->comboBoxThemeMode->setCurrentIndex(index); @@ -120,10 +119,7 @@ PuzzlePreferencesConfigurationPage::PuzzlePreferencesConfigurationPage(QWidget * } //--------------------------------------------------------------------------------------------------------------------- -PuzzlePreferencesConfigurationPage::~PuzzlePreferencesConfigurationPage() -{ - delete ui; -} +PuzzlePreferencesConfigurationPage::~PuzzlePreferencesConfigurationPage() = default; //--------------------------------------------------------------------------------------------------------------------- auto PuzzlePreferencesConfigurationPage::Apply() -> QStringList diff --git a/src/app/puzzle/dialogs/configpages/puzzlepreferencesconfigurationpage.h b/src/app/puzzle/dialogs/configpages/puzzlepreferencesconfigurationpage.h index 1e3309258..ced465d6d 100644 --- a/src/app/puzzle/dialogs/configpages/puzzlepreferencesconfigurationpage.h +++ b/src/app/puzzle/dialogs/configpages/puzzlepreferencesconfigurationpage.h @@ -29,6 +29,7 @@ #define PUZZLEPREFERENCESCONFIGURATIONPAGE_H #include +#include namespace Ui { @@ -54,7 +55,7 @@ private slots: private: // cppcheck-suppress unknownMacro Q_DISABLE_COPY_MOVE(PuzzlePreferencesConfigurationPage) // NOLINT - Ui::PuzzlePreferencesConfigurationPage *ui; + std::unique_ptr ui{}; bool m_langChanged{false}; QList m_transientShortcuts{}; diff --git a/src/app/puzzle/dialogs/configpages/puzzlepreferenceslayoutpage.cpp b/src/app/puzzle/dialogs/configpages/puzzlepreferenceslayoutpage.cpp index 3ae348679..07e46f38f 100644 --- a/src/app/puzzle/dialogs/configpages/puzzlepreferenceslayoutpage.cpp +++ b/src/app/puzzle/dialogs/configpages/puzzlepreferenceslayoutpage.cpp @@ -31,8 +31,7 @@ //--------------------------------------------------------------------------------------------------------------------- PuzzlePreferencesLayoutPage::PuzzlePreferencesLayoutPage(QWidget *parent) - : QWidget(parent), - ui(new Ui::PuzzlePreferencesLayoutPage) + : QWidget(parent) { ui->setupUi(this); @@ -131,10 +130,7 @@ PuzzlePreferencesLayoutPage::PuzzlePreferencesLayoutPage(QWidget *parent) } //--------------------------------------------------------------------------------------------------------------------- -PuzzlePreferencesLayoutPage::~PuzzlePreferencesLayoutPage() -{ - delete ui; -} +PuzzlePreferencesLayoutPage::~PuzzlePreferencesLayoutPage() = default; //--------------------------------------------------------------------------------------------------------------------- auto PuzzlePreferencesLayoutPage::Apply() -> QStringList diff --git a/src/app/puzzle/dialogs/configpages/puzzlepreferenceslayoutpage.h b/src/app/puzzle/dialogs/configpages/puzzlepreferenceslayoutpage.h index e20b885df..ad195b0b1 100644 --- a/src/app/puzzle/dialogs/configpages/puzzlepreferenceslayoutpage.h +++ b/src/app/puzzle/dialogs/configpages/puzzlepreferenceslayoutpage.h @@ -29,13 +29,14 @@ #define PUZZLEPREFERENCESLAYOUTPAGE_H #include +#include -#include "../vmisc/def.h" #include "../vlayout/dialogs/vabstractlayoutdialog.h" +#include "../vmisc/def.h" namespace Ui { - class PuzzlePreferencesLayoutPage; +class PuzzlePreferencesLayoutPage; } class PuzzlePreferencesLayoutPage : public QWidget @@ -49,7 +50,7 @@ public: auto Apply() -> QStringList; protected: - void changeEvent(QEvent* event) override; + void changeEvent(QEvent *event) override; private slots: void ConvertPaperSize(); @@ -64,7 +65,7 @@ private slots: private: // cppcheck-suppress unknownMacro Q_DISABLE_COPY_MOVE(PuzzlePreferencesLayoutPage) // NOLINT - Ui::PuzzlePreferencesLayoutPage *ui; + std::unique_ptr ui{}; Unit m_oldLayoutUnit{Unit::Mm}; bool m_settingsChanged{false}; diff --git a/src/app/puzzle/dialogs/configpages/puzzlepreferencespathpage.cpp b/src/app/puzzle/dialogs/configpages/puzzlepreferencespathpage.cpp index eb039f6d6..cbd811756 100644 --- a/src/app/puzzle/dialogs/configpages/puzzlepreferencespathpage.cpp +++ b/src/app/puzzle/dialogs/configpages/puzzlepreferencespathpage.cpp @@ -31,8 +31,7 @@ //--------------------------------------------------------------------------------------------------------------------- PuzzlePreferencesPathPage::PuzzlePreferencesPathPage(QWidget *parent) - : QWidget(parent), - ui(new Ui::PuzzlePreferencesPathPage) + : QWidget(parent) { ui->setupUi(this); @@ -53,10 +52,7 @@ PuzzlePreferencesPathPage::PuzzlePreferencesPathPage(QWidget *parent) } //--------------------------------------------------------------------------------------------------------------------- -PuzzlePreferencesPathPage::~PuzzlePreferencesPathPage() -{ - delete ui; -} +PuzzlePreferencesPathPage::~PuzzlePreferencesPathPage() = default; //--------------------------------------------------------------------------------------------------------------------- void PuzzlePreferencesPathPage::Apply() diff --git a/src/app/puzzle/dialogs/configpages/puzzlepreferencespathpage.h b/src/app/puzzle/dialogs/configpages/puzzlepreferencespathpage.h index 84be56a5b..490e19d05 100644 --- a/src/app/puzzle/dialogs/configpages/puzzlepreferencespathpage.h +++ b/src/app/puzzle/dialogs/configpages/puzzlepreferencespathpage.h @@ -29,6 +29,7 @@ #define PUZZLEPREFERENCESPATHPAGE_H #include +#include namespace Ui { @@ -55,7 +56,7 @@ private slots: private: // cppcheck-suppress unknownMacro Q_DISABLE_COPY_MOVE(PuzzlePreferencesPathPage) // NOLINT - Ui::PuzzlePreferencesPathPage *ui; + std::unique_ptr ui{}; void InitTable(); }; diff --git a/src/app/puzzle/dialogs/dialogpuzzlepreferences.cpp b/src/app/puzzle/dialogs/dialogpuzzlepreferences.cpp index 452c66d4c..091bf57ef 100644 --- a/src/app/puzzle/dialogs/dialogpuzzlepreferences.cpp +++ b/src/app/puzzle/dialogs/dialogpuzzlepreferences.cpp @@ -46,7 +46,6 @@ using namespace Qt::Literals::StringLiterals; //--------------------------------------------------------------------------------------------------------------------- DialogPuzzlePreferences::DialogPuzzlePreferences(QWidget *parent) : QDialog(parent), - ui(new Ui::DialogPuzzlePreferences), m_configurationPage(new PuzzlePreferencesConfigurationPage), m_layoutPage(new PuzzlePreferencesLayoutPage), m_pathPage(new PuzzlePreferencesPathPage) @@ -76,10 +75,7 @@ DialogPuzzlePreferences::DialogPuzzlePreferences(QWidget *parent) } //--------------------------------------------------------------------------------------------------------------------- -DialogPuzzlePreferences::~DialogPuzzlePreferences() -{ - delete ui; -} +DialogPuzzlePreferences::~DialogPuzzlePreferences() = default; //--------------------------------------------------------------------------------------------------------------------- void DialogPuzzlePreferences::showEvent(QShowEvent *event) diff --git a/src/app/puzzle/dialogs/dialogpuzzlepreferences.h b/src/app/puzzle/dialogs/dialogpuzzlepreferences.h index 96aadd907..4f8e4b1d2 100644 --- a/src/app/puzzle/dialogs/dialogpuzzlepreferences.h +++ b/src/app/puzzle/dialogs/dialogpuzzlepreferences.h @@ -29,6 +29,7 @@ #define DIALOGPUZZLEPREFERENCES_H #include +#include namespace Ui { @@ -64,7 +65,7 @@ private slots: private: // cppcheck-suppress unknownMacro Q_DISABLE_COPY_MOVE(DialogPuzzlePreferences) // NOLINT - Ui::DialogPuzzlePreferences *ui; + std::unique_ptr ui{}; bool m_isInitialized{false}; PuzzlePreferencesConfigurationPage *m_configurationPage; PuzzlePreferencesLayoutPage *m_layoutPage; diff --git a/src/app/puzzle/dialogs/dialogsavemanuallayout.cpp b/src/app/puzzle/dialogs/dialogsavemanuallayout.cpp index dcad2c6ff..d1531d085 100644 --- a/src/app/puzzle/dialogs/dialogsavemanuallayout.cpp +++ b/src/app/puzzle/dialogs/dialogsavemanuallayout.cpp @@ -59,7 +59,6 @@ QT_WARNING_POP DialogSaveManualLayout::DialogSaveManualLayout(vsizetype count, bool consoleExport, const QString &fileName, QWidget *parent) : VAbstractLayoutDialog(parent), - ui(new Ui::DialogSaveManualLayout), m_count(count), m_consoleExport(consoleExport) { @@ -142,10 +141,7 @@ DialogSaveManualLayout::DialogSaveManualLayout(vsizetype count, bool consoleExpo } //--------------------------------------------------------------------------------------------------------------------- -DialogSaveManualLayout::~DialogSaveManualLayout() -{ - delete ui; -} +DialogSaveManualLayout::~DialogSaveManualLayout() = default; //--------------------------------------------------------------------------------------------------------------------- auto DialogSaveManualLayout::Path() const -> QString diff --git a/src/app/puzzle/dialogs/dialogsavemanuallayout.h b/src/app/puzzle/dialogs/dialogsavemanuallayout.h index e720cf7f8..fd50d2a05 100644 --- a/src/app/puzzle/dialogs/dialogsavemanuallayout.h +++ b/src/app/puzzle/dialogs/dialogsavemanuallayout.h @@ -28,6 +28,8 @@ #ifndef DIALOGSAVEMANUALLAYOUT_H #define DIALOGSAVEMANUALLAYOUT_H +#include + #include "../vlayout/dialogs/vabstractlayoutdialog.h" #include "../vlayout/vlayoutdef.h" #include "../vmisc/defglobal.h" @@ -80,7 +82,7 @@ private slots: private: // cppcheck-suppress unknownMacro Q_DISABLE_COPY_MOVE(DialogSaveManualLayout) // NOLINT - Ui::DialogSaveManualLayout *ui; + std::unique_ptr ui{}; vsizetype m_count; bool m_isInitialized{false}; bool m_scaleConnected{true}; diff --git a/src/app/puzzle/dialogs/vpdialogabout.cpp b/src/app/puzzle/dialogs/vpdialogabout.cpp index b8db9ff14..dd841a70f 100644 --- a/src/app/puzzle/dialogs/vpdialogabout.cpp +++ b/src/app/puzzle/dialogs/vpdialogabout.cpp @@ -53,7 +53,6 @@ using namespace Qt::Literals::StringLiterals; //--------------------------------------------------------------------------------------------------------------------- VPDialogAbout::VPDialogAbout(QWidget *parent) : QDialog(parent), - ui(new Ui::VPDialogAbout), m_isInitialized(false) { ui->setupUi(this); @@ -85,10 +84,7 @@ VPDialogAbout::VPDialogAbout(QWidget *parent) } //--------------------------------------------------------------------------------------------------------------------- -VPDialogAbout::~VPDialogAbout() -{ - delete ui; -} +VPDialogAbout::~VPDialogAbout() = default; //--------------------------------------------------------------------------------------------------------------------- void VPDialogAbout::changeEvent(QEvent *event) diff --git a/src/app/puzzle/dialogs/vpdialogabout.h b/src/app/puzzle/dialogs/vpdialogabout.h index ea43e7465..7c34249d5 100644 --- a/src/app/puzzle/dialogs/vpdialogabout.h +++ b/src/app/puzzle/dialogs/vpdialogabout.h @@ -30,6 +30,7 @@ #define VPDIALOGABOUT_H #include +#include namespace Ui { @@ -51,7 +52,7 @@ protected: private: // cppcheck-suppress unknownMacro Q_DISABLE_COPY_MOVE(VPDialogAbout) // NOLINT - Ui::VPDialogAbout *ui; + std::unique_ptr ui{}; bool m_isInitialized; static void FontPointSize(QWidget *w, int pointSize); diff --git a/src/app/puzzle/layout/vplayout.cpp b/src/app/puzzle/layout/vplayout.cpp index 0c847af73..c506ede3f 100644 --- a/src/app/puzzle/layout/vplayout.cpp +++ b/src/app/puzzle/layout/vplayout.cpp @@ -61,10 +61,7 @@ VPLayout::VPLayout(QUndoStack *undoStack) } //--------------------------------------------------------------------------------------------------------------------- -VPLayout::~VPLayout() -{ - delete m_tileFactory; -} +VPLayout::~VPLayout() = default; //--------------------------------------------------------------------------------------------------------------------- auto VPLayout::CreateLayout(QUndoStack *undoStack) -> VPLayoutPtr @@ -75,7 +72,7 @@ auto VPLayout::CreateLayout(QUndoStack *undoStack) -> VPLayoutPtr layout->AddTrashSheet(VPSheetPtr(new VPSheet(layout))); // create a standard sheet - VPSheetPtr sheet(new VPSheet(layout)); + VPSheetPtr const sheet(new VPSheet(layout)); sheet->SetName(tr("Sheet %1").arg(layout->GetAllSheets().size() + 1)); layout->AddSheet(sheet); layout->SetFocusedSheet(sheet); @@ -100,7 +97,7 @@ auto VPLayout::CreateLayout(QUndoStack *undoStack) -> VPLayoutPtr // -------------------------------------------------------- // init the tile factory - auto *tileFactory = new VPTileFactory(layout, settings); + auto tileFactory = QSharedPointer(new VPTileFactory(layout, settings)); tileFactory->RefreshTileInfos(); tileFactory->RefreshWatermarkData(); layout->SetTileFactory(tileFactory); @@ -131,7 +128,7 @@ void VPLayout::AddPiece(const VPPiecePtr &piece) } else { - VPPiecePtr oldPiece = m_pieces.value(piece->GetUniqueID()); + VPPiecePtr const oldPiece = m_pieces.value(piece->GetUniqueID()); if (not oldPiece.isNull()) { oldPiece->Update(piece); @@ -150,15 +147,15 @@ auto VPLayout::Uuid() const -> const QUuid & } //--------------------------------------------------------------------------------------------------------------------- -auto VPLayout::TileFactory() const -> VPTileFactory * +auto VPLayout::TileFactory() const -> QSharedPointer { return m_tileFactory; } //--------------------------------------------------------------------------------------------------------------------- -void VPLayout::SetTileFactory(VPTileFactory *newTileFactory) +void VPLayout::SetTileFactory(const QSharedPointer &newTileFactory) { - delete m_tileFactory; + m_tileFactory.clear(); m_tileFactory = newTileFactory; } @@ -217,7 +214,7 @@ auto VPLayout::IsSheetsUniform() const -> bool return false; } - QSizeF sheetSize = sheet->GetSheetSize().toSize(); + QSizeF const sheetSize = sheet->GetSheetSize().toSize(); return std::all_of(sheets.begin(), sheets.end(), [sheetSize](const VPSheetPtr &sheet) @@ -226,7 +223,7 @@ auto VPLayout::IsSheetsUniform() const -> bool { return false; } - QSize size = sheet->GetSheetSize().toSize(); + QSize const size = sheet->GetSheetSize().toSize(); return size == sheetSize || size.transposed() == sheetSize; }); } @@ -377,7 +374,7 @@ auto VPLayout::PiecesForSheet(const QUuid &uuid) const -> QList { if (not piece.isNull()) { - VPSheetPtr sheet = piece->Sheet(); + VPSheetPtr const sheet = piece->Sheet(); if (not sheet.isNull() && sheet->Uuid() == uuid) { list.append(piece); diff --git a/src/app/puzzle/layout/vplayout.h b/src/app/puzzle/layout/vplayout.h index 1f3f70ca9..a4758a0f0 100644 --- a/src/app/puzzle/layout/vplayout.h +++ b/src/app/puzzle/layout/vplayout.h @@ -91,8 +91,8 @@ public: void CheckPiecesPositionValidity() const; - auto TileFactory() const -> VPTileFactory *; - void SetTileFactory(VPTileFactory *newTileFactory); + auto TileFactory() const -> QSharedPointer; + void SetTileFactory(const QSharedPointer &newTileFactory); void RefreshScenePieces() const; @@ -134,7 +134,7 @@ private: QUndoStack *m_undoStack; - VPTileFactory *m_tileFactory{nullptr}; + QSharedPointer m_tileFactory{nullptr}; QUuid m_uuid{QUuid::createUuid()}; }; diff --git a/src/app/puzzle/layout/vpsheet.cpp b/src/app/puzzle/layout/vpsheet.cpp index 39934ed4d..eedf51c4b 100644 --- a/src/app/puzzle/layout/vpsheet.cpp +++ b/src/app/puzzle/layout/vpsheet.cpp @@ -42,7 +42,7 @@ //--------------------------------------------------------------------------------------------------------------------- VPSheetSceneData::VPSheetSceneData(const VPLayoutPtr &layout, const QUuid &sheetUuid) : m_layout(layout), - m_scene(new VMainGraphicsScene()), + m_scene(QSharedPointer::create()), m_sheetUuid(sheetUuid) { SCASSERT(not layout.isNull()) @@ -68,13 +68,10 @@ VPSheetSceneData::VPSheetSceneData(const VPLayoutPtr &layout, const QUuid &sheet } //--------------------------------------------------------------------------------------------------------------------- -VPSheetSceneData::~VPSheetSceneData() -{ - delete m_scene; -} +VPSheetSceneData::~VPSheetSceneData() = default; //--------------------------------------------------------------------------------------------------------------------- -auto VPSheetSceneData::Scene() const -> VMainGraphicsScene * +auto VPSheetSceneData::Scene() const -> QSharedPointer { return m_scene; } @@ -95,19 +92,19 @@ void VPSheetSceneData::RefreshPieces() qDeleteAll(m_graphicsPieces); m_graphicsPieces.clear(); - VPLayoutPtr layout = m_layout.toStrongRef(); + VPLayoutPtr const layout = m_layout.toStrongRef(); if (layout.isNull()) { return; } - VPSheetPtr sheet = layout->GetSheet(m_sheetUuid); + VPSheetPtr const sheet = layout->GetSheet(m_sheetUuid); if (sheet.isNull()) { return; } - QList pieces = sheet->GetPieces(); + QList const pieces = sheet->GetPieces(); m_graphicsPieces.reserve(pieces.size()); for (const auto &piece : pieces) @@ -277,7 +274,7 @@ void VPSheetSceneData::SetTextAsPaths(bool textAsPaths) const //--------------------------------------------------------------------------------------------------------------------- void VPSheetSceneData::PrepareTilesScheme() { - VPLayoutPtr layout = m_layout.toStrongRef(); + VPLayoutPtr const layout = m_layout.toStrongRef(); if (not layout.isNull()) { m_showTilesSchemeTmp = layout->LayoutSettings().GetShowTiles(); @@ -293,7 +290,7 @@ void VPSheetSceneData::PrepareTilesScheme() //--------------------------------------------------------------------------------------------------------------------- void VPSheetSceneData::ClearTilesScheme() { - VPLayoutPtr layout = m_layout.toStrongRef(); + VPLayoutPtr const layout = m_layout.toStrongRef(); if (not layout.isNull()) { layout->LayoutSettings().SetShowTiles(m_showTilesSchemeTmp); @@ -317,7 +314,7 @@ void VPSheetSceneData::ConnectPiece(VPGraphicsPiece *piece) { SCASSERT(piece != nullptr) - VPLayoutPtr layout = m_layout.toStrongRef(); + VPLayoutPtr const layout = m_layout.toStrongRef(); if (layout.isNull()) { return; @@ -343,7 +340,7 @@ void VPSheetSceneData::ConnectPiece(VPGraphicsPiece *piece) VPSheet::VPSheet(const VPLayoutPtr &layout, QObject *parent) : QObject(parent), m_layout(layout), - m_sceneData(new VPSheetSceneData(layout, Uuid())) + m_sceneData(QSharedPointer::create(layout, Uuid())) { SCASSERT(not layout.isNull()) @@ -354,10 +351,7 @@ VPSheet::VPSheet(const VPLayoutPtr &layout, QObject *parent) } //--------------------------------------------------------------------------------------------------------------------- -VPSheet::~VPSheet() -{ - delete m_sceneData; -} +VPSheet::~VPSheet() = default; //--------------------------------------------------------------------------------------------------------------------- auto VPSheet::GetLayout() const -> VPLayoutPtr @@ -368,7 +362,7 @@ auto VPSheet::GetLayout() const -> VPLayoutPtr //--------------------------------------------------------------------------------------------------------------------- auto VPSheet::GetPieces() const -> QList { - VPLayoutPtr layout = GetLayout(); + VPLayoutPtr const layout = GetLayout(); if (not layout.isNull()) { return layout->PiecesForSheet(m_uuid); @@ -380,10 +374,10 @@ auto VPSheet::GetPieces() const -> QList //--------------------------------------------------------------------------------------------------------------------- auto VPSheet::GetSelectedPieces() const -> QList { - VPLayoutPtr layout = GetLayout(); + VPLayoutPtr const layout = GetLayout(); if (not layout.isNull()) { - QList list = layout->PiecesForSheet(m_uuid); + QList const list = layout->PiecesForSheet(m_uuid); QList selected; selected.reserve(list.size()); @@ -405,7 +399,7 @@ auto VPSheet::GetSelectedPieces() const -> QList //--------------------------------------------------------------------------------------------------------------------- auto VPSheet::GetAsLayoutPieces() const -> QVector { - QList pieces = GetPieces(); + QList const pieces = GetPieces(); QVector details; details.reserve(pieces.size()); @@ -520,7 +514,7 @@ void VPSheet::SetTrashSheet(bool newTrashSheet) //--------------------------------------------------------------------------------------------------------------------- void VPSheet::ValidateSuperpositionOfPieces() const { - QList pieces = GetPieces(); + QList const pieces = GetPieces(); for (const auto &piece : pieces) { @@ -633,13 +627,13 @@ auto VPSheet::GetMarginsRect() const -> QRectF //--------------------------------------------------------------------------------------------------------------------- void VPSheet::RemoveUnusedLength() { - VPLayoutPtr layout = GetLayout(); + VPLayoutPtr const layout = GetLayout(); if (layout.isNull()) { return; } - QList pieces = GetPieces(); + QList const pieces = GetPieces(); if (pieces.isEmpty()) { return; @@ -658,8 +652,8 @@ void VPSheet::RemoveUnusedLength() } const qreal extra = 2; - QRectF sheetRect = GetSheetRect(); - GrainlineType type = GrainlineOrientation(); + QRectF const sheetRect = GetSheetRect(); + GrainlineType const type = GrainlineOrientation(); if (type == GrainlineType::Vertical) { @@ -692,13 +686,13 @@ void VPSheet::RemoveUnusedLength() //--------------------------------------------------------------------------------------------------------------------- void VPSheet::CheckPiecePositionValidity(const VPPiecePtr &piece) const { - VPLayoutPtr layout = GetLayout(); + VPLayoutPtr const layout = GetLayout(); if (layout.isNull()) { return; } - QList pieces = GetPieces(); + QList const pieces = GetPieces(); if (piece.isNull() || not pieces.contains(piece)) { return; @@ -716,7 +710,7 @@ void VPSheet::CheckPiecePositionValidity(const VPPiecePtr &piece) const } //--------------------------------------------------------------------------------------------------------------------- -auto VPSheet::SceneData() const -> VPSheetSceneData * +auto VPSheet::SceneData() const -> QSharedPointer { return m_sceneData; } @@ -724,7 +718,7 @@ auto VPSheet::SceneData() const -> VPSheetSceneData * //--------------------------------------------------------------------------------------------------------------------- void VPSheet::ClearSelection() const { - QList selectedPieces = GetSelectedPieces(); + QList const selectedPieces = GetSelectedPieces(); for (const auto &piece : selectedPieces) { if (piece->IsSelected()) @@ -735,7 +729,7 @@ void VPSheet::ClearSelection() const if (not selectedPieces.isEmpty()) { - VPLayoutPtr layout = GetLayout(); + VPLayoutPtr const layout = GetLayout(); if (not layout.isNull()) { emit layout->PieceSelectionChanged(VPPiecePtr()); @@ -752,7 +746,7 @@ auto VPSheet::GetSheetOrientation() const -> QPageLayout::Orientation //--------------------------------------------------------------------------------------------------------------------- auto VPSheet::SheetUnits() const -> Unit { - VPLayoutPtr layout = GetLayout(); + VPLayoutPtr const layout = GetLayout(); if (not layout.isNull()) { return layout->LayoutSettings().GetUnit(); @@ -776,7 +770,7 @@ void VPSheet::SetSheetSize(qreal width, qreal height) //--------------------------------------------------------------------------------------------------------------------- void VPSheet::SetSheetSizeConverted(qreal width, qreal height) { - Unit unit = SheetUnits(); + Unit const unit = SheetUnits(); m_size.setWidth(UnitConvertor(width, unit, Unit::Px)); m_size.setHeight(UnitConvertor(height, unit, Unit::Px)); @@ -800,7 +794,7 @@ void VPSheet::SetSheetSize(const QSizeF &size) //--------------------------------------------------------------------------------------------------------------------- void VPSheet::SetSheetSizeConverted(const QSizeF &size) { - Unit unit = SheetUnits(); + Unit const unit = SheetUnits(); m_size = QSizeF(UnitConvertor(size.width(), unit, Unit::Px), UnitConvertor(size.height(), unit, Unit::Px)); if (m_sceneData != nullptr) @@ -818,7 +812,7 @@ auto VPSheet::GetSheetSize() const -> QSizeF //--------------------------------------------------------------------------------------------------------------------- auto VPSheet::GetSheetSizeConverted() const -> QSizeF { - Unit unit = SheetUnits(); + Unit const unit = SheetUnits(); QSizeF convertedSize = QSizeF(UnitConvertor(m_size.width(), Unit::Px, unit), UnitConvertor(m_size.height(), Unit::Px, unit)); @@ -836,7 +830,7 @@ void VPSheet::SetSheetMargins(qreal left, qreal top, qreal right, qreal bottom) //--------------------------------------------------------------------------------------------------------------------- void VPSheet::SetSheetMarginsConverted(qreal left, qreal top, qreal right, qreal bottom) { - Unit unit = SheetUnits(); + Unit const unit = SheetUnits(); m_margins.setLeft(UnitConvertor(left, unit, Unit::Px)); m_margins.setTop(UnitConvertor(top, unit, Unit::Px)); m_margins.setRight(UnitConvertor(right, unit, Unit::Px)); @@ -852,7 +846,7 @@ void VPSheet::SetSheetMargins(const QMarginsF &margins) //--------------------------------------------------------------------------------------------------------------------- void VPSheet::SetSheetMarginsConverted(const QMarginsF &margins) { - Unit unit = SheetUnits(); + Unit const unit = SheetUnits(); m_margins = UnitConvertor(margins, unit, Unit::Px); } @@ -865,7 +859,7 @@ auto VPSheet::GetSheetMargins() const -> QMarginsF //--------------------------------------------------------------------------------------------------------------------- auto VPSheet::GetSheetMarginsConverted() const -> QMarginsF { - Unit unit = SheetUnits(); + Unit const unit = SheetUnits(); return UnitConvertor(m_margins, Unit::Px, unit); } diff --git a/src/app/puzzle/layout/vpsheet.h b/src/app/puzzle/layout/vpsheet.h index a5aafd245..457ef7e70 100644 --- a/src/app/puzzle/layout/vpsheet.h +++ b/src/app/puzzle/layout/vpsheet.h @@ -56,7 +56,7 @@ public: explicit VPSheetSceneData(const VPLayoutPtr &layout, const QUuid &sheetUuid); ~VPSheetSceneData(); - auto Scene() const -> VMainGraphicsScene *; + auto Scene() const -> QSharedPointer; /** * @brief RefreshLayout Refreshes the rectangles for the layout border and the margin @@ -98,7 +98,7 @@ private: VPLayoutWeakPtr m_layout{}; - VMainGraphicsScene *m_scene; + QSharedPointer m_scene{nullptr}; VPGraphicsSheet *m_graphicsSheet{nullptr}; @@ -273,7 +273,7 @@ public: auto IgnoreMargins() const -> bool; void SetIgnoreMargins(bool newIgnoreMargins); - auto SceneData() const -> VPSheetSceneData *; + auto SceneData() const -> QSharedPointer; void ClearSelection() const; @@ -311,7 +311,7 @@ private: GrainlineType m_grainlineType{GrainlineType::NotFixed}; - VPSheetSceneData *m_sceneData{nullptr}; + QSharedPointer m_sceneData{nullptr}; auto SheetUnits() const -> Unit; }; diff --git a/src/app/puzzle/scene/vpmaingraphicsview.cpp b/src/app/puzzle/scene/vpmaingraphicsview.cpp index 86bb02ba6..44d75425c 100644 --- a/src/app/puzzle/scene/vpmaingraphicsview.cpp +++ b/src/app/puzzle/scene/vpmaingraphicsview.cpp @@ -562,9 +562,9 @@ void VPMainGraphicsView::SwitchScene(const VPSheetPtr &sheet) { if (not sheet.isNull()) { - VMainGraphicsScene *scene = sheet->SceneData()->Scene(); - setScene(scene); - connect(scene, &VMainGraphicsScene::mouseMove, this, &VPMainGraphicsView::on_SceneMouseMove, + QSharedPointer scene = sheet->SceneData()->Scene(); + setScene(scene.data()); + connect(scene.data(), &VMainGraphicsScene::mouseMove, this, &VPMainGraphicsView::on_SceneMouseMove, Qt::UniqueConnection); } } diff --git a/src/app/puzzle/vpmainwindow.cpp b/src/app/puzzle/vpmainwindow.cpp index 30844942d..6045394a4 100644 --- a/src/app/puzzle/vpmainwindow.cpp +++ b/src/app/puzzle/vpmainwindow.cpp @@ -323,7 +323,6 @@ struct VPExportData //--------------------------------------------------------------------------------------------------------------------- VPMainWindow::VPMainWindow(const VPCommandLinePtr &cmd, QWidget *parent) : VAbstractMainWindow(parent), - ui(new Ui::VPMainWindow), m_cmd(cmd), m_undoStack(new QUndoStack(this)), m_layout{VPLayout::CreateLayout(m_undoStack)}, @@ -450,12 +449,7 @@ VPMainWindow::VPMainWindow(const VPCommandLinePtr &cmd, QWidget *parent) } //--------------------------------------------------------------------------------------------------------------------- -VPMainWindow::~VPMainWindow() -{ - delete m_undoStack; - delete ui; - delete m_carrousel; -} +VPMainWindow::~VPMainWindow() = default; //--------------------------------------------------------------------------------------------------------------------- auto VPMainWindow::CurrentFile() const -> QString @@ -1286,8 +1280,8 @@ void VPMainWindow::InitPropertyTabLayout() //--------------------------------------------------------------------------------------------------------------------- void VPMainWindow::InitCarrousel() { - m_carrousel = new VPCarrousel(m_layout, ui->dockWidgetCarrousel); - ui->dockWidgetCarrousel->setWidget(m_carrousel); + m_carrousel = std::make_unique(m_layout, ui->dockWidgetCarrousel); + ui->dockWidgetCarrousel->setWidget(m_carrousel.get()); connect(ui->dockWidgetCarrousel, QOverload::of(&QDockWidget::dockLocationChanged), this, &VPMainWindow::on_CarrouselLocationChanged); @@ -1638,7 +1632,7 @@ void VPMainWindow::InitMainGraphics() connect(m_graphicsView, &VPMainGraphicsView::ScaleChanged, this, &VPMainWindow::on_ScaleChanged); connect(m_graphicsView, &VPMainGraphicsView::mouseMove, this, &VPMainWindow::on_MouseMoved); - connect(m_layout.data(), &VPLayout::PieceSheetChanged, m_carrousel, &VPCarrousel::Refresh); + connect(m_layout.data(), &VPLayout::PieceSheetChanged, m_carrousel.get(), &VPCarrousel::Refresh); } //--------------------------------------------------------------------------------------------------------------------- @@ -2438,71 +2432,80 @@ void VPMainWindow::ExportScene(const VPExportData &data) case LayoutExportFormats::SVG: exporter.SetPen(QPen(Qt::black, VAbstractApplication::VApp()->Settings()->WidthHairLine(), Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin)); - exporter.ExportToSVG(sheet->SceneData()->Scene(), sheet->SceneData()->GraphicsPiecesAsItems()); + exporter.ExportToSVG(sheet->SceneData()->Scene().data(), sheet->SceneData()->GraphicsPiecesAsItems()); break; case LayoutExportFormats::PDF: exporter.SetPen(QPen(Qt::black, VAbstractApplication::VApp()->Settings()->WidthHairLine(), Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin)); - exporter.ExportToPDF(sheet->SceneData()->Scene(), sheet->SceneData()->GraphicsPiecesAsItems()); + exporter.ExportToPDF(sheet->SceneData()->Scene().data(), sheet->SceneData()->GraphicsPiecesAsItems()); break; case LayoutExportFormats::PNG: exporter.SetPen(QPen(Qt::black, VAbstractApplication::VApp()->Settings()->WidthHairLine(), Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin)); - exporter.ExportToPNG(sheet->SceneData()->Scene(), sheet->SceneData()->GraphicsPiecesAsItems()); + exporter.ExportToPNG(sheet->SceneData()->Scene().data(), sheet->SceneData()->GraphicsPiecesAsItems()); break; case LayoutExportFormats::OBJ: - exporter.ExportToOBJ(sheet->SceneData()->Scene()); + exporter.ExportToOBJ(sheet->SceneData()->Scene().data()); break; case LayoutExportFormats::PS: exporter.SetPen(QPen(Qt::black, VAbstractApplication::VApp()->Settings()->WidthHairLine(), Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin)); - exporter.ExportToPS(sheet->SceneData()->Scene(), sheet->SceneData()->GraphicsPiecesAsItems()); + exporter.ExportToPS(sheet->SceneData()->Scene().data(), sheet->SceneData()->GraphicsPiecesAsItems()); break; case LayoutExportFormats::EPS: exporter.SetPen(QPen(Qt::black, VAbstractApplication::VApp()->Settings()->WidthHairLine(), Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin)); - exporter.ExportToEPS(sheet->SceneData()->Scene(), sheet->SceneData()->GraphicsPiecesAsItems()); + exporter.ExportToEPS(sheet->SceneData()->Scene().data(), sheet->SceneData()->GraphicsPiecesAsItems()); break; case LayoutExportFormats::DXF_AC1006_Flat: exporter.SetDxfVersion(DRW::AC1006); - exporter.ExportToFlatDXF(sheet->SceneData()->Scene(), sheet->SceneData()->GraphicsPiecesAsItems()); + exporter.ExportToFlatDXF(sheet->SceneData()->Scene().data(), + sheet->SceneData()->GraphicsPiecesAsItems()); break; case LayoutExportFormats::DXF_AC1009_Flat: exporter.SetDxfVersion(DRW::AC1009); - exporter.ExportToFlatDXF(sheet->SceneData()->Scene(), sheet->SceneData()->GraphicsPiecesAsItems()); + exporter.ExportToFlatDXF(sheet->SceneData()->Scene().data(), + sheet->SceneData()->GraphicsPiecesAsItems()); break; case LayoutExportFormats::DXF_AC1012_Flat: exporter.SetDxfVersion(DRW::AC1012); - exporter.ExportToFlatDXF(sheet->SceneData()->Scene(), sheet->SceneData()->GraphicsPiecesAsItems()); + exporter.ExportToFlatDXF(sheet->SceneData()->Scene().data(), + sheet->SceneData()->GraphicsPiecesAsItems()); break; case LayoutExportFormats::DXF_AC1014_Flat: exporter.SetDxfVersion(DRW::AC1014); - exporter.ExportToFlatDXF(sheet->SceneData()->Scene(), sheet->SceneData()->GraphicsPiecesAsItems()); + exporter.ExportToFlatDXF(sheet->SceneData()->Scene().data(), + sheet->SceneData()->GraphicsPiecesAsItems()); break; case LayoutExportFormats::DXF_AC1015_Flat: exporter.SetDxfVersion(DRW::AC1015); - exporter.ExportToFlatDXF(sheet->SceneData()->Scene(), sheet->SceneData()->GraphicsPiecesAsItems()); + exporter.ExportToFlatDXF(sheet->SceneData()->Scene().data(), + sheet->SceneData()->GraphicsPiecesAsItems()); break; case LayoutExportFormats::DXF_AC1018_Flat: exporter.SetDxfVersion(DRW::AC1018); - exporter.ExportToFlatDXF(sheet->SceneData()->Scene(), sheet->SceneData()->GraphicsPiecesAsItems()); + exporter.ExportToFlatDXF(sheet->SceneData()->Scene().data(), + sheet->SceneData()->GraphicsPiecesAsItems()); break; case LayoutExportFormats::DXF_AC1021_Flat: exporter.SetDxfVersion(DRW::AC1021); - exporter.ExportToFlatDXF(sheet->SceneData()->Scene(), sheet->SceneData()->GraphicsPiecesAsItems()); + exporter.ExportToFlatDXF(sheet->SceneData()->Scene().data(), + sheet->SceneData()->GraphicsPiecesAsItems()); break; case LayoutExportFormats::DXF_AC1024_Flat: exporter.SetDxfVersion(DRW::AC1024); - exporter.ExportToFlatDXF(sheet->SceneData()->Scene(), sheet->SceneData()->GraphicsPiecesAsItems()); + exporter.ExportToFlatDXF(sheet->SceneData()->Scene().data(), + sheet->SceneData()->GraphicsPiecesAsItems()); break; case LayoutExportFormats::DXF_AC1027_Flat: exporter.SetDxfVersion(DRW::AC1027); - exporter.ExportToFlatDXF(sheet->SceneData()->Scene(), sheet->SceneData()->GraphicsPiecesAsItems()); + exporter.ExportToFlatDXF(sheet->SceneData()->Scene().data(), + sheet->SceneData()->GraphicsPiecesAsItems()); break; case LayoutExportFormats::TIF: exporter.SetPen(QPen(Qt::black, VAbstractApplication::VApp()->Settings()->WidthHairLine(), Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin)); - exporter.ExportToTIF(sheet->SceneData()->Scene(), sheet->SceneData()->GraphicsPiecesAsItems()); + exporter.ExportToTIF(sheet->SceneData()->Scene().data(), sheet->SceneData()->GraphicsPiecesAsItems()); break; default: qDebug() << "Can't recognize file type." << Q_FUNC_INFO; diff --git a/src/app/puzzle/vpmainwindow.h b/src/app/puzzle/vpmainwindow.h index a8f12c769..f513ae7a1 100644 --- a/src/app/puzzle/vpmainwindow.h +++ b/src/app/puzzle/vpmainwindow.h @@ -32,6 +32,7 @@ #include #include #include +#include #include "../vlayout/dialogs/vabstractlayoutdialog.h" #include "../vlayout/vlayoutpiece.h" @@ -302,9 +303,9 @@ private slots: private: Q_DISABLE_COPY_MOVE(VPMainWindow) // NOLINT - Ui::VPMainWindow *ui; + std::unique_ptr ui{}; - VPCarrousel *m_carrousel{nullptr}; + std::unique_ptr m_carrousel{nullptr}; VPMainGraphicsView *m_graphicsView{nullptr}; VPCommandLinePtr m_cmd; diff --git a/src/app/tape/dialogs/configpages/tapepreferencesconfigurationpage.cpp b/src/app/tape/dialogs/configpages/tapepreferencesconfigurationpage.cpp index 0ce6dde7d..bae025159 100644 --- a/src/app/tape/dialogs/configpages/tapepreferencesconfigurationpage.cpp +++ b/src/app/tape/dialogs/configpages/tapepreferencesconfigurationpage.cpp @@ -44,7 +44,6 @@ //--------------------------------------------------------------------------------------------------------------------- TapePreferencesConfigurationPage::TapePreferencesConfigurationPage(QWidget *parent) : QWidget(parent), - ui(new Ui::TapePreferencesConfigurationPage), m_langChanged(false), m_systemChanged(false) { @@ -118,10 +117,7 @@ TapePreferencesConfigurationPage::TapePreferencesConfigurationPage(QWidget *pare } //--------------------------------------------------------------------------------------------------------------------- -TapePreferencesConfigurationPage::~TapePreferencesConfigurationPage() -{ - delete ui; -} +TapePreferencesConfigurationPage::~TapePreferencesConfigurationPage() = default; //--------------------------------------------------------------------------------------------------------------------- auto TapePreferencesConfigurationPage::Apply() -> QStringList @@ -338,7 +334,7 @@ void TapePreferencesConfigurationPage::RetranslateShortcutsTable() void TapePreferencesConfigurationPage::InitKnownMeasurements(QComboBox *combo) { VKnownMeasurementsDatabase *db = MApplication::VApp()->KnownMeasurementsDatabase(); - QHash known = db->AllKnownMeasurements(); + QHash const known = db->AllKnownMeasurements(); combo->blockSignals(true); combo->clear(); @@ -369,10 +365,10 @@ void TapePreferencesConfigurationPage::InitKnownMeasurements(QComboBox *combo) void TapePreferencesConfigurationPage::InitKnownMeasurementsDescription() { VKnownMeasurementsDatabase *db = MApplication::VApp()->KnownMeasurementsDatabase(); - QHash known = db->AllKnownMeasurements(); + QHash const known = db->AllKnownMeasurements(); ui->knownMeasurementsDescription->clear(); - QUuid id = ui->comboBoxKnownMeasurements->currentData().toUuid(); + QUuid const id = ui->comboBoxKnownMeasurements->currentData().toUuid(); if (!id.isNull() && known.contains(id)) { ui->knownMeasurementsDescription->setPlainText(known.value(id).description); diff --git a/src/app/tape/dialogs/configpages/tapepreferencesconfigurationpage.h b/src/app/tape/dialogs/configpages/tapepreferencesconfigurationpage.h index 0c13129f2..144e73e13 100644 --- a/src/app/tape/dialogs/configpages/tapepreferencesconfigurationpage.h +++ b/src/app/tape/dialogs/configpages/tapepreferencesconfigurationpage.h @@ -30,6 +30,7 @@ #define TAPEPREFERENCESCONFIGURATIONPAGE_H #include +#include class QComboBox; @@ -57,7 +58,7 @@ private slots: private: // cppcheck-suppress unknownMacro Q_DISABLE_COPY_MOVE(TapePreferencesConfigurationPage) // NOLINT - Ui::TapePreferencesConfigurationPage *ui; + std::unique_ptr ui{}; bool m_langChanged; bool m_systemChanged; QList m_transientShortcuts{}; diff --git a/src/app/tape/dialogs/configpages/tapepreferencespathpage.cpp b/src/app/tape/dialogs/configpages/tapepreferencespathpage.cpp index 3ab220cd2..73ddd768f 100644 --- a/src/app/tape/dialogs/configpages/tapepreferencespathpage.cpp +++ b/src/app/tape/dialogs/configpages/tapepreferencespathpage.cpp @@ -32,8 +32,7 @@ //--------------------------------------------------------------------------------------------------------------------- TapePreferencesPathPage::TapePreferencesPathPage(QWidget *parent) - : QWidget(parent), - ui(new Ui::TapePreferencesPathPage) + : QWidget(parent) { ui->setupUi(this); @@ -54,10 +53,7 @@ TapePreferencesPathPage::TapePreferencesPathPage(QWidget *parent) } //--------------------------------------------------------------------------------------------------------------------- -TapePreferencesPathPage::~TapePreferencesPathPage() -{ - delete ui; -} +TapePreferencesPathPage::~TapePreferencesPathPage() = default; //--------------------------------------------------------------------------------------------------------------------- auto TapePreferencesPathPage::Apply() -> QStringList diff --git a/src/app/tape/dialogs/configpages/tapepreferencespathpage.h b/src/app/tape/dialogs/configpages/tapepreferencespathpage.h index 2d934ef98..34bb6d4b5 100644 --- a/src/app/tape/dialogs/configpages/tapepreferencespathpage.h +++ b/src/app/tape/dialogs/configpages/tapepreferencespathpage.h @@ -29,6 +29,7 @@ #define TAPEPREFERENCESPATHPAGE_H #include +#include namespace Ui { @@ -55,7 +56,7 @@ private slots: private: // cppcheck-suppress unknownMacro Q_DISABLE_COPY_MOVE(TapePreferencesPathPage) // NOLINT - Ui::TapePreferencesPathPage *ui; + std::unique_ptr ui{}; void InitTable(); }; diff --git a/src/app/tape/dialogs/dialogabouttape.cpp b/src/app/tape/dialogs/dialogabouttape.cpp index 267c8ebf1..a231695f1 100644 --- a/src/app/tape/dialogs/dialogabouttape.cpp +++ b/src/app/tape/dialogs/dialogabouttape.cpp @@ -47,7 +47,6 @@ //--------------------------------------------------------------------------------------------------------------------- DialogAboutTape::DialogAboutTape(QWidget *parent) : QDialog(parent), - ui(new Ui::DialogAboutTape), m_isInitialized(false) { ui->setupUi(this); @@ -80,10 +79,7 @@ DialogAboutTape::DialogAboutTape(QWidget *parent) } //--------------------------------------------------------------------------------------------------------------------- -DialogAboutTape::~DialogAboutTape() -{ - delete ui; -} +DialogAboutTape::~DialogAboutTape() = default; //--------------------------------------------------------------------------------------------------------------------- void DialogAboutTape::changeEvent(QEvent *event) diff --git a/src/app/tape/dialogs/dialogabouttape.h b/src/app/tape/dialogs/dialogabouttape.h index 024c190fb..5f736bbf8 100644 --- a/src/app/tape/dialogs/dialogabouttape.h +++ b/src/app/tape/dialogs/dialogabouttape.h @@ -30,6 +30,7 @@ #define DIALOGABOUTTAPE_H #include +#include namespace Ui { @@ -51,7 +52,7 @@ protected: private: // cppcheck-suppress unknownMacro Q_DISABLE_COPY_MOVE(DialogAboutTape) // NOLINT - Ui::DialogAboutTape *ui; + std::unique_ptr ui{}; bool m_isInitialized; static void FontPointSize(QWidget *w, int pointSize); diff --git a/src/app/tape/dialogs/dialogdimensioncustomnames.cpp b/src/app/tape/dialogs/dialogdimensioncustomnames.cpp index 72804aead..2d22c65c2 100644 --- a/src/app/tape/dialogs/dialogdimensioncustomnames.cpp +++ b/src/app/tape/dialogs/dialogdimensioncustomnames.cpp @@ -30,9 +30,8 @@ //--------------------------------------------------------------------------------------------------------------------- DialogDimensionCustomNames::DialogDimensionCustomNames( - const QMap &dimensions, QWidget *parent) : - QDialog(parent), - ui(new Ui::DialogDimensionCustomNames) + const QMap &dimensions, QWidget *parent) + : QDialog(parent) { ui->setupUi(this); @@ -40,10 +39,7 @@ DialogDimensionCustomNames::DialogDimensionCustomNames( } //--------------------------------------------------------------------------------------------------------------------- -DialogDimensionCustomNames::~DialogDimensionCustomNames() -{ - delete ui; -} +DialogDimensionCustomNames::~DialogDimensionCustomNames() = default; //--------------------------------------------------------------------------------------------------------------------- auto DialogDimensionCustomNames::CustomNames() const -> QMap @@ -76,8 +72,8 @@ void DialogDimensionCustomNames::InitTable(const QMapType()), i.value()->Axis()); + QString name = QStringLiteral("%1 (%2)").arg(VAbstartMeasurementDimension::DimensionName(i.value()->Type()), + i.value()->Axis()); auto *itemValue = new QTableWidgetItem(name); itemValue->setTextAlignment(Qt::AlignHCenter | Qt::AlignCenter); diff --git a/src/app/tape/dialogs/dialogdimensioncustomnames.h b/src/app/tape/dialogs/dialogdimensioncustomnames.h index 44db142b6..df8a014d9 100644 --- a/src/app/tape/dialogs/dialogdimensioncustomnames.h +++ b/src/app/tape/dialogs/dialogdimensioncustomnames.h @@ -29,6 +29,7 @@ #define DIALOGDIMENSIONCUSTOMNAMES_H #include +#include #include "../vformat/vdimensions.h" @@ -51,7 +52,7 @@ public: private: // cppcheck-suppress unknownMacro Q_DISABLE_COPY_MOVE(DialogDimensionCustomNames) // NOLINT - Ui::DialogDimensionCustomNames *ui; + std::unique_ptr ui{}; void InitTable(const QMap &dimensions); }; diff --git a/src/app/tape/dialogs/dialogdimensionlabels.cpp b/src/app/tape/dialogs/dialogdimensionlabels.cpp index bfaa1f19c..6f4f343be 100644 --- a/src/app/tape/dialogs/dialogdimensionlabels.cpp +++ b/src/app/tape/dialogs/dialogdimensionlabels.cpp @@ -32,7 +32,6 @@ DialogDimensionLabels::DialogDimensionLabels(const QMap &dimensions, bool fullCircumference, QWidget *parent) : QDialog(parent), - ui(new Ui::DialogDimensionLabels), m_dimensions(dimensions), m_fullCircumference(fullCircumference) { @@ -49,10 +48,7 @@ DialogDimensionLabels::DialogDimensionLabels(const QMap #include +#include #include "../vformat/vdimensions.h" @@ -45,14 +46,14 @@ class DialogDimensionLabels : public QDialog Q_OBJECT // NOLINT public: - explicit DialogDimensionLabels(const QMap &dimensions, + explicit DialogDimensionLabels(const QMap &dimensions, bool fullCircumference, QWidget *parent = nullptr); ~DialogDimensionLabels() override; auto Labels() const -> QMap; protected: - void changeEvent(QEvent* event) override; + void changeEvent(QEvent *event) override; private slots: void DimensionChanged(); @@ -61,9 +62,9 @@ private slots: private: // cppcheck-suppress unknownMacro Q_DISABLE_COPY_MOVE(DialogDimensionLabels) // NOLINT - Ui::DialogDimensionLabels *ui; + std::unique_ptr ui{}; - QMap m_dimensions; + QMap m_dimensions; QMap m_labels{}; bool m_fullCircumference; diff --git a/src/app/tape/dialogs/dialogknownmeasurementscsvcolumns.cpp b/src/app/tape/dialogs/dialogknownmeasurementscsvcolumns.cpp index b76c67609..be105f974 100644 --- a/src/app/tape/dialogs/dialogknownmeasurementscsvcolumns.cpp +++ b/src/app/tape/dialogs/dialogknownmeasurementscsvcolumns.cpp @@ -40,6 +40,7 @@ using VTextCodec = QTextCodec; #include #include +#include #if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) #include "../vmisc/compatibility.h" @@ -48,19 +49,15 @@ using VTextCodec = QTextCodec; using namespace Qt::Literals::StringLiterals; //--------------------------------------------------------------------------------------------------------------------- -DialogKnownMeasurementsCSVColumns::DialogKnownMeasurementsCSVColumns(const QString &filename, QWidget *parent) +DialogKnownMeasurementsCSVColumns::DialogKnownMeasurementsCSVColumns(QString filename, QWidget *parent) : QDialog(parent), - ui(new Ui::DialogKnownMeasurementsCSVColumns), - m_fileName{filename} + m_fileName{std::move(filename)} { ui->setupUi(this); } //--------------------------------------------------------------------------------------------------------------------- -DialogKnownMeasurementsCSVColumns::~DialogKnownMeasurementsCSVColumns() -{ - delete ui; -} +DialogKnownMeasurementsCSVColumns::~DialogKnownMeasurementsCSVColumns() = default; //--------------------------------------------------------------------------------------------------------------------- void DialogKnownMeasurementsCSVColumns::changeEvent(QEvent *event) @@ -151,13 +148,13 @@ void DialogKnownMeasurementsCSVColumns::ColumnChanged() } //--------------------------------------------------------------------------------------------------------------------- -bool DialogKnownMeasurementsCSVColumns::ColumnMandatory(int column) const +auto DialogKnownMeasurementsCSVColumns::ColumnMandatory(int column) const -> bool { return column < static_cast(KnownMeasurementsColumns::Group); } //--------------------------------------------------------------------------------------------------------------------- -QString DialogKnownMeasurementsCSVColumns::ColumnHeader(int column) const +auto DialogKnownMeasurementsCSVColumns::ColumnHeader(int column) const -> QString { const auto individualColumn = static_cast(column); switch (individualColumn) @@ -179,19 +176,19 @@ QString DialogKnownMeasurementsCSVColumns::ColumnHeader(int column) const } //--------------------------------------------------------------------------------------------------------------------- -int DialogKnownMeasurementsCSVColumns::ImportColumnCount() const +auto DialogKnownMeasurementsCSVColumns::ImportColumnCount() const -> int { return static_cast(KnownMeasurementsColumns::LAST_DO_NOT_USE); } //--------------------------------------------------------------------------------------------------------------------- -int DialogKnownMeasurementsCSVColumns::MinimumColumns() const +auto DialogKnownMeasurementsCSVColumns::MinimumColumns() const -> int { return 1; } //--------------------------------------------------------------------------------------------------------------------- -bool DialogKnownMeasurementsCSVColumns::ColumnsValid() +auto DialogKnownMeasurementsCSVColumns::ColumnsValid() -> bool { ClearColumnCollor(); @@ -234,7 +231,7 @@ void DialogKnownMeasurementsCSVColumns::ClearColumnCollor() //--------------------------------------------------------------------------------------------------------------------- void DialogKnownMeasurementsCSVColumns::InitColumnsMap() { - QSharedPointer csv = DialogKnownMeasurementsCSVColumns::CSVModel(); + QSharedPointer const csv = DialogKnownMeasurementsCSVColumns::CSVModel(); m_columnsMap.clear(); auto InitColumn = [this, csv](int column, int &index) @@ -346,7 +343,7 @@ void DialogKnownMeasurementsCSVColumns::InitImportHeaders() } //--------------------------------------------------------------------------------------------------------------------- -QSharedPointer DialogKnownMeasurementsCSVColumns::CSVModel() const +auto DialogKnownMeasurementsCSVColumns::CSVModel() const -> QSharedPointer { return QSharedPointer::create(m_fileName, nullptr, m_withHeader, m_separator, m_codec); } @@ -359,7 +356,7 @@ void DialogKnownMeasurementsCSVColumns::ShowInputPreview() return; } - QSharedPointer csv = DialogKnownMeasurementsCSVColumns::CSVModel(); + QSharedPointer const csv = DialogKnownMeasurementsCSVColumns::CSVModel(); const int columns = csv->columnCount(); const int rows = csv->rowCount(); @@ -408,7 +405,7 @@ void DialogKnownMeasurementsCSVColumns::ShowImportPreview() return; } - QSharedPointer csv = DialogKnownMeasurementsCSVColumns::CSVModel(); + QSharedPointer const csv = DialogKnownMeasurementsCSVColumns::CSVModel(); const int importColumns = ImportColumnCount(); const int columns = csv->columnCount(); @@ -455,7 +452,7 @@ void DialogKnownMeasurementsCSVColumns::SetDefaultColumns() { SCASSERT(control != nullptr) - int index = control->findData(m_columnsMap.at(column)); + int const index = control->findData(m_columnsMap.at(column)); if (index != -1) { control->setCurrentIndex(index); @@ -488,7 +485,7 @@ void DialogKnownMeasurementsCSVColumns::CheckStatus() return; } - QSharedPointer csv = DialogKnownMeasurementsCSVColumns::CSVModel(); + QSharedPointer const csv = DialogKnownMeasurementsCSVColumns::CSVModel(); const int columns = csv->columnCount(); if (columns < MinimumColumns()) @@ -521,10 +518,10 @@ void DialogKnownMeasurementsCSVColumns::CheckStatus() } //--------------------------------------------------------------------------------------------------------------------- -template bool DialogKnownMeasurementsCSVColumns::ColumnValid(T column) const +template auto DialogKnownMeasurementsCSVColumns::ColumnValid(T column) const -> bool { const int columnNumber = static_cast(column); - int value = m_columnsMap.at(columnNumber); + int const value = m_columnsMap.at(columnNumber); if (value == -1 && not ColumnMandatory(columnNumber)) { diff --git a/src/app/tape/dialogs/dialogknownmeasurementscsvcolumns.h b/src/app/tape/dialogs/dialogknownmeasurementscsvcolumns.h index 76a81a9f1..222de3749 100644 --- a/src/app/tape/dialogs/dialogknownmeasurementscsvcolumns.h +++ b/src/app/tape/dialogs/dialogknownmeasurementscsvcolumns.h @@ -29,6 +29,7 @@ #define DIALOGKNOWNMEASUREMENTSCSVCOLUMNS_H #include +#include class QxtCsvModel; class QComboBox; @@ -60,7 +61,7 @@ class DialogKnownMeasurementsCSVColumns : public QDialog Q_OBJECT // NOLINT public: - explicit DialogKnownMeasurementsCSVColumns(const QString &filename, QWidget *parent = nullptr); + explicit DialogKnownMeasurementsCSVColumns(QString filename, QWidget *parent = nullptr); ~DialogKnownMeasurementsCSVColumns() override; auto ColumnsMap() const -> QVector; @@ -79,7 +80,7 @@ private slots: private: // cppcheck-suppress unknownMacro Q_DISABLE_COPY_MOVE(DialogKnownMeasurementsCSVColumns) // NOLINT - Ui::DialogKnownMeasurementsCSVColumns *ui; + std::unique_ptr ui{}; bool m_isInitialized{false}; QString m_fileName; bool m_withHeader{false};