1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

Add final/override specifiers

We get more compile time checking, and it's always good for performance to help the compiler
This commit is contained in:
tux3 2015-06-08 20:08:24 +02:00
parent e65cf72791
commit 36fcb5cb62
No known key found for this signature in database
GPG Key ID: 7E086DD661263264
29 changed files with 146 additions and 158 deletions

View File

@ -84,15 +84,15 @@ protected:
void scrollToBottom();
void startResizeWorker();
virtual void mouseDoubleClickEvent(QMouseEvent* ev);
virtual void mousePressEvent(QMouseEvent* ev);
virtual void mouseReleaseEvent(QMouseEvent* ev);
virtual void mouseMoveEvent(QMouseEvent* ev);
virtual void scrollContentsBy(int dx, int dy);
virtual void resizeEvent(QResizeEvent* ev);
virtual void showEvent(QShowEvent*);
virtual void focusInEvent(QFocusEvent* ev);
virtual void focusOutEvent(QFocusEvent* ev);
virtual void mouseDoubleClickEvent(QMouseEvent* ev) final override;
virtual void mousePressEvent(QMouseEvent* ev) final override;
virtual void mouseReleaseEvent(QMouseEvent* ev) final override;
virtual void mouseMoveEvent(QMouseEvent* ev) final override;
virtual void scrollContentsBy(int dx, int dy) final override;
virtual void resizeEvent(QResizeEvent* ev) final override;
virtual void showEvent(QShowEvent*) final override;
virtual void focusInEvent(QFocusEvent* ev) final override;
virtual void focusOutEvent(QFocusEvent* ev) final override;
void updateMultiSelectionRect();
void updateTypingNotification();

View File

@ -65,7 +65,7 @@ protected:
bool drawButtonAreaNeeded() const;
virtual void paintEvent(QPaintEvent*);
virtual void paintEvent(QPaintEvent*) final override;
private slots:
void on_topButton_clicked();

View File

@ -36,27 +36,27 @@ public:
void setText(const QString& txt);
virtual void setWidth(qreal width) override;
virtual void setWidth(qreal width) final;
virtual void selectionMouseMove(QPointF scenePos) override;
virtual void selectionStarted(QPointF scenePos) override;
virtual void selectionCleared() override;
virtual void selectionDoubleClick(QPointF scenePos) override;
virtual void selectionFocusChanged(bool focusIn) override;
virtual bool isOverSelection(QPointF scenePos) const override;
virtual QString getSelectedText() const override;
virtual void selectionMouseMove(QPointF scenePos) final;
virtual void selectionStarted(QPointF scenePos) final;
virtual void selectionCleared() final;
virtual void selectionDoubleClick(QPointF scenePos) final;
virtual void selectionFocusChanged(bool focusIn) final;
virtual bool isOverSelection(QPointF scenePos) const final;
virtual QString getSelectedText() const final;
virtual QRectF boundingRect() const override;
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
virtual QRectF boundingRect() const final;
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) final;
virtual void visibilityChanged(bool keepInMemory) override;
virtual void visibilityChanged(bool keepInMemory) final;
virtual qreal getAscent() const override;
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event) override;
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override;
virtual void hoverMoveEvent(QGraphicsSceneHoverEvent* event) override;
virtual qreal getAscent() const final;
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event) final override;
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) final override;
virtual void hoverMoveEvent(QGraphicsSceneHoverEvent* event) final override;
virtual QString getText() const override;
virtual QString getText() const final;
protected:
// dynamic resource management

View File

@ -6,14 +6,14 @@
qTox is libre software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
(at your option) any later version.
qTox is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
You should have received a copy of the GNU General Public License
along with qTox. If not, see <http://www.gnu.org/licenses/>.
*/
@ -40,7 +40,7 @@ protected:
void subscribe();
void unsubscribe();
virtual void paintEvent(QPaintEvent * event) override;
virtual void paintEvent(QPaintEvent * event) final override;
private slots:
void onNewFrameAvailable(std::shared_ptr<VideoFrame> newFrame);

