summaryrefslogtreecommitdiffstats
path: root/examples/widgets/tools
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/tools
parent6d87e3ed40173eac8c275d5926266359d53c74c7 (diff)
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/tools')
-rw-r--r--examples/widgets/tools/completer/fsmodel.h2
-rw-r--r--examples/widgets/tools/customcompleter/textedit.h4
-rw-r--r--examples/widgets/tools/echoplugin/plugin/echoplugin.h2
-rw-r--r--examples/widgets/tools/i18n/languagechooser.h4
-rw-r--r--examples/widgets/tools/plugandpaint/paintarea.h10
-rw-r--r--examples/widgets/tools/plugandpaintplugins/basictools/basictoolsplugin.h16
-rw-r--r--examples/widgets/tools/plugandpaintplugins/extrafilters/extrafiltersplugin.h4
-rw-r--r--examples/widgets/tools/settingseditor/settingstree.h4
-rw-r--r--examples/widgets/tools/settingseditor/variantdelegate.h8
-rw-r--r--examples/widgets/tools/styleplugin/plugin/simplestyle.h2
-rw-r--r--examples/widgets/tools/styleplugin/plugin/simplestyleplugin.h2
-rw-r--r--examples/widgets/tools/treemodelcompleter/treemodelcompleter.h4
-rw-r--r--examples/widgets/tools/undo/commands.h24
-rw-r--r--examples/widgets/tools/undo/document.h8
-rw-r--r--examples/widgets/tools/undoframework/commands.h16
-rw-r--r--examples/widgets/tools/undoframework/diagramitem.h2
-rw-r--r--examples/widgets/tools/undoframework/diagramscene.h4
17 files changed, 58 insertions, 58 deletions
diff --git a/examples/widgets/tools/completer/fsmodel.h b/examples/widgets/tools/completer/fsmodel.h
index 85b08e532b..690f8b8569 100644
--- a/examples/widgets/tools/completer/fsmodel.h
+++ b/examples/widgets/tools/completer/fsmodel.h
@@ -53,7 +53,7 @@ class FileSystemModel : public QFileSystemModel
{
public:
FileSystemModel(QObject *parent = 0);
- QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
+ QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const Q_DECL_OVERRIDE;
};
//! [0]
diff --git a/examples/widgets/tools/customcompleter/textedit.h b/examples/widgets/tools/customcompleter/textedit.h
index 362db96749..eb0b307b1c 100644
--- a/examples/widgets/tools/customcompleter/textedit.h
+++ b/examples/widgets/tools/customcompleter/textedit.h
@@ -60,8 +60,8 @@ public:
QCompleter *completer() const;
protected:
- void keyPressEvent(QKeyEvent *e);
- void focusInEvent(QFocusEvent *e);
+ void keyPressEvent(QKeyEvent *e) Q_DECL_OVERRIDE;
+ void focusInEvent(QFocusEvent *e) Q_DECL_OVERRIDE;
private slots:
void insertCompletion(const QString &completion);
diff --git a/examples/widgets/tools/echoplugin/plugin/echoplugin.h b/examples/widgets/tools/echoplugin/plugin/echoplugin.h
index fc6818c5be..30d9a673e0 100644
--- a/examples/widgets/tools/echoplugin/plugin/echoplugin.h
+++ b/examples/widgets/tools/echoplugin/plugin/echoplugin.h
@@ -53,7 +53,7 @@ class EchoPlugin : public QObject, EchoInterface
Q_INTERFACES(EchoInterface)
public:
- QString echo(const QString &message);
+ QString echo(const QString &message) Q_DECL_OVERRIDE;
};
//! [0]
diff --git a/examples/widgets/tools/i18n/languagechooser.h b/examples/widgets/tools/i18n/languagechooser.h
index a2282cdaf5..3f177a790d 100644
--- a/examples/widgets/tools/i18n/languagechooser.h
+++ b/examples/widgets/tools/i18n/languagechooser.h
@@ -61,8 +61,8 @@ public:
explicit LanguageChooser(const QString& defaultLang = QString(), QWidget *parent = 0);
protected:
- bool eventFilter(QObject *object, QEvent *event);
- void closeEvent(QCloseEvent *event);
+ bool eventFilter(QObject *object, QEvent *event) Q_DECL_OVERRIDE;
+ void closeEvent(QCloseEvent *event) Q_DECL_OVERRIDE;
private slots:
void checkBoxToggled();
diff --git a/examples/widgets/tools/plugandpaint/paintarea.h b/examples/widgets/tools/plugandpaint/paintarea.h
index 84936576cf..214e8c9c0b 100644
--- a/examples/widgets/tools/plugandpaint/paintarea.h
+++ b/examples/widgets/tools/plugandpaint/paintarea.h
@@ -66,13 +66,13 @@ public:
QImage image() const { return theImage; }
QColor brushColor() const { return color; }
int brushWidth() const { return thickness; }
- QSize sizeHint() const;
+ QSize sizeHint() const Q_DECL_OVERRIDE;
protected:
- void paintEvent(QPaintEvent *event);
- void mousePressEvent(QMouseEvent *event);
- void mouseMoveEvent(QMouseEvent *event);
- void mouseReleaseEvent(QMouseEvent *event);
+ void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE;
+ void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
+ void mouseMoveEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
+ void mouseReleaseEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
private:
void setupPainter(QPainter &painter);
diff --git a/examples/widgets/tools/plugandpaintplugins/basictools/basictoolsplugin.h b/examples/widgets/tools/plugandpaintplugins/basictools/basictoolsplugin.h
index 55593f6db0..121501a878 100644
--- a/examples/widgets/tools/plugandpaintplugins/basictools/basictoolsplugin.h
+++ b/examples/widgets/tools/plugandpaintplugins/basictools/basictoolsplugin.h
@@ -68,22 +68,22 @@ class BasicToolsPlugin : public QObject,
public:
//! [1]
// BrushInterface
- QStringList brushes() const;
+ QStringList brushes() const Q_DECL_OVERRIDE;
QRect mousePress(const QString &brush, QPainter &painter,
- const QPoint &pos);
+ const QPoint &pos) Q_DECL_OVERRIDE;
QRect mouseMove(const QString &brush, QPainter &painter,
- const QPoint &oldPos, const QPoint &newPos);
+ const QPoint &oldPos, const QPoint &newPos) Q_DECL_OVERRIDE;
QRect mouseRelease(const QString &brush, QPainter &painter,
- const QPoint &pos);
+ const QPoint &pos) Q_DECL_OVERRIDE;
// ShapeInterface
- QStringList shapes() const;
- QPainterPath generateShape(const QString &shape, QWidget *parent);
+ QStringList shapes() const Q_DECL_OVERRIDE;
+ QPainterPath generateShape(const QString &shape, QWidget *parent) Q_DECL_OVERRIDE;
// FilterInterface
- QStringList filters() const;
+ QStringList filters() const Q_DECL_OVERRIDE;
QImage filterImage(const QString &filter, const QImage &image,
- QWidget *parent);
+ QWidget *parent) Q_DECL_OVERRIDE;
//! [3]
};
//! [2] //! [3]
diff --git a/examples/widgets/tools/plugandpaintplugins/extrafilters/extrafiltersplugin.h b/examples/widgets/tools/plugandpaintplugins/extrafilters/extrafiltersplugin.h
index 6f793b26c6..bc0bae3152 100644
--- a/examples/widgets/tools/plugandpaintplugins/extrafilters/extrafiltersplugin.h
+++ b/examples/widgets/tools/plugandpaintplugins/extrafilters/extrafiltersplugin.h
@@ -56,9 +56,9 @@ class ExtraFiltersPlugin : public QObject, public FilterInterface
Q_INTERFACES(FilterInterface)
public:
- QStringList filters() const;
+ QStringList filters() const Q_DECL_OVERRIDE;
QImage filterImage(const QString &filter, const QImage &image,
- QWidget *parent);
+ QWidget *parent) Q_DECL_OVERRIDE;
};
//! [0]
diff --git a/examples/widgets/tools/settingseditor/settingstree.h b/examples/widgets/tools/settingseditor/settingstree.h
index 24c2266899..663a71c790 100644
--- a/examples/widgets/tools/settingseditor/settingstree.h
+++ b/examples/widgets/tools/settingseditor/settingstree.h
@@ -57,7 +57,7 @@ public:
SettingsTree(QWidget *parent = 0);
void setSettingsObject(QSettings *settings);
- QSize sizeHint() const;
+ QSize sizeHint() const Q_DECL_OVERRIDE;
public slots:
void setAutoRefresh(bool autoRefresh);
@@ -66,7 +66,7 @@ public slots:
void refresh();
protected:
- bool event(QEvent *event);
+ bool event(QEvent *event) Q_DECL_OVERRIDE;
private slots:
void updateSetting(QTreeWidgetItem *item);
diff --git a/examples/widgets/tools/settingseditor/variantdelegate.h b/examples/widgets/tools/settingseditor/variantdelegate.h
index 0e23c016da..fed69ef47d 100644
--- a/examples/widgets/tools/settingseditor/variantdelegate.h
+++ b/examples/widgets/tools/settingseditor/variantdelegate.h
@@ -52,12 +52,12 @@ public:
VariantDelegate(QObject *parent = 0);
void paint(QPainter *painter, const QStyleOptionViewItem &option,
- const QModelIndex &index) const;
+ const QModelIndex &index) const Q_DECL_OVERRIDE;
QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,
- const QModelIndex &index) const;
- void setEditorData(QWidget *editor, const QModelIndex &index) const;
+ const QModelIndex &index) const Q_DECL_OVERRIDE;
+ void setEditorData(QWidget *editor, const QModelIndex &index) const Q_DECL_OVERRIDE;
void setModelData(QWidget *editor, QAbstractItemModel *model,
- const QModelIndex &index) const;
+ const QModelIndex &index) const Q_DECL_OVERRIDE;
static bool isSupportedType(QVariant::Type type);
static QString displayText(const QVariant &value);
diff --git a/examples/widgets/tools/styleplugin/plugin/simplestyle.h b/examples/widgets/tools/styleplugin/plugin/simplestyle.h
index 2db04d206f..95c04c5355 100644
--- a/examples/widgets/tools/styleplugin/plugin/simplestyle.h
+++ b/examples/widgets/tools/styleplugin/plugin/simplestyle.h
@@ -54,7 +54,7 @@ class SimpleStyle : public QProxyStyle
public:
SimpleStyle() {};
- void polish(QPalette &palette);
+ void polish(QPalette &palette) Q_DECL_OVERRIDE;
};
#endif
diff --git a/examples/widgets/tools/styleplugin/plugin/simplestyleplugin.h b/examples/widgets/tools/styleplugin/plugin/simplestyleplugin.h
index 22965de121..77739168e4 100644
--- a/examples/widgets/tools/styleplugin/plugin/simplestyleplugin.h
+++ b/examples/widgets/tools/styleplugin/plugin/simplestyleplugin.h
@@ -58,7 +58,7 @@ public:
SimpleStylePlugin() {}
QStringList keys() const;
- QStyle *create(const QString &key);
+ QStyle *create(const QString &key) Q_DECL_OVERRIDE;
};
//! [0]
diff --git a/examples/widgets/tools/treemodelcompleter/treemodelcompleter.h b/examples/widgets/tools/treemodelcompleter/treemodelcompleter.h
index 69d6cdfe78..2f2a45c3d3 100644
--- a/examples/widgets/tools/treemodelcompleter/treemodelcompleter.h
+++ b/examples/widgets/tools/treemodelcompleter/treemodelcompleter.h
@@ -58,8 +58,8 @@ public slots:
void setSeparator(const QString &separator);
protected:
- QStringList splitPath(const QString &path) const;
- QString pathFromIndex(const QModelIndex &index) const;
+ QStringList splitPath(const QString &path) const Q_DECL_OVERRIDE;
+ QString pathFromIndex(const QModelIndex &index) const Q_DECL_OVERRIDE;
private:
QString sep;
diff --git a/examples/widgets/tools/undo/commands.h b/examples/widgets/tools/undo/commands.h
index b8984c1d34..f75ac34256 100644
--- a/examples/widgets/tools/undo/commands.h
+++ b/examples/widgets/tools/undo/commands.h
@@ -49,8 +49,8 @@ class AddShapeCommand : public QUndoCommand
{
public:
AddShapeCommand(Document *doc, const Shape &shape, QUndoCommand *parent = 0);
- void undo();
- void redo();
+ void undo() Q_DECL_OVERRIDE;
+ void redo() Q_DECL_OVERRIDE;
private:
Document *m_doc;
@@ -62,8 +62,8 @@ class RemoveShapeCommand : public QUndoCommand
{
public:
RemoveShapeCommand(Document *doc, const QString &shapeName, QUndoCommand *parent = 0);
- void undo();
- void redo();
+ void undo() Q_DECL_OVERRIDE;
+ void redo() Q_DECL_OVERRIDE;
private:
Document *m_doc;
@@ -77,11 +77,11 @@ public:
SetShapeColorCommand(Document *doc, const QString &shapeName, const QColor &color,
QUndoCommand *parent = 0);
- void undo();
- void redo();
+ void undo() Q_DECL_OVERRIDE;
+ void redo() Q_DECL_OVERRIDE;
- bool mergeWith(const QUndoCommand *command);
- int id() const;
+ bool mergeWith(const QUndoCommand *command) Q_DECL_OVERRIDE;
+ int id() const Q_DECL_OVERRIDE;
private:
Document *m_doc;
@@ -96,11 +96,11 @@ public:
SetShapeRectCommand(Document *doc, const QString &shapeName, const QRect &rect,
QUndoCommand *parent = 0);
- void undo();
- void redo();
+ void undo() Q_DECL_OVERRIDE;
+ void redo() Q_DECL_OVERRIDE;
- bool mergeWith(const QUndoCommand *command);
- int id() const;
+ bool mergeWith(const QUndoCommand *command) Q_DECL_OVERRIDE;
+ int id() const Q_DECL_OVERRIDE;
private:
Document *m_doc;
diff --git a/examples/widgets/tools/undo/document.h b/examples/widgets/tools/undo/document.h
index 4f362a9597..9246c9320d 100644
--- a/examples/widgets/tools/undo/document.h
+++ b/examples/widgets/tools/undo/document.h
@@ -101,10 +101,10 @@ signals:
void currentShapeChanged(const QString &shapeName);
protected:
- void paintEvent(QPaintEvent *event);
- void mousePressEvent(QMouseEvent *event);
- void mouseReleaseEvent(QMouseEvent *event);
- void mouseMoveEvent(QMouseEvent *event);
+ void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE;
+ void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
+ void mouseReleaseEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
+ void mouseMoveEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
private:
void setCurrentShape(int index);
diff --git a/examples/widgets/tools/undoframework/commands.h b/examples/widgets/tools/undoframework/commands.h
index f15e586e91..0e68c5f533 100644
--- a/examples/widgets/tools/undoframework/commands.h
+++ b/examples/widgets/tools/undoframework/commands.h
@@ -54,10 +54,10 @@ public:
MoveCommand(DiagramItem *diagramItem, const QPointF &oldPos,
QUndoCommand *parent = 0);
- void undo();
- void redo();
- bool mergeWith(const QUndoCommand *command);
- int id() const { return Id; }
+ void undo() Q_DECL_OVERRIDE;
+ void redo() Q_DECL_OVERRIDE;
+ bool mergeWith(const QUndoCommand *command) Q_DECL_OVERRIDE;
+ int id() const Q_DECL_OVERRIDE { return Id; }
private:
DiagramItem *myDiagramItem;
@@ -72,8 +72,8 @@ class DeleteCommand : public QUndoCommand
public:
explicit DeleteCommand(QGraphicsScene *graphicsScene, QUndoCommand *parent = 0);
- void undo();
- void redo();
+ void undo() Q_DECL_OVERRIDE;
+ void redo() Q_DECL_OVERRIDE;
private:
DiagramItem *myDiagramItem;
@@ -89,8 +89,8 @@ public:
QUndoCommand *parent = 0);
~AddCommand();
- void undo();
- void redo();
+ void undo() Q_DECL_OVERRIDE;
+ void redo() Q_DECL_OVERRIDE;
private:
DiagramItem *myDiagramItem;
diff --git a/examples/widgets/tools/undoframework/diagramitem.h b/examples/widgets/tools/undoframework/diagramitem.h
index 2c115c3b20..44495fc57e 100644
--- a/examples/widgets/tools/undoframework/diagramitem.h
+++ b/examples/widgets/tools/undoframework/diagramitem.h
@@ -61,7 +61,7 @@ public:
DiagramType diagramType() const {
return polygon() == boxPolygon ? Box : Triangle;
}
- int type() const { return Type; }
+ int type() const Q_DECL_OVERRIDE { return Type; }
private:
QPolygonF boxPolygon;
diff --git a/examples/widgets/tools/undoframework/diagramscene.h b/examples/widgets/tools/undoframework/diagramscene.h
index 6ad9647df5..925ab450d2 100644
--- a/examples/widgets/tools/undoframework/diagramscene.h
+++ b/examples/widgets/tools/undoframework/diagramscene.h
@@ -62,8 +62,8 @@ signals:
void itemMoved(DiagramItem *movedItem, const QPointF &movedFromPosition);
protected:
- void mousePressEvent(QGraphicsSceneMouseEvent *event);
- void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
+ void mousePressEvent(QGraphicsSceneMouseEvent *event) Q_DECL_OVERRIDE;
+ void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) Q_DECL_OVERRIDE;
private:
QGraphicsItem *movingItem;