Skip to content

Commit

Permalink
Spread some more const
Browse files Browse the repository at this point in the history
  • Loading branch information
nirvn committed Apr 12, 2024
1 parent f3d68a9 commit bdea9aa
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/core/drawingcanvas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ void DrawingCanvas::strokeEnd( const QPointF &point )
update();
}

void DrawingCanvas::drawStroke( QPainter *painter, const Stroke &stroke, bool onCanvas )
void DrawingCanvas::drawStroke( QPainter *painter, const Stroke &stroke, bool onCanvas ) const
{
QPainterPath path( onCanvas ? stroke.points.at( 0 ) : canvasToItem( stroke.points.at( 0 ) ) );
for ( int i = 1; i < stroke.points.size(); i++ )
Expand Down Expand Up @@ -310,15 +310,15 @@ void DrawingCanvas::undo()
}
}

QPointF DrawingCanvas::itemToCanvas( const QPointF &point )
QPointF DrawingCanvas::itemToCanvas( const QPointF &point ) const
{
const QPointF canvasTopLeft( size().width() / 2 - ( mBackgroundImage.size().width() * mZoomFactor / 2 ) + mOffset.x(),
size().height() / 2 - ( mBackgroundImage.size().height() * mZoomFactor / 2 ) + mOffset.y() );
return QPointF( ( point.x() - canvasTopLeft.x() ) / mZoomFactor,
( point.y() - canvasTopLeft.y() ) / mZoomFactor );
}

QPointF DrawingCanvas::canvasToItem( const QPointF &point )
QPointF DrawingCanvas::canvasToItem( const QPointF &point ) const
{
const QPointF canvasTopLeft( size().width() / 2 - ( mBackgroundImage.size().width() * mZoomFactor / 2 ) + mOffset.x(),
size().height() / 2 - ( mBackgroundImage.size().height() * mZoomFactor / 2 ) + mOffset.y() );
Expand Down
6 changes: 3 additions & 3 deletions src/core/drawingcanvas.h
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,10 @@ class DrawingCanvas : public QQuickPaintedItem
QList<QPointF> points;
};

void drawStroke( QPainter *painter, const Stroke &stroke, bool onCanvas = true );
void drawStroke( QPainter *painter, const Stroke &stroke, bool onCanvas = true ) const;

QPointF itemToCanvas( const QPointF &point );
QPointF canvasToItem( const QPointF &point );
QPointF itemToCanvas( const QPointF &point ) const;
QPointF canvasToItem( const QPointF &point ) const;

bool mIsEmpty = true;
bool mIsDirty = false;
Expand Down

0 comments on commit bdea9aa

Please sign in to comment.