View File

@ -57,7 +57,7 @@ signals:
private:
void reloadTheme();
virtual void keyPressEvent(QKeyEvent* event) final;
virtual void keyPressEvent(QKeyEvent* event) final override;
private slots:
void onUsernameChanged(const QString& newUsername, const QString& oldUsername);

View File

@ -39,9 +39,9 @@ private slots:
void PageButtonsUpdate();
protected:
virtual void mouseReleaseEvent(QMouseEvent *ev);
virtual void mousePressEvent(QMouseEvent *ev);
virtual void wheelEvent(QWheelEvent * event) override;
virtual void mouseReleaseEvent(QMouseEvent *ev) final override;
virtual void mousePressEvent(QMouseEvent *ev) final override;
virtual void wheelEvent(QWheelEvent * event) final override;
private:
QStackedWidget stack;

View File

@ -50,7 +50,7 @@ public:
void setFriendTyping(bool isTyping);
OfflineMsgEngine* getOfflineMsgEngine();
virtual void show(Ui::MainWindow &ui);
virtual void show(Ui::MainWindow &ui) final override;
signals:
void sendFile(uint32_t friendId, QString, QString, long long);
@ -108,11 +108,10 @@ protected:
void showNetcam();
void hideNetcam();
// drag & drop
void dragEnterEvent(QDragEnterEvent* ev);
void dropEvent(QDropEvent* ev);
void registerReceipt(int receipt, int messageID, ChatMessage::Ptr msg);
virtual void hideEvent(QHideEvent* event);
virtual void showEvent(QShowEvent* event);
virtual void dragEnterEvent(QDragEnterEvent* ev) final override;
virtual void dropEvent(QDropEvent* ev) final override;
virtual void hideEvent(QHideEvent* event) final override;
virtual void showEvent(QShowEvent* event) final override;
private:
Friend* f;

View File

@ -52,7 +52,8 @@ public:
GenericChatForm(QWidget *parent = 0);
~GenericChatForm();
virtual void setName(const QString &newName);
void setName(const QString &newName);
virtual void show() final = delete;
virtual void show(Ui::MainWindow &ui);
ChatMessage::Ptr addMessage(const ToxId& author, const QString &message, bool isAction, const QDateTime &datetime, bool isSent);
@ -64,7 +65,6 @@ public:
ChatLog* getChatLog() const;
bool eventFilter(QObject* object, QEvent* event);
signals:
void sendMessage(uint32_t, QString);
void sendAction(uint32_t, QString);
@ -91,12 +91,14 @@ private:
protected:
QString resolveToxId(const ToxId &id);
void insertChatMessage(ChatMessage::Ptr msg);
void hideEvent(QHideEvent* event);
void showEvent(QShowEvent *);
bool event(QEvent *);
void resizeEvent(QResizeEvent* event);
void adjustFileMenuPosition();
virtual void hideEvent(QHideEvent* event) override;
virtual void showEvent(QShowEvent *) override;
virtual bool event(QEvent *) final override;
virtual void resizeEvent(QResizeEvent* event) final override;
virtual bool eventFilter(QObject* object, QEvent* event) final override;
protected:
QAction* saveChatAction, *clearAction;
ToxId previousId;
QDateTime prevMsgDateTime;

View File

@ -39,9 +39,6 @@ public:
void onUserListChanged();
void peerAudioPlaying(int peer);
void keyPressEvent(QKeyEvent* ev);
void keyReleaseEvent(QKeyEvent* ev);
signals:
void groupTitleChanged(int groupnum, const QString& name);
@ -52,9 +49,11 @@ private slots:
void onCallClicked();
protected:
virtual void keyPressEvent(QKeyEvent* ev) final override;
virtual void keyReleaseEvent(QKeyEvent* ev) final override;
// drag & drop
void dragEnterEvent(QDragEnterEvent* ev);
void dropEvent(QDropEvent* ev);
virtual void dragEnterEvent(QDragEnterEvent* ev) final override;
virtual void dropEvent(QDropEvent* ev) final override;
private:
void retranslateUi();

