From 55b2c1b4aea9d07219282561f778a31ec80ed42d Mon Sep 17 00:00:00 2001 From: Yann Lossouarn Date: Fri, 23 Feb 2024 23:46:32 +0100 Subject: [PATCH] Code cleaning : functions that should be const --- .../configpages/puzzlepreferencesconfigurationpage.cpp | 4 ++-- .../configpages/puzzlepreferencesconfigurationpage.h | 4 ++-- .../dialogs/configpages/puzzlepreferenceslayoutpage.cpp | 2 +- .../dialogs/configpages/puzzlepreferenceslayoutpage.h | 2 +- .../dialogs/configpages/puzzlepreferencespathpage.cpp | 4 ++-- .../dialogs/configpages/puzzlepreferencespathpage.h | 4 ++-- src/app/puzzle/layout/vppiece.cpp | 4 ++-- src/app/puzzle/layout/vppiece.h | 4 ++-- src/app/puzzle/layout/vpsheet.cpp | 2 +- src/app/puzzle/layout/vpsheet.h | 2 +- src/app/puzzle/scene/vpgraphicspiece.cpp | 4 ++-- src/app/puzzle/scene/vpgraphicspiece.h | 4 ++-- src/app/puzzle/scene/vpmaingraphicsview.cpp | 8 ++++---- src/app/puzzle/scene/vpmaingraphicsview.h | 8 ++++---- 14 files changed, 28 insertions(+), 28 deletions(-) diff --git a/src/app/puzzle/dialogs/configpages/puzzlepreferencesconfigurationpage.cpp b/src/app/puzzle/dialogs/configpages/puzzlepreferencesconfigurationpage.cpp index 4744e1e05..8312c88e8 100644 --- a/src/app/puzzle/dialogs/configpages/puzzlepreferencesconfigurationpage.cpp +++ b/src/app/puzzle/dialogs/configpages/puzzlepreferencesconfigurationpage.cpp @@ -310,7 +310,7 @@ void PuzzlePreferencesConfigurationPage::InitShortcuts(bool defaults) } //--------------------------------------------------------------------------------------------------------------------- -void PuzzlePreferencesConfigurationPage::UpdateShortcutsTable() +void PuzzlePreferencesConfigurationPage::UpdateShortcutsTable() const { for (int i = 0; i < m_transientShortcuts.length(); i++) { @@ -320,7 +320,7 @@ void PuzzlePreferencesConfigurationPage::UpdateShortcutsTable() } //--------------------------------------------------------------------------------------------------------------------- -void PuzzlePreferencesConfigurationPage::RetranslateShortcutsTable() +void PuzzlePreferencesConfigurationPage::RetranslateShortcutsTable() const { VAbstractShortcutManager *manager = VAbstractApplication::VApp()->GetShortcutManager(); if (manager == nullptr) diff --git a/src/app/puzzle/dialogs/configpages/puzzlepreferencesconfigurationpage.h b/src/app/puzzle/dialogs/configpages/puzzlepreferencesconfigurationpage.h index d0d364e66..0471bbf5f 100644 --- a/src/app/puzzle/dialogs/configpages/puzzlepreferencesconfigurationpage.h +++ b/src/app/puzzle/dialogs/configpages/puzzlepreferencesconfigurationpage.h @@ -61,8 +61,8 @@ private: void SetThemeModeComboBox(); void InitShortcuts(bool defaults = false); - void UpdateShortcutsTable(); - void RetranslateShortcutsTable(); + void UpdateShortcutsTable() const; + void RetranslateShortcutsTable() const; }; #endif // PUZZLEPREFERENCESCONFIGURATIONPAGE_H diff --git a/src/app/puzzle/dialogs/configpages/puzzlepreferenceslayoutpage.cpp b/src/app/puzzle/dialogs/configpages/puzzlepreferenceslayoutpage.cpp index f3366e488..4f5bdfee4 100644 --- a/src/app/puzzle/dialogs/configpages/puzzlepreferenceslayoutpage.cpp +++ b/src/app/puzzle/dialogs/configpages/puzzlepreferenceslayoutpage.cpp @@ -680,7 +680,7 @@ void PuzzlePreferencesLayoutPage::ReadSettings() } //--------------------------------------------------------------------------------------------------------------------- -void PuzzlePreferencesLayoutPage::FindTemplate(QComboBox *box, qreal width, qreal height) +void PuzzlePreferencesLayoutPage::FindTemplate(QComboBox *box, qreal width, qreal height) const { SCASSERT(box != nullptr) const Unit paperUnit = LayoutUnit(); diff --git a/src/app/puzzle/dialogs/configpages/puzzlepreferenceslayoutpage.h b/src/app/puzzle/dialogs/configpages/puzzlepreferenceslayoutpage.h index b5aa24408..6db9c830e 100644 --- a/src/app/puzzle/dialogs/configpages/puzzlepreferenceslayoutpage.h +++ b/src/app/puzzle/dialogs/configpages/puzzlepreferenceslayoutpage.h @@ -99,7 +99,7 @@ private: void ReadSettings(); - void FindTemplate(QComboBox *box, qreal width, qreal height); + void FindTemplate(QComboBox *box, qreal width, qreal height) const; }; #endif // PUZZLEPREFERENCESLAYOUTPAGE_H diff --git a/src/app/puzzle/dialogs/configpages/puzzlepreferencespathpage.cpp b/src/app/puzzle/dialogs/configpages/puzzlepreferencespathpage.cpp index 6f9ba5d00..9b232d201 100644 --- a/src/app/puzzle/dialogs/configpages/puzzlepreferencespathpage.cpp +++ b/src/app/puzzle/dialogs/configpages/puzzlepreferencespathpage.cpp @@ -56,7 +56,7 @@ PuzzlePreferencesPathPage::PuzzlePreferencesPathPage(QWidget *parent) PuzzlePreferencesPathPage::~PuzzlePreferencesPathPage() = default; //--------------------------------------------------------------------------------------------------------------------- -void PuzzlePreferencesPathPage::Apply() +void PuzzlePreferencesPathPage::Apply() const { VPSettings *settings = VPApplication::VApp()->PuzzleSettings(); settings->SetPathSVGFonts(ui->pathTable->item(0, 1)->text()); @@ -78,7 +78,7 @@ void PuzzlePreferencesPathPage::changeEvent(QEvent *event) } //--------------------------------------------------------------------------------------------------------------------- -void PuzzlePreferencesPathPage::DefaultPath() +void PuzzlePreferencesPathPage::DefaultPath() const { const int row = ui->pathTable->currentRow(); QTableWidgetItem *item = ui->pathTable->item(row, 1); diff --git a/src/app/puzzle/dialogs/configpages/puzzlepreferencespathpage.h b/src/app/puzzle/dialogs/configpages/puzzlepreferencespathpage.h index 03959d1f7..42773b882 100644 --- a/src/app/puzzle/dialogs/configpages/puzzlepreferencespathpage.h +++ b/src/app/puzzle/dialogs/configpages/puzzlepreferencespathpage.h @@ -44,13 +44,13 @@ public: explicit PuzzlePreferencesPathPage(QWidget *parent = nullptr); ~PuzzlePreferencesPathPage() override; - void Apply(); + void Apply() const; protected: void changeEvent(QEvent *event) override; private slots: - void DefaultPath(); + void DefaultPath() const; void EditPath(); private: diff --git a/src/app/puzzle/layout/vppiece.cpp b/src/app/puzzle/layout/vppiece.cpp index 10c90038a..3d85a3a18 100644 --- a/src/app/puzzle/layout/vppiece.cpp +++ b/src/app/puzzle/layout/vppiece.cpp @@ -217,7 +217,7 @@ void VPPiece::ClearTransformations() } //--------------------------------------------------------------------------------------------------------------------- -void VPPiece::SetPosition(QPointF point) +void VPPiece::SetPosition(QPointF point) const { QTransform matrix = GetMatrix(); const QPointF offset = MappedDetailBoundingRect().topLeft(); @@ -226,7 +226,7 @@ void VPPiece::SetPosition(QPointF point) } //--------------------------------------------------------------------------------------------------------------------- -auto VPPiece::GetPosition() -> QPointF +auto VPPiece::GetPosition() const -> QPointF { QTransform const matrix = GetMatrix(); return {matrix.dx(), matrix.dy()}; diff --git a/src/app/puzzle/layout/vppiece.h b/src/app/puzzle/layout/vppiece.h index 29645c7cf..03108dfa5 100644 --- a/src/app/puzzle/layout/vppiece.h +++ b/src/app/puzzle/layout/vppiece.h @@ -65,13 +65,13 @@ public: * @brief SetPosition Sets the position of the piece, in relation to the origin of the scene * @param point the point where to set the piece */ - void SetPosition(QPointF point); + void SetPosition(QPointF point) const; /** * @brief GetPosition Returns the position of the piece * @return the position of the piece */ - auto GetPosition() -> QPointF; + auto QPointF GetPosition() -> QPointF; /** * @brief RotateToGrainline rotates the piece to follow the grainline diff --git a/src/app/puzzle/layout/vpsheet.cpp b/src/app/puzzle/layout/vpsheet.cpp index eedf51c4b..81b2892cd 100644 --- a/src/app/puzzle/layout/vpsheet.cpp +++ b/src/app/puzzle/layout/vpsheet.cpp @@ -310,7 +310,7 @@ void VPSheetSceneData::RefreshSheetSize() } //--------------------------------------------------------------------------------------------------------------------- -void VPSheetSceneData::ConnectPiece(VPGraphicsPiece *piece) +void VPSheetSceneData::ConnectPiece(VPGraphicsPiece *piece) const { SCASSERT(piece != nullptr) diff --git a/src/app/puzzle/layout/vpsheet.h b/src/app/puzzle/layout/vpsheet.h index 457ef7e70..316190d4d 100644 --- a/src/app/puzzle/layout/vpsheet.h +++ b/src/app/puzzle/layout/vpsheet.h @@ -129,7 +129,7 @@ private: bool m_outOfBoundTmp{false}; bool m_pieceSuperpositionTmp{false}; - void ConnectPiece(VPGraphicsPiece *piece); + void ConnectPiece(VPGraphicsPiece *piece) const; }; class VPSheet : public QObject diff --git a/src/app/puzzle/scene/vpgraphicspiece.cpp b/src/app/puzzle/scene/vpgraphicspiece.cpp index 84e1eb922..2a6d87232 100644 --- a/src/app/puzzle/scene/vpgraphicspiece.cpp +++ b/src/app/puzzle/scene/vpgraphicspiece.cpp @@ -205,7 +205,7 @@ VPGraphicsPiece::VPGraphicsPiece(const VPPiecePtr &piece, QGraphicsItem *parent) } //--------------------------------------------------------------------------------------------------------------------- -auto VPGraphicsPiece::GetPiece() -> VPPiecePtr +auto VPGraphicsPiece::GetPiece() const -> VPPiecePtr { return m_piece.toStrongRef(); } @@ -939,7 +939,7 @@ void VPGraphicsPiece::PaintStickyPath(QPainter *painter) } //--------------------------------------------------------------------------------------------------------------------- -void VPGraphicsPiece::PaintMirrorLine(QPainter *painter, const VPPiecePtr &piece) +void VPGraphicsPiece::PaintMirrorLine(QPainter *painter, const VPPiecePtr &piece) const { if (piece->IsShowFullPiece()) { diff --git a/src/app/puzzle/scene/vpgraphicspiece.h b/src/app/puzzle/scene/vpgraphicspiece.h index 55e2a35e0..1138d820c 100644 --- a/src/app/puzzle/scene/vpgraphicspiece.h +++ b/src/app/puzzle/scene/vpgraphicspiece.h @@ -50,7 +50,7 @@ public: * @brief GetPiece Returns the piece that corresponds to the graphics piece * @return the piece */ - auto GetPiece() -> VPPiecePtr; + auto GetPiece() const -> VPPiecePtr; auto type() const -> int override { return Type; } enum @@ -133,7 +133,7 @@ private: void PaintPassmarks(QPainter *painter, const VPPiecePtr &piece); void PaintPlaceLabels(QPainter *painter, const VPPiecePtr &piece); void PaintStickyPath(QPainter *painter); - void PaintMirrorLine(QPainter *painter, const VPPiecePtr &piece); + void PaintMirrorLine(QPainter *painter, const VPPiecePtr &piece) const; void PaintFoldLine(QPainter *painter, const VPPiecePtr &piece); void GroupMove(const QPointF &pos); diff --git a/src/app/puzzle/scene/vpmaingraphicsview.cpp b/src/app/puzzle/scene/vpmaingraphicsview.cpp index b991d965a..cde66c733 100644 --- a/src/app/puzzle/scene/vpmaingraphicsview.cpp +++ b/src/app/puzzle/scene/vpmaingraphicsview.cpp @@ -103,7 +103,7 @@ VPMainGraphicsView::VPMainGraphicsView(const VPLayoutPtr &layout, QWidget *paren } //--------------------------------------------------------------------------------------------------------------------- -void VPMainGraphicsView::RefreshLayout() +void VPMainGraphicsView::RefreshLayout() const { VPLayoutPtr const layout = m_layout.toStrongRef(); if (not layout.isNull()) @@ -117,7 +117,7 @@ void VPMainGraphicsView::RefreshLayout() } //--------------------------------------------------------------------------------------------------------------------- -void VPMainGraphicsView::RefreshPieces() +void VPMainGraphicsView::RefreshPieces() const { VPLayoutPtr const layout = m_layout.toStrongRef(); if (not layout.isNull()) @@ -570,7 +570,7 @@ void VPMainGraphicsView::SwitchScene(const VPSheetPtr &sheet) } //--------------------------------------------------------------------------------------------------------------------- -void VPMainGraphicsView::ClearSelection() +void VPMainGraphicsView::ClearSelection() const { VPLayoutPtr const layout = m_layout.toStrongRef(); if (layout.isNull()) @@ -593,7 +593,7 @@ void VPMainGraphicsView::ClearSelection() } //--------------------------------------------------------------------------------------------------------------------- -void VPMainGraphicsView::ZValueMove(int move) +void VPMainGraphicsView::ZValueMove(int move) const { VPLayoutPtr const layout = m_layout.toStrongRef(); if (layout.isNull()) diff --git a/src/app/puzzle/scene/vpmaingraphicsview.h b/src/app/puzzle/scene/vpmaingraphicsview.h index 7424d2079..0452304bc 100644 --- a/src/app/puzzle/scene/vpmaingraphicsview.h +++ b/src/app/puzzle/scene/vpmaingraphicsview.h @@ -52,7 +52,7 @@ public: /** * @brief RefreshLayout Refreshes the rectangles for the layout border and the margin */ - void RefreshLayout(); + void RefreshLayout() const; public slots: /** @@ -64,7 +64,7 @@ public slots: void on_ActiveSheetChanged(const VPSheetPtr &focusedSheet); - void RefreshPieces(); + void RefreshPieces() const; signals: /** @@ -108,9 +108,9 @@ private: void TranslatePiecesOn(qreal dx, qreal dy); void SwitchScene(const VPSheetPtr &sheet); - void ClearSelection(); + void ClearSelection() const; - void ZValueMove(int move); + void ZValueMove(int move) const; void RemovePiece() const; void MovePiece(QKeyEvent *event);