Fix warnings about marking functions override

Change-Id: I7737469d3016f9522e497b443edd864fa4d714cc
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
This commit is contained in:
Andreas Buhr 2021-03-10 16:01:20 +01:00
parent 346d30144a
commit d0ba43f0f5
9 changed files with 94 additions and 79 deletions

View File

@ -128,11 +128,13 @@ public:
{ {
} }
virtual void draw(QPainter *p, const QRect &rect, int iterationCount) { void draw(QPainter *p, const QRect &rect, int iterationCount) override
{
p->fillRect(rect, randomColor(iterationCount)); p->fillRect(rect, randomColor(iterationCount));
} }
virtual QString name() const { QString name() const override
{
return QString::fromLatin1("fillRect(%1)").arg(m_size.width()); return QString::fromLatin1("fillRect(%1)").arg(m_size.width());
} }
}; };
@ -154,11 +156,10 @@ public:
m_brush = QBrush(m_content); m_brush = QBrush(m_content);
} }
virtual void draw(QPainter *p, const QRect &rect, int) { void draw(QPainter *p, const QRect &rect, int) override { p->fillRect(rect, m_brush); }
p->fillRect(rect, m_brush);
}
virtual QString name() const { QString name() const override
{
return QString::fromLatin1("fillRect with image(%1)").arg(m_size.width()); return QString::fromLatin1("fillRect with image(%1)").arg(m_size.width());
} }
@ -176,17 +177,16 @@ public:
{ {
} }
virtual void begin(QPainter *p, int) { void begin(QPainter *p, int) override
{
p->setPen(Qt::NoPen); p->setPen(Qt::NoPen);
p->setBrush(randomColor(m_size.width())); p->setBrush(randomColor(m_size.width()));
} }
void draw(QPainter *p, const QRect &rect, int) override { p->drawRect(rect); }
virtual void draw(QPainter *p, const QRect &rect, int) { QString name() const override
p->drawRect(rect); {
}
virtual QString name() const {
return QString::fromLatin1("drawRect(%1)").arg(m_size.width()); return QString::fromLatin1("drawRect(%1)").arg(m_size.width());
} }
}; };
@ -200,17 +200,16 @@ public:
{ {
} }
virtual void begin(QPainter *p, int) { void begin(QPainter *p, int) override { p->setPen(Qt::NoPen); }
p->setPen(Qt::NoPen);
}
void draw(QPainter *p, const QRect &rect, int i) override
virtual void draw(QPainter *p, const QRect &rect, int i) { {
p->setBrush(randomColor(i)); p->setBrush(randomColor(i));
p->drawRect(rect); p->drawRect(rect);
} }
virtual QString name() const { QString name() const override
{
return QString::fromLatin1("drawRect with brushchange(%1)").arg(m_size.width()); return QString::fromLatin1("drawRect with brushchange(%1)").arg(m_size.width());
} }
}; };
@ -224,16 +223,19 @@ public:
m_roundness = size / 4.; m_roundness = size / 4.;
} }
virtual void begin(QPainter *p, int) { void begin(QPainter *p, int) override
{
p->setPen(Qt::NoPen); p->setPen(Qt::NoPen);
p->setBrush(Qt::red); p->setBrush(Qt::red);
} }
virtual void draw(QPainter *p, const QRect &rect, int) { void draw(QPainter *p, const QRect &rect, int) override
{
p->drawRoundedRect(rect, m_roundness, m_roundness); p->drawRoundedRect(rect, m_roundness, m_roundness);
} }
virtual QString name() const { QString name() const override
{
return QString::fromLatin1("drawRoundedRect(%1)").arg(m_size.width()); return QString::fromLatin1("drawRoundedRect(%1)").arg(m_size.width());
} }
@ -262,7 +264,8 @@ public:
{ {
} }
virtual void begin(QPainter *p, int) { void begin(QPainter *p, int) override
{
if (m_type & Stroked) if (m_type & Stroked)
p->setPen(Qt::black); p->setPen(Qt::black);
else else
@ -274,7 +277,8 @@ public:
p->setBrush(Qt::NoBrush); p->setBrush(Qt::NoBrush);
} }
virtual void draw(QPainter *p, const QRect &rect, int) { void draw(QPainter *p, const QRect &rect, int) override
{
switch (m_type & Shapes) { switch (m_type & Shapes) {
case ArcShape: case ArcShape:
p->drawArc(rect, 45*16, 120*16); p->drawArc(rect, 45*16, 120*16);
@ -291,7 +295,8 @@ public:
} }
} }
virtual QString name() const { QString name() const override
{
QString fillStroke; QString fillStroke;
if ((m_type & (Stroked|Filled)) == (Stroked|Filled)) { if ((m_type & (Stroked|Filled)) == (Stroked|Filled)) {
@ -336,18 +341,18 @@ public:
{ {
} }
virtual void begin(QPainter *p, int) { void begin(QPainter *p, int) override { p->scale(m_scale, m_scale); }
p->scale(m_scale, m_scale);
}
virtual void draw(QPainter *p, const QRect &rect, int) { void draw(QPainter *p, const QRect &rect, int) override
{
if (m_as_pixmap) if (m_as_pixmap)
p->drawPixmap(rect.topLeft(), m_pixmap); p->drawPixmap(rect.topLeft(), m_pixmap);
else else
p->drawImage(rect.topLeft(), m_image); p->drawImage(rect.topLeft(), m_image);
} }
virtual QString name() const { QString name() const override
{
return QString::fromLatin1("draw%4(%1) at scale=%2, depth=%3") return QString::fromLatin1("draw%4(%1) at scale=%2, depth=%3")
.arg(m_size.width()) .arg(m_size.width())
.arg(m_scale) .arg(m_scale)
@ -382,7 +387,8 @@ public:
{ {
} }
virtual void draw(QPainter *p, const QRect &rect, int) { void draw(QPainter *p, const QRect &rect, int) override
{
QTransform oldTransform = p->transform(); QTransform oldTransform = p->transform();
p->translate(0.5 * rect.width() + rect.left(), 0.5 * rect.height() + rect.top()); p->translate(0.5 * rect.width() + rect.left(), 0.5 * rect.height() + rect.top());
p->shear(0.25, 0.0); p->shear(0.25, 0.0);
@ -394,7 +400,8 @@ public:
p->setTransform(oldTransform); p->setTransform(oldTransform);
} }
virtual QString name() const { QString name() const override
{
return QString::fromLatin1("draw%3(%1) w/transform, depth=%2") return QString::fromLatin1("draw%3(%1) w/transform, depth=%2")
.arg(m_size.width()) .arg(m_size.width())
.arg(m_as_pixmap ? m_pixmap.depth() : m_image.depth()) .arg(m_as_pixmap ? m_pixmap.depth() : m_image.depth())
@ -428,14 +435,16 @@ public:
{ {
} }
virtual void draw(QPainter *p, const QRect &rect, int) { void draw(QPainter *p, const QRect &rect, int) override
{
if (m_as_pixmap) if (m_as_pixmap)
p->drawPixmap(rect.topLeft(), m_pixmap); p->drawPixmap(rect.topLeft(), m_pixmap);
else else
p->drawImage(rect.topLeft(), m_image); p->drawImage(rect.topLeft(), m_image);
} }
virtual QString name() const { QString name() const override
{
return QString::fromLatin1("draw%2(%1), depth=%3") return QString::fromLatin1("draw%2(%1), depth=%3")
.arg(m_size.width()) .arg(m_size.width())
.arg(m_type) .arg(m_type)
@ -469,7 +478,8 @@ public:
{ {
} }
virtual void begin(QPainter *p, int iterations) { void begin(QPainter *p, int iterations) override
{
m_staticTexts.clear(); m_staticTexts.clear();
m_currentStaticText = 0; m_currentStaticText = 0;
m_pixmaps.clear(); m_pixmaps.clear();
@ -557,7 +567,7 @@ public:
} }
} }
virtual void draw(QPainter *p, const QRect &rect, int) void draw(QPainter *p, const QRect &rect, int) override
{ {
switch (m_mode) { switch (m_mode) {
case PainterMode: case PainterMode:
@ -589,7 +599,8 @@ public:
} }
} }
virtual QString name() const { QString name() const override
{
int letters = m_text.length(); int letters = m_text.length();
int lines = m_text.count('\n'); int lines = m_text.count('\n');
if (lines == 0) if (lines == 0)
@ -644,7 +655,8 @@ public:
{ {
} }
virtual void begin(QPainter *p, int) { void begin(QPainter *p, int) override
{
QRect m_bounds = QRect(0,0,p->device()->width(), p->device()->height()); QRect m_bounds = QRect(0,0,p->device()->width(), p->device()->height());
p->setPen(Qt::NoPen); p->setPen(Qt::NoPen);
p->setBrush(Qt::red); p->setBrush(Qt::red);
@ -706,11 +718,10 @@ public:
} }
} }
virtual void draw(QPainter *p, const QRect &rect, int) { void draw(QPainter *p, const QRect &rect, int) override { p->drawRect(rect); }
p->drawRect(rect);
}
virtual QString name() const { QString name() const override
{
QString namedType; QString namedType;
switch (m_type) { switch (m_type) {
case RectClip: case RectClip:
@ -764,7 +775,8 @@ public:
} }
virtual void draw(QPainter *p, const QRect &rect, int) { void draw(QPainter *p, const QRect &rect, int) override
{
switch (m_type) { switch (m_type) {
case Horizontal_Integer: case Horizontal_Integer:
p->drawLine(QLine(rect.x(), rect.y(), rect.x() + m_length, rect.y())); p->drawLine(QLine(rect.x(), rect.y(), rect.x() + m_length, rect.y()));
@ -787,7 +799,8 @@ public:
} }
} }
virtual QString name() const { QString name() const override
{
const char *names[] = { const char *names[] = {
"Hor_I", "Hor_I",
"Diag_I", "Diag_I",

View File

@ -39,7 +39,7 @@ class BenchWidget : public QWidget
public: public:
BenchWidget(Benchmark *benchmark); BenchWidget(Benchmark *benchmark);
void paintEvent(QPaintEvent *event); void paintEvent(QPaintEvent *event) override;
bool done() const { return m_done; } bool done() const { return m_done; }
qreal result() const { return m_result; } qreal result() const { return m_result; }

View File

@ -56,7 +56,7 @@ class RectWidget : public QGraphicsWidget
public: public:
RectWidget(QGraphicsItem *parent = nullptr) : QGraphicsWidget(parent){} RectWidget(QGraphicsItem *parent = nullptr) : QGraphicsWidget(parent){}
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override
{ {
Q_UNUSED(option); Q_UNUSED(option);
Q_UNUSED(widget); Q_UNUSED(widget);

View File

@ -49,7 +49,7 @@ class RectWidget : public QGraphicsWidget
public: public:
RectWidget(QGraphicsItem *parent = nullptr, Qt::WindowFlags wFlags = { }) : QGraphicsWidget(parent, wFlags), setGeometryCalls(0) {} RectWidget(QGraphicsItem *parent = nullptr, Qt::WindowFlags wFlags = { }) : QGraphicsWidget(parent, wFlags), setGeometryCalls(0) {}
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override
{ {
Q_UNUSED(option); Q_UNUSED(option);
Q_UNUSED(widget); Q_UNUSED(widget);
@ -58,7 +58,7 @@ public:
painter->drawLine(rect().bottomLeft(), rect().topRight()); painter->drawLine(rect().bottomLeft(), rect().topRight());
} }
void setGeometry(const QRectF &rect) void setGeometry(const QRectF &rect) override
{ {
//qDebug() << "setGeometry():" << this->data(0).toString(); //qDebug() << "setGeometry():" << this->data(0).toString();
setGeometryCalls->insert(this, rect); setGeometryCalls->insert(this, rect);

View File

@ -47,7 +47,7 @@ private slots:
struct MySquareWidget : public QGraphicsWidget struct MySquareWidget : public QGraphicsWidget
{ {
MySquareWidget() {} MySquareWidget() {}
virtual QSizeF sizeHint ( Qt::SizeHint which, const QSizeF & constraint = QSizeF() ) const QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint = QSizeF()) const override
{ {
if (which != Qt::PreferredSize) if (which != Qt::PreferredSize)
return QGraphicsWidget::sizeHint(which, constraint); return QGraphicsWidget::sizeHint(which, constraint);

View File

@ -37,14 +37,14 @@ class Chip : public QGraphicsItem
public: public:
Chip(const QColor &color, int x, int y); Chip(const QColor &color, int x, int y);
QRectF boundingRect() const; QRectF boundingRect() const override;
QPainterPath shape() const; QPainterPath shape() const override;
void paint(QPainter *painter, const QStyleOptionGraphicsItem *item, QWidget *widget); void paint(QPainter *painter, const QStyleOptionGraphicsItem *item, QWidget *widget) override;
protected: protected:
void mousePressEvent(QGraphicsSceneMouseEvent *event); void mousePressEvent(QGraphicsSceneMouseEvent *event) override;
void mouseMoveEvent(QGraphicsSceneMouseEvent *event); void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override;
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event); void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override;
private: private:
int x, y; int x, y;

View File

@ -54,8 +54,8 @@ public:
void setOperation(Operation operation); void setOperation(Operation operation);
protected: protected:
void paintEvent(QPaintEvent *event); void paintEvent(QPaintEvent *event) override;
void timerEvent(QTimerEvent *event); void timerEvent(QTimerEvent *event) override;
private: private:
void populateScene(); void populateScene();

View File

@ -81,14 +81,14 @@ public:
} }
protected: protected:
void paintEvent(QPaintEvent *event) void paintEvent(QPaintEvent *event) override
{ {
QGraphicsView::paintEvent(event); QGraphicsView::paintEvent(event);
if (waiting) if (waiting)
eventLoop.exit(); eventLoop.exit();
} }
void timerEvent(QTimerEvent *event) void timerEvent(QTimerEvent *event) override
{ {
if (event->timerId() == timerId) if (event->timerId() == timerId)
eventLoop.exit(); eventLoop.exit();
@ -479,7 +479,7 @@ public:
} }
protected: protected:
void advance(int i) void advance(int i) override
{ {
if (!i) if (!i)
return; return;
@ -587,7 +587,7 @@ public:
} }
protected: protected:
void advance(int i) void advance(int i) override
{ {
if (!i) if (!i)
return; return;
@ -693,14 +693,15 @@ public:
yspeed = y; yspeed = y;
} }
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0) void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget = 0) override
{ {
QGraphicsPixmapItem::paint(painter,option,widget); QGraphicsPixmapItem::paint(painter,option,widget);
//We just want to wait, and we don't want to process the event loop with qWait //We just want to wait, and we don't want to process the event loop with qWait
QTest::qSleep(3); QTest::qSleep(3);
} }
protected: protected:
void advance(int i) void advance(int i) override
{ {
if (!i) if (!i)
return; return;
@ -792,12 +793,13 @@ public:
{ {
} }
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0) void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget = 0) override
{ {
QGraphicsPixmapItem::paint(painter,option,widget); QGraphicsPixmapItem::paint(painter,option,widget);
} }
protected: protected:
void advance(int i) void advance(int i) override
{ {
Q_UNUSED(i); Q_UNUSED(i);
if (partial) if (partial)

View File

@ -45,11 +45,11 @@ public:
row_count(rows), row_count(rows),
column_count(columns) {} column_count(columns) {}
int rowCount(const QModelIndex& = QModelIndex()) const { return row_count; } int rowCount(const QModelIndex & = QModelIndex()) const override { return row_count; }
int columnCount(const QModelIndex& = QModelIndex()) const { return column_count; } int columnCount(const QModelIndex & = QModelIndex()) const override { return column_count; }
bool isEditable(const QModelIndex &) const { return true; } bool isEditable(const QModelIndex &) const { return true; }
QVariant data(const QModelIndex &idx, int role) const QVariant data(const QModelIndex &idx, int role) const override
{ {
if (!idx.isValid() || idx.row() >= row_count || idx.column() >= column_count) { if (!idx.isValid() || idx.row() >= row_count || idx.column() >= column_count) {
qWarning() << "Invalid modelIndex [%d,%d,%p]" << idx; qWarning() << "Invalid modelIndex [%d,%d,%p]" << idx;
@ -62,7 +62,7 @@ public:
return QVariant(); return QVariant();
} }
bool insertRows(int start, int count, const QModelIndex &parent = QModelIndex()) bool insertRows(int start, int count, const QModelIndex &parent = QModelIndex()) override
{ {
if (start < 0 || start > row_count) if (start < 0 || start > row_count)
return false; return false;
@ -73,7 +73,7 @@ public:
return true; return true;
} }
bool removeRows(int start, int count, const QModelIndex &parent = QModelIndex()) bool removeRows(int start, int count, const QModelIndex &parent = QModelIndex()) override
{ {
if (start < 0 || start >= row_count || row_count < count) if (start < 0 || start >= row_count || row_count < count)
return false; return false;
@ -84,7 +84,7 @@ public:
return true; return true;
} }
bool insertColumns(int start, int count, const QModelIndex &parent = QModelIndex()) bool insertColumns(int start, int count, const QModelIndex &parent = QModelIndex()) override
{ {
if (start < 0 || start > column_count) if (start < 0 || start > column_count)
return false; return false;
@ -95,7 +95,7 @@ public:
return true; return true;
} }
bool removeColumns(int start, int count, const QModelIndex &parent = QModelIndex()) bool removeColumns(int start, int count, const QModelIndex &parent = QModelIndex()) override
{ {
if (start < 0 || start >= column_count || column_count < count) if (start < 0 || start >= column_count || column_count < count)
return false; return false;