View File

@ -44,7 +44,7 @@ public:
signals:
void clicked();
protected:
void mouseReleaseEvent(QMouseEvent*) {emit clicked();}
virtual void mouseReleaseEvent(QMouseEvent*) final override {emit clicked();}
};
class ProfileForm : public QWidget
@ -53,6 +53,7 @@ class ProfileForm : public QWidget
public:
ProfileForm(QWidget *parent = nullptr);
~ProfileForm();
virtual void show() final = delete;
void show(Ui::MainWindow &ui);
signals:

View File

@ -28,13 +28,13 @@ namespace Ui {
class AdvancedSettings;
}
class AdvancedForm : public GenericForm
class AdvancedForm final : public GenericForm
{
Q_OBJECT
public:
AdvancedForm();
virtual ~AdvancedForm();
QString getFormName() final {return tr("Advanced");}
~AdvancedForm();
virtual QString getFormName() final override {return tr("Advanced");}
protected:
bool eventFilter(QObject *o, QEvent *e);

View File

@ -33,13 +33,13 @@ class AVSettings;
class CameraSource;
class VideoSurface;
class AVForm : public GenericForm
class AVForm final : public GenericForm
{
Q_OBJECT
public:
AVForm();
~AVForm();
QString getFormName() final {return tr("Audio/Video");}
virtual QString getFormName() final override {return tr("Audio/Video");}
private:
void getAudioInDevices();
@ -65,11 +65,11 @@ private slots:
void onVideoDevChanged(int index);
void onResProbingFinished(QList<QSize> res);
virtual void hideEvent(QHideEvent*);
virtual void showEvent(QShowEvent*);
virtual void hideEvent(QHideEvent*) final override;
virtual void showEvent(QShowEvent*) final override;
protected:
bool eventFilter(QObject *o, QEvent *e);
virtual bool eventFilter(QObject *o, QEvent *e) final override;
void updateVideoModes(int curIndex);
private:

View File

@ -28,13 +28,13 @@ class GeneralSettings;
class SettingsWidget;
class GeneralForm : public GenericForm
class GeneralForm final : public GenericForm
{
Q_OBJECT
public:
GeneralForm(SettingsWidget *parent);
~GeneralForm();
QString getFormName() final {return tr("General");}
virtual QString getFormName() final override {return tr("General");}
private slots:
void onEnableIPv6Updated();

View File

@ -25,7 +25,7 @@ class GenericForm : public QWidget
Q_OBJECT
public:
GenericForm(const QPixmap &icon) : formIcon(icon) {;}
~GenericForm() {;}
~GenericForm() {}
virtual QString getFormName() = 0;
QPixmap getFormIcon() {return formIcon;}

View File

@ -26,13 +26,13 @@ namespace Ui {
class PrivacySettings;
}
class PrivacyForm : public GenericForm
class PrivacyForm final : public GenericForm
{
Q_OBJECT
public:
PrivacyForm();
~PrivacyForm();
QString getFormName() final {return tr("Privacy");}
virtual QString getFormName() final override {return tr("Privacy");}
private slots:
void onEnableLoggingUpdated();
@ -40,7 +40,7 @@ private slots:
void setNospam();
void generateRandomNospam();
void onNospamEdit();
virtual void showEvent(QShowEvent*);
virtual void showEvent(QShowEvent*) final override;
private:
void retranslateUi();

View File

@ -32,8 +32,8 @@ public:
explicit VerticalOnlyScroller(QWidget *parent = 0);
protected:
void resizeEvent(QResizeEvent *event);
void showEvent(QShowEvent *event);
virtual void resizeEvent(QResizeEvent *event) final override;
virtual void showEvent(QShowEvent *event) final override;
};
#endif // VERTICALONLYSCROLLER_H

View File

@ -25,18 +25,18 @@
class QPixmap;
class MaskablePixmapWidget;
struct FriendWidget : public GenericChatroomWidget
struct FriendWidget final : public GenericChatroomWidget
{
Q_OBJECT
public:
FriendWidget(int FriendId, QString id);
void contextMenuEvent(QContextMenuEvent * event);
void setAsActiveChatroom();
void setAsInactiveChatroom();
void updateStatusLight();
void setChatForm(Ui::MainWindow &);
void resetEventFlags();
QString getStatusString();
virtual void contextMenuEvent(QContextMenuEvent * event) override;
virtual void setAsActiveChatroom() override;
virtual void setAsInactiveChatroom() override;
virtual void updateStatusLight() override;
virtual void setChatForm(Ui::MainWindow &) override;
virtual void resetEventFlags() override;
virtual QString getStatusString() override;
signals:
void friendWidgetClicked(FriendWidget* widget);
@ -49,8 +49,8 @@ public slots:
void setAlias(const QString& alias);
protected:
void mousePressEvent(QMouseEvent* ev);
void mouseMoveEvent(QMouseEvent* ev);
virtual void mousePressEvent(QMouseEvent* ev) final override;
virtual void mouseMoveEvent(QMouseEvent* ev) final override;
void setFriendAlias();
public:

View File

@ -65,10 +65,10 @@ signals:
void chatroomWidgetClicked(GenericChatroomWidget* widget);
protected:
virtual void mousePressEvent(QMouseEvent* event);
virtual void mouseReleaseEvent (QMouseEvent* event);
virtual void enterEvent(QEvent* e);
virtual void leaveEvent(QEvent* e);
virtual void mousePressEvent(QMouseEvent* event) override;
virtual void mouseReleaseEvent (QMouseEvent* event) override;
virtual void enterEvent(QEvent* e) override;
virtual void leaveEvent(QEvent* e) override;
protected:
QColor lastColor;

View File

@ -162,21 +162,6 @@ void GroupWidget::dropEvent(QDropEvent *ev)
}
}
void GroupWidget::keyPressEvent(QKeyEvent* ev)
{
Group* g = GroupList::findGroup(groupId);
if (g)
g->getChatForm()->keyPressEvent(ev);
}
void GroupWidget::keyReleaseEvent(QKeyEvent* ev)
{
Group* g = GroupList::findGroup(groupId);
if (g)
g->getChatForm()->keyReleaseEvent(ev);
}
void GroupWidget::setName(const QString& name)
{
nameLabel->setText(name);

View File

@ -28,15 +28,15 @@ class GroupWidget : public GenericChatroomWidget
Q_OBJECT
public:
GroupWidget(int GroupId, QString Name);
void onUserListChanged();
void contextMenuEvent(QContextMenuEvent * event);
void setAsInactiveChatroom();
void setAsActiveChatroom();
void updateStatusLight();
void setChatForm(Ui::MainWindow &);
void resetEventFlags();
virtual void contextMenuEvent(QContextMenuEvent * event) final override;
virtual void setAsInactiveChatroom() final override;
virtual void setAsActiveChatroom() final override;
virtual void updateStatusLight() final override;
virtual void setChatForm(Ui::MainWindow &) final override;
virtual void resetEventFlags() final override;
virtual QString getStatusString() final override;
void setName(const QString& name);
QString getStatusString();
void onUserListChanged();
signals:
void groupWidgetClicked(GroupWidget* widget);
@ -44,10 +44,8 @@ signals:
protected:
// drag & drop
void dragEnterEvent(QDragEnterEvent* ev);
void dropEvent(QDropEvent* ev);
void keyPressEvent(QKeyEvent* ev);
void keyReleaseEvent(QKeyEvent* ev);
virtual void dragEnterEvent(QDragEnterEvent* ev) final override;
virtual void dropEvent(QDropEvent* ev) final override;
public:
int groupId;

View File

@ -22,7 +22,7 @@
#include <QWidget>
class MaskablePixmapWidget : public QWidget
class MaskablePixmapWidget final : public QWidget
{
Q_OBJECT
public:
@ -39,8 +39,8 @@ signals:
void clicked();
protected:
virtual void paintEvent(QPaintEvent *);
virtual void mousePressEvent(QMouseEvent *);
virtual void paintEvent(QPaintEvent *) final override;
virtual void mousePressEvent(QMouseEvent *) final override;
private:
QPixmap pixmap, mask, unscaled; // a lot of memory...

View File

@ -22,14 +22,15 @@
#include <QScrollArea>
class AdjustingScrollArea : public QScrollArea
class AdjustingScrollArea final : public QScrollArea
{
Q_OBJECT
public:
explicit AdjustingScrollArea(QWidget *parent = 0);
virtual void resizeEvent(QResizeEvent *ev) override;
virtual QSize sizeHint() const override;
protected:
virtual void resizeEvent(QResizeEvent *ev) final override;
virtual QSize sizeHint() const final override;
};
#endif // ADJUSTINGSCROLLAREA_H

View File

@ -32,7 +32,7 @@ class QShowEvent;
/// This is a widget with dialog buttons to accept/reject a call
/// It tracks the position of another widget called the anchor
/// and looks like a bubble at the bottom of that widget.
class CallConfirmWidget : public QWidget
class CallConfirmWidget final : public QWidget
{
Q_OBJECT
public:
@ -43,8 +43,8 @@ signals:
void rejected();
protected:
virtual void paintEvent(QPaintEvent* event) override;
virtual void showEvent(QShowEvent * event) override;
virtual void paintEvent(QPaintEvent* event) final override;
virtual void showEvent(QShowEvent * event) final override;
protected slots:
void reposition(); ///< Recalculate our positions to track the anchor

View File

@ -22,13 +22,12 @@
#include <QTextEdit>
class ChatTextEdit : public QTextEdit
class ChatTextEdit final : public QTextEdit
{
Q_OBJECT
public:
explicit ChatTextEdit(QWidget *parent = 0);
~ChatTextEdit();
virtual void keyPressEvent(QKeyEvent * event) override;
void setLastMessage(QString lm);
signals:
@ -36,6 +35,9 @@ signals:
void tabPressed();
void keyPressed();
protected:
virtual void keyPressEvent(QKeyEvent * event) final override;
private:
void retranslateUi();

View File

@ -24,7 +24,7 @@
class QLineEdit;
class CroppingLabel : public QLabel
class CroppingLabel final : public QLabel
{
Q_OBJECT
public:
@ -33,13 +33,7 @@ public:
void setEditable(bool editable);
void setEdlideMode(Qt::TextElideMode elide);
virtual void setText(const QString& text);
virtual void resizeEvent(QResizeEvent *ev);
virtual QSize sizeHint() const;
virtual QSize minimumSizeHint() const;
virtual void mouseReleaseEvent(QMouseEvent *e);
virtual bool eventFilter(QObject *obj, QEvent *e);
void setText(const QString& text);
QString fullText(); ///< Returns the un-cropped text
signals:
@ -50,6 +44,11 @@ protected:
void setElidedText();
void hideTextEdit(bool acceptText);
void showTextEdit();
virtual void resizeEvent(QResizeEvent *ev) final override;
virtual QSize sizeHint() const final override;
virtual QSize minimumSizeHint() const final override;
virtual void mouseReleaseEvent(QMouseEvent *e) final override;
virtual bool eventFilter(QObject *obj, QEvent *e) final override;
private:
QString origText;

View File

@ -22,14 +22,14 @@
#include <QGraphicsItemGroup>
class ScreenGrabberChooserRectItem : public QObject, public QGraphicsItemGroup
class ScreenGrabberChooserRectItem final : public QObject, public QGraphicsItemGroup
{
Q_OBJECT
public:
ScreenGrabberChooserRectItem(QGraphicsScene* scene);
~ScreenGrabberChooserRectItem();
QRectF boundingRect() const;
virtual QRectF boundingRect() const final override;
void beginResize(QPointF mousePos);
QRect chosenRect() const;
@ -43,7 +43,7 @@ signals:
void regionChosen(QRect rect);
protected:
bool sceneEventFilter(QGraphicsItem* watched, QEvent* event);
virtual bool sceneEventFilter(QGraphicsItem* watched, QEvent* event) final override;
private:

View File

@ -24,7 +24,7 @@
class ScreenshotGrabber;
class ScreenGrabberOverlayItem : public QObject, public QGraphicsRectItem
class ScreenGrabberOverlayItem final : public QObject, public QGraphicsRectItem
{
Q_OBJECT
public:
@ -33,10 +33,9 @@ public:
void setChosenRect(QRect rect);
void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget);
protected:
void mousePressEvent(QGraphicsSceneMouseEvent* event);
virtual void mousePressEvent(QGraphicsSceneMouseEvent* event) final override;
virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget) final override;
private:
ScreenshotGrabber* screnshootGrabber;

View File

@ -24,7 +24,7 @@
#include <QPropertyAnimation>
#include <QObject>
class ToolBoxGraphicsItem : public QObject, public QGraphicsItemGroup
class ToolBoxGraphicsItem final : public QObject, public QGraphicsItemGroup
{
Q_OBJECT
Q_PROPERTY(qreal opacity READ opacity WRITE setOpacity)
@ -32,11 +32,11 @@ public:
ToolBoxGraphicsItem();
~ToolBoxGraphicsItem();
void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget);
virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget) final override;
protected:
void hoverEnterEvent(QGraphicsSceneHoverEvent* event);
void hoverLeaveEvent(QGraphicsSceneHoverEvent* event);
virtual void hoverEnterEvent(QGraphicsSceneHoverEvent* event) final override;
virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent* event) final override;
private:

View File

@ -48,23 +48,12 @@ class ProfileForm;
class SettingsWidget;
class AddFriendForm;
class Widget : public QMainWindow
class Widget final : public QMainWindow
{
Q_OBJECT
protected:
bool eventFilter(QObject *obj, QEvent *event);
public:
enum FilterCriteria
{
All=0,
Online,
Offline,
Friends,
Groups
};
explicit Widget(QWidget *parent = 0);
~Widget();
void init();
void setCentralWidget(QWidget *widget, const QString &widgetName);
QString getUsername();
@ -75,11 +64,6 @@ public:
bool getIsWindowMinimized();
void updateIcons();
void clearContactsList();
~Widget();
virtual void closeEvent(QCloseEvent *event);
virtual void changeEvent(QEvent *event);
virtual void resizeEvent(QResizeEvent *event);
static void confirmExecutableOpen(const QFileInfo file);
@ -135,6 +119,13 @@ signals:
void statusMessageChanged(const QString& statusMessage);
void resized();
protected:
virtual bool eventFilter(QObject *obj, QEvent *event) final override;
virtual bool event(QEvent * e) final override;
virtual void closeEvent(QCloseEvent *event) final override;
virtual void changeEvent(QEvent *event) final override;
virtual void resizeEvent(QResizeEvent *event) final override;
private slots:
void onAddClicked();
void onGroupClicked();
@ -168,9 +159,19 @@ private:
SettingButton,
None,
};
enum FilterCriteria
{
All=0,
Online,
Offline,
Friends,
Groups
};
private:
void setActiveToolMenuButton(ActiveToolMenuButton newActiveButton);
void hideMainForms();
virtual bool event(QEvent * e);
Group *createGroup(int groupId);
void removeFriend(Friend* f, bool fake = false);
void removeGroup(Group* g, bool fake = false);
@ -178,6 +179,8 @@ private:
void saveSplitterGeometry();
void cycleContacts(int offset);
void retranslateUi();
private:
SystemTrayIcon *icon;
QMenu *trayMenu;
QAction *statusOnline,