summaryrefslogtreecommitdiffstats
path: root/examples/network/torrent
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/network/torrent
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/network/torrent')
-rw-r--r--examples/network/torrent/filemanager.h2
-rw-r--r--examples/network/torrent/mainwindow.cpp8
-rw-r--r--examples/network/torrent/mainwindow.h4
-rw-r--r--examples/network/torrent/peerwireclient.h14
-rw-r--r--examples/network/torrent/torrentclient.h2
-rw-r--r--examples/network/torrent/torrentserver.h2
-rw-r--r--examples/network/torrent/trackerclient.h2
7 files changed, 17 insertions, 17 deletions
diff --git a/examples/network/torrent/filemanager.h b/examples/network/torrent/filemanager.h
index 41f1aa9a40..81b0321ae5 100644
--- a/examples/network/torrent/filemanager.h
+++ b/examples/network/torrent/filemanager.h
@@ -90,7 +90,7 @@ signals:
void pieceVerified(int pieceIndex, bool verified);
protected:
- void run();
+ void run() Q_DECL_OVERRIDE;
private slots:
bool verifySinglePiece(int pieceIndex);
diff --git a/examples/network/torrent/mainwindow.cpp b/examples/network/torrent/mainwindow.cpp
index 3ac7d9dfdd..fe7bbdaf3b 100644
--- a/examples/network/torrent/mainwindow.cpp
+++ b/examples/network/torrent/mainwindow.cpp
@@ -57,8 +57,8 @@ signals:
void fileDropped(const QString &fileName);
protected:
- void dragMoveEvent(QDragMoveEvent *event);
- void dropEvent(QDropEvent *event);
+ void dragMoveEvent(QDragMoveEvent *event) Q_DECL_OVERRIDE;
+ void dropEvent(QDropEvent *event) Q_DECL_OVERRIDE;
#endif
};
@@ -69,8 +69,8 @@ class TorrentViewDelegate : public QItemDelegate
public:
inline TorrentViewDelegate(MainWindow *mainWindow) : QItemDelegate(mainWindow) {}
- inline void paint(QPainter *painter, const QStyleOptionViewItem &option,
- const QModelIndex &index ) const
+ void paint(QPainter *painter, const QStyleOptionViewItem &option,
+ const QModelIndex &index ) const Q_DECL_OVERRIDE
{
if (index.column() != 2) {
QItemDelegate::paint(painter, option, index);
diff --git a/examples/network/torrent/mainwindow.h b/examples/network/torrent/mainwindow.h
index 6ba42be81f..1862d857ff 100644
--- a/examples/network/torrent/mainwindow.h
+++ b/examples/network/torrent/mainwindow.h
@@ -63,11 +63,11 @@ class MainWindow : public QMainWindow
public:
MainWindow(QWidget *parent = 0);
- QSize sizeHint() const;
+ QSize sizeHint() const Q_DECL_OVERRIDE;
const TorrentClient *clientForRow(int row) const;
protected:
- void closeEvent(QCloseEvent *event);
+ void closeEvent(QCloseEvent *event) Q_DECL_OVERRIDE;
private slots:
void loadSettings();
diff --git a/examples/network/torrent/peerwireclient.h b/examples/network/torrent/peerwireclient.h
index 35e4cc6ffb..12ce0696f6 100644
--- a/examples/network/torrent/peerwireclient.h
+++ b/examples/network/torrent/peerwireclient.h
@@ -112,14 +112,14 @@ public:
qint64 uploadSpeed() const;
bool canTransferMore() const;
- qint64 bytesAvailable() const { return incomingBuffer.size() + QTcpSocket::bytesAvailable(); }
+ qint64 bytesAvailable() const Q_DECL_OVERRIDE { return incomingBuffer.size() + QTcpSocket::bytesAvailable(); }
qint64 socketBytesAvailable() const { return socket.bytesAvailable(); }
qint64 socketBytesToWrite() const { return socket.bytesToWrite(); }
- void setReadBufferSize(qint64 size);
+ void setReadBufferSize(qint64 size) Q_DECL_OVERRIDE;
void connectToHost(const QHostAddress &address,
- quint16 port, OpenMode openMode = ReadWrite);
+ quint16 port, OpenMode openMode = ReadWrite) Q_DECL_OVERRIDE;
void diconnectFromHost();
signals:
@@ -138,11 +138,11 @@ signals:
void bytesReceived(qint64 size);
protected:
- void timerEvent(QTimerEvent *event);
+ void timerEvent(QTimerEvent *event) Q_DECL_OVERRIDE;
- qint64 readData(char *data, qint64 maxlen);
- qint64 readLineData(char *data, qint64 maxlen);
- qint64 writeData(const char *data, qint64 len);
+ qint64 readData(char *data, qint64 maxlen) Q_DECL_OVERRIDE;
+ qint64 readLineData(char *data, qint64 maxlen) Q_DECL_OVERRIDE;
+ qint64 writeData(const char *data, qint64 len) Q_DECL_OVERRIDE;
private slots:
void sendHandShake();
diff --git a/examples/network/torrent/torrentclient.h b/examples/network/torrent/torrentclient.h
index 7f48d1697c..ef9c99aea1 100644
--- a/examples/network/torrent/torrentclient.h
+++ b/examples/network/torrent/torrentclient.h
@@ -158,7 +158,7 @@ public slots:
void setupIncomingConnection(PeerWireClient *client);
protected slots:
- void timerEvent(QTimerEvent *event);
+ void timerEvent(QTimerEvent *event) Q_DECL_OVERRIDE;
private slots:
// File management
diff --git a/examples/network/torrent/torrentserver.h b/examples/network/torrent/torrentserver.h
index 50cc99c7d6..0f1be50c5b 100644
--- a/examples/network/torrent/torrentserver.h
+++ b/examples/network/torrent/torrentserver.h
@@ -58,7 +58,7 @@ public:
void removeClient(TorrentClient *client);
protected:
- void incomingConnection(qintptr socketDescriptor);
+ void incomingConnection(qintptr socketDescriptor) Q_DECL_OVERRIDE;
private slots:
void removeClient();
diff --git a/examples/network/torrent/trackerclient.h b/examples/network/torrent/trackerclient.h
index 6647422e3f..da8b457b0f 100644
--- a/examples/network/torrent/trackerclient.h
+++ b/examples/network/torrent/trackerclient.h
@@ -78,7 +78,7 @@ signals:
void stopped();
protected:
- void timerEvent(QTimerEvent *event);
+ void timerEvent(QTimerEvent *event) Q_DECL_OVERRIDE;
private slots:
void fetchPeerList();