Code cleaning : functions that should be const

This commit is contained in:
Yann Lossouarn 2024-02-23 23:46:32 +01:00
parent 95db2eb133
commit 55b2c1b4ae
14 changed files with 28 additions and 28 deletions

View File

@ -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++) 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(); VAbstractShortcutManager *manager = VAbstractApplication::VApp()->GetShortcutManager();
if (manager == nullptr) if (manager == nullptr)

View File

@ -61,8 +61,8 @@ private:
void SetThemeModeComboBox(); void SetThemeModeComboBox();
void InitShortcuts(bool defaults = false); void InitShortcuts(bool defaults = false);
void UpdateShortcutsTable(); void UpdateShortcutsTable() const;
void RetranslateShortcutsTable(); void RetranslateShortcutsTable() const;
}; };
#endif // PUZZLEPREFERENCESCONFIGURATIONPAGE_H #endif // PUZZLEPREFERENCESCONFIGURATIONPAGE_H

View File

@ -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) SCASSERT(box != nullptr)
const Unit paperUnit = LayoutUnit(); const Unit paperUnit = LayoutUnit();

View File

@ -99,7 +99,7 @@ private:
void ReadSettings(); void ReadSettings();
void FindTemplate(QComboBox *box, qreal width, qreal height); void FindTemplate(QComboBox *box, qreal width, qreal height) const;
}; };
#endif // PUZZLEPREFERENCESLAYOUTPAGE_H #endif // PUZZLEPREFERENCESLAYOUTPAGE_H

View File

