From 58e2b9c01b31cef8a0fa263de3d984c22f1d7ca7 Mon Sep 17 00:00:00 2001 From: Sergio Ahumada Date: Sat, 15 Sep 2012 13:46:14 +0200 Subject: examples: Mark ctor's as explicit Make C++ class constructors that can be used with only one required argument 'explicit' to minimize wrong use of the class. Change-Id: Ida9f9c2f0c8608c35b0137b2512a6747afd69515 Reviewed-by: Mitch Curtis Reviewed-by: Thiago Macieira --- examples/widgets/animation/stickman/node.h | 2 +- examples/widgets/animation/sub-attaq/boat_p.h | 10 +++++----- examples/widgets/animation/sub-attaq/states.h | 4 ++-- examples/widgets/animation/sub-attaq/submarine_p.h | 4 ++-- examples/widgets/dialogs/tabdialog/tabdialog.h | 8 ++++---- examples/widgets/draganddrop/puzzle/pieceslist.h | 2 +- examples/widgets/draganddrop/puzzle/puzzlewidget.h | 2 +- examples/widgets/graphicsview/boxes/glbuffers.h | 4 ++-- examples/widgets/graphicsview/boxes/roundedbox.h | 2 +- examples/widgets/graphicsview/chip/view.h | 2 +- examples/widgets/graphicsview/diagramscene/diagramscene.h | 2 +- examples/widgets/graphicsview/embeddeddialogs/customproxy.h | 2 +- examples/widgets/graphicsview/padnavigator/flippablepad.h | 2 +- examples/widgets/itemviews/editabletreemodel/treeitem.h | 2 +- examples/widgets/itemviews/puzzle/piecesmodel.h | 2 +- examples/widgets/itemviews/puzzle/puzzlewidget.h | 2 +- examples/widgets/itemviews/simpledommodel/dommodel.h | 2 +- examples/widgets/itemviews/simpletreemodel/treeitem.h | 2 +- examples/widgets/itemviews/simpletreemodel/treemodel.h | 2 +- examples/widgets/itemviews/stardelegate/starrating.h | 2 +- examples/widgets/layouts/borderlayout/borderlayout.h | 2 +- examples/widgets/layouts/flowlayout/flowlayout.h | 4 ++-- examples/widgets/mainwindows/mainwindow/colorswatch.h | 2 +- examples/widgets/painting/deform/pathdeform.h | 2 +- examples/widgets/painting/painterpaths/renderarea.h | 2 +- examples/widgets/painting/pathstroke/pathstroke.h | 2 +- examples/widgets/widgets/calculator/button.h | 2 +- examples/widgets/widgets/elidedlabel/elidedlabel.h | 2 +- examples/widgets/widgets/wiggly/dialog.h | 2 +- 29 files changed, 40 insertions(+), 40 deletions(-) (limited to 'examples/widgets') diff --git a/examples/widgets/animation/stickman/node.h b/examples/widgets/animation/stickman/node.h index ae6e2a3ed0..ca04d7813b 100644 --- a/examples/widgets/animation/stickman/node.h +++ b/examples/widgets/animation/stickman/node.h @@ -47,7 +47,7 @@ class Node: public QGraphicsObject { Q_OBJECT public: - Node(const QPointF &pos, QGraphicsItem *parent = 0); + explicit Node(const QPointF &pos, QGraphicsItem *parent = 0); ~Node(); QRectF boundingRect() const; diff --git a/examples/widgets/animation/sub-attaq/boat_p.h b/examples/widgets/animation/sub-attaq/boat_p.h index 38be985777..03f7df2835 100644 --- a/examples/widgets/animation/sub-attaq/boat_p.h +++ b/examples/widgets/animation/sub-attaq/boat_p.h @@ -139,7 +139,7 @@ private: class MoveStateRight : public QState { public: - MoveStateRight(Boat *boat,QState *parent = 0) : QState(parent), boat(boat) + explicit MoveStateRight(Boat *boat,QState *parent = 0) : QState(parent), boat(boat) { } protected: @@ -156,7 +156,7 @@ private: class MoveStateLeft : public QState { public: - MoveStateLeft(Boat *boat,QState *parent = 0) : QState(parent), boat(boat) + explicit MoveStateLeft(Boat *boat,QState *parent = 0) : QState(parent), boat(boat) { } protected: @@ -173,7 +173,7 @@ private: class StopState : public QState { public: - StopState(Boat *boat,QState *parent = 0) : QState(parent), boat(boat) + explicit StopState(Boat *boat,QState *parent = 0) : QState(parent), boat(boat) { } protected: @@ -191,7 +191,7 @@ private: class LaunchStateRight : public QState { public: - LaunchStateRight(Boat *boat,QState *parent = 0) : QState(parent), boat(boat) + explicit LaunchStateRight(Boat *boat,QState *parent = 0) : QState(parent), boat(boat) { } protected: @@ -212,7 +212,7 @@ private: class LaunchStateLeft : public QState { public: - LaunchStateLeft(Boat *boat,QState *parent = 0) : QState(parent), boat(boat) + explicit LaunchStateLeft(Boat *boat,QState *parent = 0) : QState(parent), boat(boat) { } protected: diff --git a/examples/widgets/animation/sub-attaq/states.h b/examples/widgets/animation/sub-attaq/states.h index e43370302c..98799ddd94 100644 --- a/examples/widgets/animation/sub-attaq/states.h +++ b/examples/widgets/animation/sub-attaq/states.h @@ -59,7 +59,7 @@ QT_END_NAMESPACE class PlayState : public QState { public: - PlayState(GraphicsScene *scene, QState *parent = 0); + explicit PlayState(GraphicsScene *scene, QState *parent = 0); ~PlayState(); protected: @@ -96,7 +96,7 @@ private : class PauseState : public QState { public: - PauseState(GraphicsScene *scene, QState *parent = 0); + explicit PauseState(GraphicsScene *scene, QState *parent = 0); protected: void onEntry(QEvent *); diff --git a/examples/widgets/animation/sub-attaq/submarine_p.h b/examples/widgets/animation/sub-attaq/submarine_p.h index f24487aa17..c9b9829eb6 100644 --- a/examples/widgets/animation/sub-attaq/submarine_p.h +++ b/examples/widgets/animation/sub-attaq/submarine_p.h @@ -67,7 +67,7 @@ class MovementState : public QAnimationState { Q_OBJECT public: - MovementState(SubMarine *submarine, QState *parent = 0) : QAnimationState(parent) + explicit MovementState(SubMarine *submarine, QState *parent = 0) : QAnimationState(parent) { movementAnimation = new QPropertyAnimation(submarine, "pos"); connect(movementAnimation,SIGNAL(valueChanged(const QVariant &)),this,SLOT(onAnimationMovementValueChanged(const QVariant &))); @@ -106,7 +106,7 @@ private: class ReturnState : public QAnimationState { public: - ReturnState(SubMarine *submarine, QState *parent = 0) : QAnimationState(parent) + explicit ReturnState(SubMarine *submarine, QState *parent = 0) : QAnimationState(parent) { returnAnimation = new QPropertyAnimation(submarine->rotation(), "angle"); returnAnimation->setDuration(500); diff --git a/examples/widgets/dialogs/tabdialog/tabdialog.h b/examples/widgets/dialogs/tabdialog/tabdialog.h index c2b46f0e92..c0d74c18e3 100644 --- a/examples/widgets/dialogs/tabdialog/tabdialog.h +++ b/examples/widgets/dialogs/tabdialog/tabdialog.h @@ -55,7 +55,7 @@ class GeneralTab : public QWidget Q_OBJECT public: - GeneralTab(const QFileInfo &fileInfo, QWidget *parent = 0); + explicit GeneralTab(const QFileInfo &fileInfo, QWidget *parent = 0); }; //! [0] @@ -66,7 +66,7 @@ class PermissionsTab : public QWidget Q_OBJECT public: - PermissionsTab(const QFileInfo &fileInfo, QWidget *parent = 0); + explicit PermissionsTab(const QFileInfo &fileInfo, QWidget *parent = 0); }; //! [1] @@ -77,7 +77,7 @@ class ApplicationsTab : public QWidget Q_OBJECT public: - ApplicationsTab(const QFileInfo &fileInfo, QWidget *parent = 0); + explicit ApplicationsTab(const QFileInfo &fileInfo, QWidget *parent = 0); }; //! [2] @@ -88,7 +88,7 @@ class TabDialog : public QDialog Q_OBJECT public: - TabDialog(const QString &fileName, QWidget *parent = 0); + explicit TabDialog(const QString &fileName, QWidget *parent = 0); private: QTabWidget *tabWidget; diff --git a/examples/widgets/draganddrop/puzzle/pieceslist.h b/examples/widgets/draganddrop/puzzle/pieceslist.h index 3c6b042b4e..16091f5767 100644 --- a/examples/widgets/draganddrop/puzzle/pieceslist.h +++ b/examples/widgets/draganddrop/puzzle/pieceslist.h @@ -48,7 +48,7 @@ class PiecesList : public QListWidget Q_OBJECT public: - PiecesList(int pieceSize, QWidget *parent = 0); + explicit PiecesList(int pieceSize, QWidget *parent = 0); void addPiece(QPixmap pixmap, QPoint location); protected: diff --git a/examples/widgets/draganddrop/puzzle/puzzlewidget.h b/examples/widgets/draganddrop/puzzle/puzzlewidget.h index 1c0fc77a5f..98056ec217 100644 --- a/examples/widgets/draganddrop/puzzle/puzzlewidget.h +++ b/examples/widgets/draganddrop/puzzle/puzzlewidget.h @@ -57,7 +57,7 @@ class PuzzleWidget : public QWidget Q_OBJECT public: - PuzzleWidget(int imageSize, QWidget *parent = 0); + explicit PuzzleWidget(int imageSize, QWidget *parent = 0); void clear(); int pieceSize() const; diff --git a/examples/widgets/graphicsview/boxes/glbuffers.h b/examples/widgets/graphicsview/boxes/glbuffers.h index 2b91915e8e..b3b1777f81 100644 --- a/examples/widgets/graphicsview/boxes/glbuffers.h +++ b/examples/widgets/graphicsview/boxes/glbuffers.h @@ -99,7 +99,7 @@ class GLTexture2D : public GLTexture { public: GLTexture2D(int width, int height); - GLTexture2D(const QString& fileName, int width = 0, int height = 0); + explicit GLTexture2D(const QString& fileName, int width = 0, int height = 0); void load(int width, int height, QRgb *data); virtual void bind(); virtual void unbind(); @@ -120,7 +120,7 @@ class GLTextureCube : public GLTexture { public: GLTextureCube(int size); - GLTextureCube(const QStringList& fileNames, int size = 0); + explicit GLTextureCube(const QStringList& fileNames, int size = 0); void load(int size, int face, QRgb *data); virtual void bind(); virtual void unbind(); diff --git a/examples/widgets/graphicsview/boxes/roundedbox.h b/examples/widgets/graphicsview/boxes/roundedbox.h index 3edfb69fa8..0ab6766af3 100644 --- a/examples/widgets/graphicsview/boxes/roundedbox.h +++ b/examples/widgets/graphicsview/boxes/roundedbox.h @@ -65,7 +65,7 @@ class GLRoundedBox : public GLTriangleMesh { public: // 0 < r < 0.5, 0 <= n <= 125 - GLRoundedBox(float r = 0.25f, float scale = 1.0f, int n = 10); + explicit GLRoundedBox(float r = 0.25f, float scale = 1.0f, int n = 10); }; diff --git a/examples/widgets/graphicsview/chip/view.h b/examples/widgets/graphicsview/chip/view.h index 7753efff55..c688506d42 100644 --- a/examples/widgets/graphicsview/chip/view.h +++ b/examples/widgets/graphicsview/chip/view.h @@ -68,7 +68,7 @@ class View : public QFrame { Q_OBJECT public: - View(const QString &name, QWidget *parent = 0); + explicit View(const QString &name, QWidget *parent = 0); QGraphicsView *view() const; diff --git a/examples/widgets/graphicsview/diagramscene/diagramscene.h b/examples/widgets/graphicsview/diagramscene/diagramscene.h index 9f65eba890..53a34b050d 100644 --- a/examples/widgets/graphicsview/diagramscene/diagramscene.h +++ b/examples/widgets/graphicsview/diagramscene/diagramscene.h @@ -63,7 +63,7 @@ class DiagramScene : public QGraphicsScene public: enum Mode { InsertItem, InsertLine, InsertText, MoveItem }; - DiagramScene(QMenu *itemMenu, QObject *parent = 0); + explicit DiagramScene(QMenu *itemMenu, QObject *parent = 0); QFont font() const { return myFont; } QColor textColor() const diff --git a/examples/widgets/graphicsview/embeddeddialogs/customproxy.h b/examples/widgets/graphicsview/embeddeddialogs/customproxy.h index c85bbaccd3..12de414d11 100644 --- a/examples/widgets/graphicsview/embeddeddialogs/customproxy.h +++ b/examples/widgets/graphicsview/embeddeddialogs/customproxy.h @@ -49,7 +49,7 @@ class CustomProxy : public QGraphicsProxyWidget { Q_OBJECT public: - CustomProxy(QGraphicsItem *parent = 0, Qt::WindowFlags wFlags = 0); + explicit CustomProxy(QGraphicsItem *parent = 0, Qt::WindowFlags wFlags = 0); QRectF boundingRect() const; void paintWindowFrame(QPainter *painter, const QStyleOptionGraphicsItem *option, diff --git a/examples/widgets/graphicsview/padnavigator/flippablepad.h b/examples/widgets/graphicsview/padnavigator/flippablepad.h index e0d1fe24e5..ce49ef1a59 100644 --- a/examples/widgets/graphicsview/padnavigator/flippablepad.h +++ b/examples/widgets/graphicsview/padnavigator/flippablepad.h @@ -51,7 +51,7 @@ class FlippablePad : public RoundRectItem { public: - FlippablePad(const QSize &size, QGraphicsItem *parent = 0); + explicit FlippablePad(const QSize &size, QGraphicsItem *parent = 0); RoundRectItem *iconAt(int column, int row) const; diff --git a/examples/widgets/itemviews/editabletreemodel/treeitem.h b/examples/widgets/itemviews/editabletreemodel/treeitem.h index 8426514759..a0f8ed0577 100644 --- a/examples/widgets/itemviews/editabletreemodel/treeitem.h +++ b/examples/widgets/itemviews/editabletreemodel/treeitem.h @@ -49,7 +49,7 @@ class TreeItem { public: - TreeItem(const QVector &data, TreeItem *parent = 0); + explicit TreeItem(const QVector &data, TreeItem *parent = 0); ~TreeItem(); TreeItem *child(int number); diff --git a/examples/widgets/itemviews/puzzle/piecesmodel.h b/examples/widgets/itemviews/puzzle/piecesmodel.h index e8fa45a9a0..f306c51331 100644 --- a/examples/widgets/itemviews/puzzle/piecesmodel.h +++ b/examples/widgets/itemviews/puzzle/piecesmodel.h @@ -56,7 +56,7 @@ class PiecesModel : public QAbstractListModel Q_OBJECT public: - PiecesModel(int pieceSize, QObject *parent = 0); + explicit PiecesModel(int pieceSize, QObject *parent = 0); QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; Qt::ItemFlags flags(const QModelIndex &index) const; diff --git a/examples/widgets/itemviews/puzzle/puzzlewidget.h b/examples/widgets/itemviews/puzzle/puzzlewidget.h index 1c0fc77a5f..98056ec217 100644 --- a/examples/widgets/itemviews/puzzle/puzzlewidget.h +++ b/examples/widgets/itemviews/puzzle/puzzlewidget.h @@ -57,7 +57,7 @@ class PuzzleWidget : public QWidget Q_OBJECT public: - PuzzleWidget(int imageSize, QWidget *parent = 0); + explicit PuzzleWidget(int imageSize, QWidget *parent = 0); void clear(); int pieceSize() const; diff --git a/examples/widgets/itemviews/simpledommodel/dommodel.h b/examples/widgets/itemviews/simpledommodel/dommodel.h index 386f976f79..bef3ba781c 100644 --- a/examples/widgets/itemviews/simpledommodel/dommodel.h +++ b/examples/widgets/itemviews/simpledommodel/dommodel.h @@ -54,7 +54,7 @@ class DomModel : public QAbstractItemModel Q_OBJECT public: - DomModel(QDomDocument document, QObject *parent = 0); + explicit DomModel(QDomDocument document, QObject *parent = 0); ~DomModel(); QVariant data(const QModelIndex &index, int role) const; diff --git a/examples/widgets/itemviews/simpletreemodel/treeitem.h b/examples/widgets/itemviews/simpletreemodel/treeitem.h index b2a7a83066..03da562201 100644 --- a/examples/widgets/itemviews/simpletreemodel/treeitem.h +++ b/examples/widgets/itemviews/simpletreemodel/treeitem.h @@ -48,7 +48,7 @@ class TreeItem { public: - TreeItem(const QList &data, TreeItem *parent = 0); + explicit TreeItem(const QList &data, TreeItem *parent = 0); ~TreeItem(); void appendChild(TreeItem *child); diff --git a/examples/widgets/itemviews/simpletreemodel/treemodel.h b/examples/widgets/itemviews/simpletreemodel/treemodel.h index 9cf870c0fc..edddf482ae 100644 --- a/examples/widgets/itemviews/simpletreemodel/treemodel.h +++ b/examples/widgets/itemviews/simpletreemodel/treemodel.h @@ -53,7 +53,7 @@ class TreeModel : public QAbstractItemModel Q_OBJECT public: - TreeModel(const QString &data, QObject *parent = 0); + explicit TreeModel(const QString &data, QObject *parent = 0); ~TreeModel(); QVariant data(const QModelIndex &index, int role) const; diff --git a/examples/widgets/itemviews/stardelegate/starrating.h b/examples/widgets/itemviews/stardelegate/starrating.h index 04fae2509a..54de31989b 100644 --- a/examples/widgets/itemviews/stardelegate/starrating.h +++ b/examples/widgets/itemviews/stardelegate/starrating.h @@ -51,7 +51,7 @@ class StarRating public: enum EditMode { Editable, ReadOnly }; - StarRating(int starCount = 1, int maxStarCount = 5); + explicit StarRating(int starCount = 1, int maxStarCount = 5); void paint(QPainter *painter, const QRect &rect, const QPalette &palette, EditMode mode) const; diff --git a/examples/widgets/layouts/borderlayout/borderlayout.h b/examples/widgets/layouts/borderlayout/borderlayout.h index 937517dc17..91f927bb21 100644 --- a/examples/widgets/layouts/borderlayout/borderlayout.h +++ b/examples/widgets/layouts/borderlayout/borderlayout.h @@ -50,7 +50,7 @@ class BorderLayout : public QLayout public: enum Position { West, North, South, East, Center }; - BorderLayout(QWidget *parent, int margin = 0, int spacing = -1); + explicit BorderLayout(QWidget *parent, int margin = 0, int spacing = -1); BorderLayout(int spacing = -1); ~BorderLayout(); diff --git a/examples/widgets/layouts/flowlayout/flowlayout.h b/examples/widgets/layouts/flowlayout/flowlayout.h index 2a27f93772..2b98f000f1 100644 --- a/examples/widgets/layouts/flowlayout/flowlayout.h +++ b/examples/widgets/layouts/flowlayout/flowlayout.h @@ -48,8 +48,8 @@ class FlowLayout : public QLayout { public: - FlowLayout(QWidget *parent, int margin = -1, int hSpacing = -1, int vSpacing = -1); - FlowLayout(int margin = -1, int hSpacing = -1, int vSpacing = -1); + explicit FlowLayout(QWidget *parent, int margin = -1, int hSpacing = -1, int vSpacing = -1); + explicit FlowLayout(int margin = -1, int hSpacing = -1, int vSpacing = -1); ~FlowLayout(); void addItem(QLayoutItem *item); diff --git a/examples/widgets/mainwindows/mainwindow/colorswatch.h b/examples/widgets/mainwindows/mainwindow/colorswatch.h index 794a69cd6c..95facc568f 100644 --- a/examples/widgets/mainwindows/mainwindow/colorswatch.h +++ b/examples/widgets/mainwindows/mainwindow/colorswatch.h @@ -79,7 +79,7 @@ class ColorSwatch : public QDockWidget QAction *windowModifiedAction; public: - ColorSwatch(const QString &colorName, QWidget *parent = 0, Qt::WindowFlags flags = 0); + explicit ColorSwatch(const QString &colorName, QWidget *parent = 0, Qt::WindowFlags flags = 0); QMenu *menu; void setCustomSizeHint(const QSize &size); diff --git a/examples/widgets/painting/deform/pathdeform.h b/examples/widgets/painting/deform/pathdeform.h index 6f0d647f4e..07f615d31e 100644 --- a/examples/widgets/painting/deform/pathdeform.h +++ b/examples/widgets/painting/deform/pathdeform.h @@ -58,7 +58,7 @@ class PathDeformRenderer : public ArthurFrame Q_PROPERTY(QString text READ text WRITE setText) public: - PathDeformRenderer(QWidget *widget, bool smallScreen = false); + explicit PathDeformRenderer(QWidget *widget, bool smallScreen = false); void paint(QPainter *painter); diff --git a/examples/widgets/painting/painterpaths/renderarea.h b/examples/widgets/painting/painterpaths/renderarea.h index 5c310fdf62..ec6c4ea291 100644 --- a/examples/widgets/painting/painterpaths/renderarea.h +++ b/examples/widgets/painting/painterpaths/renderarea.h @@ -50,7 +50,7 @@ class RenderArea : public QWidget Q_OBJECT public: - RenderArea(const QPainterPath &path, QWidget *parent = 0); + explicit RenderArea(const QPainterPath &path, QWidget *parent = 0); QSize minimumSizeHint() const; QSize sizeHint() const; diff --git a/examples/widgets/painting/pathstroke/pathstroke.h b/examples/widgets/painting/pathstroke/pathstroke.h index 743a757b0a..5e2a1ea579 100644 --- a/examples/widgets/painting/pathstroke/pathstroke.h +++ b/examples/widgets/painting/pathstroke/pathstroke.h @@ -53,7 +53,7 @@ class PathStrokeRenderer : public ArthurFrame public: enum PathMode { CurveMode, LineMode }; - PathStrokeRenderer(QWidget *parent, bool smallScreen = false); + explicit PathStrokeRenderer(QWidget *parent, bool smallScreen = false); void paint(QPainter *); void mousePressEvent(QMouseEvent *e); diff --git a/examples/widgets/widgets/calculator/button.h b/examples/widgets/widgets/calculator/button.h index 50874ea574..d84d7e92e8 100644 --- a/examples/widgets/widgets/calculator/button.h +++ b/examples/widgets/widgets/calculator/button.h @@ -49,7 +49,7 @@ class Button : public QToolButton Q_OBJECT public: - Button(const QString &text, QWidget *parent = 0); + explicit Button(const QString &text, QWidget *parent = 0); QSize sizeHint() const; }; diff --git a/examples/widgets/widgets/elidedlabel/elidedlabel.h b/examples/widgets/widgets/elidedlabel/elidedlabel.h index 2c19589bc2..118c8c2741 100644 --- a/examples/widgets/widgets/elidedlabel/elidedlabel.h +++ b/examples/widgets/widgets/elidedlabel/elidedlabel.h @@ -55,7 +55,7 @@ class ElidedLabel : public QFrame Q_PROPERTY(bool isElided READ isElided) public: - ElidedLabel(const QString &text, QWidget *parent = 0); + explicit ElidedLabel(const QString &text, QWidget *parent = 0); void setText(const QString &text); const QString & text() const { return content; } diff --git a/examples/widgets/widgets/wiggly/dialog.h b/examples/widgets/widgets/wiggly/dialog.h index 84167d9153..e6117f8ee2 100644 --- a/examples/widgets/widgets/wiggly/dialog.h +++ b/examples/widgets/widgets/wiggly/dialog.h @@ -49,7 +49,7 @@ class Dialog : public QDialog Q_OBJECT public: - Dialog(QWidget *parent = 0, bool smallScreen = false); + explicit Dialog(QWidget *parent = 0, bool smallScreen = false); }; //! [0] -- cgit v1.2.3