diff options
9 files changed, 94 insertions, 79 deletions
diff --git a/tests/benchmarks/gui/painting/qtbench/benchmarktests.h b/tests/benchmarks/gui/painting/qtbench/benchmarktests.h index ed03182597..bffdd5bf2d 100644 --- a/tests/benchmarks/gui/painting/qtbench/benchmarktests.h +++ b/tests/benchmarks/gui/painting/qtbench/benchmarktests.h @@ -128,13 +128,15 @@ 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)); } - virtual QString name() const { + QString name() const override + { return QString::fromLatin1("fillRect(%1)").arg(m_size.width()); - } + } }; class ImageFillRectBenchmark : public Benchmark @@ -154,13 +156,12 @@ public: m_brush = QBrush(m_content); } - virtual void draw(QPainter *p, const QRect &rect, int) { - p->fillRect(rect, m_brush); - } + void draw(QPainter *p, const QRect &rect, int) override { p->fillRect(rect, m_brush); } - virtual QString name() const { + QString name() const override + { return QString::fromLatin1("fillRect with image(%1)").arg(m_size.width()); - } + } private: QImage m_content; @@ -176,19 +177,18 @@ public: { } - virtual void begin(QPainter *p, int) { + void begin(QPainter *p, int) override + { p->setPen(Qt::NoPen); 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) { - p->drawRect(rect); - } - - virtual QString name() const { + QString name() const override + { return QString::fromLatin1("drawRect(%1)").arg(m_size.width()); - } + } }; @@ -200,19 +200,18 @@ public: { } - virtual void begin(QPainter *p, int) { - p->setPen(Qt::NoPen); - } - + void begin(QPainter *p, int) override { p->setPen(Qt::NoPen); } - virtual void draw(QPainter *p, const QRect &rect, int i) { + void draw(QPainter *p, const QRect &rect, int i) override + { p->setBrush(randomColor(i)); p->drawRect(rect); } - virtual QString name() const { + QString name() const override + { return QString::fromLatin1("drawRect with brushchange(%1)").arg(m_size.width()); - } + } }; class RoundRectBenchmark : public Benchmark @@ -224,16 +223,19 @@ public: m_roundness = size / 4.; } - virtual void begin(QPainter *p, int) { + void begin(QPainter *p, int) override + { p->setPen(Qt::NoPen); 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); } - virtual QString name() const { + QString name() const override + { 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) p->setPen(Qt::black); else @@ -274,7 +277,8 @@ public: 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) { case ArcShape: p->drawArc(rect, 45*16, 120*16); @@ -291,7 +295,8 @@ public: } } - virtual QString name() const { + QString name() const override + { QString fillStroke; if ((m_type & (Stroked|Filled)) == (Stroked|Filled)) { @@ -336,24 +341,24 @@ public: { } - virtual void begin(QPainter *p, int) { - p->scale(m_scale, m_scale); - } + void begin(QPainter *p, int) override { 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) p->drawPixmap(rect.topLeft(), m_pixmap); else 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") .arg(m_size.width()) .arg(m_scale) .arg(m_as_pixmap ? m_pixmap.depth() : m_image.depth()) .arg(m_type); - } + } private: QImage m_image; @@ -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(); p->translate(0.5 * rect.width() + rect.left(), 0.5 * rect.height() + rect.top()); p->shear(0.25, 0.0); @@ -394,12 +400,13 @@ public: p->setTransform(oldTransform); } - virtual QString name() const { + QString name() const override + { return QString::fromLatin1("draw%3(%1) w/transform, depth=%2") .arg(m_size.width()) .arg(m_as_pixmap ? m_pixmap.depth() : m_image.depth()) .arg(m_type); - } + } private: QImage m_image; @@ -428,19 +435,21 @@ public: { } - virtual void draw(QPainter *p, const QRect &rect, int) { + void draw(QPainter *p, const QRect &rect, int) override + { if (m_as_pixmap) p->drawPixmap(rect.topLeft(), m_pixmap); else p->drawImage(rect.topLeft(), m_image); } - virtual QString name() const { + QString name() const override + { return QString::fromLatin1("draw%2(%1), depth=%3") .arg(m_size.width()) .arg(m_type) .arg(m_as_pixmap ? m_pixmap.depth() : m_image.depth()); - } + } private: QImage m_image; @@ -469,7 +478,8 @@ public: { } - virtual void begin(QPainter *p, int iterations) { + void begin(QPainter *p, int iterations) override + { m_staticTexts.clear(); m_currentStaticText = 0; 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) { case PainterMode: @@ -589,7 +599,8 @@ public: } } - virtual QString name() const { + QString name() const override + { int letters = m_text.length(); int lines = m_text.count('\n'); 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()); p->setPen(Qt::NoPen); p->setBrush(Qt::red); @@ -706,11 +718,10 @@ public: } } - virtual void draw(QPainter *p, const QRect &rect, int) { - p->drawRect(rect); - } + void draw(QPainter *p, const QRect &rect, int) override { p->drawRect(rect); } - virtual QString name() const { + QString name() const override + { QString namedType; switch (m_type) { case RectClip: @@ -739,7 +750,7 @@ public: break; } return QString::fromLatin1("%1-clipped-drawRect(%2)").arg(namedType).arg(m_size.width()); - } + } ClipType m_type; }; @@ -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) { case Horizontal_Integer: 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[] = { "Hor_I", "Diag_I", diff --git a/tests/benchmarks/gui/painting/qtbench/tst_qtbench.cpp b/tests/benchmarks/gui/painting/qtbench/tst_qtbench.cpp index 40485e303f..c44eeb3b67 100644 --- a/tests/benchmarks/gui/painting/qtbench/tst_qtbench.cpp +++ b/tests/benchmarks/gui/painting/qtbench/tst_qtbench.cpp @@ -39,7 +39,7 @@ class BenchWidget : public QWidget public: BenchWidget(Benchmark *benchmark); - void paintEvent(QPaintEvent *event); + void paintEvent(QPaintEvent *event) override; bool done() const { return m_done; } qreal result() const { return m_result; } diff --git a/tests/benchmarks/widgets/graphicsview/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp b/tests/benchmarks/widgets/graphicsview/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp index 357c173356..7e86e96830 100644 --- a/tests/benchmarks/widgets/graphicsview/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp +++ b/tests/benchmarks/widgets/graphicsview/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp @@ -56,7 +56,7 @@ class RectWidget : public QGraphicsWidget public: 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(widget); diff --git a/tests/benchmarks/widgets/graphicsview/qgraphicslayout/tst_qgraphicslayout.cpp b/tests/benchmarks/widgets/graphicsview/qgraphicslayout/tst_qgraphicslayout.cpp index 7cf5f43706..73fad597b2 100644 --- a/tests/benchmarks/widgets/graphicsview/qgraphicslayout/tst_qgraphicslayout.cpp +++ b/tests/benchmarks/widgets/graphicsview/qgraphicslayout/tst_qgraphicslayout.cpp @@ -49,7 +49,7 @@ class RectWidget : public QGraphicsWidget public: 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(widget); @@ -58,7 +58,7 @@ public: painter->drawLine(rect().bottomLeft(), rect().topRight()); } - void setGeometry(const QRectF &rect) + void setGeometry(const QRectF &rect) override { //qDebug() << "setGeometry():" << this->data(0).toString(); setGeometryCalls->insert(this, rect); diff --git a/tests/benchmarks/widgets/graphicsview/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp b/tests/benchmarks/widgets/graphicsview/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp index 163be6b2e8..afa11cd553 100644 --- a/tests/benchmarks/widgets/graphicsview/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp +++ b/tests/benchmarks/widgets/graphicsview/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp @@ -47,7 +47,7 @@ private slots: struct MySquareWidget : public QGraphicsWidget { 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) return QGraphicsWidget::sizeHint(which, constraint); diff --git a/tests/benchmarks/widgets/graphicsview/qgraphicsview/chiptester/chip.h b/tests/benchmarks/widgets/graphicsview/qgraphicsview/chiptester/chip.h index 754dd8dfa7..e716b4dafc 100644 --- a/tests/benchmarks/widgets/graphicsview/qgraphicsview/chiptester/chip.h +++ b/tests/benchmarks/widgets/graphicsview/qgraphicsview/chiptester/chip.h @@ -37,14 +37,14 @@ class Chip : public QGraphicsItem public: Chip(const QColor &color, int x, int y); - QRectF boundingRect() const; - QPainterPath shape() const; - void paint(QPainter *painter, const QStyleOptionGraphicsItem *item, QWidget *widget); + QRectF boundingRect() const override; + QPainterPath shape() const override; + void paint(QPainter *painter, const QStyleOptionGraphicsItem *item, QWidget *widget) override; protected: - void mousePressEvent(QGraphicsSceneMouseEvent *event); - void mouseMoveEvent(QGraphicsSceneMouseEvent *event); - void mouseReleaseEvent(QGraphicsSceneMouseEvent *event); + void mousePressEvent(QGraphicsSceneMouseEvent *event) override; + void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override; + void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override; private: int x, y; diff --git a/tests/benchmarks/widgets/graphicsview/qgraphicsview/chiptester/chiptester.h b/tests/benchmarks/widgets/graphicsview/qgraphicsview/chiptester/chiptester.h index c615635ad4..e6d383dc1b 100644 --- a/tests/benchmarks/widgets/graphicsview/qgraphicsview/chiptester/chiptester.h +++ b/tests/benchmarks/widgets/graphicsview/qgraphicsview/chiptester/chiptester.h @@ -54,8 +54,8 @@ public: void setOperation(Operation operation); protected: - void paintEvent(QPaintEvent *event); - void timerEvent(QTimerEvent *event); + void paintEvent(QPaintEvent *event) override; + void timerEvent(QTimerEvent *event) override; private: void populateScene(); diff --git a/tests/benchmarks/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp b/tests/benchmarks/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp index 7be7f3f90d..1b275fbd29 100644 --- a/tests/benchmarks/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp +++ b/tests/benchmarks/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp @@ -81,14 +81,14 @@ public: } protected: - void paintEvent(QPaintEvent *event) + void paintEvent(QPaintEvent *event) override { QGraphicsView::paintEvent(event); if (waiting) eventLoop.exit(); } - void timerEvent(QTimerEvent *event) + void timerEvent(QTimerEvent *event) override { if (event->timerId() == timerId) eventLoop.exit(); @@ -479,7 +479,7 @@ public: } protected: - void advance(int i) + void advance(int i) override { if (!i) return; @@ -587,7 +587,7 @@ public: } protected: - void advance(int i) + void advance(int i) override { if (!i) return; @@ -693,14 +693,15 @@ public: 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); //We just want to wait, and we don't want to process the event loop with qWait QTest::qSleep(3); } protected: - void advance(int i) + void advance(int i) override { if (!i) 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); } protected: - void advance(int i) + void advance(int i) override { Q_UNUSED(i); if (partial) diff --git a/tests/benchmarks/widgets/itemviews/qtableview/tst_qtableview.cpp b/tests/benchmarks/widgets/itemviews/qtableview/tst_qtableview.cpp index 007f12516f..157ee7a152 100644 --- a/tests/benchmarks/widgets/itemviews/qtableview/tst_qtableview.cpp +++ b/tests/benchmarks/widgets/itemviews/qtableview/tst_qtableview.cpp @@ -45,11 +45,11 @@ public: row_count(rows), column_count(columns) {} - int rowCount(const QModelIndex& = QModelIndex()) const { return row_count; } - int columnCount(const QModelIndex& = QModelIndex()) const { return column_count; } + int rowCount(const QModelIndex & = QModelIndex()) const override { return row_count; } + int columnCount(const QModelIndex & = QModelIndex()) const override { return column_count; } 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) { qWarning() << "Invalid modelIndex [%d,%d,%p]" << idx; @@ -62,7 +62,7 @@ public: 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) return false; @@ -73,7 +73,7 @@ public: 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) return false; @@ -84,7 +84,7 @@ public: 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) return false; @@ -95,7 +95,7 @@ public: 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) return false; |