@ -56,7 +56,7 @@ PuzzlePreferencesPathPage::PuzzlePreferencesPathPage(QWidget *parent)
PuzzlePreferencesPathPage::~PuzzlePreferencesPathPage() = default; PuzzlePreferencesPathPage::~PuzzlePreferencesPathPage() = default;
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void PuzzlePreferencesPathPage::Apply() void PuzzlePreferencesPathPage::Apply() const
{ {
VPSettings *settings = VPApplication::VApp()->PuzzleSettings(); VPSettings *settings = VPApplication::VApp()->PuzzleSettings();
settings->SetPathSVGFonts(ui->pathTable->item(0, 1)->text()); 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(); const int row = ui->pathTable->currentRow();
QTableWidgetItem *item = ui->pathTable->item(row, 1); QTableWidgetItem *item = ui->pathTable->item(row, 1);

View File

@ -44,13 +44,13 @@ public:
explicit PuzzlePreferencesPathPage(QWidget *parent = nullptr); explicit PuzzlePreferencesPathPage(QWidget *parent = nullptr);
~PuzzlePreferencesPathPage() override; ~PuzzlePreferencesPathPage() override;
void Apply(); void Apply() const;
protected: protected:
void changeEvent(QEvent *event) override; void changeEvent(QEvent *event) override;
private slots: private slots:
void DefaultPath(); void DefaultPath() const;
void EditPath(); void EditPath();
private: private:

View File

@ -217,7 +217,7 @@ void VPPiece::ClearTransformations()
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPPiece::SetPosition(QPointF point) void VPPiece::SetPosition(QPointF point) const
{ {
QTransform matrix = GetMatrix(); QTransform matrix = GetMatrix();
const QPointF offset = MappedDetailBoundingRect().topLeft(); 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(); QTransform const matrix = GetMatrix();
return {matrix.dx(), matrix.dy()}; return {matrix.dx(), matrix.dy()};

View File

@ -65,13 +65,13 @@ public:
* @brief SetPosition Sets the position of the piece, in relation to the origin of the scene * @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 * @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 * @brief GetPosition Returns the position of the piece
* @return 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 * @brief RotateToGrainline rotates the piece to follow the grainline

View File

@ -310,7 +310,7 @@ void VPSheetSceneData::RefreshSheetSize()
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPSheetSceneData::ConnectPiece(VPGraphicsPiece *piece) void VPSheetSceneData::ConnectPiece(VPGraphicsPiece *piece) const
{ {
SCASSERT(piece != nullptr) SCASSERT(piece != nullptr)

View File

@ -129,7 +129,7 @@ private:
bool m_outOfBoundTmp{false}; bool m_outOfBoundTmp{false};
bool m_pieceSuperpositionTmp{false}; bool m_pieceSuperpositionTmp{false};
void ConnectPiece(VPGraphicsPiece *piece); void ConnectPiece(VPGraphicsPiece *piece) const;
}; };
class VPSheet : public QObject class VPSheet : public QObject

View File

@ -205,7 +205,7 @@ VPGraphicsPiece::VPGraphicsPiece(const VPPiecePtr &piece, QGraphicsItem *parent)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VPGraphicsPiece::GetPiece() -> VPPiecePtr auto VPGraphicsPiece::GetPiece() const -> VPPiecePtr
{ {
return m_piece.toStrongRef(); 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()) if (piece->IsShowFullPiece())
{ {

View File

@ -50,7 +50,7 @@ public:
* @brief GetPiece Returns the piece that corresponds to the graphics piece * @brief GetPiece Returns the piece that corresponds to the graphics piece
* @return the piece * @return the piece
*/ */
auto GetPiece() -> VPPiecePtr; auto GetPiece() const -> VPPiecePtr;
auto type() const -> int override { return Type; } auto type() const -> int override { return Type; }
enum enum
@ -133,7 +133,7 @@ private:
void PaintPassmarks(QPainter *painter, const VPPiecePtr &piece); void PaintPassmarks(QPainter *painter, const VPPiecePtr &piece);
void PaintPlaceLabels(QPainter *painter, const VPPiecePtr &piece); void PaintPlaceLabels(QPainter *painter, const VPPiecePtr &piece);
void PaintStickyPath(QPainter *painter); 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 PaintFoldLine(QPainter *painter, const VPPiecePtr &piece);
void GroupMove(const QPointF &pos); void GroupMove(const QPointF &pos);

View File

@ -103,7 +103,7 @@ VPMainGraphicsView::VPMainGraphicsView(const VPLayoutPtr &layout, QWidget *paren
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPMainGraphicsView::RefreshLayout() void VPMainGraphicsView::RefreshLayout() const
{ {
VPLayoutPtr const layout = m_layout.toStrongRef(); VPLayoutPtr const layout = m_layout.toStrongRef();
if (not layout.isNull()) if (not layout.isNull())
@ -117,7 +117,7 @@ void VPMainGraphicsView::RefreshLayout()
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPMainGraphicsView::RefreshPieces() void VPMainGraphicsView::RefreshPieces() const
{ {
VPLayoutPtr const layout = m_layout.toStrongRef(); VPLayoutPtr const layout = m_layout.toStrongRef();
if (not layout.isNull()) 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(); VPLayoutPtr const layout = m_layout.toStrongRef();
if (layout.isNull()) 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(); VPLayoutPtr const layout = m_layout.toStrongRef();
if (layout.isNull()) if (layout.isNull())

View File

@ -52,7 +52,7 @@ public:
/** /**
* @brief RefreshLayout Refreshes the rectangles for the layout border and the margin * @brief RefreshLayout Refreshes the rectangles for the layout border and the margin
*/ */
void RefreshLayout(); void RefreshLayout() const;
public slots: public slots:
/** /**
@ -64,7 +64,7 @@ public slots:
void on_ActiveSheetChanged(const VPSheetPtr &focusedSheet); void on_ActiveSheetChanged(const VPSheetPtr &focusedSheet);
void RefreshPieces(); void RefreshPieces() const;
signals: signals:
/** /**
@ -108,9 +108,9 @@ private:
void TranslatePiecesOn(qreal dx, qreal dy); void TranslatePiecesOn(qreal dx, qreal dy);
void SwitchScene(const VPSheetPtr &sheet); void SwitchScene(const VPSheetPtr &sheet);
void ClearSelection(); void ClearSelection() const;
void ZValueMove(int move); void ZValueMove(int move) const;
void RemovePiece() const; void RemovePiece() const;
void MovePiece(QKeyEvent *event); void MovePiece(QKeyEvent *event);