summaryrefslogtreecommitdiff
path: root/examples/widgets/animation/sub-attaq
diff options
context:
space:
mode:
authorOlivier Goffart <ogoffart@woboq.com>2014-07-14 09:13:02 +0200
committerOlivier Goffart <ogoffart@woboq.com>2014-07-15 08:44:44 +0200
commit3b0c2b7c1b3ccdfe6867884a7e210bfc63e10f84 (patch)
tree4c75a4fa9f023c4bfc6746a4412922a8efe3b017 /examples/widgets/animation/sub-attaq
parent6d87e3ed40173eac8c275d5926266359d53c74c7 (diff)
downloadqtbase-3b0c2b7c1b3ccdfe6867884a7e210bfc63e10f84.tar.gz
Examples: Add Q_DECL_OVERRIDE to overridden functions
Q_DECL_OVERRIDE (which expands to 'override' for supported compiler) helps to declare the intent (that it is an overridden function) and force compilation error when there is no such virtual function in the base class. The examples should show the best practice of having it, as it may save the programmer quite some time in case of change of API or typo in the function name or arguments. This change was done automatically with clang-modernize -add-override -override-macros And fixed MSVC compilation by removing inline for TorrentViewDelegate::paint Change-Id: Ice66ae93fae571266f908703d5b8892b2c1ebb1a Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@digia.com>
Diffstat (limited to 'examples/widgets/animation/sub-attaq')
-rw-r--r--examples/widgets/animation/sub-attaq/boat.h2
-rw-r--r--examples/widgets/animation/sub-attaq/boat_p.h18
-rw-r--r--examples/widgets/animation/sub-attaq/pixmapitem.h4
-rw-r--r--examples/widgets/animation/sub-attaq/qanimationstate.h6
-rw-r--r--examples/widgets/animation/sub-attaq/states.h22
-rw-r--r--examples/widgets/animation/sub-attaq/submarine.h2
-rw-r--r--examples/widgets/animation/sub-attaq/submarine_p.h6
7 files changed, 30 insertions, 30 deletions
diff --git a/examples/widgets/animation/sub-attaq/boat.h b/examples/widgets/animation/sub-attaq/boat.h
index 82f43572e8..561ba49d27 100644
--- a/examples/widgets/animation/sub-attaq/boat.h
+++ b/examples/widgets/animation/sub-attaq/boat.h
@@ -77,7 +77,7 @@ public:
void updateBoatMovement();
- virtual int type() const;
+ virtual int type() const Q_DECL_OVERRIDE;
signals:
void boatDestroyed();
diff --git a/examples/widgets/animation/sub-attaq/boat_p.h b/examples/widgets/animation/sub-attaq/boat_p.h
index fc3ba81d63..19c5dad9ba 100644
--- a/examples/widgets/animation/sub-attaq/boat_p.h
+++ b/examples/widgets/animation/sub-attaq/boat_p.h
@@ -72,7 +72,7 @@ public:
{
}
protected:
- virtual bool eventTest(QEvent *event)
+ virtual bool eventTest(QEvent *event) Q_DECL_OVERRIDE
{
if (!QKeyEventTransition::eventTest(event))
return false;
@@ -91,13 +91,13 @@ public:
{
}
protected:
- virtual bool eventTest(QEvent *event)
+ virtual bool eventTest(QEvent *event) Q_DECL_OVERRIDE
{
if (!QKeyEventTransition::eventTest(event))
return false;
return (boat->currentSpeed() >= 0);
}
- void onTransition(QEvent *)
+ void onTransition(QEvent *) Q_DECL_OVERRIDE
{
//We decrease the speed if needed
if (key == Qt::Key_Left && boat->currentDirection() == Boat::Right)
@@ -122,7 +122,7 @@ public:
{
}
protected:
- virtual bool eventTest(QEvent *event)
+ virtual bool eventTest(QEvent *event) Q_DECL_OVERRIDE
{
if (!QKeyEventTransition::eventTest(event))
return false;
@@ -141,7 +141,7 @@ public:
{
}
protected:
- void onEntry(QEvent *)
+ void onEntry(QEvent *) Q_DECL_OVERRIDE
{
boat->setCurrentDirection(Boat::Right);
boat->updateBoatMovement();
@@ -158,7 +158,7 @@ public:
{
}
protected:
- void onEntry(QEvent *)
+ void onEntry(QEvent *) Q_DECL_OVERRIDE
{
boat->setCurrentDirection(Boat::Left);
boat->updateBoatMovement();
@@ -175,7 +175,7 @@ public:
{
}
protected:
- void onEntry(QEvent *)
+ void onEntry(QEvent *) Q_DECL_OVERRIDE
{
boat->setCurrentSpeed(0);
boat->setCurrentDirection(Boat::None);
@@ -193,7 +193,7 @@ public:
{
}
protected:
- void onEntry(QEvent *)
+ void onEntry(QEvent *) Q_DECL_OVERRIDE
{
Bomb *b = new Bomb();
b->setPos(boat->x()+boat->size().width(),boat->y());
@@ -214,7 +214,7 @@ public:
{
}
protected:
- void onEntry(QEvent *)
+ void onEntry(QEvent *) Q_DECL_OVERRIDE
{
Bomb *b = new Bomb();
b->setPos(boat->x() - b->size().width(), boat->y());
diff --git a/examples/widgets/animation/sub-attaq/pixmapitem.h b/examples/widgets/animation/sub-attaq/pixmapitem.h
index e093fbd5b5..baca0c1cba 100644
--- a/examples/widgets/animation/sub-attaq/pixmapitem.h
+++ b/examples/widgets/animation/sub-attaq/pixmapitem.h
@@ -54,8 +54,8 @@ public:
PixmapItem(const QString &fileName, GraphicsScene::Mode mode, QGraphicsItem * parent = 0);
PixmapItem(const QString &fileName, QGraphicsScene *scene);
QSizeF size() const;
- QRectF boundingRect() const;
- void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *);
+ QRectF boundingRect() const Q_DECL_OVERRIDE;
+ void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *) Q_DECL_OVERRIDE;
private:
QPixmap pix;
};
diff --git a/examples/widgets/animation/sub-attaq/qanimationstate.h b/examples/widgets/animation/sub-attaq/qanimationstate.h
index 68eac43e13..c2b7e12211 100644
--- a/examples/widgets/animation/sub-attaq/qanimationstate.h
+++ b/examples/widgets/animation/sub-attaq/qanimationstate.h
@@ -71,9 +71,9 @@ signals:
void animationFinished();
protected:
- void onEntry(QEvent *);
- void onExit(QEvent *);
- bool event(QEvent *e);
+ void onEntry(QEvent *) Q_DECL_OVERRIDE;
+ void onExit(QEvent *) Q_DECL_OVERRIDE;
+ bool event(QEvent *e) Q_DECL_OVERRIDE;
private:
Q_DISABLE_COPY(QAnimationState)
diff --git a/examples/widgets/animation/sub-attaq/states.h b/examples/widgets/animation/sub-attaq/states.h
index 3cd27be9a4..19016cb76e 100644
--- a/examples/widgets/animation/sub-attaq/states.h
+++ b/examples/widgets/animation/sub-attaq/states.h
@@ -63,7 +63,7 @@ public:
~PlayState();
protected:
- void onEntry(QEvent *);
+ void onEntry(QEvent *) Q_DECL_OVERRIDE;
private :
GraphicsScene *scene;
@@ -85,7 +85,7 @@ class LevelState : public QState
public:
LevelState(GraphicsScene *scene, PlayState *game, QState *parent = 0);
protected:
- void onEntry(QEvent *);
+ void onEntry(QEvent *) Q_DECL_OVERRIDE;
private :
void initializeLevel();
GraphicsScene *scene;
@@ -98,8 +98,8 @@ public:
explicit PauseState(GraphicsScene *scene, QState *parent = 0);
protected:
- void onEntry(QEvent *);
- void onExit(QEvent *);
+ void onEntry(QEvent *) Q_DECL_OVERRIDE;
+ void onExit(QEvent *) Q_DECL_OVERRIDE;
private :
GraphicsScene *scene;
};
@@ -110,8 +110,8 @@ public:
LostState(GraphicsScene *scene, PlayState *game, QState *parent = 0);
protected:
- void onEntry(QEvent *);
- void onExit(QEvent *);
+ void onEntry(QEvent *) Q_DECL_OVERRIDE;
+ void onExit(QEvent *) Q_DECL_OVERRIDE;
private :
GraphicsScene *scene;
PlayState *game;
@@ -123,8 +123,8 @@ public:
WinState(GraphicsScene *scene, PlayState *game, QState *parent = 0);
protected:
- void onEntry(QEvent *);
- void onExit(QEvent *);
+ void onEntry(QEvent *) Q_DECL_OVERRIDE;
+ void onExit(QEvent *) Q_DECL_OVERRIDE;
private :
GraphicsScene *scene;
PlayState *game;
@@ -143,7 +143,7 @@ class UpdateScoreTransition : public QSignalTransition
public:
UpdateScoreTransition(GraphicsScene *scene, PlayState *game, QAbstractState *target);
protected:
- virtual bool eventTest(QEvent *event);
+ virtual bool eventTest(QEvent *event) Q_DECL_OVERRIDE;
private:
PlayState * game;
GraphicsScene *scene;
@@ -155,7 +155,7 @@ class WinTransition : public QSignalTransition
public:
WinTransition(GraphicsScene *scene, PlayState *game, QAbstractState *target);
protected:
- virtual bool eventTest(QEvent *event);
+ virtual bool eventTest(QEvent *event) Q_DECL_OVERRIDE;
private:
PlayState * game;
GraphicsScene *scene;
@@ -167,7 +167,7 @@ private:
public:
CustomSpaceTransition(QWidget *widget, PlayState *game, QEvent::Type type, int key);
protected:
- virtual bool eventTest(QEvent *event);
+ virtual bool eventTest(QEvent *event) Q_DECL_OVERRIDE;
private:
PlayState *game;
};
diff --git a/examples/widgets/animation/sub-attaq/submarine.h b/examples/widgets/animation/sub-attaq/submarine.h
index 802bf6f81c..b087d0178d 100644
--- a/examples/widgets/animation/sub-attaq/submarine.h
+++ b/examples/widgets/animation/sub-attaq/submarine.h
@@ -72,7 +72,7 @@ public:
void launchTorpedo(int speed);
void destroy();
- virtual int type() const;
+ virtual int type() const Q_DECL_OVERRIDE;
QGraphicsRotation *rotation() const { return graphicsRotation; }
diff --git a/examples/widgets/animation/sub-attaq/submarine_p.h b/examples/widgets/animation/sub-attaq/submarine_p.h
index e1755505df..f117be7b8c 100644
--- a/examples/widgets/animation/sub-attaq/submarine_p.h
+++ b/examples/widgets/animation/sub-attaq/submarine_p.h
@@ -84,7 +84,7 @@ protected slots:
}
protected:
- void onEntry(QEvent *e)
+ void onEntry(QEvent *e) Q_DECL_OVERRIDE
{
if (submarine->currentDirection() == SubMarine::Left) {
movementAnimation->setEndValue(QPointF(0,submarine->y()));
@@ -116,14 +116,14 @@ public:
}
protected:
- void onEntry(QEvent *e)
+ void onEntry(QEvent *e) Q_DECL_OVERRIDE
{
returnAnimation->stop();
returnAnimation->setEndValue(submarine->currentDirection() == SubMarine::Right ? 360. : 180.);
QAnimationState::onEntry(e);
}
- void onExit(QEvent *e)
+ void onExit(QEvent *e) Q_DECL_OVERRIDE
{
submarine->currentDirection() == SubMarine::Right ? submarine->setCurrentDirection(SubMarine::Left) : submarine->setCurrentDirection(SubMarine::Right);
QAnimationState::onExit(e);