Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 061d596a authored by Alexander Semke's avatar Alexander Semke

Added some constness to worksheetview.

parent 765d3c2b
......@@ -39,10 +39,6 @@ WorksheetView::WorksheetView(Worksheet* scene, QWidget* parent) : QGraphicsView(
setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
}
WorksheetView::~WorksheetView()
{
}
void WorksheetView::makeVisible(const QRectF& sceneRect)
{
const qreal w = viewport()->width();
......@@ -142,7 +138,7 @@ void WorksheetView::makeVisible(const QRectF& sceneRect)
m_animation->start();
}
bool WorksheetView::isVisible(const QRectF& sceneRect)
bool WorksheetView::isVisible(const QRectF& sceneRect) const
{
const qreal w = viewport()->width();
const qreal h = viewport()->height();
......@@ -167,7 +163,7 @@ bool WorksheetView::isVisible(const QRectF& sceneRect)
return QRectF(x,y,w,h).contains(rect);
}
bool WorksheetView::isAtEnd()
bool WorksheetView::isAtEnd() const
{
bool atEnd = true;
if (verticalScrollBar())
......@@ -175,7 +171,7 @@ bool WorksheetView::isAtEnd()
return atEnd;
}
void WorksheetView::scrollToEnd()
void WorksheetView::scrollToEnd() const
{
if (verticalScrollBar())
verticalScrollBar()->setValue(verticalScrollBar()->maximum());
......@@ -214,17 +210,17 @@ void WorksheetView::endAnimation()
m_animation = nullptr;
}
QPoint WorksheetView::viewCursorPos()
QPoint WorksheetView::viewCursorPos() const
{
return viewport()->mapFromGlobal(QCursor::pos());
}
QPointF WorksheetView::sceneCursorPos()
QPointF WorksheetView::sceneCursorPos() const
{
return mapToScene(viewCursorPos());
}
QRectF WorksheetView::viewRect()
QRectF WorksheetView::viewRect() const
{
const qreal w = viewport()->width() / m_scale;
const qreal h = viewport()->height() / m_scale;
......@@ -233,13 +229,13 @@ QRectF WorksheetView::viewRect()
return QRectF(x, y, w, h);
}
void WorksheetView::resizeEvent(QResizeEvent * event)
void WorksheetView::resizeEvent(QResizeEvent* event)
{
QGraphicsView::resizeEvent(event);
updateSceneSize();
}
qreal WorksheetView::scaleFactor()
qreal WorksheetView::scaleFactor() const
{
return m_scale;
}
......@@ -251,7 +247,7 @@ void WorksheetView::updateSceneSize()
sendViewRectChange();
}
void WorksheetView::sceneRectChanged(const QRectF& sceneRect)
void WorksheetView::sceneRectChanged(const QRectF& sceneRect) const
{
Q_UNUSED(sceneRect);
if (verticalScrollBar())
......@@ -262,7 +258,7 @@ void WorksheetView::sceneRectChanged(const QRectF& sceneRect)
this, SLOT(sendViewRectChange()), Qt::UniqueConnection);
}
void WorksheetView::sendViewRectChange()
void WorksheetView::sendViewRectChange() const
{
emit viewRectChanged(viewRect());
}
......
......@@ -31,38 +31,34 @@ class Worksheet;
class WorksheetView : public QGraphicsView
{
Q_OBJECT
public:
public:
WorksheetView(Worksheet* scene, QWidget* parent);
~WorksheetView() override;
void makeVisible(const QRectF& sceneRect);
bool isVisible(const QRectF& sceneRect);
bool isAtEnd();
void scrollToEnd();
bool isVisible(const QRectF& sceneRect) const;
bool isAtEnd() const;
void scrollToEnd() const;
void scrollBy(int dy);
QPoint viewCursorPos();
QPointF sceneCursorPos();
QRectF viewRect();
void resizeEvent(QResizeEvent* event) Q_DECL_OVERRIDE;
qreal scaleFactor();
QPoint viewCursorPos() const;
QPointF sceneCursorPos() const;
QRectF viewRect() const;
qreal scaleFactor() const;
void updateSceneSize();
Q_SIGNALS:
void viewRectChanged(QRectF rect);
Q_SIGNALS:
void viewRectChanged(QRectF rect) const;
public Q_SLOTS:
public Q_SLOTS:
void zoomIn();
void zoomOut();
void endAnimation();
void sceneRectChanged(const QRectF& sceneRect);
void sendViewRectChange();
void sceneRectChanged(const QRectF& sceneRect) const;
void sendViewRectChange() const;
private:
void resizeEvent(QResizeEvent*) override;
private:
qreal m_scale;
QParallelAnimationGroup* m_animation;
QPropertyAnimation* m_hAnimation;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment