Skip to content

Commit

Permalink
doc: Add missing override and remove redundant virtual for snippets
Browse files Browse the repository at this point in the history
Change-Id: I2395fd01b93c4ea364225e0cf1a5f59908b691d0
Reviewed-by: Martin Smith <[email protected]>
  • Loading branch information
Alexander Volkov committed Aug 16, 2018
1 parent 9b59a2e commit 242ea38
Show file tree
Hide file tree
Showing 37 changed files with 95 additions and 95 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
//! [0]
class HelloWorldTask : public QRunnable
{
void run()
void run() override
{
qDebug() << "Hello world from thread" << QThread::currentThread();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
class ZipEngineHandler : public QAbstractFileEngineHandler
{
public:
QAbstractFileEngine *create(const QString &fileName) const;
QAbstractFileEngine *create(const QString &fileName) const override;
};

QAbstractFileEngine *ZipEngineHandler::create(const QString &fileName) const
Expand Down Expand Up @@ -105,20 +105,20 @@ class CustomIterator : public QAbstractFileEngineIterator
entries << "entry1" << "entry2" << "entry3";
}

bool hasNext() const
bool hasNext() const override
{
return index < entries.size() - 1;
}

QString next()
QString next() override
{
if (!hasNext())
return QString();
++index;
return currentFilePath();
}

QString currentFileName()
QString currentFileName() override
{
return entries.at(index);
}
Expand Down
2 changes: 1 addition & 1 deletion src/corelib/doc/snippets/code/src_corelib_io_qprocess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ class SandboxProcess : public QProcess
{
...
protected:
void setupChildProcess();
void setupChildProcess() override;
...
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ class CustomDataProxy : public QSortFilterProxyModel

...

QVariant data(const QModelIndex &index, int role)
QVariant data(const QModelIndex &index, int role) override
{
if (role != Qt::BackgroundRole)
return QSortFilterProxyModel::data(index, role);
Expand Down
8 changes: 4 additions & 4 deletions src/corelib/doc/snippets/code/src_corelib_kernel_qobject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ class MainWindow : public QMainWindow
MainWindow();

protected:
bool eventFilter(QObject *obj, QEvent *ev);
bool eventFilter(QObject *obj, QEvent *ev) override;

private:
QTextEdit *textEdit;
Expand Down Expand Up @@ -147,7 +147,7 @@ class MyObject : public QObject
MyObject(QObject *parent = 0);

protected:
void timerEvent(QTimerEvent *event);
void timerEvent(QTimerEvent *event) override;
};

MyObject::MyObject(QObject *parent)
Expand Down Expand Up @@ -215,7 +215,7 @@ class KeyPressEater : public QObject
...

protected:
bool eventFilter(QObject *obj, QEvent *event);
bool eventFilter(QObject *obj, QEvent *event) override;
};

bool KeyPressEater::eventFilter(QObject *obj, QEvent *event)
Expand Down Expand Up @@ -508,7 +508,7 @@ class MyClass : public QWidget
MyClass(QWidget *parent = 0);
~MyClass();

bool event(QEvent* ev)
bool event(QEvent* ev) override
{
if (ev->type() == QEvent::PolishRequest) {
// overwrite handling of PolishRequest if any
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@
class MyException : public QException
{
public:
void raise() const { throw *this; }
MyException *clone() const { return new MyException(*this); }
void raise() const override { throw *this; }
MyException *clone() const override { return new MyException(*this); }
};

//! [0]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class DateFormatProxyModel : public QIdentityProxyModel
m_formatString = formatString;
}

QVariant data(const QModelIndex &index, int role) const
QVariant data(const QModelIndex &index, int role) const override
{
if (role != Qt::DisplayRole)
return QIdentityProxyModel::data(index, role);
Expand Down
2 changes: 1 addition & 1 deletion src/corelib/doc/snippets/eventfilters/filterobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class FilterObject : public QObject

public:
FilterObject(QObject *parent = 0);
bool eventFilter(QObject *object, QEvent *event);
bool eventFilter(QObject *object, QEvent *event) override;
void setFilteredObject(QObject *object);

private:
Expand Down
4 changes: 2 additions & 2 deletions src/corelib/doc/snippets/events/events.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
class MyCheckBox : public QCheckBox
{
public:
void mousePressEvent(QMouseEvent *event);
void mousePressEvent(QMouseEvent *event) override;
};

//! [0]
Expand All @@ -72,7 +72,7 @@ void MyCheckBox::mousePressEvent(QMouseEvent *event)
class MyWidget : public QWidget
{
public:
bool event(QEvent *event);
bool event(QEvent *event) override;
};

static const int MyCustomEventType = 1099;
Expand Down
2 changes: 1 addition & 1 deletion src/corelib/doc/snippets/settings/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ class MainWindow : public QMainWindow
void readSettings();

protected:
void closeEvent(QCloseEvent *event);
void closeEvent(QCloseEvent *event) override;
};

//! [16]
Expand Down
4 changes: 2 additions & 2 deletions src/corelib/doc/snippets/statemachine/eventtest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class MyTransition : public QAbstractTransition

protected:
//![0]
bool eventTest(QEvent *event)
bool eventTest(QEvent *event) override
{
if (event->type() == QEvent::Wrapped) {
QEvent *wrappedEvent = static_cast<QStateMachine::WrappedEvent *>(event)->event();
Expand All @@ -71,7 +71,7 @@ class MyTransition : public QAbstractTransition
}
//![0]

void onTransition(QEvent *event)
void onTransition(QEvent *event) override
{

}
Expand Down
4 changes: 2 additions & 2 deletions src/corelib/doc/snippets/statemachine/main4.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,15 @@ class StringTransition : public QAbstractTransition
: m_value(value) {}

protected:
virtual bool eventTest(QEvent *e)
bool eventTest(QEvent *e) override
{
if (e->type() != QEvent::Type(QEvent::User+1)) // StringEvent
return false;
StringEvent *se = static_cast<StringEvent*>(e);
return (m_value == se->value);
}

virtual void onTransition(QEvent *) {}
void onTransition(QEvent *) override {}

private:
QString m_value;
Expand Down
8 changes: 4 additions & 4 deletions src/gui/doc/snippets/draganddrop/dragwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@ class DragWidget : public QFrame
void mimeTypes(const QStringList &types);

protected:
void dragEnterEvent(QDragEnterEvent *event);
void dropEvent(QDropEvent *event);
void mouseMoveEvent(QMouseEvent *event);
void mousePressEvent(QMouseEvent *event);
void dragEnterEvent(QDragEnterEvent *event) override;
void dropEvent(QDropEvent *event) override;
void mouseMoveEvent(QMouseEvent *event) override;
void mousePressEvent(QMouseEvent *event) override;

private:
QByteArray data;
Expand Down
2 changes: 1 addition & 1 deletion src/gui/doc/snippets/dragging/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class MainWindow : public QMainWindow
MainWindow(QWidget *parent = 0);

protected:
void mousePressEvent(QMouseEvent *event);
void mousePressEvent(QMouseEvent *event) override;

private:
QLabel *iconLabel;
Expand Down
4 changes: 2 additions & 2 deletions src/gui/doc/snippets/dropevents/window.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ class Window : public QWidget
Window(QWidget *parent = 0);

protected:
void dragEnterEvent(QDragEnterEvent *event);
void dropEvent(QDropEvent *event);
void dragEnterEvent(QDragEnterEvent *event) override;
void dropEvent(QDropEvent *event) override;

private:
QComboBox *mimeTypeCombo;
Expand Down
4 changes: 2 additions & 2 deletions src/gui/doc/snippets/droprectangle/window.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ class Window : public QWidget
Window(QWidget *parent = 0);

protected:
void dragMoveEvent(QDragMoveEvent *event);
void dropEvent(QDropEvent *event);
void dragMoveEvent(QDragMoveEvent *event) override;
void dropEvent(QDropEvent *event) override;

private:
QComboBox *mimeTypeCombo;
Expand Down
6 changes: 3 additions & 3 deletions src/gui/doc/snippets/matrix/matrix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@

class SimpleTransformation : public QWidget
{
void paintEvent(QPaintEvent *);
void paintEvent(QPaintEvent *) override;
};

//! [0]
Expand All @@ -73,7 +73,7 @@ void SimpleTransformation::paintEvent(QPaintEvent *)

class CombinedTransformation : public QWidget
{
void paintEvent(QPaintEvent *);
void paintEvent(QPaintEvent *) override;
};

//! [1]
Expand All @@ -97,7 +97,7 @@ void CombinedTransformation::paintEvent(QPaintEvent *)

class BasicOperations : public QWidget
{
void paintEvent(QPaintEvent *);
void paintEvent(QPaintEvent *) override;
};

//! [2]
Expand Down
2 changes: 1 addition & 1 deletion src/gui/doc/snippets/plaintextlayout/window.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class Window : public QWidget
Window(QWidget *parent = 0);

protected:
void paintEvent(QPaintEvent *event);
void paintEvent(QPaintEvent *event) override;

private:
QFont font;
Expand Down
2 changes: 1 addition & 1 deletion src/gui/doc/snippets/qfileopenevent/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class MyApplication : public QApplication
{
}

bool event(QEvent *event)
bool event(QEvent *event) override
{
if (event->type() == QEvent::FileOpen) {
QFileOpenEvent *openEvent = static_cast<QFileOpenEvent *>(event);
Expand Down
4 changes: 2 additions & 2 deletions src/gui/doc/snippets/separations/finalwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ class FinalWidget : public QFrame
const QPixmap *pixmap() const;

protected:
void mouseMoveEvent(QMouseEvent *event);
void mousePressEvent(QMouseEvent *event);
void mouseMoveEvent(QMouseEvent *event) override;
void mousePressEvent(QMouseEvent *event) override;

private:
void createImage();
Expand Down
4 changes: 2 additions & 2 deletions src/gui/doc/snippets/textdocument-imagedrop/textedit.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ class TextEdit : public QTextEdit

public:
TextEdit(QWidget *parent=0);
bool canInsertFromMimeData( const QMimeData *source ) const;
void insertFromMimeData( const QMimeData *source );
bool canInsertFromMimeData( const QMimeData *source ) const override;
void insertFromMimeData( const QMimeData *source ) override;
};

#endif
6 changes: 3 additions & 3 deletions src/gui/doc/snippets/transform/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@

class SimpleTransformation : public QWidget
{
void paintEvent(QPaintEvent *);
void paintEvent(QPaintEvent *) override;
};

//! [0]
Expand All @@ -73,7 +73,7 @@ void SimpleTransformation::paintEvent(QPaintEvent *)

class CombinedTransformation : public QWidget
{
void paintEvent(QPaintEvent *);
void paintEvent(QPaintEvent *) override;
};

//! [1]
Expand All @@ -97,7 +97,7 @@ void CombinedTransformation::paintEvent(QPaintEvent *)

class BasicOperations : public QWidget
{
void paintEvent(QPaintEvent *);
void paintEvent(QPaintEvent *) override;
};

//! [2]
Expand Down
6 changes: 3 additions & 3 deletions src/opengl/doc/snippets/code/src_opengl_qgl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ class MyGLDrawer : public QGLWidget

protected:

void initializeGL()
void initializeGL() override
{
// Set up the rendering context, define display lists etc.:
...
Expand All @@ -155,7 +155,7 @@ class MyGLDrawer : public QGLWidget
...
}

void resizeGL(int w, int h)
void resizeGL(int w, int h) override
{
// setup viewport, projection etc.:
glViewport(0, 0, (GLint)w, (GLint)h);
Expand All @@ -164,7 +164,7 @@ class MyGLDrawer : public QGLWidget
...
}

void paintGL()
void paintGL() override
{
// draw the scene:
...
Expand Down
Loading

0 comments on commit 242ea38

Please sign in to comment.